Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYTopographieGraphic.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 
25 #include "TYTopographieGraphic.h"
26 
28 {
29  // Pour materialiser l'emprise
31  _pEmpriseGraphic->setElement(pElement);
32 }
33 
34 void TYTopographieGraphic::update(bool force /*=false*/)
35 {
36  // Cet element est toujours actif quelque soit le calcul courant
37  getElement()->setInCurrentCalcul(true);
38 
40 }
41 
42 void TYTopographieGraphic::getChilds(TYListPtrTYElementGraphic& childs, bool recursif /*=true*/)
43 {
44  TYListPtrTYElementGraphic Localchilds;
45 
46  Localchilds.push_back(_pEmpriseGraphic);
47 
48  unsigned int i = 0;
49 
50  // Courbes de niveau
51  TYTabCourbeNiveauGeoNode* pTabCrbNiv = &getElement()->getListCrbNiv();
52  for (i = 0; i < pTabCrbNiv->size(); i++)
53  {
54  TYCourbeNiveauGeoNode* pCrbNivGeoNode = pTabCrbNiv->operator[](i);
55  Localchilds.push_back(pCrbNivGeoNode->getGraphicObject().getRealPointer());
56  }
57 
58  // Plans d'eau
59  TYTabPlanEauGeoNode* pTabPlanEau = &getElement()->getListPlanEau();
60  for (i = 0; i < pTabPlanEau->size(); i++)
61  {
62  TYPlanEauGeoNode* pPlanEauGeoNode = pTabPlanEau->operator[](i);
63  Localchilds.push_back(pPlanEauGeoNode->getGraphicObject().getRealPointer());
64  }
65 
66  // 1 altimetry for all the site hierarchy. From the topography, retrieve the parent
67  // site, and from this site, the root site and its altimetry.
68  TYTopographie* pTYTopographie = getElement();
69  LPTYSiteNode pParentSite = dynamic_cast<TYSiteNode*>(pTYTopographie->getParent());
70  assert(pParentSite != nullptr && "The parent of a TYTopographie element must be a TYSiteNode");
71  if (pParentSite->getRoot())
72  {
73  LPTYAltimetrie altimetrie = pParentSite->getAltimetry();
74  Localchilds.push_back(altimetrie->getGraphicObject().getRealPointer());
75  }
76 
77  // Terrains
78  TYTabTerrainGeoNode* pTabTerrain = &getElement()->getListTerrain();
79  for (i = 0; i < pTabTerrain->size(); i++)
80  {
81  TYTerrainGeoNode* pTerrainGeoNode = pTabTerrain->operator[](i);
82  Localchilds.push_back(pTerrainGeoNode->getGraphicObject().getRealPointer());
83  }
84 
85  // Cours d'Eau
86  TYTabCoursEauGeoNode* pTabCrsEau = &getElement()->getListCrsEau();
87  for (i = 0; i < pTabCrsEau->size(); i++)
88  {
89  TYCoursEauGeoNode* pCrsEauGeoNode = pTabCrsEau->operator[](i);
90  Localchilds.push_back(pCrsEauGeoNode->getGraphicObject().getRealPointer());
91  }
92 
93  TYListPtrTYElementGraphic::iterator ite = Localchilds.begin();
94  for (i = 0; i < Localchilds.size(); i++)
95  {
96  TYElementGraphic* pTYElementGraphic = (TYElementGraphic*)(*ite);
97  childs.push_back(pTYElementGraphic);
98  if (recursif)
99  {
100  pTYElementGraphic->getChilds(childs, recursif);
101  }
102  ite++;
103  }
104 }
105 
106 void TYTopographieGraphic::display(TYElement* pModelerElement /*= nullptr*/, GLenum mode /*= GL_RENDER*/)
107 {
108  unsigned int i = 0;
109 
110  // Emprise
112  _pEmpriseGraphic->setTabPoint(getElement()->getEmprise());
113 
114  float r = 0.0f, g = 0.0f, b = 0.0f;
115 #if TY_USE_IHM // L'emprise est de la couleur par defaut des polylines
116  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "TYPolylineGraphicColorR"))
117  {
118  TYPreferenceManager::getColor(TYDIRPREFERENCEMANAGER, "TYPolylineGraphicColorR", r, g, b);
119  }
120  else
121  {
122  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, "TYPolylineGraphicColorR", r, g, b);
123  }
124 #endif
125 
126  getElement()->setEmpriseColor(OColor(r / 255, g / 255, b / 255));
127 
128  glColor4fv(getElement()->getEmpriseColor());
129  _pEmpriseGraphic->display(pModelerElement, mode);
130 
131  TYTopographie* pTYTopographie = getElement();
132  LPTYSiteNode pParentSite = dynamic_cast<TYSiteNode*>(pTYTopographie->getParent());
133  if (pParentSite->getRoot())
134  {
135  assert(pParentSite != nullptr && "The parent of a TYTopographie element must be a TYSiteNode");
136  LPTYAltimetrie altimetrie = pParentSite->getAltimetry();
137  LPTYElementGraphic ElementGraphic = altimetrie->getGraphicObject();
138  ElementGraphic->display(pModelerElement, mode);
139  }
140 
141  // Plans d'eau
142  TYTabPlanEauGeoNode* pTabPlanEau = &getElement()->getListPlanEau();
143  TYPlanEauGeoNode* pPlanEauGeoNode = NULL;
144  for (i = 0; i < pTabPlanEau->size(); i++)
145  {
146  pPlanEauGeoNode = pTabPlanEau->operator[](i);
147  pPlanEauGeoNode->getGraphicObject()->display(pModelerElement, mode);
148  }
149 
150  // Terrains
151  TYTabTerrainGeoNode* pTabTerrain = &getElement()->getListTerrain();
152  TYTerrainGeoNode* pTerrainGeoNode = NULL;
153  for (i = 0; i < pTabTerrain->size(); i++)
154  {
155  pTerrainGeoNode = pTabTerrain->operator[](i);
156  pTerrainGeoNode->getGraphicObject()->display(pModelerElement, mode);
157  }
158 
159  // Cours d'Eau
160  TYTabCoursEauGeoNode* pTabCrsEau = &getElement()->getListCrsEau();
161  TYCoursEauGeoNode* pCrsEauGeoNode = NULL;
162  for (i = 0; i < pTabCrsEau->size(); i++)
163  {
164  pCrsEauGeoNode = pTabCrsEau->operator[](i);
165  pCrsEauGeoNode->getGraphicObject()->display(pModelerElement, mode);
166  }
167 
168  // Courbes de niveau
169  // xbh: les courbes de niveau en dernier et separement pour que l'anti-aliasing soit correct
170  TYTabCourbeNiveauGeoNode* pTabCrbNiv = &getElement()->getListCrbNiv();
171  TYCourbeNiveauGeoNode* pCrbNivGeoNode = NULL;
172  for (i = 0; i < pTabCrbNiv->size(); i++)
173  {
174  pCrbNivGeoNode = pTabCrbNiv->operator[](i);
175  pCrbNivGeoNode->getGraphicObject()->display(pModelerElement, mode);
176  }
177 }
178 
179 void TYTopographieGraphic::setBackgroundImage(QString sTopoFileName, int semiX, int semiY, TYPoint ptPosition,
180  OVector3D bgOrientation)
181 {
182  TYTopographie* pTYTopographie = getElement();
183  LPTYSiteNode pParentSite = dynamic_cast<TYSiteNode*>(pTYTopographie->getParent());
184  assert(pParentSite != nullptr && "The parent of a TYTopographie element must be a TYSiteNode");
185  if (pParentSite->getRoot())
186  {
187  LPTYAltimetrie altimetrie = pParentSite->getAltimetry();
188  LPTYElementGraphic ElementGraphic = altimetrie->getGraphicObject();
189  ((TYAltimetrieGraphic*)((TYElementGraphic*)ElementGraphic))
190  ->setBackgroundImage(sTopoFileName, semiX, semiY, ptPosition, bgOrientation);
191  }
192 }
193 
195 {
196  TYTopographie* pTYTopographie = getElement();
197  LPTYSiteNode pParentSite = dynamic_cast<TYSiteNode*>(pTYTopographie->getParent());
198  assert(pParentSite != nullptr && "The parent of a TYTopographie element must be a TYSiteNode");
199  if (pParentSite->getRoot())
200  {
201  LPTYAltimetrie altimetrie = pParentSite->getAltimetry();
202  LPTYElementGraphic ElementGraphic = altimetrie->getGraphicObject();
203  ((TYAltimetrieGraphic*)((TYElementGraphic*)ElementGraphic))->unsetBackgroundImage();
204  }
205 }
Representation graphique de l'altimetrie (fichier header)
std::vector< LPTYCourbeNiveauGeoNode > TYTabCourbeNiveauGeoNode
Collection de noeuds geometriques de type TYCourbeNiveau.
std::vector< LPTYCoursEauGeoNode > TYTabCoursEauGeoNode
Collection de noeuds geometriques de type TYCoursEau.
Definition: TYCoursEau.h:70
list< TYElementGraphic * > TYListPtrTYElementGraphic
List de pointeur de TYElement.
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:52
std::vector< LPTYPlanEauGeoNode > TYTabPlanEauGeoNode
Collection de noeuds geometriques de type TYPlanEau.
Definition: TYPlanEau.h:202
std::vector< LPTYTerrainGeoNode > TYTabTerrainGeoNode
Collection de noeuds geometriques de type TYTerrain.
Definition: TYTerrain.h:181
Representation graphique d'une topographie (fichier header)
Definition: color.h:31
The 3D vector class.
Definition: 3d.h:298
classe graphique pour une altimetrie
classe graphique pour un element de base
void setModified(bool modified=true)
virtual void update(bool force=false)
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
void setElement(TYElement *pElt)
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)
TYElement * getParent() const
Definition: TYElement.h:699
classe graphique pour representer une polyligne a partir d'un tableau de points.
void setTabPoint(const TYTabPoint &tabPts)
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)
LPTYAltimetrie getAltimetry() const
bool getRoot() const
Definition: TYSiteNode.h:311
LPTYPolyLineGraphic _pEmpriseGraphic
Objet graphic pour materialiser l'emprise.
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)
virtual void update(bool force=false)
void setBackgroundImage(QString sTopoFileName, int semiX, int semiY, TYPoint ptPosition, OVector3D bgOrientation)
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
TYTopographieGraphic(TYTopographie *pElement)