Code_TYMPAN  4.2.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 
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 
34 #if TY_USE_IHM
35 #include <QtOpenGL>
36 #include <GL/gl.h>
37 #include <GL/glu.h>
38 /* #include <qobject.h> */
39 /* #include <qgl.h> */
40 #else
41 #include <GL/gl.h>
42 #include <GL/glu.h>
43 #endif // TY_USE_IHM
44 
46 #include "Tympan/core/color.h"
47 #include "Tympan/core/smartptr.h"
48 
49 class TYElement;
50 
51 
52 #define TY_DECL_METIER_GRAPHIC(classname) \
53  public: \
54  inline classname * getElement() const { return (classname *) _pElement; }
55 
56 
57 #include <list>
58 // Pour l'utilisation de la librairie standard STL.
59 using std::list;
60 
63 typedef list<TYElementGraphic*> TYListPtrTYElementGraphic;
64 
70 {
71  // Methodes
72 public:
76  virtual ~TYElementGraphic();
77 
81  void setElement(TYElement* pElt);
86 
91  void updateTree();
92 
101  virtual void update(bool force = false);
102 
108  virtual void display(GLenum mode = GL_RENDER);
109 
113  void setModified(bool modified = true) { _modified = modified;}
117  bool getModified(bool andReset = false);
118 
122  void setVisible(bool visible = true) { _visible = visible; }
126  bool getVisible() { return _visible;}
130  void setRecursiveVisible(bool visible = true);
131 
135  void setTexture(bool state = true) { _texture = state; }
139  bool getTexture() { return _texture;}
140 
144  OBox GetBox() { return _boundingBox;}
145 
146  virtual void computeBoundingBox();
147  virtual void getChilds(TYListPtrTYElementGraphic& childs, bool recursif = true) {};
148 
153  void highlight(bool state = true);
154 
158  bool getHighlightState();
159 
163  void viewOnlyHighlight(bool state = true);
168 
169 
170 public:
171 
172 #if TY_USE_IHM
173  virtual void activateSignal() {};
174 
178  virtual void connectUpdateSignal(QObject* pReceiver, const char* member) {};
182  virtual void disconnectUpdateSignal(QObject* pReceiver, const char* member) {};
183 #endif // TY_USE_IHM
184 
186 
187 
188 protected:
193 
194  void displayNormal(OVector3D normal, OPoint3D p1);
195 
196  void glVertex3fAndEnlargeBB(GLfloat x, GLfloat y, GLfloat z);
197  void glVertex3dAndEnlargeBB(GLdouble x, GLdouble y, GLdouble z);
198  void gluDiskAndEnlargeBB(GLUquadric* qobj,
199  GLdouble innerRadius,
200  GLdouble outerRadius,
201  GLint slices,
202  GLint loops);
203  void gluCylinderAndEnlargeBB(GLUquadric* qobj,
204  GLdouble baseRadius,
205  GLdouble topRadius,
206  GLdouble height,
207  GLint slices,
208  GLint stacks);
209  void gluPartialDiskAndEnlargeBB(GLUquadric* qobj,
210  GLdouble innerRadius,
211  GLdouble outerRadius,
212  GLint slices,
213  GLint loops,
214  GLdouble startAngle,
215  GLdouble sweepAngle);
216  void drawBoundingBox();
217  void drawLineBoundingBox();
218  void drawName();
219 
220 public:
222  static bool _gDrawNormals;
223 
225  static bool _gDrawPlafond;
226 
227 private:
229  bool _modified;
230 
233 protected:
237 
240 
242  bool _texture;
243 
245  bool _visible;
246 
248 };
249 
250 
253 
254 
255 #endif // __TY_ELEMENT_GRAPHIC__
The 3D vector class.
Definition: 3d.h:296
static bool _gDrawNormals
Indique si les normals doivent etre visible.
list< TYElementGraphic * > TYListPtrTYElementGraphic
List de pointeur de TYElement.
bool _visible
Inique si l&#39;element est visible.
bool _viewOnlyHighlight
Inique si on affiche la bounding box seule.
void gluCylinderAndEnlargeBB(GLUquadric *qobj, GLdouble baseRadius, GLdouble topRadius, GLdouble height, GLint slices, GLint stacks)
void glVertex3dAndEnlargeBB(GLdouble x, GLdouble y, GLdouble z)
void viewOnlyHighlight(bool state=true)
The box class.
Definition: 3d.h:1292
virtual ~TYElementGraphic()
bool getModified(bool andReset=false)
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
static OBox _globalBoundingBox
bool _highlight
Indique si le highlight est active pour cet element.
TYElement * getTYElement()
TYElementGraphic(TYElement *pElt)
bool _modified
Indique si l&#39;element associe a ete modifie.
virtual void update(bool force=false)
void displayNormal(OVector3D normal, OPoint3D p1)
void setTexture(bool state=true)
void gluDiskAndEnlargeBB(GLUquadric *qobj, GLdouble innerRadius, GLdouble outerRadius, GLint slices, GLint loops)
void glVertex3fAndEnlargeBB(GLfloat x, GLfloat y, GLfloat z)
void setRecursiveVisible(bool visible=true)
void gluPartialDiskAndEnlargeBB(GLUquadric *qobj, GLdouble innerRadius, GLdouble outerRadius, GLint slices, GLint loops, GLdouble startAngle, GLdouble sweepAngle)
classe graphique pour un element de base
static bool _gDrawPlafond
Indique si les plafonds doivent etre visible.
virtual void computeBoundingBox()
The 3D point class.
Definition: 3d.h:484
void setElement(TYElement *pElt)
void setModified(bool modified=true)
void setVisible(bool visible=true)
TYElement * _pElement
L&#39;element metier auquel cet element graphique metier est associe.
SmartPtr< TYElementGraphic > LPTYElementGraphic
Smart pointer sur TYElementGraphic.
bool _texture
Indique si le texturing est active pour cet element.
virtual void display(GLenum mode=GL_RENDER)
void highlight(bool state=true)