Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYPlanEauGraphic.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 
23 #include "gui/gl/TYRenderContext.h"
24 #include <QtOpenGL>
25 
26 #include "TYPlanEauGraphic.h"
27 
29 
32 #include "gui/gl/TYRenderContext.h"
33 
35 {
36  _pPolygon = new TYPolygon();
37 }
38 
39 void TYPlanEauGraphic::update(bool force /*=false*/)
40 {
42 }
43 
44 void TYPlanEauGraphic::getChilds(TYListPtrTYElementGraphic& childs, bool recursif /*=true*/)
45 {
46  TYElementGraphic* pTYElementGraphic = _pPolygon->getGraphicObject();
47  childs.push_back(pTYElementGraphic);
48  if (recursif)
49  {
50  pTYElementGraphic->getChilds(childs, recursif);
51  }
52 }
53 
55 {
57  boundingBox = _pPolygon->getGraphicObject()->boundingBox();
58  return boundingBox;
59 }
60 
62 {
63  if (!_visible || !getElement()->isInCurrentCalcul())
64  {
65  return;
66  }
67 
68  TYElementGraphic::display(renderContext);
69 
70  TYTabPoint tabpoints = getElement()->getListPoints();
71 
72  // Ajout d'un offset pour limiter le flickering avec l'altimetrie
73  for (unsigned int i = 0; i < tabpoints.size(); i++)
74  {
75  tabpoints[i]._z += 0.5; // Anciennement 0.05
76  }
77 
78  _pPolygon->setPoints(tabpoints);
79 
80  if (renderContext.type == TYRenderType::Picking)
81  {
82  TYPickingTable::addElement(getElement());
83  glPushName((GLuint)(TYPickingTable::getIndex()));
84  }
85 
86  glColor4fv(getElement()->getColor());
87 
88  _pPolygon->getGraphicObject()->setBoundingBoxVisible(_highlight);
89  _pPolygon->getGraphicObject()->display(renderContext);
90  if ((_highlight) && (renderContext.pass == TYRenderPass::Overlay))
91  {
92  drawName(renderContext);
93  }
94 
95  if (renderContext.type == TYRenderType::Picking)
96  {
97  glPopName();
98  }
99 }
QColor getColor
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)
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
classe graphique pour un element de base
void drawName(TYRenderContext &renderContext)
bool _visible
Inique si l'element est visible.
OBox boundingBox() const
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(TYRenderContext &renderContext)
static int getIndex()
static void addElement(TYElement *pElt)
LPTYPolygon _pPolygon
virtual void display(TYRenderContext &renderContext)
virtual void update(bool force=false)
TYPlanEauGraphic(TYPlanEau *pElement)
virtual OBox computeBoundingBox() const
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
void setPoints(const TYTabPoint &pts)
Definition: TYPolygon.cpp:389
const TYRenderType type
const TYRenderPass pass