glc_structinstance.h

Go to the documentation of this file.
00001 
00002 /****************************************************************************
00003 
00004  This file is part of the GLC-lib library.
00005  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
00006  http://glc-lib.sourceforge.net
00007 
00008  GLC-lib is free software; you can redistribute it and/or modify
00009  it under the terms of the GNU Lesser General Public License as published by
00010  the Free Software Foundation; either version 3 of the License, or
00011  (at your option) any later version.
00012 
00013  GLC-lib is distributed in the hope that it will be useful,
00014  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  GNU Lesser General Public License for more details.
00017 
00018  You should have received a copy of the GNU Lesser General Public License
00019  along with GLC-lib; if not, write to the Free Software
00020  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00021 
00022 *****************************************************************************/
00023 
00025 
00026 #ifndef GLC_STRUCTINSTANCE_H_
00027 #define GLC_STRUCTINSTANCE_H_
00028 
00029 #include <QList>
00030 #include <QString>
00031 #include "../maths/glc_matrix4x4.h"
00032 #include "glc_3dviewinstance.h"
00033 #include "glc_attributes.h"
00034 
00035 #include "../glc_config.h"
00036 
00037 class GLC_StructReference;
00038 class GLC_StructOccurence;
00039 
00042 
00043 
00044 class GLC_LIB_EXPORT GLC_StructInstance
00045 {
00046 public:
00048         GLC_StructInstance(GLC_StructReference* pRef= NULL);
00049 
00051         GLC_StructInstance(GLC_Rep*);
00052 
00054         GLC_StructInstance(const GLC_StructInstance&);
00055 
00057         GLC_StructInstance(GLC_StructInstance*);
00058 
00060         GLC_StructInstance(const QString&);
00061 
00063         void setReference(GLC_StructReference*);
00064 
00065         // Destructor
00066         virtual ~GLC_StructInstance();
00068 
00070 
00071 public:
00073         inline bool hasStructOccurence() const
00074         { return !m_ListOfOccurences.isEmpty();}
00075 
00077         inline int numberOfOccurence() const
00078         {return m_ListOfOccurences.size();}
00079 
00081         inline GLC_StructOccurence* firstOccurenceHandle() const
00082         { return m_ListOfOccurences.first();}
00083 
00085         inline GLC_Matrix4x4 relativeMatrix() const
00086         { return m_RelativeMatrix;}
00087 
00089         inline GLC_StructReference* structReference() const
00090         { return m_pStructReference;}
00091 
00093         inline QList<GLC_StructOccurence*> listOfStructOccurences() const
00094         { return m_ListOfOccurences;}
00095 
00097         inline QString name() const
00098         {return m_Name;}
00099 
00101         inline bool containsAttributes() const
00102         { return ((NULL != m_pAttributes) && !m_pAttributes->isEmpty());}
00103 
00105         inline GLC_Attributes* attributesHandle() const
00106         {return m_pAttributes;}
00107 
00109         inline int usageCount() const
00110         {return *m_pNumberOfInstance;}
00111 
00113 
00114 
00116 
00117 public:
00119         inline void structOccurenceCreated(GLC_StructOccurence* pOccurence)
00120         {
00121                 Q_ASSERT(!m_ListOfOccurences.contains(pOccurence));
00122                 m_ListOfOccurences.append(pOccurence);
00123         }
00124 
00125         inline void structOccurenceDeleted(GLC_StructOccurence *pOccurence)
00126         {
00127                 m_ListOfOccurences.removeOne(pOccurence);
00128         }
00129 
00131         inline GLC_StructInstance* move(const GLC_Matrix4x4& matrix)
00132         {
00133                 m_RelativeMatrix= matrix * m_RelativeMatrix;
00134                 return this;
00135         }
00136 
00138         inline GLC_StructInstance* translate(double Tx, double Ty, double Tz)
00139         {
00140                 m_RelativeMatrix= GLC_Matrix4x4(Tx, Ty, Tz) * m_RelativeMatrix;
00141                 return this;
00142         }
00143 
00145         inline GLC_StructInstance* translate(const GLC_Vector3d& v)
00146         {
00147                 return translate(v.x(), v.y(), v.z());
00148         }
00149 
00151         inline GLC_StructInstance* setMatrix(const GLC_Matrix4x4 &SetMat)
00152         {
00153                 m_RelativeMatrix= SetMat;
00154                 return this;
00155         }
00156 
00158         inline GLC_StructInstance* resetMatrix()
00159         {
00160                 m_RelativeMatrix = GLC_Matrix4x4();
00161                 return this;
00162         }
00163 
00165         inline void setName(const QString& name)
00166         {m_Name= name;}
00167 
00169         inline void setAttributes(const GLC_Attributes& attr)
00170         {
00171                 delete m_pAttributes;
00172                 m_pAttributes= new GLC_Attributes(attr);
00173         }
00174 
00176         void updateOccurencesAbsoluteMatrix();
00177 
00178 
00180 
00182 // Private members
00184 private:
00186         int* m_pNumberOfInstance;
00187 
00189         GLC_StructReference* m_pStructReference;
00190 
00192         QList<GLC_StructOccurence*> m_ListOfOccurences;
00193 
00195         GLC_Matrix4x4 m_RelativeMatrix;
00196 
00198         QString m_Name;
00199 
00201         GLC_Attributes* m_pAttributes;
00202 };
00203 
00204 #endif /* GLC_STRUCTINSTANCE_H_ */

SourceForge.net Logo

©2005-2011 Laurent Ribon