Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYColorInterface.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
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