Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYAcousticSemiCircleGraphic.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 "gui/gl/TYRenderContext.h"
27 #include <QtOpenGL>
28 
30  : TYElementGraphic(pElement)
31 {
32 }
33 
35 
36 void TYAcousticSemiCircleGraphic::update(bool force /*=false*/)
37 {
39 }
40 
42 {
44 
45  double rayon = getElement()->getDiameter() / 2.0;
46  boundingBox.Enlarge((float)(getElement()->getCenter()._x + rayon),
47  (float)(getElement()->getCenter()._y + rayon), (float)(getElement()->getCenter()._z));
48  boundingBox.Enlarge((float)(getElement()->getCenter()._x - rayon),
49  (float)(getElement()->getCenter()._y - rayon), (float)(getElement()->getCenter()._z));
50  return boundingBox;
51 }
52 
54 {
55  // CLM-NT35: En overlay, affiche seulement le nom de l'élément localisé
56  if (renderContext.pass == TYRenderPass::Overlay)
57  {
58  drawName(renderContext);
59  }
60  else
61  {
62 
63  if (_visible)
64  {
65  OColor tmpColor;
66  glGetFloatv(GL_CURRENT_COLOR, tmpColor);
67  // glColor4fv(getElement()->getColor());
68  glColor3fv(getElement()->getColor());
69 
70  double rayon = getElement()->getDiameter() / 2.0;
71 
72  // Resolution
73  int resolution = TYDEFAULTRESOLUTIONIONCIRCLE;
74 
75 #if TY_USE_IHM
76  // static const char prefName[] = "ResolutionCircle";
77 
78  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "ResolutionCircle"))
79  {
80  resolution = TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "ResolutionCircle");
81  }
82  else
83  {
84  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "ResolutionCircle", resolution);
85  }
86 #endif // TY_USE_IHM
87 
88  GLUquadricObj* qobj = gluNewQuadric();
89  glPushMatrix();
90  glTranslatef(getElement()->getCenter()._x, getElement()->getCenter()._y,
91  getElement()->getCenter()._z);
92 
93  if (renderContext.type == TYRenderType::Picking)
94  {
95  TYPickingTable::addElement(getElement());
96  glPushName((GLuint)(TYPickingTable::getIndex()));
97  }
98 
99  gluPartialDisk(qobj, 0, rayon, resolution, 1, 0, 180);
100 
101  if (renderContext.type == TYRenderType::Picking)
102  {
103  glPopName();
104  }
105 
106  gluDeleteQuadric(qobj);
107  glPopMatrix();
108 
109  // Affichage de la source surfacique
110  getElement()->getSrcSurf()->getGraphicObject()->display(renderContext);
111  }
112  }
113 }
Représentation graphique d'1/2 cercle acoustique (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:36
virtual void display(TYRenderContext &renderContext)
virtual void update(bool force=false)
TYAcousticSemiCircleGraphic(TYAcousticSemiCircle *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)
static int getIndex()
static void addElement(TYElement *pElt)
TYRenderType type
TYRenderPass pass