Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYAcousticSemiCylinderGraphic.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 
26 #include <QtOpenGL>
27 
29  : TYElementGraphic(pElement)
30 {
31 }
32 
34 
35 void TYAcousticSemiCylinderGraphic::update(bool force /*=false*/)
36 {
38 }
39 
41 {
42  TYElementGraphic* pTYElementGraphic = nullptr;
43  pTYElementGraphic = getElement()->getSrcSurf()->getGraphicObject();
44  childs.push_back(pTYElementGraphic);
45  if (recursif)
46  {
47  pTYElementGraphic->getChilds(childs, recursif);
48  }
49 
50  pTYElementGraphic = getElement()->getSemiCircTop()->getGraphicObject();
51  childs.push_back(pTYElementGraphic);
52  if (recursif)
53  {
54  pTYElementGraphic->getChilds(childs, recursif);
55  }
56 
57  pTYElementGraphic = getElement()->getSemiCircBottom()->getGraphicObject();
58  childs.push_back(pTYElementGraphic);
59  if (recursif)
60  {
61  pTYElementGraphic->getChilds(childs, recursif);
62  }
63 
64  // Face laterale
65  pTYElementGraphic = getElement()->getRect()->getGraphicObject();
66  childs.push_back(pTYElementGraphic);
67  if (recursif)
68  {
69  pTYElementGraphic->getChilds(childs, recursif);
70  }
71 }
72 
74 {
76 
77  // Src surf
78  boundingBox.Enlarge(getElement()->getSrcSurf()->getGraphicObject()->boundingBox());
79 
80  // Cercle top
81  boundingBox.Enlarge(getElement()->getSemiCircTop()->getGraphicObject()->boundingBox());
82 
83  // Cercle bottom
84  boundingBox.Enlarge(getElement()->getSemiCircBottom()->getGraphicObject()->boundingBox());
85 
86  return boundingBox;
87 }
88 
90 {
91  // TYElementGraphic::display(renderContext);
92 
93  // CLM-NT35: En overlay, affiche seulement le nom de l'élément localisé
94  if (renderContext.pass == TYRenderPass::Overlay)
95  {
96  drawName(renderContext);
97  }
98  else
99  {
100 
101  if (_visible)
102  {
103  // Src surf
104  getElement()->getSrcSurf()->getGraphicObject()->display(renderContext);
105 
106  if (renderContext.type == TYRenderType::Picking)
107  {
108  TYPickingTable::addElement(getElement());
109  glPushName((GLuint)(TYPickingTable::getIndex()));
110  }
111 
112  // Face laterale
113  getElement()->getRect()->getGraphicObject()->display(renderContext);
114 
115  // Cercle top
116  getElement()->getSemiCircTop()->getGraphicObject()->display(renderContext);
117 
118  // Cercle bottom
119  getElement()->getSemiCircBottom()->getGraphicObject()->display(renderContext);
120 
121  // Couleur
122  glColor3fv(getElement()->getColor());
123 
124  // Resolution
125  int resolution = TYDEFAULTRESOLUTIONIONCIRCLE;
126 
127 #if TY_USE_IHM
128  // static const char prefName[] = "ResolutionCircle";
129 
130  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "ResolutionCircle"))
131  {
132  resolution = TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "ResolutionCircle");
133  }
134  else
135  {
136  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "ResolutionCircle", resolution);
137  }
138 
139 #endif // TY_USE_IHM
140 
141  glTranslatef(getElement()->getCenter()._x, getElement()->getCenter()._y,
142  getElement()->getCenter()._z);
143 
144  // Dessin de l'enveloppe
145  TYTabRectangle tabRect = getElement()->getEnveloppe(resolution);
146 
147  for (int i = 0; i < resolution; i++)
148  {
149  tabRect[i].getGraphicObject()->display(renderContext);
150  }
151 
152  if (renderContext.type == TYRenderType::Picking)
153  {
154  glPopName();
155  }
156  }
157  }
158 }
QColor getColor
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: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
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
virtual void display(TYRenderContext &renderContext)
virtual void update(bool force=false)
TYAcousticSemiCylinderGraphic(TYAcousticSemiCylinder *pElement)
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