ColorXML.cxx
Go to the documentation of this file.
1 
11 // for dll interface warning
12 #ifdef _MSC_VER
13 #include "msdevstudio/MSconfig.h"
14 #endif
15 
16 #include "ColorXML.h"
17 
18 #include "XmlElement.h"
19 
20 #include "graphics/Color.h"
21 
22 using std::string;
23 
24 namespace hippodraw {
25 
27  : BaseXML ( "Color", controller ),
28  m_red ( "red" ),
29  m_green ( "green" ),
30  m_blue ( "blue" )
31 {
32 }
33 
35 {
37 
38  tag->setAttribute ( m_red, color.getRed () );
39  tag->setAttribute ( m_green, color.getGreen () );
40  tag->setAttribute ( m_blue, color.getBlue () );
41 
42  return tag;
43 }
44 
46 {
47  int red = 0;
48  bool ok = element->attribute ( m_red, red );
49 
50  int green = 0;
51  ok = element->attribute ( m_green, green );
52 
53  int blue = 0;
54  ok = element->attribute ( m_blue, blue );
55 
56  Color * color = new Color ();
57  color->setColor ( red, green, blue );
58 
59  return color;
60 }
61 
62 } // namespace hippodraw
63 
XmlElement * createElement()
Creates a new element node.
Definition: BaseXML.cxx:43
virtual bool attribute(const std::string &name, bool &value) const =0
Sets value to the attribute name's value.
void setColor(const std::string &)
Sets the color.
Definition: Color.cxx:112
std::string m_red
Attribute name for red.
Definition: ColorXML.h:37
A pure virtual base class of XML element wrapper.
Definition: XmlElement.h:30
ColorXML class interface.
int getRed() const
Definition: Color.cxx:164
A Color class for creating the color object following the standard RGB color space.
Definition: Color.h:37
bool ok
Definition: CanvasView.cxx:163
int getGreen() const
Definition: Color.cxx:169
Color class interface.
XmlElement class interface.
Color * createObject(const XmlElement *element)
Sets the attributes of the object from the element values.
Definition: ColorXML.cxx:45
A base class of XML element controllers.
Definition: BaseXML.h:35
std::string m_blue
Attribute name for blue.
Definition: ColorXML.h:43
A base class that is the interface between GUI and the XML serialization and deserialization.
Definition: XmlController.h:53
int getBlue() const
Definition: Color.cxx:174
std::string m_green
Attribute name for green.
Definition: ColorXML.h:40
virtual void setAttribute(const std::string &name, bool value)=0
Sets attribute named name to the int value value.
ColorXML(const ColorXML &)
A private copy constructor in order to avoid copying.

Generated for HippoDraw Class Library by doxygen