glc_structoccurence.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the GLC-lib library.
00004  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
00005  http://glc-lib.sourceforge.net
00006 
00007  GLC-lib is free software; you can redistribute it and/or modify
00008  it under the terms of the GNU Lesser General Public License as published by
00009  the Free Software Foundation; either version 3 of the License, or
00010  (at your option) any later version.
00011 
00012  GLC-lib is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU Lesser General Public License for more details.
00016 
00017  You should have received a copy of the GNU Lesser General Public License
00018  along with GLC-lib; if not, write to the Free Software
00019  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021 *****************************************************************************/
00022 
00024 
00025 #ifndef GLC_STRUCTOCCURENCE_H_
00026 #define GLC_STRUCTOCCURENCE_H_
00027 
00028 #include "../maths/glc_matrix4x4.h"
00029 #include "../glc_boundingbox.h"
00030 #include "glc_structinstance.h"
00031 #include <QSet>
00032 
00033 #include "../glc_config.h"
00034 
00035 class GLC_WorldHandle;
00036 class GLC_Material;
00037 class GLC_RenderProperties;
00038 
00041 
00042 
00043 class GLC_LIB_EXPORT GLC_StructOccurence
00044 {
00046 
00048 
00049 
00050 public:
00052         GLC_StructOccurence();
00053 
00055         GLC_StructOccurence(GLC_StructInstance*, GLC_WorldHandle* pWorldHandle= NULL, GLuint shaderId=0);
00056 
00058         GLC_StructOccurence(GLC_3DRep*);
00059 
00061         GLC_StructOccurence(GLC_WorldHandle*, const GLC_StructOccurence&, bool shareInstance);
00062 
00064         virtual ~GLC_StructOccurence();
00066 
00067 
00069 
00070 public:
00072         inline GLC_uint id() const
00073         {return m_Uid;}
00074 
00076         inline const QString name() const
00077         {return m_pStructInstance->name();}
00078 
00080         inline GLC_Matrix4x4 absoluteMatrix() const
00081         { return m_AbsoluteMatrix;}
00082 
00084         inline bool isOrphan() const
00085         { return NULL == m_pParent;}
00086 
00088         inline bool hasParent() const
00089         { return NULL != m_pParent;}
00090 
00092         bool hasRepresentation() const;
00093 
00095         bool has3DViewInstance() const;
00096 
00098         inline GLC_StructInstance* structInstance() const
00099         { return m_pStructInstance;}
00100 
00102         inline GLC_StructReference* structReference() const
00103         {
00104                 Q_ASSERT(NULL != m_pStructInstance);
00105                 return m_pStructInstance->structReference();
00106         }
00107 
00109         inline int childCount() const
00110         { return m_Childs.size();}
00111 
00113         inline bool hasChild() const
00114         {return childCount() > 0;}
00115 
00117         bool canBeAddedToChildren(GLC_StructOccurence* pOccurence) const;
00118 
00120         inline GLC_StructOccurence* parent() const
00121         {return m_pParent;}
00122 
00124 
00125         inline GLC_StructOccurence* child(const int index) const
00126         {return m_Childs.at(index);}
00127 
00129         inline QList<GLC_StructOccurence*> children() const
00130         {return m_Childs;}
00131 
00133         QList<GLC_StructOccurence*> subOccurenceList() const;
00134 
00136         unsigned int numberOfFaces() const;
00137 
00139         unsigned int numberOfVertex() const;
00140 
00142         unsigned int numberOfMaterials() const;
00143 
00145         QSet<GLC_Material*> materialSet() const;
00146 
00148         GLC_StructOccurence* clone(GLC_WorldHandle*, bool shareInstance) const;
00149 
00151         bool isVisible() const;
00152 
00154         GLC_BoundingBox boundingBox() const;
00155 
00157         inline unsigned int occurenceNumber() const
00158         {return m_OccurenceNumber;}
00159 
00161         GLC_RenderProperties* renderPropertiesHandle() const
00162         {return m_pRenderProperties;}
00163 
00165         unsigned int nodeCount() const;
00166 
00168         inline GLC_WorldHandle* worldHandle() const
00169         {return m_pWorldHandle;}
00170 
00172         QSet<GLC_StructReference*> childrenReferences() const;
00173 
00175         static QSet<GLC_StructReference*> parentsReferences(const GLC_StructOccurence* pOccurence);
00176 
00178         inline bool useAutomatic3DViewInstanceCreation() const
00179         {return m_AutomaticCreationOf3DViewInstance;}
00180 
00181 
00183 
00184 
00186 
00187 public:
00188 
00190         inline void setName(const QString name) {m_pStructInstance->setName(name);}
00191 
00193         GLC_StructOccurence* updateAbsoluteMatrix();
00194 
00196         GLC_StructOccurence* updateChildrenAbsoluteMatrix();
00197 
00199 
00200         void addChild(GLC_StructOccurence*);
00201 
00203         GLC_StructOccurence* addChild(GLC_StructInstance*);
00204 
00206         void makeOrphan();
00207 
00209 
00210         bool removeChild(GLC_StructOccurence* pChild);
00211 
00213         void reverseNormals();
00214 
00216         bool create3DViewInstance();
00217 
00219         bool remove3DViewInstance();
00220 
00222         void setWorldHandle(GLC_WorldHandle*);
00223 
00225         bool loadRepresentation();
00226 
00228         bool unloadRepresentation();
00229 
00231         inline void setOccurenceNumber(unsigned int n)
00232         {m_OccurenceNumber= n;}
00233 
00235         unsigned int updateOccurenceNumber(unsigned int n);
00236 
00238         void setVisibility(bool visibility);
00239 
00241         void setRenderProperties(const GLC_RenderProperties& renderProperties);
00242 
00244         void removeEmptyChildren();
00245 
00247         void setReference(GLC_StructReference* pRef);
00248 
00250         inline void setAutomatic3DViewInstanceCreationUsage(bool usage)
00251         {m_AutomaticCreationOf3DViewInstance= usage;}
00252 
00253 
00255 
00257 // Private services function
00259 private:
00261         void detach();
00262 
00264 // Private members
00266 private:
00268         GLC_uint m_Uid;
00269 
00271         GLC_WorldHandle* m_pWorldHandle;
00272 
00274         int* m_pNumberOfOccurence;
00275 
00277         GLC_StructInstance* m_pStructInstance;
00278 
00280         GLC_StructOccurence* m_pParent;
00281 
00283         QList<GLC_StructOccurence*> m_Childs;
00284 
00286         GLC_Matrix4x4 m_AbsoluteMatrix;
00287 
00289         unsigned int m_OccurenceNumber;
00290 
00292         bool m_IsVisible;
00293 
00295         GLC_RenderProperties* m_pRenderProperties;
00296 
00298         bool m_AutomaticCreationOf3DViewInstance;
00299 
00300 };
00301 
00302 #endif /* GLC_STRUCTOCCURENCE_H_ */

SourceForge.net Logo

©2005-2011 Laurent Ribon