<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>HippoDraw Class Library</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> <link rel="shortcut icon" href="hippoApp.ico"> </head><body> <!-- Generated by Doxygen 1.6.2 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="dir_d71d549033b3d00bbeb107001643b90a.html">xml</a> </div> </div> <div class="contents"> <h1>ViewBaseXML.cxx</h1><a href="ViewBaseXML_8cxx.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <a name="l00012"></a>00012 <span class="comment">// for truncation warning</span> <a name="l00013"></a>00013 <span class="preprocessor">#ifdef _MSC_VER</span> <a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#include "msdevstudio/MSconfig.h"</span> <a name="l00015"></a>00015 <span class="preprocessor">#endif</span> <a name="l00016"></a>00016 <span class="preprocessor"></span> <a name="l00017"></a>00017 <span class="preprocessor">#include "<a class="code" href="ViewBaseXML_8h.html" title="ViewBaseXML class interface.">ViewBaseXML.h</a>"</span> <a name="l00018"></a>00018 <a name="l00019"></a>00019 <span class="preprocessor">#include "<a class="code" href="PlotterBaseXML_8h.html" title="PlotterBaseXML class interface.">PlotterBaseXML.h</a>"</span> <a name="l00020"></a>00020 <span class="preprocessor">#include "<a class="code" href="XmlController_8h.html" title="XmlController class interface.">XmlController.h</a>"</span> <a name="l00021"></a>00021 <span class="preprocessor">#include "<a class="code" href="XmlElement_8h.html" title="XmlElement class interface.">XmlElement.h</a>"</span> <a name="l00022"></a>00022 <a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="ViewBase_8h.html" title="hippodraw::ViewBase class interface">graphics/ViewBase.h</a>"</span> <a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="PlotterBase_8h.html" title="hippodraw::PlotterBase class interface.">plotters/PlotterBase.h</a>"</span> <a name="l00025"></a>00025 <a name="l00026"></a>00026 <span class="keyword">using</span> std::list; <a name="l00027"></a>00027 <span class="keyword">using</span> std::string; <a name="l00028"></a>00028 <a name="l00029"></a>00029 <span class="keyword">using namespace </span>hippodraw; <a name="l00030"></a>00030 <a name="l00031"></a><a class="code" href="classhippodraw_1_1ViewBaseXML.html#a839e7b4e9303fd377f56caba20d5a79b">00031</a> ViewBaseXML::ViewBaseXML ( <a class="code" href="classhippodraw_1_1XmlController.html" title="A base class that is the interface between GUI and the XML serialization and deserialization...">XmlController</a> * controller ) <a name="l00032"></a>00032 : <a class="code" href="classhippodraw_1_1BaseXML.html" title="A base class of XML element controllers.">BaseXML</a> ( <span class="stringliteral">"ViewBase"</span>, controller ), <a name="l00033"></a>00033 m_x ( <span class="stringliteral">"x"</span> ), <a name="l00034"></a>00034 m_y ( <span class="stringliteral">"y"</span> ), <a name="l00035"></a>00035 m_w ( <span class="stringliteral">"w"</span> ), <a name="l00036"></a>00036 m_h ( <span class="stringliteral">"h"</span> ) <a name="l00037"></a>00037 { <a name="l00038"></a>00038 <a class="code" href="classhippodraw_1_1ViewBaseXML.html#a61b9c476758aac5cb4a2a86761834e2f" title="The PlotterBaseXML instance used by this object.">m_plotter_xml</a> = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1PlotterBaseXML.html" title="A class that is does XML serialization and de-serialization of derived classes of...">PlotterBaseXML</a> ( controller ); <a name="l00039"></a>00039 } <a name="l00040"></a>00040 <a name="l00041"></a>00041 <a class="code" href="classhippodraw_1_1ViewBaseXML.html#a69f0e7a9d08888c0f5526712065a5bc7" title="The destructor.">ViewBaseXML::</a> <a name="l00042"></a><a class="code" href="classhippodraw_1_1ViewBaseXML.html#a69f0e7a9d08888c0f5526712065a5bc7">00042</a> <a class="code" href="classhippodraw_1_1ViewBaseXML.html#a69f0e7a9d08888c0f5526712065a5bc7" title="The destructor.">~ViewBaseXML</a> () <a name="l00043"></a>00043 { <a name="l00044"></a>00044 <span class="keyword">delete</span> <a class="code" href="classhippodraw_1_1ViewBaseXML.html#a61b9c476758aac5cb4a2a86761834e2f" title="The PlotterBaseXML instance used by this object.">m_plotter_xml</a>; <a name="l00045"></a>00045 } <a name="l00046"></a>00046 <a name="l00047"></a><a class="code" href="classhippodraw_1_1ViewBaseXML.html#ad239e7913d617307586b9845287f7a0e">00047</a> <span class="keywordtype">bool</span> <a class="code" href="classhippodraw_1_1ViewBaseXML.html#ad239e7913d617307586b9845287f7a0e" title="Returns true if all the NTuple objects used by the view have been save to or read...">ViewBaseXML::areDataSourcesSaved</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1ViewBase.html" title="The abstract base class for views.">ViewBase</a> & view ) <a name="l00048"></a>00048 { <a name="l00049"></a>00049 <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1PlotterBase.html" title="The base class for the PlotterBase hierarchy.">PlotterBase</a> * plotter = view.<a class="code" href="classhippodraw_1_1ViewBase.html#a78aa09930b4007dfa886e1ecb2dbf57b" title="Returns the plotter used by this view.">getPlotter</a> (); <a name="l00050"></a>00050 <a name="l00051"></a>00051 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1ViewBaseXML.html#a61b9c476758aac5cb4a2a86761834e2f" title="The PlotterBaseXML instance used by this object.">m_plotter_xml</a>-><a class="code" href="classhippodraw_1_1PlotterBaseXML.html#a6eb68a6f37633bd77ac1eb8f29266432" title="Returns true if all the NTuple objects used by the plotter are save to or read from...">areDataSourcesSaved</a> ( *plotter ); <a name="l00052"></a>00052 } <a name="l00053"></a>00053 <a name="l00054"></a><a class="code" href="classhippodraw_1_1ViewBaseXML.html#aad969b29a2601981991e2ebb67884038">00054</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1ViewBaseXML.html#aad969b29a2601981991e2ebb67884038" title="Create the child element, i.e.">ViewBaseXML::createChild</a> ( <a class="code" href="classhippodraw_1_1XmlElement.html" title="A pure virtual base class of XML element wrapper.">XmlElement</a> & tag, <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1ViewBase.html" title="The abstract base class for views.">ViewBase</a> & view ) <a name="l00055"></a>00055 { <a name="l00056"></a>00056 <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1PlotterBase.html" title="The base class for the PlotterBase hierarchy.">PlotterBase</a> * plotter = view.<a class="code" href="classhippodraw_1_1ViewBase.html#a78aa09930b4007dfa886e1ecb2dbf57b" title="Returns the plotter used by this view.">getPlotter</a> (); <a name="l00057"></a>00057 <span class="keywordflow">if</span> ( plotter != 0 ) { <a name="l00058"></a>00058 <a class="code" href="classhippodraw_1_1XmlElement.html" title="A pure virtual base class of XML element wrapper.">XmlElement</a> * element = <a class="code" href="classhippodraw_1_1ViewBaseXML.html#a61b9c476758aac5cb4a2a86761834e2f" title="The PlotterBaseXML instance used by this object.">m_plotter_xml</a>-><a class="code" href="classhippodraw_1_1PlotterBaseXML.html#aa1bfc596f3b3bb9744ac2b5b4e0c2bf8" title="Returns a newly created XmlElement with attributes set for plotter.">createElement</a> ( *plotter ); <a name="l00059"></a>00059 tag.<a class="code" href="classhippodraw_1_1XmlNode.html#ae8f46895ca8b33a11cbff29b56ba48e4" title="Appends a child element to the element.">appendChild</a> ( *element ); <a name="l00060"></a>00060 } <a name="l00061"></a>00061 } <a name="l00062"></a>00062 <a name="l00063"></a><a class="code" href="classhippodraw_1_1ViewBaseXML.html#a9511a02d3c63f37e6b31c8acf358c4ec">00063</a> <a class="code" href="classhippodraw_1_1XmlElement.html" title="A pure virtual base class of XML element wrapper.">XmlElement</a> * <a class="code" href="classhippodraw_1_1BaseXML.html#afa1d42a894a8739e0d120ed9c4383d38" title="Creates a new element node.">ViewBaseXML::createElement</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1ViewBase.html" title="The abstract base class for views.">ViewBase</a> & view ) <a name="l00064"></a>00064 { <a name="l00065"></a>00065 <a class="code" href="classhippodraw_1_1XmlElement.html" title="A pure virtual base class of XML element wrapper.">XmlElement</a> * tag = <a class="code" href="classhippodraw_1_1BaseXML.html#afa1d42a894a8739e0d120ed9c4383d38" title="Creates a new element node.">BaseXML::createElement</a> (); <a name="l00066"></a>00066 <a name="l00067"></a>00067 <span class="keyword">const</span> <span class="keywordtype">void</span> * addr = reinterpret_cast < <span class="keyword">const</span> <span class="keywordtype">void</span> * > ( & view ); <a name="l00068"></a>00068 <span class="keywordtype">int</span> <span class="keywordtype">id</span> = <a class="code" href="classhippodraw_1_1BaseXML.html#ae50d78be58d5938b4434515f4f037ece" title="The singleton XML controller object.">m_controller</a> -> getId ( addr ); <a name="l00069"></a>00069 <a class="code" href="classhippodraw_1_1BaseXML.html#aba09fa4e77f2c85cc12df1116cb5f31e" title="Sets the unique identification of the object.">setId</a> ( *tag, <span class="keywordtype">id</span> ); <a name="l00070"></a>00070 <a name="l00071"></a>00071 <a class="code" href="classhippodraw_1_1Rect.html" title="Class representing a rectangle.">Rect</a> rect = view.<a class="code" href="classhippodraw_1_1ViewBase.html#a4a8f555bf8d011b2eb5a2ba4a379bff3" title="Returns the drawing Rectangle in the devices coordinate system.">getDrawRect</a> (); <a name="l00072"></a>00072 tag-><a class="code" href="classhippodraw_1_1XmlElement.html#abf6f7e218f61b094107a9e93ab267fd8" title="Sets attribute named name to the int value value.">setAttribute</a> ( <a class="code" href="classhippodraw_1_1ViewBaseXML.html#a9f9a5086f36e247587cfa92d2ca2f584" title="Attribute name for the X coordinate.">m_x</a>, rect.<a class="code" href="classhippodraw_1_1Rect.html#af71e522ec6aa935c2618819b54f20e02" title="A shortcut to get origin.X.">getX</a>() ); <a name="l00073"></a>00073 tag-><a class="code" href="classhippodraw_1_1XmlElement.html#abf6f7e218f61b094107a9e93ab267fd8" title="Sets attribute named name to the int value value.">setAttribute</a> ( <a class="code" href="classhippodraw_1_1ViewBaseXML.html#a1ac68854adfed872c1dacc4ce440ea0e" title="Attribute name for the Y coordinate.">m_y</a>, rect.<a class="code" href="classhippodraw_1_1Rect.html#acd84440598b1da2a23c326ce371db4e4" title="A shortcut to get origin.Y.">getY</a>() ); <a name="l00074"></a>00074 tag-><a class="code" href="classhippodraw_1_1XmlElement.html#abf6f7e218f61b094107a9e93ab267fd8" title="Sets attribute named name to the int value value.">setAttribute</a> ( <a class="code" href="classhippodraw_1_1ViewBaseXML.html#a896bf4720af1fc72a8077eb9cb68b400" title="Attribute name for the width.">m_w</a>, rect.<a class="code" href="classhippodraw_1_1Rect.html#a5410fe8e5b318eb82d84dcccf3634d8b" title="A shortcut to get size.width.">getWidth</a>() ); <a name="l00075"></a>00075 tag-><a class="code" href="classhippodraw_1_1XmlElement.html#abf6f7e218f61b094107a9e93ab267fd8" title="Sets attribute named name to the int value value.">setAttribute</a> ( <a class="code" href="classhippodraw_1_1ViewBaseXML.html#a3ffe99a3833e0901ea010ca2dc3972e7" title="Attribute name for the height.">m_h</a>, rect.<a class="code" href="classhippodraw_1_1Rect.html#ab22b7a83bfd69953e9421f6941bc9304" title="A shortcut to get size.height.">getHeight</a>() ); <a name="l00076"></a>00076 <a name="l00077"></a>00077 <a class="code" href="classhippodraw_1_1ViewBaseXML.html#aad969b29a2601981991e2ebb67884038" title="Create the child element, i.e.">createChild</a> ( *tag, view ); <a name="l00078"></a>00078 <a name="l00079"></a>00079 <span class="keywordflow">return</span> tag; <a name="l00080"></a>00080 } <a name="l00081"></a>00081 <a name="l00082"></a><a class="code" href="classhippodraw_1_1ViewBaseXML.html#a372f77f6a24c5dc1ad480d2ad8a3c67d">00082</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1ViewBaseXML.html#a372f77f6a24c5dc1ad480d2ad8a3c67d" title="Creates an object derived from ViewBase.">ViewBaseXML::getObjects</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1XmlElement.html" title="A pure virtual base class of XML element wrapper.">XmlElement</a> * view_element ) <a name="l00083"></a>00083 { <a name="l00084"></a>00084 <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1XmlElement.html" title="A pure virtual base class of XML element wrapper.">XmlElement</a> * element = <a class="code" href="classhippodraw_1_1ViewBaseXML.html#a61b9c476758aac5cb4a2a86761834e2f" title="The PlotterBaseXML instance used by this object.">m_plotter_xml</a>-><a class="code" href="classhippodraw_1_1BaseXML.html#af145db70f519c8883e84023299d30356" title="Returns the single child node of element of the type that can be handled by this...">getNode</a> ( view_element ); <a name="l00085"></a>00085 <a class="code" href="classhippodraw_1_1PlotterBase.html" title="The base class for the PlotterBase hierarchy.">PlotterBase</a> * plotter = <a class="code" href="classhippodraw_1_1ViewBaseXML.html#a61b9c476758aac5cb4a2a86761834e2f" title="The PlotterBaseXML instance used by this object.">m_plotter_xml</a>-><a class="code" href="classhippodraw_1_1PlotterBaseXML.html#a940ba78ed732e884dbe0e85ac9393f55" title="Returns the PlotterBase object represented by the element.">getObject</a> ( element ); <a name="l00086"></a>00086 <a name="l00087"></a>00087 <span class="keywordflow">if</span> ( plotter != 0 ) { <a name="l00088"></a>00088 <a class="code" href="classhippodraw_1_1ViewBase.html" title="The abstract base class for views.">ViewBase</a> * view = <a class="code" href="classhippodraw_1_1BaseXML.html#ae50d78be58d5938b4434515f4f037ece" title="The singleton XML controller object.">m_controller</a>-><a class="code" href="classhippodraw_1_1XmlController.html#a03e6d999e0bcaddad4931e7e5a693ea1" title="Creates a new view for the current PlotterBase object and adds it to the list of...">createView</a> ( plotter ); <a name="l00089"></a>00089 <a name="l00090"></a>00090 <span class="keywordtype">float</span> x; <a name="l00091"></a>00091 <span class="keywordtype">bool</span> ok = view_element-><a class="code" href="classhippodraw_1_1XmlElement.html#afa83a3518bac3d6ae2bc519084071fad" title="Sets value to the attribute name&#39;s value.">attribute</a> ( <a class="code" href="classhippodraw_1_1ViewBaseXML.html#a9f9a5086f36e247587cfa92d2ca2f584" title="Attribute name for the X coordinate.">m_x</a>, x ); <a name="l00092"></a>00092 <a name="l00093"></a>00093 <span class="keywordtype">float</span> y; <a name="l00094"></a>00094 ok &= view_element-><a class="code" href="classhippodraw_1_1XmlElement.html#afa83a3518bac3d6ae2bc519084071fad" title="Sets value to the attribute name&#39;s value.">attribute</a> ( <a class="code" href="classhippodraw_1_1ViewBaseXML.html#a1ac68854adfed872c1dacc4ce440ea0e" title="Attribute name for the Y coordinate.">m_y</a>, y ); <a name="l00095"></a>00095 <a name="l00096"></a>00096 <span class="keywordtype">float</span> w; <a name="l00097"></a>00097 ok &= view_element-><a class="code" href="classhippodraw_1_1XmlElement.html#afa83a3518bac3d6ae2bc519084071fad" title="Sets value to the attribute name&#39;s value.">attribute</a> ( <a class="code" href="classhippodraw_1_1ViewBaseXML.html#a896bf4720af1fc72a8077eb9cb68b400" title="Attribute name for the width.">m_w</a>, w ); <a name="l00098"></a>00098 <a name="l00099"></a>00099 <span class="keywordtype">float</span> h; <a name="l00100"></a>00100 ok &= view_element-><a class="code" href="classhippodraw_1_1XmlElement.html#afa83a3518bac3d6ae2bc519084071fad" title="Sets value to the attribute name&#39;s value.">attribute</a> ( <a class="code" href="classhippodraw_1_1ViewBaseXML.html#a3ffe99a3833e0901ea010ca2dc3972e7" title="Attribute name for the height.">m_h</a>, h ); <a name="l00101"></a>00101 <a name="l00102"></a>00102 view-><a class="code" href="classhippodraw_1_1ViewBase.html#a07fc05a06bba1c4e2a56bd4024b09c30" title="Sets the drawing Rectangle in the devices coordinate system.">setDrawRect</a> ( x, y, w, h ); <a name="l00103"></a>00103 } <a name="l00104"></a>00104 } <a name="l00105"></a>00105 <a name="l00106"></a>00106 <span class="keywordtype">void</span> <a name="l00107"></a>00107 <a class="code" href="classhippodraw_1_1ViewBaseXML.html#a9acc0749d0f760d35d43d7cfae0acf21" title="Connects the plotters that reference each other.">ViewBaseXML::</a> <a name="l00108"></a><a class="code" href="classhippodraw_1_1ViewBaseXML.html#a9acc0749d0f760d35d43d7cfae0acf21">00108</a> <a class="code" href="classhippodraw_1_1ViewBaseXML.html#a9acc0749d0f760d35d43d7cfae0acf21" title="Connects the plotters that reference each other.">connectPlotters</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1XmlElement.html" title="A pure virtual base class of XML element wrapper.">XmlElement</a> * root ) <a name="l00109"></a>00109 { <a name="l00110"></a>00110 list < XmlElement * > nodelist; <a name="l00111"></a>00111 <a class="code" href="classhippodraw_1_1ViewBaseXML.html#a61b9c476758aac5cb4a2a86761834e2f" title="The PlotterBaseXML instance used by this object.">m_plotter_xml</a> -> <a class="code" href="classhippodraw_1_1BaseXML.html#a5341ca7744d304c2746a8f5564ce237b" title="Fills the nodelist with immediate child nodes of element with nodes that can be handled...">fillNodeList</a> ( root, nodelist ); <a name="l00112"></a>00112 <a name="l00113"></a>00113 std::list < XmlElement * > ::const_iterator first = nodelist.begin (); <a name="l00114"></a>00114 <span class="keywordflow">while</span> ( first != nodelist.end () ) { <a name="l00115"></a>00115 <a class="code" href="classhippodraw_1_1XmlElement.html" title="A pure virtual base class of XML element wrapper.">XmlElement</a> * element = *first++; <a name="l00116"></a>00116 <span class="keywordtype">int</span> ref; <a name="l00117"></a>00117 <span class="keywordtype">bool</span> ok = element -> attribute ( <span class="stringliteral">"ref"</span>, ref ); <a name="l00118"></a>00118 <span class="keywordflow">if</span> ( ok ) { <a name="l00119"></a>00119 <span class="keywordtype">int</span> <span class="keywordtype">id</span> = element -> getID (); <a name="l00120"></a>00120 <a class="code" href="classhippodraw_1_1PlotterBase.html" title="The base class for the PlotterBase hierarchy.">PlotterBase</a> * source = <a class="code" href="classhippodraw_1_1BaseXML.html#ae50d78be58d5938b4434515f4f037ece" title="The singleton XML controller object.">m_controller</a> -> getPlotter ( <span class="keywordtype">id</span> ); <a name="l00121"></a>00121 <a class="code" href="classhippodraw_1_1PlotterBase.html" title="The base class for the PlotterBase hierarchy.">PlotterBase</a> * target = <a class="code" href="classhippodraw_1_1BaseXML.html#ae50d78be58d5938b4434515f4f037ece" title="The singleton XML controller object.">m_controller</a> -> getPlotter ( ref ); <a name="l00122"></a>00122 source -> setParentPlotter ( target ); <a name="l00123"></a>00123 } <a name="l00124"></a>00124 } <a name="l00125"></a>00125 } </pre></div></div> <hr size="1"><address style="align: right;"><small> Generated for HippoDraw Class Library by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border=0> </a> </small></address> </body> </html>