MapMatrixProjectorXML.cxx
Go to the documentation of this file.
1 
12 // for truncation warning
13 #ifdef _MSC_VER
14 #include "msdevstudio/MSconfig.h"
15 #endif
16 
17 #include "MapMatrixProjectorXML.h"
18 
19 #include "XmlController.h"
20 #include "XmlDocument.h"
21 #include "XmlElement.h"
22 
23 #include "axes/Range.h"
25 
26 namespace hippodraw {
27 
29  : BaseXML ( "MapMatrixProjector", controller ),
30  m_x_bins ( "xbins" ),
31  m_y_bins ( "ybins" ),
32  m_x_step ( "xstep" ),
33  m_y_step ( "ystep" ),
34  m_x_orig ( "xorig" ),
35  m_y_orig ( "yorig" )
36 {
37 }
38 
39 XmlElement *
41 createElement ( const MapMatrixProjector & projector )
42 {
43  XmlElement * tag = BaseXML::createElement (); // in base class
44 
45  const void * addr = reinterpret_cast < const void * > ( & projector );
46  int id = m_controller -> getId ( addr );
47  setId ( *tag, id );
48 
49  int number = projector.getNumberOfBins ( Axes::X );
50  tag -> setAttribute ( m_x_bins, number );
51  number = projector.getNumberOfBins ( Axes::Y );
52  tag -> setAttribute ( m_y_bins, number );
53 
54  double step = projector.getBinWidth ( Axes::X );
55  tag->setAttribute ( m_x_step, step );
56  step = projector.getBinWidth ( Axes::Y );
57  tag->setAttribute ( m_y_step, step );
58 
59  double orig = projector.getOffset ( Axes::X );
60  tag->setAttribute ( m_x_orig, orig );
61  orig = projector.getOffset ( Axes::Y );
62  tag->setAttribute ( m_y_orig, orig );
63 
64  return tag;
65 }
66 
67 void
69 setAttributes ( const XmlElement * element, ProjectorBase * projector )
70 {
71  int number = 0;
72  bool ok = element -> attribute ( m_x_bins, number );
73  projector -> setNumberOfBins ( Axes::X, number );
74  ok = element -> attribute ( m_y_bins, number );
75  projector -> setNumberOfBins ( Axes::Y, number );
76 
77  double value = 0.;
78  ok = element -> attribute ( m_x_step, value );
79  projector -> setBinWidth ( Axes::X, value );
80  ok = element -> attribute ( m_y_step, value );
81  projector -> setBinWidth ( Axes::Y, value );
82 
83  ok = element -> attribute ( m_x_orig, value );
84  projector -> setOffset ( Axes::X, value );
85  ok = element -> attribute ( m_y_orig, value );
86  projector -> setOffset ( Axes::Y, value );
87 
88  projector -> matrixTranspose(true);
89 }
90 
91 } // namespace hippodraw
92 
std::string m_y_step
Name of attribute for number step size in Y direction.
XmlElement * createElement()
Creates a new element node.
Definition: BaseXML.cxx:43
XmlDocument class interface.
XmlController class interface.
A pure virtual base class of XML element wrapper.
Definition: XmlElement.h:30
MapMatrixProjectorXML(const MapMatrixProjectorXML &)
A private copy constructor in order to avoid copying.
hippodraw::MapMatrixProjector class interface
void setId(XmlElement &tag, int id)
Sets the unique identification of the object.
Definition: BaseXML.cxx:64
virtual double getOffset(hippodraw::Axes::Type axis) const
Returns the origin along the axis axis.
virtual double getBinWidth(hippodraw::Axes::Type axis) const
Returns the step size along the axis axis.
bool ok
Definition: CanvasView.cxx:163
std::string m_y_orig
Name of attribute for origin along Y direction.
std::string m_x_bins
Name of attribute for number X bins.
A derived class of NTupleProjector that maps 1 DataSource column to a Y axis of two dimensional proje...
void setAttributes(const XmlElement *element, ProjectorBase *projector)
Sets the MapMatrixProjector attributes of the projector from child nodes of the parent XML element...
XmlController * m_controller
The singleton XML controller object.
Definition: BaseXML.h:60
XmlElement class interface.
The base class for the Projector hierarchy.
Definition: ProjectorBase.h:56
std::string m_x_orig
Name of attribute for origin along X direction.
hippodraw::Range class interface
A base class of XML element controllers.
Definition: BaseXML.h:35
std::string m_y_bins
Name of attribute for number Y bins.
MapMatrixProjectorXML class interface.
A base class that is the interface between GUI and the XML serialization and deserialization.
Definition: XmlController.h:53
std::string m_x_step
Name of attribute for number step size in X direction.
virtual int getNumberOfBins(hippodraw::Axes::Type axis) const
Returns the number of bins.
virtual void setAttribute(const std::string &name, bool value)=0
Sets attribute named name to the int value value.

Generated for HippoDraw Class Library by doxygen