XYPlot.cxx
Go to the documentation of this file.
1 
12 // for truncation warning in debug mode
13 #ifdef _MSC_VER
14 #include "msdevstudio/MSconfig.h"
15 #endif
16 
17 #include "XYPlot.h"
18 
20 #include "reps/SymbolPointRep.h"
21 
22 using namespace hippodraw;
23 
24 using std::string;
25 using std::vector;
26 
27 
29 {
30  m_name = "XY Plot";
31 
32  Map2Projector * projector = new Map2Projector();
33  projector->setXErrorOption ( true ); // method not in ProjectorBase
34  projector->setYErrorOption ( true );
35  m_projector = projector;
36 
38 }
39 
41 {
42  return new XYPlot( *this );
43 }
44 
50 void
53 {
54  DataRep::setPointRep ( rep );
55  if ( rep -> name () == "Symbol" ) {
56  rep -> setSize ( 4.0 );
57  const vector < string > & bindings = m_projector -> getAxisBindings ();
58 
59  bool yes = bindings[2] != "nil";
60  setErrorDisplay ( Axes::X, yes );
61 
62  yes = bindings[3] != "nil";
63  setErrorDisplay ( Axes::Y, yes );
64  }
65 }
66 
67 bool XYPlot::acceptFunction ( int num )
68 {
69  return num == 1;
70 }
71 
72 bool
75 {
76  bool yes = true;
77 
78  if ( m_rep -> name () == "Symbol" ) {
79  const vector < string > & bindings = m_projector -> getAxisBindings ();
80 
81  yes = bindings[2] != "nil" || bindings[3] != "nil";
82  }
83 
84  return yes;
85 }
86 
87 
88 void
90 setAxisBinding ( const std::string & axis, const std::string & label )
91 {
92  DataRep::setAxisBinding ( axis, label );
93 
94  NTupleProjector * projector
95  = dynamic_cast < NTupleProjector * > ( m_projector );
96  unsigned int index = projector -> indexOfBindingOption ( axis );
97 
98  bool yes = label != "nil";
99  if ( index == 2 ) {
100  setErrorDisplay ( Axes::X, yes );
101  }
102 
103  if ( index == 3 ) {
104  setErrorDisplay ( Axes::Y, yes );
105  }
106 }
107 
108 void
109 XYPlot::
110 setAxisBindings ( const std::vector < std::string > & new_bindings )
111 {
112  DataRep::setAxisBindings ( new_bindings );
113 
114  const vector < string > & bindings = m_projector ->getAxisBindings ();
115  bool yes = bindings[2] != "nil";
116  setErrorDisplay ( Axes::X, yes );
117 
118  yes = bindings[3] != "nil";
119  setErrorDisplay ( Axes::Y, yes );
120 }
121 
122 bool
123 XYPlot::
125 {
126  return axis == Axes::X || axis == Axes::Y;
127 }
128 
129 bool
130 XYPlot::
131 hasZoomY ( ) const
132 {
133  return true;
134 }
std::string m_name
The name of the display as it might be displayed in a GUI.
Definition: DataRep.h:76
virtual void setAxisBinding(const std::string &axis, const std::string &label)
Sets the axis binding.
Definition: DataRep.cxx:102
hippodraw::SymbolPointRep class interface
A derived class of NTupleProjector that maps 2 ntuple columns to a two dimensional projection...
Definition: Map2Projector.h:29
virtual void setAxisBindings(const std::vector< std::string > &bindings)
Sets the axis bindings.
Definition: DataRep.cxx:112
const std::string & name() const
Returns the name of the display.
Definition: DataRep.cxx:72
virtual void setPointRep(RepBase *pointrep)
Sets the representation of the data points.
Definition: DataRep.cxx:217
void setErrorDisplay(Axes::Type axis, bool)
Sets the display of error bar, if applicable, on the specified axis.
Definition: DataRep.cxx:186
An NTupleProjector is a projector that projects data from an DataSource object.
virtual bool hasAxis(hippodraw::Axes::Type) const
Returns true if the data representation has specified axis type axis.
Definition: XYPlot.cxx:124
XYPlot()
The default constructor.
Definition: XYPlot.cxx:28
return rep
Definition: Inspector.cxx:3843
virtual void setYErrorOption(bool enable)
Sets whether the Y error options are to be enabled or not.
virtual const std::vector< std::string > & getAxisBindings() const
Returns the axis bindings.
RepBase * m_rep
The representation used for drawing each data point in the view.
Definition: DataRep.h:94
return yes
Definition: CanvasView.cxx:883
virtual void setAxisBindings(const std::vector< std::string > &bindings)
Sets the axis bindings.
Definition: XYPlot.cxx:110
A PointRep class draws a symbol to represent the value.
virtual void setRepresentation(RepBase *point_rep)
Sets the point representation.
Definition: XYPlot.cxx:52
The base class for data representations.
Definition: DataRep.h:68
virtual bool hasErrorDisplay() const
Returns true.
Definition: XYPlot.cxx:74
virtual void setXErrorOption(bool enable)
Sets whether the X error options are to be enabled or not.
bool acceptFunction(int num)
Returns true if the DataRep accepts functions on number variables.
Definition: XYPlot.cxx:67
ProjectorBase * m_projector
A projector used to transform data to projected values that will be plotted.
Definition: DataRep.h:90
XYPlot classes interface.
return index
Definition: PickTable.cxx:182
virtual void setAxisBinding(const std::string &axis, const std::string &label)
Sets the axis bindings.
Definition: XYPlot.cxx:90
virtual DataRep * clone()
The clone function returns an object of its own kind which is a copy of this object at this moment...
Definition: XYPlot.cxx:40
Type
Axes constants.
Definition: AxesType.h:31
The base class for the point representation hierarchy.
Definition: RepBase.h:45
virtual bool hasZoomY() const
Returns true to allow zooming on Y asis.
Definition: XYPlot.cxx:131
hippodraw::Map2Projector class interface

Generated for HippoDraw Class Library by doxygen