Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYAcousticSemiCircleGraphic.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 
26 
28  : TYElementGraphic(pElement)
29 {
30 }
31 
33 
34 void TYAcousticSemiCircleGraphic::update(bool force /*=false*/)
35 {
37 }
38 
40 {
41  OBox reset;
42  _boundingBox = reset;
43 
44  double rayon = getElement()->getDiameter() / 2.0;
45  _boundingBox.Enlarge((float)(getElement()->getCenter()._x + rayon),
46  (float)(getElement()->getCenter()._y + rayon),
47  (float)(getElement()->getCenter()._z));
48  _boundingBox.Enlarge((float)(getElement()->getCenter()._x - rayon),
49  (float)(getElement()->getCenter()._y - rayon),
50  (float)(getElement()->getCenter()._z));
51 }
52 
53 void TYAcousticSemiCircleGraphic::display(TYElement* pModelerElement /*= nullptr*/,
54  GLenum mode /*= GL_RENDER*/)
55 {
56  // CLM-NT35: En overlay, affiche seulement le nom de l'élément localisé
57  if (mode == GL_COMPILE)
58  {
59  drawName(pModelerElement);
60  }
61  else
62  {
63  // TYElementGraphic::display(mode);
64  if (_highlight)
65  {
66  if (_bFirstDisp)
67  {
69  _bFirstDisp = false;
70  }
71 
73  }
74 
75  if (_visible)
76  {
77  OColor tmpColor;
78  glGetFloatv(GL_CURRENT_COLOR, tmpColor);
79  // glColor4fv(getElement()->getColor());
80  glColor3fv(getElement()->getColor());
81 
82  double rayon = getElement()->getDiameter() / 2.0;
83 
84  // Resolution
85  int resolution = TYDEFAULTRESOLUTIONIONCIRCLE;
86 
87 #if TY_USE_IHM
88  // static const char prefName[] = "ResolutionCircle";
89 
90  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "ResolutionCircle"))
91  {
92  resolution = TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "ResolutionCircle");
93  }
94  else
95  {
96  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "ResolutionCircle", resolution);
97  }
98 #endif // TY_USE_IHM
99 
100  GLUquadricObj* qobj = gluNewQuadric();
101  glPushMatrix();
102  glTranslatef(getElement()->getCenter()._x, getElement()->getCenter()._y,
103  getElement()->getCenter()._z);
104 
105  if (mode == GL_SELECT)
106  {
107  TYPickingTable::addElement(getElement());
108  glPushName((GLuint)(TYPickingTable::getIndex()));
109  }
110 
111  gluPartialDiskAndEnlargeBB(qobj, 0, rayon, resolution, 1, 0, 180);
112 
113  if (mode == GL_SELECT)
114  {
115  glPopName();
116  }
117 
118  gluDeleteQuadric(qobj);
119  glPopMatrix();
120  // Calcul du volume englobant pour le fit:
122 
123  // Affichage de la source surfacique
124  getElement()->getSrcSurf()->getGraphicObject()->display(pModelerElement, mode);
125  }
126  }
127 }
Représentation graphique d'1/2 cercle acoustique (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
virtual void update(bool force=false)
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)
TYAcousticSemiCircleGraphic(TYAcousticSemiCircle *pElement)
classe graphique pour un element de base
void drawName(TYElement *pModelerElement=nullptr)
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.
bool _highlight
Indique si le highlight est active pour cet element.
virtual void update(bool force=false)
static int getIndex()
static void addElement(TYElement *pElt)