GLC_lib  2.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
glc_renderer.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 
3  This file is part of the GLC-lib library.
4  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
5  http://glc-lib.sourceforge.net
6 
7  GLC-lib is free software; you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  GLC-lib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with GLC-lib; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21 *****************************************************************************/
22 
24 
25 #include <QtDebug>
26 
27 #include "../sceneGraph/glc_3dviewcollection.h"
28 
29 #include "glc_renderer.h"
30 
32 : m_pCollection(NULL)
33 , m_IdToRenderProperties()
34 , m_IsCurrent(false)
35 {
36 
37 }
38 
40 : m_pCollection(pCollection)
41 , m_IdToRenderProperties()
42 , m_IsCurrent(false)
43 {
44 
45 }
46 
48 : m_pCollection(other.m_pCollection)
49 , m_IdToRenderProperties(other.m_IdToRenderProperties)
50 , m_IsCurrent(false)
51 {
52 
53 }
54 
56 {
57  clear();
58 }
59 
61 {
62  return m_IdToRenderProperties.contains(id);
63 }
64 
66 {
67  Q_ASSERT(m_IdToRenderProperties.contains(id));
68  return m_IdToRenderProperties.find(id).value();
69 }
70 
72 {
73  m_pCollection= NULL;
74  m_IdToRenderProperties.clear();
75 }
76 
78 {
79  if (this != &other)
80  {
83  // m_IsCurrent doesn't change
84  }
85 
86  return *this;
87 }
88 
90 {
91  if (pCollection != m_pCollection)
92  {
93  clear();
94  m_pCollection= pCollection;
95  }
96 }
97 
99 {
100  if (NULL != m_pCollection)
101  {
102  Q_ASSERT(!m_IsCurrent);
103  m_IsCurrent= true;
104  QHash<GLC_uint, GLC_RenderProperties>::const_iterator iRender= m_IdToRenderProperties.constBegin();
105  while (iRender != m_IdToRenderProperties.constEnd())
106  {
107  if (m_pCollection->contains(iRender.key()))
108  {
109  m_pCollection->instanceHandle(iRender.key())->renderPropertiesHandle()->operator =(iRender.value());
110  }
111  ++iRender;
112  }
113  m_IdToRenderProperties.clear();
114  }
115 }
116 
118 {
119  if (NULL != m_pCollection)
120  {
121  Q_ASSERT(m_IdToRenderProperties.isEmpty());
122  Q_ASSERT(m_IsCurrent);
123  m_IsCurrent= false;
124  QList<GLC_3DViewInstance*> instances= m_pCollection->instancesHandle();
125  const int count= instances.count();
126  for (int i= 0; i < count; ++i)
127  {
128  GLC_3DViewInstance* pInstance= instances.at(i);
129  m_IdToRenderProperties.insert(pInstance->id(), *(pInstance->renderPropertiesHandle()));
130  }
131  }
132 }
133 
135 {
136  Q_ASSERT(NULL != m_pCollection);
137  Q_ASSERT(m_pCollection->contains(id));
139 }

©2005-2013 Laurent Ribon