Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYLinearMaillageGraphic.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 
21 #include "Tympan/core/defines.h"
29 
30 #include <math.h>
31 
33 {
34  _scalarX = 0.8;
35  _scalarY = 0.25;
36 
37  _scalarW = 150.0;
38  _scalarH = 15.0;
39 
40  _panelW = 125.0;
41  _panelH = 40.0;
42 
43  TYElementGraphic* pTYElementGraphic = getElement()->getPalette()->getGraphicObject();
44  ((TYPaletteGraphic*)pTYElementGraphic)->setWidth(_scalarW);
45  ((TYPaletteGraphic*)pTYElementGraphic)->setHeight(_scalarH);
46 
47  pTYElementGraphic = getElement()->getPanel()->getGraphicObject();
48  ((TYPanelGraphic*)pTYElementGraphic)->setWidth(_panelW);
49  ((TYPanelGraphic*)pTYElementGraphic)->setHeight(_panelH);
50  pTYElementGraphic->setVisible(false);
51 }
52 
54 
55 void TYLinearMaillageGraphic::update(bool force /*=false*/)
56 {
57  TYLinearMaillage* pMaillage = getElement();
58  pMaillage->getPalette()->getGraphicObject()->update(force);
59 
61 }
62 
64 {
65  OBox reset;
66  _boundingBox = reset;
67  TYTabLPPointCalcul* pPtsCalcul = &getElement()->getPtsCalcul();
68  TYPointCalcul* pPtCalcul = NULL;
69  for (unsigned int i = 0; i < pPtsCalcul->size(); i++)
70  {
71  pPtCalcul = pPtsCalcul->at(i);
72  _boundingBox.Enlarge((float)(pPtCalcul->_x), (float)(pPtCalcul->_y), (float)(pPtCalcul->_z));
73  }
74 }
75 
76 void TYLinearMaillageGraphic::display(TYElement* pModelerElement /*= nullptr*/, GLenum mode /*= GL_RENDER*/)
77 {
78  // Pas affiche si inactif
79  if (getElement()->etat() == false)
80  {
81  return;
82  }
83 
84  // Les points de ce maillage
85  TYTabLPPointCalcul* pPtsCalcul = &getElement()->getPtsCalcul();
86 
87  if (_visible)
88  {
89 
90  if (mode == GL_SELECT)
91  {
92  TYPickingTable::addElement(getElement());
93  glPushName((GLuint)(TYPickingTable::getIndex()));
94  }
95 
96  float opacity = 1.0;
97 
98 #if TY_USE_IHM
99  // static const char prefName[] = "MaillageOpacity";
100 
101  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MaillageOpacity"))
102  {
103  opacity = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "MaillageOpacity");
104  }
105  else
106  {
107  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "MaillageOpacity", opacity);
108  }
109 #endif // TY_USE_IHM
110 
111  glBegin(GL_LINE_STRIP);
112  TYPointCalcul* pPtCalcul = NULL;
113  double value = 0.0;
114  for (unsigned int i = 0; i < pPtsCalcul->size(); i++)
115  {
116  pPtCalcul = pPtsCalcul->at(i);
117 
118  // Valeur du scalaire pour la color map
119  switch (getElement()->getDataType())
120  {
122  default:
123  value = pPtCalcul->getSpectre()->valGlobDBA();
124  break;
126  value = pPtCalcul->getSpectre()->valGlobDBLin();
127  break;
129  value = pPtCalcul->getSpectre()->getValueReal(getElement()->getDataFreq());
130  break;
131  }
132  const OColor& color = getElement()->getPalette()->getColorFromValue(value);
133  glColor4f(color.r, color.g, color.b, opacity);
134  glVertex3f(pPtCalcul->_x, pPtCalcul->_y, pPtCalcul->_z);
135  }
136  glEnd();
137 
138  if (mode == GL_SELECT)
139  {
140  glPopName();
141  }
142 
143  // Affichage du panel
144  TYElementGraphic* pTYElementGraphic = getElement()->getPanel()->getGraphicObject();
145  TYPanelGraphic* pTYPanelGraphic = (TYPanelGraphic*)pTYElementGraphic;
146  pTYPanelGraphic->display();
147 
148  // Calcul du volume englobant pour le fit:
150  }
151 
152  if (_highlight)
153  {
154  GLfloat pointSize = NAN;
155  glGetFloatv(GL_POINT_SIZE, &pointSize);
156 
157  if (_bFirstDisp)
158  {
160  _bFirstDisp = false;
161  }
163  if (mode == GL_COMPILE)
164  {
165  drawName(pModelerElement);
166  }
167 
168  glPointSize(pointSize);
169 
170  TYElementGraphic* pTYElementGraphic = getElement()->getPalette()->getGraphicObject();
171  TYPaletteGraphic* pTYPaletteGraphic = (TYPaletteGraphic*)pTYElementGraphic;
172  pTYPaletteGraphic->setPosX(OSizeManager::get()->getWidth() * _scalarX);
173  pTYPaletteGraphic->setPosY(OSizeManager::get()->getHeight() * _scalarY);
174  pTYPaletteGraphic->display();
175  }
176 }
std::vector< LPTYPointCalcul > TYTabLPPointCalcul
Collection de pointeurs de TYPointCalcul.
Definition: TYDefines.h:358
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:52
Representation graphique d'un maillage lineaire (fichier header)
Representation d'une palette graphique (fichier header)
Representation graphique d'un panel d'informations (fichier header)
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
Definition: color.h:31
float b
Definition: color.h:33
float r
Definition: color.h:33
float g
Definition: color.h:33
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
static LPOSizeManager get()
double valGlobDBA() const
Compute the global value dB[A] of a one-third Octave spectrum.
Definition: spectre.cpp:683
double valGlobDBLin() const
Compute the global value dB[Lin] of a one-third Octave spectrum.
Definition: spectre.cpp:671
double getValueReal(double freq)
Definition: spectre.cpp:959
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)
void setVisible(bool visible=true)
virtual void update(bool force=false)
TYLinearMaillageGraphic(TYLinearMaillage *pElement)
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)
Classe de definition d'un maillage lineaire.
@ ValGlobalDBLin
Definition: TYMaillage.h:299
LPTYPalette getPalette()
Get de la palette (_pPalette)
Definition: TYMaillage.h:265
Classe graphique pour representer une palette.
void setPosX(double x)
void setPosY(double y)
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)
classe graphique pour un panel d'informations
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)
static int getIndex()
static void addElement(TYElement *pElt)
Classe de definition d'un point de calcul.C'est une classe derivee a TYPoint avec en plus un spectrep...
Definition: TYPointCalcul.h:33
virtual LPTYSpectre getSpectre()
Get du spectre resultat d'un calcul donne.