Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYPlanEau.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 
16 #include "Tympan/core/logging.h"
17 #include "TYPlanEau.h"
18 #include <limits>
19 
20 #if TY_USE_IHM
24 #endif
25 #undef max
26 
29 
31 {
33 
34  // Couleur par default
35  float r = 0.0, g = 0.0, b = 255.0;
36 
37 #if TY_USE_IHM
38  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "TYPlanEauGraphicColorR"))
39  {
40  TYPreferenceManager::getColor(TYDIRPREFERENCEMANAGER, "TYPlanEauGraphicColor", r, g, b);
41  }
42  else
43  {
44  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, "TYPlanEauGraphicColor", r, g, b);
45  }
46 #endif
47 
48  setColor(OColor(r / 255, g / 255, b / 255));
49 
50  _pCrbNiv = new TYCourbeNiveau();
51  _pCrbNiv->setParent(this);
52 
53  _pSol->setEpaisseur(1);
54  _pSol->setResistivite(std::numeric_limits<double>::max());
55 }
56 
58 {
59  *this = other;
60 }
61 
62 TYPlanEau::TYPlanEau(const TYTabPoint& pts, double alt)
63 {
64  _pCrbNiv = new TYCourbeNiveau();
65  _pCrbNiv->setListPoints(pts);
66  _pCrbNiv->setAltitude(alt);
67 }
68 
70 
72 {
73  if (this != &other)
74  {
75  TYTerrain::operator=(other);
76  _pCrbNiv = other._pCrbNiv;
77  }
78  return *this;
79 }
80 
81 bool TYPlanEau::operator==(const TYPlanEau& other) const
82 {
83  if (this != &other)
84  {
85  if (TYTerrain::operator!=(other))
86  {
87  return false;
88  }
89  if (_pCrbNiv != other._pCrbNiv)
90  {
91  return false;
92  }
93  }
94  return true;
95 }
96 
97 bool TYPlanEau::operator!=(const TYPlanEau& other) const
98 {
99  return !operator==(other);
100 }
101 
102 bool TYPlanEau::deepCopy(const TYElement* pOther, bool copyId /*=true*/, bool pUseCopyTag /*=false*/)
103 {
104  if (!TYTerrain::deepCopy(pOther, copyId, pUseCopyTag))
105  {
106  return false;
107  }
108 
109  TYPlanEau* pOtherPlanEau = (TYPlanEau*)pOther;
110 
111  _pCrbNiv->deepCopy(pOtherPlanEau->_pCrbNiv, copyId);
112 
113  return true;
114 }
115 
116 std::string TYPlanEau::toString() const
117 {
118  return "TYPlanEau";
119 }
120 
122 {
123  DOM_Element domNewElem = TYTerrain::toXML(domElement);
124 
125  _pCrbNiv->toXML(domNewElem);
126 
127  return domNewElem;
128 }
129 
131 {
132  TYTerrain::fromXML(domElement);
133 
134  DOM_Element elemCur;
135 
136  QDomNodeList childs = domElement.childNodes();
137  for (unsigned int i = 0; i < childs.length(); i++)
138  {
139  elemCur = childs.item(i).toElement();
140  _pCrbNiv->callFromXMLIfEqual(elemCur);
141  // We set the resistivity effect to the maximum for loaded models (to simulate the total reflection
142  // effect)
143  _pSol->setResistivite(std::numeric_limits<double>::max());
144  }
145 
146  return 1;
147 }
148 
149 void TYPlanEau::setIsGeometryModified(bool isModified)
150 {
152 
153  if (_pParent)
154  {
155  _pParent->setIsGeometryModified(isModified);
156  }
157 }
158 
160 {
161  TYTabPoint listPoints = getListPoints();
162  for (unsigned int i = 0; i < listPoints.size(); i++)
163  {
164  listPoints[i]._x += 10;
165  listPoints[i]._y -= 10;
166  }
167  setListPoints(listPoints);
168 }
QDomElement DOM_Element
Definition: QT2DOM.h:30
std::vector< TYPoint > TYTabPoint
Collection de TYPoint.
Definition: TYDefines.h:340
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:51
Representation graphique d'un plan d'eau (fichier header)
outil IHM pour un plan d'eau (fichier header)
TY_EXTENSION_INST(TYPlanEau)
TY_EXT_GRAPHIC_INST(TYPlanEau)
Definition: color.h:36
virtual const char * getClassName() const
Definition: TYElement.h:248
virtual void setColor(const OColor &color)
virtual DOM_Element toXML(DOM_Element &domElement)
void setListPoints(const TYTabPoint &pts)
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
void setAltitude(double alt)
QString _name
Nom courant de l'element.
Definition: TYElement.h:956
bool callFromXMLIfEqual(DOM_Element &domElement, int *pRetVal=NULL)
Definition: TYElement.cpp:545
TYElement * _pParent
Reference sur l'element parent.
Definition: TYElement.h:959
void setParent(TYElement *pParent)
Definition: TYElement.h:690
virtual void setIsGeometryModified(bool isModified)
Definition: TYElement.cpp:253
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
static TYNameManager * get()
Retourne l'instance singleton.
bool operator!=(const TYPlanEau &other) const
Operateur !=.
Definition: TYPlanEau.cpp:97
virtual void setListPoints(const TYTabPoint &liste)
Definition: TYPlanEau.h:132
LPTYCourbeNiveau _pCrbNiv
Une courbe de niveau correspondant a ce plan d'eau.
Definition: TYPlanEau.h:194
virtual std::string toString() const
Definition: TYPlanEau.cpp:116
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYPlanEau.cpp:102
virtual int fromXML(DOM_Element domElement)
Definition: TYPlanEau.cpp:130
virtual ~TYPlanEau()
Definition: TYPlanEau.cpp:69
virtual TYTabPoint & getListPoints()
Definition: TYPlanEau.h:118
bool operator==(const TYPlanEau &other) const
Operateur ==.
Definition: TYPlanEau.cpp:81
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYPlanEau.cpp:121
void offsetListPoints()
Definition: TYPlanEau.cpp:159
TYPlanEau & operator=(const TYPlanEau &other)
Operateur =.
Definition: TYPlanEau.cpp:71
virtual void setIsGeometryModified(bool isModified)
Definition: TYPlanEau.cpp:149
void setEpaisseur(double epais)
Definition: TYSol.h:93
void setResistivite(double res)
Definition: TYSol.h:77
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYTerrain.cpp:115
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYTerrain.cpp:151
LPTYSol _pSol
Materiau.
Definition: TYTerrain.h:164
virtual int fromXML(DOM_Element domElement)
Definition: TYTerrain.cpp:176
TYTerrain & operator=(const TYTerrain &other)
Operateur =.
Definition: TYTerrain.cpp:64