GLC_lib  2.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
glc_structinstance.h
Go to the documentation of this file.
1 
2 /****************************************************************************
3 
4  This file is part of the GLC-lib library.
5  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
6  http://glc-lib.sourceforge.net
7 
8  GLC-lib is free software; you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12 
13  GLC-lib is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License
19  along with GLC-lib; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 
22 *****************************************************************************/
23 
25 
26 #ifndef GLC_STRUCTINSTANCE_H_
27 #define GLC_STRUCTINSTANCE_H_
28 
29 #include <QList>
30 #include <QString>
31 #include "../maths/glc_matrix4x4.h"
32 #include "glc_3dviewinstance.h"
33 #include "glc_attributes.h"
34 
35 #include "../glc_config.h"
36 
39 
42 
43 
45 {
46 public:
49 
52 
55 
58 
60  GLC_StructInstance(const QString&);
61 
63  void setReference(GLC_StructReference*);
64 
65  // Destructor
66  virtual ~GLC_StructInstance();
68 
70 
71 public:
73  inline bool hasStructOccurence() const
74  { return !m_ListOfOccurences.isEmpty();}
75 
77  inline int numberOfOccurence() const
78  {return m_ListOfOccurences.size();}
79 
81  inline GLC_StructOccurence* firstOccurenceHandle() const
82  { return m_ListOfOccurences.first();}
83 
85  inline GLC_Matrix4x4 relativeMatrix() const
86  { return m_RelativeMatrix;}
87 
89  inline GLC_StructReference* structReference() const
90  { return m_pStructReference;}
91 
93  inline QList<GLC_StructOccurence*> listOfStructOccurences() const
94  { return m_ListOfOccurences;}
95 
97  inline QString name() const
98  {return m_Name;}
99 
101  inline bool containsAttributes() const
102  { return ((NULL != m_pAttributes) && !m_pAttributes->isEmpty());}
103 
105  inline GLC_Attributes* attributesHandle() const
106  {return m_pAttributes;}
107 
109  inline int usageCount() const
110  {return *m_pNumberOfInstance;}
111 
113 
114 
116 
117 public:
119  inline void structOccurenceCreated(GLC_StructOccurence* pOccurence)
120  {
121  Q_ASSERT(!m_ListOfOccurences.contains(pOccurence));
122  m_ListOfOccurences.append(pOccurence);
123  }
124 
125  inline void structOccurenceDeleted(GLC_StructOccurence *pOccurence)
126  {
127  m_ListOfOccurences.removeOne(pOccurence);
128  }
129 
131  inline GLC_StructInstance* move(const GLC_Matrix4x4& matrix)
132  {
133  m_RelativeMatrix= matrix * m_RelativeMatrix;
134  return this;
135  }
136 
138  inline GLC_StructInstance* translate(double Tx, double Ty, double Tz)
139  {
140  m_RelativeMatrix= GLC_Matrix4x4(Tx, Ty, Tz) * m_RelativeMatrix;
141  return this;
142  }
143 
145  inline GLC_StructInstance* translate(const GLC_Vector3d& v)
146  {
147  return translate(v.x(), v.y(), v.z());
148  }
149 
151  inline GLC_StructInstance* setMatrix(const GLC_Matrix4x4 &SetMat)
152  {
153  m_RelativeMatrix= SetMat;
154  return this;
155  }
156 
158  inline GLC_StructInstance* resetMatrix()
159  {
160  m_RelativeMatrix = GLC_Matrix4x4();
161  return this;
162  }
163 
165  inline void setName(const QString& name)
166  {m_Name= name;}
167 
169  inline void setAttributes(const GLC_Attributes& attr)
170  {
171  delete m_pAttributes;
172  m_pAttributes= new GLC_Attributes(attr);
173  }
174 
176  void updateOccurencesAbsoluteMatrix();
177 
178 
180 
182 // Private members
184 private:
187 
190 
192  QList<GLC_StructOccurence*> m_ListOfOccurences;
193 
196 
198  QString m_Name;
199 
202 };
203 
204 #endif /* GLC_STRUCTINSTANCE_H_ */

©2005-2013 Laurent Ribon