GLC_lib  2.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
glc_structoccurence.h
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 #ifndef GLC_STRUCTOCCURENCE_H_
26 #define GLC_STRUCTOCCURENCE_H_
27 
28 #include "../maths/glc_matrix4x4.h"
29 #include "../glc_boundingbox.h"
30 #include "glc_structinstance.h"
31 #include <QSet>
32 
33 #include "../glc_config.h"
34 
35 class GLC_WorldHandle;
36 class GLC_Material;
38 
41 
42 
44 {
46 
48 
49 
50 public:
53 
55  GLC_StructOccurence(GLC_StructInstance* pStructInstance, GLC_WorldHandle* pWorldHandle= NULL, GLuint shaderId=0);
56 
58  GLC_StructOccurence(GLC_StructInstance* pStructInstance, GLC_uint id, GLC_WorldHandle* pWorldHandle= NULL, GLuint shaderId=0);
59 
62 
65 
67  GLC_StructOccurence(GLC_WorldHandle*, const GLC_StructOccurence&, bool shareInstance);
68 
70  virtual ~GLC_StructOccurence();
72 
73 
75 
76 public:
78  inline GLC_uint id() const
79  {return m_Uid;}
80 
82  inline const QString name() const
83  {return m_pStructInstance->name();}
84 
86  inline GLC_Matrix4x4 absoluteMatrix() const
87  { return m_AbsoluteMatrix;}
88 
90  GLC_Matrix4x4 occurrenceRelativeMatrix() const;
91 
93  inline bool isOrphan() const
94  { return NULL == m_pParent;}
95 
97  inline bool hasParent() const
98  { return NULL != m_pParent;}
99 
101  bool hasRepresentation() const;
102 
104  bool has3DViewInstance() const;
105 
107  inline GLC_StructInstance* structInstance() const
108  { return m_pStructInstance;}
109 
111  inline GLC_StructReference* structReference() const
112  {
113  Q_ASSERT(NULL != m_pStructInstance);
114  return m_pStructInstance->structReference();
115  }
116 
118  inline int childCount() const
119  { return m_Childs.size();}
120 
122  inline bool hasChild() const
123  {return childCount() > 0;}
124 
126  bool canBeAddedToChildren(GLC_StructOccurence* pOccurence) const;
127 
129  inline GLC_StructOccurence* parent() const
130  {return m_pParent;}
131 
133  QList<GLC_StructOccurence*> ancestorList() const;
134 
136 
137  inline GLC_StructOccurence* child(const int index) const
138  {return m_Childs.at(index);}
139 
141  inline QList<GLC_StructOccurence*> children() const
142  {return m_Childs;}
143 
145  QList<GLC_StructOccurence*> subOccurenceList() const;
146 
148  unsigned int numberOfFaces() const;
149 
151  unsigned int numberOfVertex() const;
152 
154  unsigned int numberOfMaterials() const;
155 
157  QSet<GLC_Material*> materialSet() const;
158 
160  GLC_StructOccurence* clone(GLC_WorldHandle*, bool shareInstance) const;
161 
163  bool isVisible() const;
164 
166  GLC_BoundingBox boundingBox() const;
167 
169  inline unsigned int occurenceNumber() const
170  {return m_OccurenceNumber;}
171 
173  GLC_RenderProperties* renderPropertiesHandle() const
174  {return m_pRenderProperties;}
175 
177  unsigned int nodeCount() const;
178 
180  inline GLC_WorldHandle* worldHandle() const
181  {return m_pWorldHandle;}
182 
184  QSet<GLC_StructReference*> childrenReferences() const;
185 
187  static QSet<GLC_StructReference*> parentsReferences(const GLC_StructOccurence* pOccurence);
188 
190  inline bool useAutomatic3DViewInstanceCreation() const
191  {return m_AutomaticCreationOf3DViewInstance;}
192 
194  inline bool isFlexible() const
195  {return (m_pRelativeMatrix != NULL);}
196 
198 
199  int indexOf(const GLC_StructOccurence* pOcc) const;
200 
202  bool containsChild(const GLC_StructOccurence* pOcc) const;
204 
205 
207 
208 public:
209 
211  inline void setName(const QString name) {m_pStructInstance->setName(name);}
212 
214  GLC_StructOccurence* updateAbsoluteMatrix();
215 
217  GLC_StructOccurence* updateChildrenAbsoluteMatrix();
218 
220 
221  void addChild(GLC_StructOccurence*);
222 
224 
225  void insertChild(int index, GLC_StructOccurence* pChild);
226 
229 
231  GLC_StructOccurence* insertChild(int index, GLC_StructInstance* pInstance);
232 
234  void makeOrphan();
235 
237 
238  bool removeChild(GLC_StructOccurence* pChild);
239 
241  void reverseNormals();
242 
244  bool create3DViewInstance(GLuint shaderId= 0);
245 
247  bool remove3DViewInstance();
248 
250  void setWorldHandle(GLC_WorldHandle*);
251 
253  bool loadRepresentation();
254 
256  bool unloadRepresentation();
257 
259  inline void setOccurenceNumber(unsigned int n)
260  {m_OccurenceNumber= n;}
261 
263  unsigned int updateOccurenceNumber(unsigned int n);
264 
266  void setVisibility(bool visibility);
267 
269  void setRenderProperties(const GLC_RenderProperties& renderProperties);
270 
272  void removeEmptyChildren();
273 
275  void setReference(GLC_StructReference* pRef);
276 
278  inline void setAutomatic3DViewInstanceCreationUsage(bool usage)
279  {m_AutomaticCreationOf3DViewInstance= usage;}
280 
282  void makeFlexible(const GLC_Matrix4x4& relativeMatrix);
283 
285  void makeRigid();
286 
288 
289  void swap(int i, int j);
291 
293 // Private services function
295 private:
297  void detach();
298 
300  void doCreateOccurrenceFromInstance(GLuint shaderId);
301 
303 // Private members
305 private:
308 
311 
314 
317 
320 
322  QList<GLC_StructOccurence*> m_Childs;
323 
326 
328  unsigned int m_OccurenceNumber;
329 
332 
335 
338 
341 
342 };
343 
344 #endif /* GLC_STRUCTOCCURENCE_H_ */

©2005-2013 Laurent Ribon