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