Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYParoi.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 /*
17  *
18  */
19 
20 #if TY_USE_IHM
22 #endif
23 
24 #include "TYParoi.h"
25 #include "Tympan/core/logging.h"
26 
28 
30 {
32 
33  _epaisseur = 1;
34 
36  _matStruct->setParent(this);
38  _matFace1->setParent(this);
40  _matFace2->setParent(this);
41 }
42 
44 {
45  *this = other;
46 }
47 
49 
51 {
52  if (this != &other)
53  {
54  TYElement::operator=(other);
55  _epaisseur = other._epaisseur;
56  _matStruct = other._matStruct;
57  _matFace1 = other._matFace1;
58  _matFace2 = other._matFace2;
59  }
60  return *this;
61 }
62 
63 bool TYParoi::operator==(const TYParoi& other) const
64 {
65  if (this != &other)
66  {
67  if (TYElement::operator!=(other))
68  {
69  return false;
70  }
71  if (_epaisseur != other._epaisseur)
72  {
73  return false;
74  }
75  if (_matStruct != other._matStruct)
76  {
77  return false;
78  }
79  if (_matFace1 != other._matFace1)
80  {
81  return false;
82  }
83  if (_matFace2 != other._matFace2)
84  {
85  return false;
86  }
87  }
88  return true;
89 }
90 
91 bool TYParoi::operator!=(const TYParoi& other) const
92 {
93  return !operator==(other);
94 }
95 
96 bool TYParoi::deepCopy(const TYElement* pOther, bool copyId /*=true*/, bool pUseCopyTag /*=false*/)
97 {
98  if (!TYElement::deepCopy(pOther, copyId))
99  {
100  return false;
101  }
102 
103  TYParoi* pOtherParoi = (TYParoi*)pOther;
104 
105  _epaisseur = pOtherParoi->_epaisseur;
106 
107  _matStruct->deepCopy(pOtherParoi->_matStruct, copyId);
108  _matFace1->deepCopy(pOtherParoi->_matFace1, copyId);
109  _matFace2->deepCopy(pOtherParoi->_matFace2, copyId);
110 
111  return true;
112 }
113 
114 std::string TYParoi::toString() const
115 {
116  return "TYParoi";
117 }
118 
120 {
121  DOM_Element domNewElem = TYElement::toXML(domElement);
122 
123  TYXMLTools::addElementDoubleValue(domNewElem, "epaisseur", _epaisseur);
124 
125  _matStruct->toXML(domNewElem);
126  _matFace1->toXML(domNewElem);
127  _matFace2->toXML(domNewElem);
128 
129  return domNewElem;
130 }
131 
133 {
134  TYElement::fromXML(domElement);
135 
136  bool epaisseurOk = false;
137  bool matStructFound = false;
138  bool matFace1Found = false;
139  bool matFace2Found = false;
140 
141  DOM_Element elemCur;
142 
143  QDomNodeList childs = domElement.childNodes();
144  for (unsigned int i = 0; i < childs.length(); i++)
145  {
146  elemCur = childs.item(i).toElement();
147  TYXMLTools::getElementDoubleValue(elemCur, "epaisseur", _epaisseur, epaisseurOk);
148 
149  if (!matStructFound)
150  {
151  matStructFound = _matStruct->callFromXMLIfEqual(elemCur);
152  }
153  else if (!matFace1Found)
154  {
155  matFace1Found = _matFace1->callFromXMLIfEqual(elemCur);
156  }
157  else if (!matFace2Found)
158  {
159  matFace2Found = _matFace2->callFromXMLIfEqual(elemCur);
160  }
161  }
162 
163  return 1;
164 }
QDomElement DOM_Element
Definition: QT2DOM.h:30
outil IHM pour une paroi (fichier header)
TY_EXTENSION_INST(TYParoi)
virtual const char * getClassName() const
Definition: TYElement.h:249
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYElement.cpp:307
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYElement.cpp:368
QString _name
Nom courant de l'element.
Definition: TYElement.h:966
TYElement & operator=(const TYElement &other)
Definition: TYElement.cpp:265
bool callFromXMLIfEqual(DOM_Element &domElement, int *pRetVal=NULL)
Definition: TYElement.cpp:544
void setParent(TYElement *pParent)
Definition: TYElement.h:692
virtual int fromXML(DOM_Element domElement)
Definition: TYElement.cpp:381
virtual DOM_Element toXML(DOM_Element &domElement)
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
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
LPTYMateriauConstruction _matStruct
Materiau interne.
Definition: TYParoi.h:171
TYParoi()
Definition: TYParoi.cpp:29
virtual ~TYParoi()
Definition: TYParoi.cpp:48
TYParoi & operator=(const TYParoi &other)
Operateur =.
Definition: TYParoi.cpp:50
double _epaisseur
Epaisseur.
Definition: TYParoi.h:168
virtual int fromXML(DOM_Element domElement)
Definition: TYParoi.cpp:132
LPTYMateriauConstruction _matFace2
Materiau face 2 (exterieure)
Definition: TYParoi.h:175
bool operator!=(const TYParoi &other) const
Operateur !=.
Definition: TYParoi.cpp:91
bool operator==(const TYParoi &other) const
Operateur ==.
Definition: TYParoi.cpp:63
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYParoi.cpp:96
LPTYMateriauConstruction _matFace1
Materiau face 1 (interieure)
Definition: TYParoi.h:173
virtual std::string toString() const
Definition: TYParoi.cpp:114
static void addElementDoubleValue(DOM_Element &parentElem, DOMString nodeName, double nodeValue)
Definition: TYXMLTools.cpp:87
static bool getElementDoubleValue(DOM_Element parentElem, DOMString nodeName, double &nodeValue)
Definition: TYXMLTools.cpp:243