Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYDalle.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 #if TY_USE_IHM
20 #endif
21 #include "Tympan/core/logging.h"
23 #include "TYDalle.h"
24 
27 
29 {
31 
32  _pParoi = new TYParoi();
33  _pParoi->setParent(this);
34  _bParoiLocked = false;
35 
36  // Couleur par default R=162 G=124 B=1
37 
38  float r = 211.0f, g = 211.0f, b = 0.0f;
39 
40 #if TY_USE_IHM
41  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "TYDalleGraphicColorR"))
42  {
43  TYPreferenceManager::getColor(TYDIRPREFERENCEMANAGER, "TYDalleGraphicColor", r, g, b);
44  }
45  else
46  {
47  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, "TYDalleGraphicColor", r, g, b);
48  }
49 #endif
50  OColor color;
51  color.r = r / 255;
52  color.g = g / 255;
53  color.b = b / 255;
54 
55  setColor(color);
56 }
57 
59 {
60  *this = other;
61 }
62 
64 
66 {
67  if (this != &other)
68  {
70  _pParoi = other._pParoi;
72  }
73  return *this;
74 }
75 
76 bool TYDalle::operator==(const TYDalle& other) const
77 {
78  if (this != &other)
79  {
80  if (TYAcousticPolygon::operator!=(other))
81  {
82  return false;
83  }
84  if (_pParoi != other._pParoi)
85  {
86  return false;
87  }
88  }
89  return true;
90 }
91 
92 bool TYDalle::operator!=(const TYDalle& other) const
93 {
94  return !operator==(other);
95 }
96 
97 bool TYDalle::deepCopy(const TYElement* pOther, bool copyId /*=true*/, bool pUseCopyTag /*=false*/)
98 {
99  if (!TYAcousticPolygon::deepCopy(pOther, copyId))
100  {
101  return false;
102  }
103 
104  TYDalle* pOtherDalle = (TYDalle*)pOther;
105 
106  _pParoi->deepCopy(pOtherDalle->_pParoi, copyId);
107 
108  _bParoiLocked = pOtherDalle->_bParoiLocked;
109 
110  return true;
111 }
112 
113 std::string TYDalle::toString() const
114 {
115  return "TYDalle";
116 }
117 
119 {
120  DOM_Element domNewElem = TYAcousticPolygon::toXML(domElement);
121 
122  TYXMLTools::addElementBoolValue(domNewElem, "paroiLocked", _bParoiLocked);
123  _pParoi->toXML(domNewElem);
124 
125  return domNewElem;
126 }
127 
129 {
130  bool statParoiOk = false;
131 
132  TYAcousticPolygon::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 
141  TYXMLTools::getElementBoolValue(elemCur, "paroiLocked", _bParoiLocked, statParoiOk);
142  _pParoi->callFromXMLIfEqual(elemCur);
143  }
144 
145  return 1;
146 }
147 
148 void TYDalle::setParoi(const LPTYParoi pParoi)
149 {
150  assert(pParoi);
151  assert(_pParoi);
152 
153  if (!_bParoiLocked) // Si elle est lockee, on ne peut pas la modifier
154  {
155  *_pParoi = *pParoi;
156  _pParoi->setParent(this);
157  }
158 }
159 
160 void TYDalle::setParoiLocked(const bool& bVal)
161 {
162  _bParoiLocked = bVal;
163 
164  if (_pParent) // Inutile de verifier le lockage setParoi y pourvoira
165  {
167  }
168 }
169 
171 {
172  return _pParoi->getMatFace2();
173 }
QDomElement DOM_Element
Definition: QT2DOM.h:30
Representation graphique d'une dalle (fichier header)
Outil IHM pour une dalle (fichier header)
TY_EXTENSION_INST(TYDalle)
TY_EXT_GRAPHIC_INST(TYDalle)
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:52
Definition: color.h:31
float b
Definition: color.h:33
float r
Definition: color.h:33
float g
Definition: color.h:33
virtual const char * getClassName() const
Definition: TYElement.h:249
static OPrototype * safeDownCast(OPrototype *pObject)
Definition: TYElement.cpp:71
TYAcousticPolygon & operator=(const TYAcousticPolygon &other)
Operateur =.
virtual int fromXML(DOM_Element domElement)
virtual DOM_Element toXML(DOM_Element &domElement)
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
virtual void setColor(const OColor &color)
TYMateriauConstruction * getMateriau()
Surcharge de la methode getMateriau pour la dalle.
Definition: TYDalle.cpp:170
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYDalle.cpp:97
bool operator!=(const TYDalle &other) const
Operateur !=.
Definition: TYDalle.cpp:92
virtual ~TYDalle()
Definition: TYDalle.cpp:63
LPTYParoi _pParoi
Une paroi associee a cette dalle.
Definition: TYDalle.h:123
virtual std::string toString() const
Definition: TYDalle.cpp:113
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYDalle.cpp:118
bool operator==(const TYDalle &other) const
Operateur ==.
Definition: TYDalle.cpp:76
void setParoiLocked(const bool &bVal)
Definition: TYDalle.cpp:160
LPTYParoi getParoi()
Definition: TYDalle.h:84
virtual int fromXML(DOM_Element domElement)
Definition: TYDalle.cpp:128
bool _bParoiLocked
Definition: TYDalle.h:129
void setParoi(const LPTYParoi pParoi)
Definition: TYDalle.cpp:148
TYDalle()
Definition: TYDalle.cpp:28
TYDalle & operator=(const TYDalle &other)
Operateur =.
Definition: TYDalle.cpp:65
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
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
static TYNameManager * get()
Retourne l'instance singleton.
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYParoi.cpp:119
TYMateriauConstruction * getMatFace2()
Definition: TYParoi.h:143
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYParoi.cpp:96
static bool getElementBoolValue(DOM_Element parentElem, DOMString nodeName, bool &nodeValue)
Definition: TYXMLTools.cpp:179
static void addElementBoolValue(DOM_Element &parentElem, DOMString nodeName, bool nodeValue)
Definition: TYXMLTools.cpp:77