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 #if _MSC_VER > 1000
26  #pragma once
27 #endif // _MSC_VER > 1000
28 
29 #ifdef _MSC_VER
30  #pragma warning(disable : 4284)
31 #endif
32 
34 #include "Tympan/core/color.h"
35 #include "Tympan/core/smartptr.h"
36 
37 class QObject;
38 class TYRenderContext;
39 class TYElement;
40 
41 #define TY_DECL_METIER_GRAPHIC(classname) \
42 public: \
43  inline classname* getElement() const \
44  { \
45  return (classname*)_pElement; \
46  }
47 
48 #include <list>
49 // Pour l'utilisation de la librairie standard STL.
50 using std::list;
51 
52 class TYElementGraphic;
54 typedef list<TYElementGraphic*> TYListPtrTYElementGraphic;
56 typedef list<const TYElementGraphic*> TYListPtrConstTYElementGraphic;
57 
63 {
64  // Methodes
65 public:
69  virtual ~TYElementGraphic();
70 
74  void setElement(TYElement* pElt);
80  {
81  return _pElement;
82  }
83 
88  const TYElement* getTYElement() const
89  {
90  return _pElement;
91  }
92 
97  void updateTree();
98 
107  virtual void update(bool force = false);
108 
115  virtual void display(TYRenderContext& renderContext);
116 
120  void setModified(bool modified = true)
121  {
122  _modified = modified;
123  if (modified)
124  {
126  }
127  }
131  bool getModified() const;
132 
136  void setVisible(bool visible = true)
137  {
138  _visible = visible;
139  }
143  bool getVisible()
144  {
145  return _visible;
146  }
150  void setRecursiveVisible(bool visible = true);
151 
155  void setTexture(bool state = true)
156  {
157  _texture = state;
158  }
162  bool getTexture()
163  {
164  return _texture;
165  }
166 
170  OBox boundingBox() const;
171 
175  virtual OBox computeBoundingBox() const;
176 
181  virtual void getChilds(TYListPtrTYElementGraphic& childs, bool recursif = true){};
182 
187  void getChilds(TYListPtrConstTYElementGraphic& childs, bool recursif = true) const
188  {
189  TYListPtrTYElementGraphic childsNonConst;
190  const_cast<TYElementGraphic*>(this)->getChilds(childsNonConst, recursif);
191  for (auto elem : childsNonConst)
192  {
193  childs.push_back(elem);
194  }
195  };
196 
201  void setBoundingBoxVisible(bool state = true);
202 
206  bool isBoundingBoxVisible() const;
207 
211  void setOnlyBoundingBox(bool state = true);
212 
213 public:
214 #if TY_USE_IHM
215  virtual void activateSignal(){};
216 
220  virtual void connectUpdateSignal(QObject* pReceiver, const char* member){};
224  virtual void disconnectUpdateSignal(QObject* pReceiver, const char* member){};
225 #endif // TY_USE_IHM
226 
227 protected:
232 
233  void displayNormal(OVector3D normal, OPoint3D p1);
234 
235  void drawName(TYRenderContext& renderContext);
236 
237  void invalidateBoundingBox();
238 
239 public:
241  static bool _gDrawNormals;
242 
244  static bool _gDrawPlafond;
245 
246 private:
247  // Indique si la boite englobante doit etre recalculee
248  mutable bool _boundingBoxDirty;
249 
251  bool _modified;
252 
255 
256  // Cache de la boite englobante de l'element
258 
259 protected:
262 
265 
267  bool _texture;
268 
270  bool _visible;
271 };
272 
275 
276 #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()
void setRecursiveVisible(bool visible=true)
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)
void setElement(TYElement *pElt)
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()
void setVisible(bool visible=true)
bool _viewOnlyHighlight
Inique si on affiche la bounding box seule.