Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYAcousticCylinderGraphic.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 TYAcousticCylinderGraphic::update(bool force /*=false*/)
35 {
37 }
38 
40 {
41  TYElementGraphic* pTYElementGraphic = nullptr;
42  // Src surf
43  pTYElementGraphic = getElement()->getSrcSurf()->getGraphicObject();
44  childs.push_back(pTYElementGraphic);
45  if (recursif)
46  {
47  pTYElementGraphic->getChilds(childs, recursif);
48  }
49  // Cercle top
50  pTYElementGraphic = getElement()->getCircTop()->getGraphicObject();
51  childs.push_back(pTYElementGraphic);
52  if (recursif)
53  {
54  pTYElementGraphic->getChilds(childs, recursif);
55  }
56  // Cercle bottom
57  pTYElementGraphic = getElement()->getCircBottom()->getGraphicObject();
58  childs.push_back(pTYElementGraphic);
59  if (recursif)
60  {
61  pTYElementGraphic->getChilds(childs, recursif);
62  }
63 }
64 
66 {
67  OBox reset;
68  _boundingBox = reset;
69 
70  TYTabPoint sommets = getElement()->sommets();
71 
72  size_t nbPts = sommets.size();
73  TYPoint pt;
74  for (size_t i = 0; i < nbPts; i++)
75  {
76  pt = sommets[i];
77  _boundingBox.Enlarge((float)(pt._x), (float)(pt._y), (float)(pt._z));
78  }
79 }
80 
81 void TYAcousticCylinderGraphic::display(TYElement* pModelerElement /*= nullptr*/, GLenum mode /*= GL_RENDER*/)
82 {
83  if (mode == GL_COMPILE)
84  {
85  drawName(pModelerElement);
86  }
87  else
88  {
89  if (_highlight)
90  {
91  if (_bFirstDisp)
92  {
94  _bFirstDisp = false;
95  }
97  }
98 
99  if (_visible)
100  {
101  if (mode == GL_SELECT)
102  {
103  TYPickingTable::addElement(getElement());
104  glPushName((GLuint)(TYPickingTable::getIndex()));
105  }
106 
107  // Enveloppe
108  getElement()->getSrcSurf()->getGraphicObject()->display(pModelerElement, mode);
109  // Cercle top
110  getElement()->getCircTop()->getGraphicObject()->display(pModelerElement, mode);
111  // Cercle bottom
112  getElement()->getCircBottom()->getGraphicObject()->display(pModelerElement, mode);
113 
114  // Couleur
115  glColor3fv(getElement()->getColor());
116 
117  // Centre
118  double center[3];
119  getElement()->getCenter().getToOGL(center);
120 
121  // Resolution
122  int resolution = TYDEFAULTRESOLUTIONIONCIRCLE;
123 
124 #if TY_USE_IHM
125  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "ResolutionCircle"))
126  {
127  resolution = TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "ResolutionCircle");
128  }
129  else
130  {
131  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "ResolutionCircle", resolution);
132  }
133 
134 #endif // TY_USE_IHM
135 
136  OPoint3D oCenter = getElement()->getCenter();
137  glTranslatef(oCenter._x, oCenter._y, oCenter._z);
138 
139  // Dessin de l'enveloppe
140  TYTabRectangle tabRect = getElement()->getEnveloppe(resolution);
141 
142  for (int i = 0; i < resolution; i++)
143  {
144  tabRect[i].getGraphicObject()->display(pModelerElement, mode);
145  }
146 
147  if (mode == GL_SELECT)
148  {
149  glPopName();
151  }
152  }
153  }
154 }
Representation graphique d'un cylindre accoustique (fichier header)
std::vector< TYRectangle > TYTabRectangle
Collection de TYRectangle.
Definition: TYDefines.h:346
std::vector< TYPoint > TYTabPoint
Collection de TYPoint.
Definition: TYDefines.h:340
#define TYDEFAULTRESOLUTIONIONCIRCLE
Resolution par defaut pour la representation des cercles par des segments.
Definition: TYDefines.h:415
list< TYElementGraphic * > TYListPtrTYElementGraphic
List de pointeur de TYElement.
#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
double _y
y coordinate of OCoord3D
Definition: 3d.h:283
double _z
z coordinate of OCoord3D
Definition: 3d.h:284
double _x
x coordinate of OCoord3D
Definition: 3d.h:282
The 3D point class.
Definition: 3d.h:487
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
TYAcousticCylinderGraphic(TYAcousticCylinder *pElement)
virtual void update(bool force=false)
classe graphique pour un element de base
void drawName(TYElement *pModelerElement=nullptr)
static OBox _globalBoundingBox
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)
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
static int getIndex()
static void addElement(TYElement *pElt)