Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYMurElement.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 
22 #include "Tympan/core/logging.h"
24 #include "TYMurElement.h"
25 
28 
30 {
32 
33  float r = 170.0f, g = 170.0f, b = 127.0f;
34  _color.a = 1.0f;
35 
36 #if TY_USE_IHM
37  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "SubRectColorR"))
38  {
39  TYPreferenceManager::getColor(TYDIRPREFERENCEMANAGER, "SubRectColor", r, g, b);
40  }
41  else
42  {
43  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, "SubRectColor", r, g, b);
44  }
45 
46  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "WinOpacity"))
47  {
48  _color.a = TYPreferenceManager::getDouble(TYDIRPREFERENCEMANAGER, "WinOpacity");
49  }
50  else
51  {
52  TYPreferenceManager::setDouble(TYDIRPREFERENCEMANAGER, "WinOpacity", _color.a);
53  }
54 #endif // TY_USE_IHM
55 
56  _color.r = r / 255;
57  _color.g = g / 255;
58  _color.b = b / 255;
59 
60  _pParoi = new TYParoi();
61  _pParoi->setParent(this);
62 }
63 
65 {
66  *this = other;
67 }
68 
70 
72 {
73  if (this != &other)
74  {
76  _pParoi = other._pParoi;
77  }
78  return *this;
79 }
80 
81 bool TYMurElement::operator==(const TYMurElement& other) const
82 {
83  if (this != &other)
84  {
85  if (TYAcousticRectangle::operator!=(other))
86  {
87  return false;
88  }
89  if (_pParoi != other._pParoi)
90  {
91  return false;
92  }
93  }
94  return true;
95 }
96 
97 bool TYMurElement::operator!=(const TYMurElement& other) const
98 {
99  return !operator==(other);
100 }
101 
102 bool TYMurElement::deepCopy(const TYElement* pOther, bool copyId /*=true*/, bool pUseCopyTag /*=false*/)
103 {
104  if (!TYAcousticRectangle::deepCopy(pOther, copyId))
105  {
106  return false;
107  }
108 
109  TYMurElement* pOtherMurElt = (TYMurElement*)pOther;
110 
111  _pParoi->deepCopy(pOtherMurElt->_pParoi, copyId);
112 
113  return true;
114 }
115 
116 std::string TYMurElement::toString() const
117 {
118  return "TYMurElement";
119 }
120 
122 {
123  DOM_Element domNewElem = TYAcousticRectangle::toXML(domElement);
124 
125  _pParoi->toXML(domNewElem);
126 
127  return domNewElem;
128 }
129 
131 {
132  TYAcousticRectangle::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  _pParoi->callFromXMLIfEqual(elemCur);
141  }
142 
143  return 1;
144 }
145 
146 void TYMurElement::setColor(const OColor& color)
147 {
149 
150  if (getParent())
151  if (!getIsSub())
152  {
153  TYMur::safeDownCast(getParent())->setColor(color);
154  }
155 }
156 
158 {
160 }
161 
163 {
165 }
166 
168 {
170 }
171 
173 {
175 }
176 
177 double TYMurElement::surface() const
178 {
180 }
181 
183 {
184  return TYAcousticRectangle::intersects(pSurf, seg);
185 }
186 
187 int TYMurElement::intersects(const OSegment3D& seg, OPoint3D& pt) const
188 {
189  return TYAcousticRectangle::intersects(seg, pt);
190 }
QDomElement DOM_Element
Definition: QT2DOM.h:30
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:52
Representation graphique d'un element de mur (fichier header)
outil IHM pour un element de mur (fichier header)
TY_EXT_GRAPHIC_INST(TYMurElement)
TY_EXTENSION_INST(TYMurElement)
std::vector< LPTYSourcePonctuelleGeoNode > TYTabSourcePonctuelleGeoNode
Collection de noeuds geometriques de type TYSourcePonctuelle.
Definition: color.h:31
float b
Definition: color.h:33
float a
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 int intersects(const TYSurfaceInterface *pSurf, OSegment3D &seg) const
virtual int fromXML(DOM_Element domElement)
TYAcousticRectangle & operator=(const TYAcousticRectangle &other)
Operateur =.
virtual DOM_Element toXML(DOM_Element &domElement)
virtual double surface() const
virtual TYSourcePonctuelle srcPonctEquiv() const
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
virtual TYTabSourcePonctuelleGeoNode getSrcs() const
virtual void setColor(const OColor &color)
TYElement * getParent() const
Definition: TYElement.h:699
QString _name
Nom courant de l'element.
Definition: TYElement.h:966
bool callFromXMLIfEqual(DOM_Element &domElement, int *pRetVal=NULL)
Definition: TYElement.cpp:544
void setParent(TYElement *pParent)
Definition: TYElement.h:692
virtual ~TYMurElement()
virtual TYSourcePonctuelle srcPonctEquiv() const
virtual int intersects(const TYSurfaceInterface *pSurf, OSegment3D &seg) const
virtual double surface() const
virtual void setColor(const OColor &color)
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
virtual std::string toString() const
virtual int fromXML(DOM_Element domElement)
bool operator==(const TYMurElement &other) const
Operateur ==.
bool operator!=(const TYMurElement &other) const
Operateur !=.
LPTYParoi _pParoi
Paroi.
Definition: TYMurElement.h:122
virtual DOM_Element toXML(DOM_Element &domElement)
virtual TYTabSourcePonctuelleGeoNode getSrcs() const
virtual void distriSrcs()
virtual bool setSrcsLw()
TYMurElement & operator=(const TYMurElement &other)
Operateur =.
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
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYParoi.cpp:96