Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYAcousticCircleGraphic.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 
31 
32 void TYAcousticCircleGraphic::update(bool force /*=false*/)
33 {
35 }
36 
38 {
40 
41  double diametre = getElement()->getDiameter();
42  boundingBox.Enlarge((float)(-diametre / 2), (float)(-diametre / 2),
43  (float)(getElement()->getCenter()._z));
44  boundingBox.Enlarge((float)(diametre / 2), (float)(diametre / 2), (float)(getElement()->getCenter()._z));
45  return boundingBox;
46 }
47 
49 {
50 
51  // CLM-NT35: En overlay, on affiche seulement le nom de l'élement localisé
52  if (renderContext.pass == TYRenderPass::Overlay)
53  {
54  drawName(renderContext);
55  }
56  else
57  {
58 
59  if (_visible)
60  {
61  OColor tmpColor;
62  glGetFloatv(GL_CURRENT_COLOR, tmpColor);
63  glColor4fv(getElement()->getColor());
64 
65  double rayon = getElement()->getDiameter() / 2.0;
66 
67  // Resolution
68  int resolution = TYDEFAULTRESOLUTIONIONCIRCLE;
69 
70 #if TY_USE_IHM
71  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "ResolutionCircle"))
72  {
73  resolution = TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "ResolutionCircle");
74  }
75  else
76  {
77  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "ResolutionCircle", resolution);
78  }
79 #endif // TY_USE_IHM
80 
81  GLUquadricObj* qobj = gluNewQuadric();
82  glPushMatrix();
83  glTranslatef(0.0, 0.0, getElement()->getCenter()._z);
84 
85  if (renderContext.type == TYRenderType::Picking)
86  {
87  TYPickingTable::addElement(getElement());
88  glPushName((GLuint)(TYPickingTable::getIndex()));
89  }
90 
91  // Dessine un disque de centre [0 0 getElement()->getCenter()._z]:
92  gluDisk(qobj, 0, rayon, resolution, 1);
93 
94  if (renderContext.type == TYRenderType::Picking)
95  {
96  glPopName();
97  }
98  gluDeleteQuadric(qobj);
99  glPopMatrix();
100 
101  // Affichage de la normale
103  {
104  OPoint3D p1 = getElement()->getCenter();
105  OVector3D n = getElement()->normal();
106  n.normalize();
107  n = n * 5;
108  displayNormal(n, p1);
109  }
110 
111  glColor3fv(tmpColor);
112 
113  // Affichage de la source surfacique
114  getElement()->getSrcSurf()->getGraphicObject()->display(renderContext);
115  }
116  }
117 }
QColor getColor
Representation graphique d'un cercle accoustique (fichier header)
#define TYDEFAULTRESOLUTIONIONCIRCLE
Resolution par defaut pour la representation des cercles par des segments.
Definition: TYDefines.h:415
#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
Definition: color.h:31
The 3D point class.
Definition: 3d.h:487
The 3D vector class.
Definition: 3d.h:298
OVector3D normal(const OVector3D &vector2, const OVector3D &vector3) const
Computes the normal with this vector and 2 others.
Definition: 3d.cpp:220
void normalize()
Normalizes this vector.
Definition: 3d.cpp:225
virtual OBox computeBoundingBox() const
virtual void update(bool force=false)
virtual void display(TYRenderContext &renderContext)
TYAcousticCircleGraphic(TYAcousticCircle *pElement)
classe graphique pour un element de base
void drawName(TYRenderContext &renderContext)
bool _visible
Inique si l'element est visible.
static bool _gDrawNormals
Indique si les normals doivent etre visible.
OBox boundingBox() const
void displayNormal(OVector3D normal, OPoint3D p1)
virtual void update(bool force=false)
static int getIndex()
static void addElement(TYElement *pElt)
const TYRenderType type
const TYRenderPass pass