Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYColorInterface.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 #include "TYColorInterface.h"
17 
19 
21 {
22  *this = other;
23 }
24 
26 
28 {
29  if (this != &other)
30  {
31  _color = other._color;
32  }
33  return *this;
34 }
35 
37 {
38  if (this != &other)
39  {
40  if (_color != other._color)
41  {
42  return false;
43  }
44  }
45  return true;
46 }
47 
49 {
50  return !operator==(other);
51 }
52 
53 void TYColorInterface::deepCopy(const TYColorInterface* pOther, bool copyId /*= true*/,
54  bool pUseCopyTag /*=false*/)
55 {
56  _color = pOther->_color;
57 }
58 
60 {
61  QDomDocument domDoc = domElement.ownerDocument();
62  QDomElement domNewElem = domDoc.createElement("Color");
63 
64  domNewElem.setAttribute("r", _color.r);
65  domNewElem.setAttribute("g", _color.g);
66  domNewElem.setAttribute("b", _color.b);
67 
68  domElement.appendChild(domNewElem);
69 
70  return domElement;
71 }
72 
74 {
75  DOM_Element elemCur;
76  QString tagName = "";
77  elemCur = domElement.firstChild().toElement();
78  if (!elemCur.isNull())
79  {
80  tagName = elemCur.tagName();
81  }
82 
83  if (tagName == "Color")
84  {
88 
89  return 1;
90  }
91 
92  return 0;
93 }
94 
96 {
97  _color = color;
98 }
99 
101 {
102  return _color;
103 }
QDomElement DOM_Element
Definition: QT2DOM.h:30
Definition: color.h:31
float b
Definition: color.h:33
float r
Definition: color.h:33
float g
Definition: color.h:33
int fromXML(DOM_Element domElement)
TYColorInterface & operator=(const TYColorInterface &other)
OColor getColor() const
virtual void setColor(const OColor &color)
bool operator==(const TYColorInterface &other) const
bool operator!=(const TYColorInterface &other) const
virtual ~TYColorInterface()
void deepCopy(const TYColorInterface *pOther, bool copyId=true, bool pUseCopyTag=false)
DOM_Element toXML(DOM_Element &domElement)
static double getElementAttributeToDouble(DOM_Element parentElem, DOMString attName, bool *ok=NULL)
Definition: TYXMLTools.cpp:288