Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYAcousticCircleGraphic.cpp
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 
25 
27 
29 
30 void TYAcousticCircleGraphic::update(bool force /*=false*/)
31 {
33 }
34 
36 {
37  OBox reset;
38  _boundingBox = reset;
39 
40  double diametre = getElement()->getDiameter();
41  _boundingBox.Enlarge((float)(-diametre / 2), (float)(-diametre / 2),
42  (float)(getElement()->getCenter()._z));
43  _boundingBox.Enlarge((float)(diametre / 2), (float)(diametre / 2), (float)(getElement()->getCenter()._z));
44 }
45 
46 void TYAcousticCircleGraphic::display(TYElement* pModelerElement /*= nullptr*/, GLenum mode /*= GL_RENDER*/)
47 {
48 
49  // CLM-NT35: En overlay, on affiche seulement le nom de l'élement localisé
50  if (mode == GL_COMPILE)
51  {
52  drawName(pModelerElement);
53  }
54  else
55  {
56  if (_highlight)
57  {
58  if (_bFirstDisp)
59  {
61  _bFirstDisp = false;
62  }
64  }
65 
66  if (_visible)
67  {
68  OColor tmpColor;
69  glGetFloatv(GL_CURRENT_COLOR, tmpColor);
70  glColor4fv(getElement()->getColor());
71 
72  double rayon = getElement()->getDiameter() / 2.0;
73 
74  // Resolution
75  int resolution = TYDEFAULTRESOLUTIONIONCIRCLE;
76 
77 #if TY_USE_IHM
78  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "ResolutionCircle"))
79  {
80  resolution = TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "ResolutionCircle");
81  }
82  else
83  {
84  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "ResolutionCircle", resolution);
85  }
86 #endif // TY_USE_IHM
87 
88  GLUquadricObj* qobj = gluNewQuadric();
89  glPushMatrix();
90  glTranslatef(0.0, 0.0, getElement()->getCenter()._z);
91 
92  if (mode == GL_SELECT)
93  {
94  TYPickingTable::addElement(getElement());
95  glPushName((GLuint)(TYPickingTable::getIndex()));
96  }
97 
98  // Dessine un disque de centre [0 0 getElement()->getCenter()._z]:
99  gluDiskAndEnlargeBB(qobj, 0, rayon, resolution, 1);
100 
101  if (mode == GL_SELECT)
102  {
103  glPopName();
104  }
105  gluDeleteQuadric(qobj);
106  glPopMatrix();
107 
108  // Calcul du volume englobant pour le fit:
110 
111  // Affichage de la normale
113  {
114  OPoint3D p1 = getElement()->getCenter();
115  OVector3D n = getElement()->normal();
116  n.normalize();
117  n = n * 5;
118  displayNormal(n, p1);
119  }
120 
121  glColor3fv(tmpColor);
122 
123  // Affichage de la source surfacique
124  getElement()->getSrcSurf()->getGraphicObject()->display(pModelerElement, mode);
125  }
126  }
127 }
Representation graphique d'un cercle accoustique (fichier header)
#define TYDEFAULTRESOLUTIONIONCIRCLE
Resolution par defaut pour la representation des cercles par des segments.
Definition: TYDefines.h:415
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:52
Gestion de la table de correspondance indice/element pour le picking (fichier header)
The box class.
Definition: 3d.h:1294
virtual void Enlarge(const OPoint3D &pt)
Enlarge the box with the point if the point is outside the box.
Definition: 3d.cpp:1614
Definition: color.h:31
The 3D point class.
Definition: 3d.h:487
The 3D vector class.
Definition: 3d.h:298
OVector3D normal(const OVector3D &vector2, const OVector3D &vector3) const
Computes the normal with this vector and 2 others.
Definition: 3d.cpp:220
void normalize()
Normalizes this vector.
Definition: 3d.cpp:225
virtual void update(bool force=false)
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)
TYAcousticCircleGraphic(TYAcousticCircle *pElement)
classe graphique pour un element de base
void drawName(TYElement *pModelerElement=nullptr)
static OBox _globalBoundingBox
bool _visible
Inique si l'element est visible.
static bool _gDrawNormals
Indique si les normals doivent etre visible.
bool _highlight
Indique si le highlight est active pour cet element.
void displayNormal(OVector3D normal, OPoint3D p1)
virtual void update(bool force=false)
void gluDiskAndEnlargeBB(GLUquadric *qobj, GLdouble innerRadius, GLdouble outerRadius, GLint slices, GLint loops)
static int getIndex()
static void addElement(TYElement *pElt)