Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYAcousticSemiCylinderGraphic.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 TYAcousticSemiCylinderGraphic::update(bool force /*=false*/)
35 {
37 }
38 
40 {
41  TYElementGraphic* pTYElementGraphic = nullptr;
42  pTYElementGraphic = getElement()->getSrcSurf()->getGraphicObject();
43  childs.push_back(pTYElementGraphic);
44  if (recursif)
45  {
46  pTYElementGraphic->getChilds(childs, recursif);
47  }
48 
49  pTYElementGraphic = getElement()->getSemiCircTop()->getGraphicObject();
50  childs.push_back(pTYElementGraphic);
51  if (recursif)
52  {
53  pTYElementGraphic->getChilds(childs, recursif);
54  }
55 
56  pTYElementGraphic = getElement()->getSemiCircBottom()->getGraphicObject();
57  childs.push_back(pTYElementGraphic);
58  if (recursif)
59  {
60  pTYElementGraphic->getChilds(childs, recursif);
61  }
62 
63  // Face laterale
64  pTYElementGraphic = getElement()->getRect()->getGraphicObject();
65  childs.push_back(pTYElementGraphic);
66  if (recursif)
67  {
68  pTYElementGraphic->getChilds(childs, recursif);
69  }
70 
71  // Resolution
72  int resolution = TYDEFAULTRESOLUTIONIONCIRCLE;
73  TYTabRectangle tabRect = getElement()->getEnveloppe(resolution);
74  for (int i = 0; i < resolution; i++)
75  {
76  pTYElementGraphic = tabRect[i].getGraphicObject();
77  childs.push_back(pTYElementGraphic);
78  if (recursif)
79  {
80  pTYElementGraphic->getChilds(childs, recursif);
81  }
82  }
83 }
84 
86 {
87  OBox reset;
88  _boundingBox = reset;
89 
90  // Src surf
91  getElement()->getSrcSurf()->getGraphicObject()->computeBoundingBox();
92  _boundingBox.Enlarge(getElement()->getSrcSurf()->getGraphicObject()->GetBox());
93 
94  // Cercle top
95  getElement()->getSemiCircTop()->getGraphicObject()->computeBoundingBox();
96  _boundingBox.Enlarge(getElement()->getSemiCircTop()->getGraphicObject()->GetBox());
97 
98  // Cercle bottom
99  getElement()->getSemiCircBottom()->getGraphicObject()->computeBoundingBox();
100  _boundingBox.Enlarge(getElement()->getSemiCircBottom()->getGraphicObject()->GetBox());
101 }
102 
103 void TYAcousticSemiCylinderGraphic::display(TYElement* pModelerElement /*= nullptr*/,
104  GLenum mode /*= GL_RENDER*/)
105 {
106  // TYElementGraphic::display(mode);
107 
108  // CLM-NT35: En overlay, affiche seulement le nom de l'élément localisé
109  if (mode == GL_COMPILE)
110  {
111  drawName(pModelerElement);
112  }
113  else
114  {
115  if (_highlight)
116  {
117  if (_bFirstDisp)
118  {
120  _bFirstDisp = false;
121  }
123  }
124 
125  if (_visible)
126  {
127  // Src surf
128  getElement()->getSrcSurf()->getGraphicObject()->display(pModelerElement, mode);
129 
130  if (mode == GL_SELECT)
131  {
132  TYPickingTable::addElement(getElement());
133  glPushName((GLuint)(TYPickingTable::getIndex()));
134  }
135 
136  // Face laterale
137  getElement()->getRect()->getGraphicObject()->display(pModelerElement, mode);
138 
139  // Cercle top
140  getElement()->getSemiCircTop()->getGraphicObject()->display(pModelerElement, mode);
141 
142  // Cercle bottom
143  getElement()->getSemiCircBottom()->getGraphicObject()->display(pModelerElement, mode);
144 
145  // Couleur
146  glColor3fv(getElement()->getColor());
147 
148  // Resolution
149  int resolution = TYDEFAULTRESOLUTIONIONCIRCLE;
150 
151 #if TY_USE_IHM
152  // static const char prefName[] = "ResolutionCircle";
153 
154  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "ResolutionCircle"))
155  {
156  resolution = TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "ResolutionCircle");
157  }
158  else
159  {
160  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "ResolutionCircle", resolution);
161  }
162 
163 #endif // TY_USE_IHM
164 
165  glTranslatef(getElement()->getCenter()._x, getElement()->getCenter()._y,
166  getElement()->getCenter()._z);
167 
168  // Dessin de l'enveloppe
169  TYTabRectangle tabRect = getElement()->getEnveloppe(resolution);
170 
171  for (int i = 0; i < resolution; i++)
172  {
173  tabRect[i].getGraphicObject()->display(pModelerElement, mode);
174  }
175 
176  if (mode == GL_SELECT)
177  {
178  glPopName();
179  // Calcul du volume englobant pour le fit:
181  }
182  }
183  }
184 }
Representation graphique d'un 1/2 cylindre acoustique (fichier header)
std::vector< TYRectangle > TYTabRectangle
Collection de TYRectangle.
Definition: TYDefines.h:346
#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
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
virtual void update(bool force=false)
TYAcousticSemiCylinderGraphic(TYAcousticSemiCylinder *pElement)
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)