Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYPlanEauGraphic.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 
23 #include "TYPlanEauGraphic.h"
24 
26 
29 
31 {
32  _pPolygon = new TYPolygon();
33 }
34 
35 void TYPlanEauGraphic::update(bool force /*=false*/)
36 {
38 }
39 
40 void TYPlanEauGraphic::getChilds(TYListPtrTYElementGraphic& childs, bool recursif /*=true*/)
41 {
42  TYElementGraphic* pTYElementGraphic = _pPolygon->getGraphicObject();
43  childs.push_back(pTYElementGraphic);
44  if (recursif)
45  {
46  pTYElementGraphic->getChilds(childs, recursif);
47  }
48 }
49 
51 {
52  OBox reset;
53  _boundingBox = reset;
54  _pPolygon->getGraphicObject()->computeBoundingBox();
55  _boundingBox = _pPolygon->getGraphicObject()->GetBox();
56 }
57 
58 void TYPlanEauGraphic::display(TYElement* pModelerElement /*= nullptr*/, GLenum mode /*= GL_RENDER*/)
59 {
60  if (!_visible)
61  {
62  return;
63  }
64 
65  TYElementGraphic::display(pModelerElement, mode);
66 
67  TYTabPoint tabpoints = getElement()->getListPoints();
68 
69  // Ajout d'un offset pour limiter le flickering avec l'altimetrie
70  for (unsigned int i = 0; i < tabpoints.size(); i++)
71  {
72  tabpoints[i]._z += 0.5; // Anciennement 0.05
73  }
74 
75  _pPolygon->setPoints(tabpoints);
76 
77  if (mode == GL_SELECT)
78  {
79  TYPickingTable::addElement(getElement());
80  glPushName((GLuint)(TYPickingTable::getIndex()));
81  }
82 
83  glColor4fv(getElement()->getColor());
84 
85  _pPolygon->getGraphicObject()->highlight(_highlight);
86  _pPolygon->getGraphicObject()->display(pModelerElement, mode);
87  if ((_highlight) && (mode == GL_COMPILE))
88  {
90  drawName(pModelerElement);
91  }
92 
93  if (mode == GL_SELECT)
94  {
95  glPopName();
96  }
97 }
std::vector< TYPoint > TYTabPoint
Collection de TYPoint.
Definition: TYDefines.h:340
list< TYElementGraphic * > TYListPtrTYElementGraphic
List de pointeur de TYElement.
Gestion de la table de correspondance indice/element pour le picking (fichier header)
Representation graphique d'un plan d'eau (fichier header)
The box class.
Definition: 3d.h:1294
classe graphique pour un element de base
void drawName(TYElement *pModelerElement=nullptr)
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)
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)
static int getIndex()
static void addElement(TYElement *pElt)
LPTYPolygon _pPolygon
virtual void computeBoundingBox()
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)
virtual void update(bool force=false)
TYPlanEauGraphic(TYPlanEau *pElement)
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
void setPoints(const TYTabPoint &pts)
Definition: TYPolygon.cpp:389