Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYReseauTransport.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"
22 #include "TYReseauTransport.h"
23 
26 
27 TYReseauTransport::TYReseauTransport() : _nbBrins(2), _tension(230), _puissance(50), _hauteurMoyenne(2)
28 {
30 
31  float r = 0.0f, g = 0.0f, b = 0.0f;
32 
33 #if TY_USE_IHM
34  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "TYReseauTransportGraphicColorR"))
35  {
36  TYPreferenceManager::getColor(TYDIRPREFERENCEMANAGER, "TYReseauTransportGraphicColor", r, g, b);
37  }
38  else
39  {
40  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, "TYReseauTransportGraphicColor", r, g, b);
41  }
42 #endif // TY_USE_IHM
43 
44  OColor color;
45  color.r = r / 255;
46  color.g = g / 255;
47  color.b = b / 255;
48 
49  setColor(color);
50 
51  _largeur = 10.0;
52 }
53 
55 {
56  *this = other;
57 }
58 
60 
62 {
63  if (this != &other)
64  {
66  _nbBrins = other._nbBrins;
67  _tension = other._tension;
68  _puissance = other._puissance;
70  }
71  return *this;
72 }
73 
75 {
76  if (this != &other)
77  {
78  if (TYAcousticLine::operator!=(other))
79  {
80  return false;
81  }
82  if (_nbBrins != other._nbBrins)
83  {
84  return false;
85  }
86  if (_tension != other._tension)
87  {
88  return false;
89  }
90  if (_puissance != other._puissance)
91  {
92  return false;
93  }
94  if (_hauteurMoyenne != other._hauteurMoyenne)
95  {
96  return false;
97  }
98  }
99  return true;
100 }
101 
103 {
104  return !operator==(other);
105 }
106 
107 bool TYReseauTransport::deepCopy(const TYElement* pOther, bool copyId /*=true*/, bool pUseCopyTag /*=false*/)
108 {
109  if (!TYAcousticLine::deepCopy(pOther, copyId))
110  {
111  return false;
112  }
113 
114  TYReseauTransport* pOtherRes = (TYReseauTransport*)pOther;
115 
116  _nbBrins = pOtherRes->_nbBrins;
117  _tension = pOtherRes->_tension;
118  _puissance = pOtherRes->_puissance;
119  _hauteurMoyenne = pOtherRes->_hauteurMoyenne;
120 
121  return true;
122 }
123 
124 std::string TYReseauTransport::toString() const
125 {
126  return "TYReseauTransport";
127 }
128 
130 {
131  DOM_Element domNewElem = TYAcousticLine::toXML(domElement);
132 
133  TYXMLTools::addElementIntValue(domNewElem, "nbBrins", _nbBrins);
134  TYXMLTools::addElementDoubleValue(domNewElem, "tension", _tension);
135  TYXMLTools::addElementDoubleValue(domNewElem, "puissance", _puissance);
136  TYXMLTools::addElementDoubleValue(domNewElem, "hauteurMoyenne", _hauteurMoyenne);
137 
138  return domNewElem;
139 }
140 
142 {
143  TYAcousticLine::fromXML(domElement);
144 
145  bool nbBrinsOk = false;
146  bool tensionOk = false;
147  bool puissanceOk = false;
148  bool hauteurMoyenneOk = false;
149  DOM_Element elemCur;
150 
151  QDomNodeList childs = domElement.childNodes();
152  for (unsigned int i = 0; i < childs.length(); i++)
153  {
154  elemCur = childs.item(i).toElement();
155  TYXMLTools::getElementIntValue(elemCur, "nbBrins", _nbBrins, nbBrinsOk);
156  TYXMLTools::getElementDoubleValue(elemCur, "tension", _tension, tensionOk);
157  TYXMLTools::getElementDoubleValue(elemCur, "puissance", _puissance, puissanceOk);
158  TYXMLTools::getElementDoubleValue(elemCur, "hauteurMoyenne", _hauteurMoyenne, hauteurMoyenneOk);
159  }
160 
161  return 1;
162 }
163 
164 bool TYReseauTransport::updateAcoustic(const bool& force) // force = false
165 {
167  {
168  }
169 
170  // Distribution des sources et affectation de la puissance acoustique
172 
173  return true;
174 }
QDomElement DOM_Element
Definition: QT2DOM.h:30
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:52
Representation graphique d'un reseau electrique (fichier header)
Outil IHM pour un reseau de transport (fichier header)
TY_EXT_GRAPHIC_INST(TYReseauTransport)
TY_EXTENSION_INST(TYReseauTransport)
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
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
virtual int fromXML(DOM_Element domElement)
virtual bool updateAcoustic(const bool &force=false)
double _largeur
Largeur.
TYAcousticLine & operator=(const TYAcousticLine &other)
Operateur =.
int _typeDistribution
Indique le type de distribution a utiliser. pour l'etat courant.
virtual DOM_Element toXML(DOM_Element &domElement)
virtual void setColor(const OColor &color)
QString _name
Nom courant de l'element.
Definition: TYElement.h:966
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
static TYNameManager * get()
Retourne l'instance singleton.
double _hauteurMoyenne
Hauteur Moyenne.
virtual std::string toString() const
bool operator!=(const TYReseauTransport &other) const
Operateur !=.
virtual bool updateAcoustic(const bool &force=false)
bool operator==(const TYReseauTransport &other) const
Operateur ==.
double _puissance
Puissance transportee.
double _tension
Tension.
virtual DOM_Element toXML(DOM_Element &domElement)
virtual int fromXML(DOM_Element domElement)
int _nbBrins
Nombre de brins.
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
TYReseauTransport & operator=(const TYReseauTransport &other)
Operateur =.
static void addElementDoubleValue(DOM_Element &parentElem, DOMString nodeName, double nodeValue)
Definition: TYXMLTools.cpp:87
static void addElementIntValue(DOM_Element &parentElem, DOMString nodeName, int nodeValue)
Definition: TYXMLTools.cpp:72
static bool getElementIntValue(DOM_Element parentElem, DOMString nodeName, int &nodeValue)
Definition: TYXMLTools.cpp:129
static bool getElementDoubleValue(DOM_Element parentElem, DOMString nodeName, double &nodeValue)
Definition: TYXMLTools.cpp:243