Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYAcousticCylinderGraphic.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
25 #include "gui/gl/TYRenderContext.h"
26 #include <QtOpenGL>
27 
29  : TYElementGraphic(pElement)
30 {
31 }
32 
34 
35 void TYAcousticCylinderGraphic::update(bool force /*=false*/)
36 {
38 }
39 
41 {
42  TYElementGraphic* pTYElementGraphic = nullptr;
43  // Src surf
44  pTYElementGraphic = getElement()->getSrcSurf()->getGraphicObject();
45  childs.push_back(pTYElementGraphic);
46  if (recursif)
47  {
48  pTYElementGraphic->getChilds(childs, recursif);
49  }
50  // Cercle top
51  pTYElementGraphic = getElement()->getCircTop()->getGraphicObject();
52  childs.push_back(pTYElementGraphic);
53  if (recursif)
54  {
55  pTYElementGraphic->getChilds(childs, recursif);
56  }
57  // Cercle bottom
58  pTYElementGraphic = getElement()->getCircBottom()->getGraphicObject();
59  childs.push_back(pTYElementGraphic);
60  if (recursif)
61  {
62  pTYElementGraphic->getChilds(childs, recursif);
63  }
64 }
65 
67 {
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  return boundingBox;
80 }
81 
83 {
84  if (renderContext.pass == TYRenderPass::Overlay)
85  {
86  drawName(renderContext);
87  }
88  else
89  {
90  if (_visible)
91  {
92  if (renderContext.type == TYRenderType::Picking)
93  {
94  TYPickingTable::addElement(getElement());
95  glPushName((GLuint)(TYPickingTable::getIndex()));
96  }
97 
98  // Enveloppe
99  getElement()->getSrcSurf()->getGraphicObject()->display(renderContext);
100  // Cercle top
101  getElement()->getCircTop()->getGraphicObject()->display(renderContext);
102  // Cercle bottom
103  getElement()->getCircBottom()->getGraphicObject()->display(renderContext);
104 
105  // Couleur
106  glColor3fv(getElement()->getColor());
107 
108  // Centre
109  double center[3];
110  getElement()->getCenter().getToOGL(center);
111 
112  // Resolution
113  int resolution = TYDEFAULTRESOLUTIONIONCIRCLE;
114 
115 #if TY_USE_IHM
116  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "ResolutionCircle"))
117  {
118  resolution = TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "ResolutionCircle");
119  }
120  else
121  {
122  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "ResolutionCircle", resolution);
123  }
124 
125 #endif // TY_USE_IHM
126 
127  OPoint3D oCenter = getElement()->getCenter();
128  glTranslatef(oCenter._x, oCenter._y, oCenter._z);
129 
130  // Dessin de l'enveloppe
131  TYTabRectangle tabRect = getElement()->getEnveloppe(resolution);
132 
133  for (int i = 0; i < resolution; i++)
134  {
135  tabRect[i].getGraphicObject()->display(renderContext);
136  }
137 
138  if (renderContext.type == TYRenderType::Picking)
139  {
140  glPopName();
141  }
142  }
143  }
144 }
QColor getColor
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:51
Gestion de la table de correspondance indice/element pour le picking (fichier header)
Contexte de rendu utilisé par les fonctions d'affichage.
@ Picking
The current render is only done for picking purpose.
@ Overlay
The current render pass is for overlay elements.
The box class.
Definition: 3d.h:1346
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(TYRenderContext &renderContext)
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(TYRenderContext &renderContext)
bool _visible
Inique si l'element est visible.
OBox boundingBox() const
virtual void update(bool force=false)
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
static int getIndex()
static void addElement(TYElement *pElt)
const TYRenderType type
const TYRenderPass pass