Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYMur.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"
25 #include "TYMur.h"
26 
29 
31 {
33 
34  // Nettoie l'init fait par le constructeur parent (TYAcousticRectangleNode)
35  purge();
36 
37  // Couleur du mur par default R=156 G=97 B=1
38  float r = 158.0f, g = 158.0f, b = 0.0f;
39 
40 #if TY_USE_IHM
41  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "TYMurGraphicColorR"))
42  {
43  TYPreferenceManager::getColor(TYDIRPREFERENCEMANAGER, "TYMurGraphicColor", r, g, b);
44  }
45  else
46  {
47  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, "TYMurGraphicColor", r, g, b);
48  }
49 #endif
50 
51  OColor defaultColor;
52  defaultColor.r = r / 255.0f;
53  defaultColor.g = g / 255.0f;
54  defaultColor.b = b / 255.0f;
55 
56  setColor(defaultColor);
57 
58  _pParoi = new TYParoi();
59  _pParoi->setParent(this);
60  _pParoi->setEpaisseur(0.5);
61 
62  _bParoiLocked = false;
63 
64  TYMurElement* pMurElt = new TYMurElement();
65  pMurElt->setColor(defaultColor);
66  pMurElt->getBoundingRect()->setSize(getSizeX(), getSizeY());
67  addAcousticSurf(pMurElt);
68 }
69 
70 TYMur::TYMur(const TYMur& other)
71 {
72  *this = other;
73 }
74 
76 
78 {
79  if (this != &other)
80  {
82  _pParoi = other._pParoi;
84  }
85  return *this;
86 }
87 
88 bool TYMur::operator==(const TYMur& other) const
89 {
90  if (this != &other)
91  {
92  if (TYAcousticRectangleNode::operator!=(other))
93  {
94  return false;
95  }
96  if (_pParoi != other._pParoi)
97  {
98  return false;
99  }
100  }
101  return true;
102 }
103 
104 bool TYMur::operator!=(const TYMur& other) const
105 {
106  return !operator==(other);
107 }
108 
109 bool TYMur::deepCopy(const TYElement* pOther, bool copyId /*=true*/, bool pUseCopyTag /*=false*/)
110 {
111  if (!TYAcousticRectangleNode::deepCopy(pOther, copyId))
112  {
113  return false;
114  }
115 
116  TYMur* pOtherMur = (TYMur*)pOther;
117 
118  _pParoi->deepCopy(pOtherMur->_pParoi, copyId);
119 
120  _bParoiLocked = pOtherMur->_bParoiLocked;
121 
122  return true;
123 }
124 
125 bool TYMur::makeGrid(int nbCol, int nbRow)
126 {
127  return TYAcousticRectangleNode::makeGrid(nbCol, nbRow, "TYMurElement");
128 }
129 
131 {
132  TYAcousticRectangleNode::updateGrid("TYMurElement");
133 }
134 
135 std::string TYMur::toString() const
136 {
137  return "TYMur";
138 }
139 
141 {
142  DOM_Element domNewElem = TYAcousticRectangleNode::toXML(domElement);
143 
144  TYXMLTools::addElementBoolValue(domNewElem, "paroiLocked", _bParoiLocked);
145  _pParoi->toXML(domNewElem);
146 
147  return domNewElem;
148 }
149 
151 {
152  bool statParoiOk = false;
153 
155 
156  DOM_Element elemCur;
157 
158  QDomNodeList childs = domElement.childNodes();
159  for (unsigned int i = 0; i < childs.length(); i++)
160  {
161  elemCur = childs.item(i).toElement();
162  TYXMLTools::getElementBoolValue(elemCur, "paroiLocked", _bParoiLocked, statParoiOk);
163  _pParoi->callFromXMLIfEqual(elemCur);
164  }
165 
166  return 1;
167 }
168 
170 {
172 }
173 
175 {
177 }
178 
180 {
182 }
183 
185 {
187 }
188 
189 double TYMur::surface() const
190 {
192 }
193 
194 int TYMur::intersects(const TYSurfaceInterface* pSurf, OSegment3D& seg) const
195 {
196  return TYAcousticRectangleNode::intersects(pSurf, seg);
197 }
198 
199 int TYMur::intersects(const OSegment3D& seg, OPoint3D& pt) const
200 {
201  return TYAcousticRectangleNode::intersects(seg, pt);
202 }
203 
204 bool TYMur::abso(const TYPoint& pt, TYSpectre& spectre) const
205 {
206  printf("TYMur::abso non implemente.\n");
207  return false;
208 }
209 
210 bool TYMur::transm(const TYPoint& pt, TYSpectre& spectre) const
211 {
212  printf("TYMur::absom non implemente.\n");
213  return false;
214 }
215 
216 void TYMur::setParoi(const LPTYParoi pParoi)
217 {
218  assert(pParoi);
219  assert(_pParoi);
220 
221  if (!_bParoiLocked) // Si elle est lockee, on ne peut pas la modifier
222  {
223  *_pParoi = *pParoi;
224  _pParoi->setParent(this);
225  }
226 }
227 
228 void TYMur::setParoiLocked(const bool& bVal)
229 {
230  _bParoiLocked = bVal;
231 
232  if (_pParent) // Inutile de verifier le lockage setParoi y pourvoira
233  {
235  }
236 }
237 
239 {
240  for (unsigned int j = 0; j < _tabAcousticSurf.size(); j++)
241  {
243 
244  pSurf->remAllSrcs();
245  }
246 }
247 
249 {
250  return _pParoi->getMatFace2();
251 }
All base classes related to 3D manipulation.
QDomElement DOM_Element
Definition: QT2DOM.h:30
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:52
Representation graphique d'un mur (fichier header)
outil IHM pour un mur (fichier header)
TY_EXT_GRAPHIC_INST(TYMur)
TY_EXTENSION_INST(TYMur)
std::vector< LPTYSourcePonctuelleGeoNode > TYTabSourcePonctuelleGeoNode
Collection de noeuds geometriques de type TYSourcePonctuelle.
Definition: color.h:31
float b
Definition: color.h:33
float r
Definition: color.h:33
float g
Definition: color.h:33
The 3D point class.
Definition: 3d.h:487
virtual const char * getClassName() const
Definition: TYElement.h:249
static OPrototype * safeDownCast(OPrototype *pObject)
Definition: TYElement.cpp:71
Class to define a segment.
Definition: 3d.h:1089
virtual DOM_Element toXML(DOM_Element &domElement)
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
virtual TYTabSourcePonctuelleGeoNode getSrcs() const
virtual TYSourcePonctuelle srcPonctEquiv() const
TYAcousticRectangleNode & operator=(const TYAcousticRectangleNode &other)
Operateur =.
virtual bool makeGrid(int nbCol, int nbRow)
virtual int fromXML(DOM_Element domElement)
virtual int intersects(const TYSurfaceInterface *pSurf, OSegment3D &seg) const
TYTabAcousticSurfaceGeoNode _tabAcousticSurf
Tableau des AcousticSurfaces.
virtual double surface() const
bool addAcousticSurf(LPTYAcousticSurfaceGeoNode pAccSurfGeoNode)
virtual void remAllSrcs()
TYRectangle * getBoundingRect()
virtual void setColor(const OColor &color)
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 setColor(const OColor &color)
Definition: TYMur.h:36
bool abso(const TYPoint &pt, TYSpectre &spectre) const
Definition: TYMur.cpp:204
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYMur.cpp:109
void setParoi(const LPTYParoi pParoi)
Definition: TYMur.cpp:216
TYMateriauConstruction * getMateriau()
Surcharge de la methode getMateriau pour la dalle.
Definition: TYMur.cpp:248
virtual bool setSrcsLw()
Definition: TYMur.cpp:184
TYMur & operator=(const TYMur &other)
Operateur =.
Definition: TYMur.cpp:77
TYMur()
Definition: TYMur.cpp:30
virtual void updateGrid()
Definition: TYMur.cpp:130
bool transm(const TYPoint &pt, TYSpectre &spectre) const
Definition: TYMur.cpp:210
virtual void remAllSrcs()
Definition: TYMur.cpp:238
virtual int fromXML(DOM_Element domElement)
Definition: TYMur.cpp:150
virtual std::string toString() const
Definition: TYMur.cpp:135
void setParoiLocked(const bool &bVal)
Definition: TYMur.cpp:228
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYMur.cpp:140
virtual double surface() const
Definition: TYMur.cpp:189
virtual ~TYMur()
Definition: TYMur.cpp:75
virtual void distriSrcs()
Definition: TYMur.cpp:179
virtual int intersects(const TYSurfaceInterface *pSurf, OSegment3D &seg) const
Definition: TYMur.cpp:194
LPTYParoi _pParoi
Definition: TYMur.h:153
virtual TYTabSourcePonctuelleGeoNode getSrcs() const
Definition: TYMur.cpp:169
virtual TYSourcePonctuelle srcPonctEquiv() const
Definition: TYMur.cpp:174
TYParoi * getParoi() const
Definition: TYMur.h:116
bool operator!=(const TYMur &other) const
Operateur !=.
Definition: TYMur.cpp:104
bool _bParoiLocked
Definition: TYMur.h:159
virtual bool makeGrid(int nbCol, int nbRow)
Definition: TYMur.cpp:125
bool operator==(const TYMur &other) const
Operateur ==.
Definition: TYMur.cpp:88
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
void setEpaisseur(double epaisseur)
Definition: TYParoi.h:85
TYMateriauConstruction * getMatFace2()
Definition: TYParoi.h:143
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYParoi.cpp:96
void setSize(float sizeX, float sizeY)
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