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