Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYElementGraphic.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
22 #ifndef __TY_ELEMENT_GRAPHIC__
23 #define __TY_ELEMENT_GRAPHIC__
24 
25 #include <qmatrix4x4.h>
26 #if _MSC_VER > 1000
27  #pragma once
28 #endif // _MSC_VER > 1000
29 
30 #ifdef _MSC_VER
31  #pragma warning(disable : 4284)
32 #endif
33 
35 #include "Tympan/core/color.h"
36 #include "Tympan/core/smartptr.h"
37 
38 class QObject;
39 class TYRenderContext;
40 class TYElement;
42 class OGLMeshInstance;
43 
44 #define TY_DECL_METIER_GRAPHIC(classname) \
45 public: \
46  inline classname* getElement() const \
47  { \
48  return (classname*)_pElement; \
49  }
50 
51 #include <list>
52 // Pour l'utilisation de la librairie standard STL.
53 using std::list;
54 
55 class TYElementGraphic;
57 typedef list<TYElementGraphic*> TYListPtrTYElementGraphic;
59 typedef list<const TYElementGraphic*> TYListPtrConstTYElementGraphic;
60 
66 {
67  // Methodes
68 public:
72  virtual ~TYElementGraphic();
73 
77  void setElement(TYElement* pElt);
83  {
84  return _pElement;
85  }
86 
91  const TYElement* getTYElement() const
92  {
93  return _pElement;
94  }
95 
100  void updateTree();
101 
110  virtual void update(bool force = false);
111 
118  virtual void display(TYRenderContext& renderContext);
119 
123  void setModified(bool modified = true);
127  bool getModified() const;
128 
132  void setVisible(bool visible = true)
133  {
134  _visible = visible;
135  }
139  bool getVisible() const
140  {
141  return _visible;
142  }
143 
147  void setTexture(bool state = true)
148  {
149  _texture = state;
150  }
154  bool getTexture()
155  {
156  return _texture;
157  }
158 
162  OBox boundingBox() const;
163 
167  virtual OBox computeBoundingBox() const;
168 
173  virtual void getChilds(TYListPtrTYElementGraphic& childs, bool recursif = true){};
174 
179  void getChilds(TYListPtrConstTYElementGraphic& childs, bool recursif = true) const
180  {
181  TYListPtrTYElementGraphic childsNonConst;
182  const_cast<TYElementGraphic*>(this)->getChilds(childsNonConst, recursif);
183  for (auto elem : childsNonConst)
184  {
185  childs.push_back(elem);
186  }
187  };
188 
193  void setBoundingBoxVisible(bool state = true);
194 
198  bool isBoundingBoxVisible() const;
199 
203  void setOnlyBoundingBox(bool state = true);
204 
208  bool getOnlyBoundingBox() const;
209 
213  virtual void collectMeshInstances(std::vector<OGLMeshInstance>& meshInstances,
214  TYRenderContext* renderContext) const;
215 
219  const TYGeometryNodeGraphic* nearestGeoNode() const;
220 
224  QMatrix4x4 globalMatrix() const;
225 
226 public:
227 #if TY_USE_IHM
228  virtual void activateSignal(){};
229 
233  virtual void connectUpdateSignal(QObject* pReceiver, const char* member){};
237  virtual void disconnectUpdateSignal(QObject* pReceiver, const char* member){};
238 #endif // TY_USE_IHM
239 
240 protected:
245 
246  void displayNormal(OVector3D normal, OPoint3D p1);
247 
248  void drawName(TYRenderContext& renderContext);
249 
250  void invalidateBoundingBox();
251 
252 public:
254  static bool _gDrawNormals;
255 
257  static bool _gDrawPlafond;
258 
259 private:
260  // Indique si la boite englobante doit etre recalculee
261  mutable bool _boundingBoxDirty;
262 
264  bool _modified;
265 
268 
269  // Cache de la boite englobante de l'element
271 
272 protected:
275 
278 
280  bool _texture;
281 
283  bool _visible;
284 };
285 
288 
289 #endif // __TY_ELEMENT_GRAPHIC__
All base classes related to 3D manipulation.
list< TYElementGraphic * > TYListPtrTYElementGraphic
List de pointeur de TYElement.
SmartPtr< TYElementGraphic > LPTYElementGraphic
Smart pointer sur TYElementGraphic.
list< const TYElementGraphic * > TYListPtrConstTYElementGraphic
List de pointeur de TYElement.
The box class.
Definition: 3d.h:1346
The 3D point class.
Definition: 3d.h:487
The 3D vector class.
Definition: 3d.h:298
classe graphique pour un element de base
void setTexture(bool state=true)
bool _modified
Indique si l'element associe a ete modifie.
void setOnlyBoundingBox(bool state=true)
void drawName(TYRenderContext &renderContext)
bool _visible
Inique si l'element est visible.
void setModified(bool modified=true)
TYElement * getTYElement()
static bool _gDrawNormals
Indique si les normals doivent etre visible.
bool _texture
Indique si le texturing est active pour cet element.
OBox boundingBox() const
void setBoundingBoxVisible(bool state=true)
TYElementGraphic(TYElement *pElt)
bool _highlight
Indique si le highlight est active pour cet element.
void displayNormal(OVector3D normal, OPoint3D p1)
virtual void update(bool force=false)
bool isBoundingBoxVisible() const
static bool _gDrawPlafond
Indique si les plafonds doivent etre visible.
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
virtual void display(TYRenderContext &renderContext)
const TYGeometryNodeGraphic * nearestGeoNode() const
void setElement(TYElement *pElt)
QMatrix4x4 globalMatrix() const
TYElement * _pElement
L'element metier auquel cet element graphique metier est associe.
virtual OBox computeBoundingBox() const
const TYElement * getTYElement() const
bool getModified() const
void getChilds(TYListPtrConstTYElementGraphic &childs, bool recursif=true) const
virtual ~TYElementGraphic()
virtual void collectMeshInstances(std::vector< OGLMeshInstance > &meshInstances, TYRenderContext *renderContext) const
void setVisible(bool visible=true)
bool getVisible() const
bool _viewOnlyHighlight
Inique si on affiche la bounding box seule.
bool getOnlyBoundingBox() const
classe graphique pour un GeometryNode