Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYElementGraphic.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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 
33 #if TY_USE_IHM
34  #include <QtOpenGL>
35  #include <GL/gl.h>
36  #include <GL/glu.h>
37 /* #include <qobject.h> */
38 /* #include <qgl.h> */
39 #else
40  #include <GL/gl.h>
41  #include <GL/glu.h>
42 #endif // TY_USE_IHM
43 
45 #include "Tympan/core/color.h"
46 #include "Tympan/core/smartptr.h"
47 
48 class TYElement;
49 
50 #define TY_DECL_METIER_GRAPHIC(classname) \
51 public: \
52  inline classname* getElement() const \
53  { \
54  return (classname*)_pElement; \
55  }
56 
57 #include <list>
58 // Pour l'utilisation de la librairie standard STL.
59 using std::list;
60 
61 class TYElementGraphic;
63 typedef list<TYElementGraphic*> TYListPtrTYElementGraphic;
64 
70 {
71  // Methodes
72 public:
76  virtual ~TYElementGraphic();
77 
81  void setElement(TYElement* pElt);
87  {
88  return _pElement;
89  }
90 
95  void updateTree();
96 
105  virtual void update(bool force = false);
106 
113  virtual void display(TYElement* pModelerElement = nullptr, GLenum mode = GL_RENDER);
114 
118  void setModified(bool modified = true)
119  {
120  _modified = modified;
121  }
125  bool getModified(bool andReset = false);
126 
130  void setVisible(bool visible = true)
131  {
132  _visible = visible;
133  }
137  bool getVisible()
138  {
139  return _visible;
140  }
144  void setRecursiveVisible(bool visible = true);
145 
149  void setTexture(bool state = true)
150  {
151  _texture = state;
152  }
156  bool getTexture()
157  {
158  return _texture;
159  }
160 
165  {
166  return _boundingBox;
167  }
168 
172  virtual void computeBoundingBox();
173 
178  virtual void getChilds(TYListPtrTYElementGraphic& childs, bool recursif = true){};
179 
184  void highlight(bool state = true);
185 
189  bool getHighlightState();
190 
194  void viewOnlyHighlight(bool state = true);
199  {
200  return _viewOnlyHighlight;
201  }
202 
203 public:
204 #if TY_USE_IHM
205  virtual void activateSignal(){};
206 
210  virtual void connectUpdateSignal(QObject* pReceiver, const char* member){};
214  virtual void disconnectUpdateSignal(QObject* pReceiver, const char* member){};
215 #endif // TY_USE_IHM
216 
218 
219 protected:
224 
225  void displayNormal(OVector3D normal, OPoint3D p1);
226 
227  void glVertex3fAndEnlargeBB(GLfloat x, GLfloat y, GLfloat z);
228  void glVertex3dAndEnlargeBB(GLdouble x, GLdouble y, GLdouble z);
229  void gluDiskAndEnlargeBB(GLUquadric* qobj, GLdouble innerRadius, GLdouble outerRadius, GLint slices,
230  GLint loops);
231  void gluCylinderAndEnlargeBB(GLUquadric* qobj, GLdouble baseRadius, GLdouble topRadius, GLdouble height,
232  GLint slices, GLint stacks);
233  void gluPartialDiskAndEnlargeBB(GLUquadric* qobj, GLdouble innerRadius, GLdouble outerRadius,
234  GLint slices, GLint loops, GLdouble startAngle, GLdouble sweepAngle);
235  void drawBoundingBox();
236  void drawLineBoundingBox();
237  void drawName(TYElement* pModelerElement = nullptr);
238 
239 public:
241  static bool _gDrawNormals;
242 
244  static bool _gDrawPlafond;
245 
246 private:
248  bool _modified;
249 
252 
253 protected:
257 
260 
262  bool _texture;
263 
265  bool _visible;
266 
268 };
269 
272 
273 #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.
The box class.
Definition: 3d.h:1294
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)
void drawName(TYElement *pModelerElement=nullptr)
void glVertex3fAndEnlargeBB(GLfloat x, GLfloat y, GLfloat z)
void glVertex3dAndEnlargeBB(GLdouble x, GLdouble y, GLdouble z)
virtual void computeBoundingBox()
bool _modified
Indique si l'element associe a ete modifie.
static OBox _globalBoundingBox
void gluPartialDiskAndEnlargeBB(GLUquadric *qobj, GLdouble innerRadius, GLdouble outerRadius, GLint slices, GLint loops, GLdouble startAngle, GLdouble sweepAngle)
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.
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)
static bool _gDrawPlafond
Indique si les plafonds doivent etre visible.
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
void setElement(TYElement *pElt)
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)
TYElement * _pElement
L'element metier auquel cet element graphique metier est associe.
void gluDiskAndEnlargeBB(GLUquadric *qobj, GLdouble innerRadius, GLdouble outerRadius, GLint slices, GLint loops)
void viewOnlyHighlight(bool state=true)
void gluCylinderAndEnlargeBB(GLUquadric *qobj, GLdouble baseRadius, GLdouble topRadius, GLdouble height, GLint slices, GLint stacks)
bool getModified(bool andReset=false)
void highlight(bool state=true)
virtual ~TYElementGraphic()
void setVisible(bool visible=true)
bool _viewOnlyHighlight
Inique si on affiche la bounding box seule.