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 Version 2.0.0 Beta 1, packaged on April 2010. 00007 00008 http://glc-lib.sourceforge.net 00009 00010 GLC-lib is free software; you can redistribute it and/or modify 00011 it under the terms of the GNU General Public License as published by 00012 the Free Software Foundation; either version 2 of the License, or 00013 (at your option) any later version. 00014 00015 GLC-lib is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 along with GLC-lib; if not, write to the Free Software 00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00023 00024 *****************************************************************************/ 00025 00027 00028 #ifndef GLC_STRUCTINSTANCE_H_ 00029 #define GLC_STRUCTINSTANCE_H_ 00030 00031 #include <QList> 00032 #include <QString> 00033 #include "../maths/glc_matrix4x4.h" 00034 #include "glc_3dviewinstance.h" 00035 #include "glc_attributes.h" 00036 00037 #include "../glc_config.h" 00038 00039 class GLC_StructReference; 00040 class GLC_StructOccurence; 00041 00044 00045 00046 class GLC_LIB_EXPORT GLC_StructInstance 00047 { 00048 public: 00050 GLC_StructInstance(GLC_StructReference* pRef= NULL); 00051 00053 GLC_StructInstance(GLC_Rep*); 00054 00056 GLC_StructInstance(const GLC_StructInstance&); 00057 00059 GLC_StructInstance(GLC_StructInstance*); 00060 00062 GLC_StructInstance(const QString&); 00063 00065 void setReference(GLC_StructReference*); 00066 00067 // Destructor 00068 virtual ~GLC_StructInstance(); 00070 00072 00073 public: 00075 inline bool hasStructOccurence() const 00076 { return !m_ListOfOccurences.isEmpty();} 00077 00079 inline int numberOfOccurence() const 00080 {return m_ListOfOccurences.size();} 00081 00083 inline GLC_StructOccurence* firstOccurenceHandle() const 00084 { return m_ListOfOccurences.first();} 00085 00087 inline GLC_Matrix4x4 relativeMatrix() const 00088 { return m_RelativeMatrix;} 00089 00091 inline GLC_StructReference* structReference() const 00092 { return m_pStructReference;} 00093 00095 inline QList<GLC_StructOccurence*> listOfStructOccurences() const 00096 { return m_ListOfOccurences;} 00097 00099 inline QString name() const 00100 {return m_Name;} 00101 00103 inline bool containsAttributes() const 00104 { return ((NULL != m_pAttributes) && !m_pAttributes->isEmpty());} 00105 00107 inline GLC_Attributes* attributesHandle() const 00108 {return m_pAttributes;} 00109 00111 00112 00114 00115 public: 00117 inline void structOccurenceCreated(GLC_StructOccurence* pOccurence) 00118 { 00119 Q_ASSERT(!m_ListOfOccurences.contains(pOccurence)); 00120 m_ListOfOccurences.append(pOccurence); 00121 } 00122 00123 inline void structOccurenceDeleted(GLC_StructOccurence *pOccurence) 00124 {m_ListOfOccurences.removeOne(pOccurence);} 00125 00127 inline GLC_StructInstance* move(const GLC_Matrix4x4& matrix) 00128 { 00129 m_RelativeMatrix= matrix * m_RelativeMatrix; 00130 return this; 00131 } 00132 00134 inline GLC_StructInstance* translate(double Tx, double Ty, double Tz) 00135 { 00136 m_RelativeMatrix= GLC_Matrix4x4(Tx, Ty, Tz) * m_RelativeMatrix; 00137 return this; 00138 } 00139 00141 inline GLC_StructInstance* translate(const GLC_Vector3d& v) 00142 { 00143 return translate(v.x(), v.y(), v.z()); 00144 } 00145 00147 inline GLC_StructInstance* setMatrix(const GLC_Matrix4x4 &SetMat) 00148 { 00149 m_RelativeMatrix= SetMat; 00150 return this; 00151 } 00152 00154 inline GLC_StructInstance* resetMatrix() 00155 { 00156 m_RelativeMatrix = GLC_Matrix4x4(); 00157 return this; 00158 } 00159 00161 inline void setName(const QString& name) 00162 {m_Name= name;} 00163 00165 void setAttributes(const GLC_Attributes& attr) 00166 { 00167 delete m_pAttributes; 00168 m_pAttributes= new GLC_Attributes(attr); 00169 } 00170 00171 00173 00175 // Private members 00177 private: 00179 int* m_pNumberOfInstance; 00180 00182 GLC_StructReference* m_pStructReference; 00183 00185 QList<GLC_StructOccurence*> m_ListOfOccurences; 00186 00188 GLC_Matrix4x4 m_RelativeMatrix; 00189 00191 QString m_Name; 00192 00194 GLC_Attributes* m_pAttributes; 00195 }; 00196 00197 #endif /* GLC_STRUCTINSTANCE_H_ */