XYPlot.cxx

Go to the documentation of this file.
00001 
00012 // for truncation warning in debug mode
00013 #ifdef _MSC_VER
00014 #include "msdevstudio/MSconfig.h"
00015 #endif
00016 
00017 #include "XYPlot.h"
00018 
00019 #include "projectors/Map2Projector.h"
00020 #include "reps/SymbolPointRep.h"
00021 
00022 using namespace hippodraw;
00023 
00024 using std::string;
00025 using std::vector;
00026 
00027 
00028 XYPlot::XYPlot ( )
00029 {
00030   m_name = "XY Plot";
00031 
00032   Map2Projector * projector = new Map2Projector();
00033   projector->setXErrorOption ( true ); // method not in ProjectorBase
00034   projector->setYErrorOption ( true );
00035   m_projector = projector;
00036 
00037   m_rep = new SymbolPointRep ( Symbol::SOLIDSQUARE, 4.0 );
00038 }
00039 
00040 DataRep * XYPlot::clone ()
00041 {
00042   return new XYPlot( *this );
00043 }
00044 
00050 void
00051 XYPlot::
00052 setRepresentation ( RepBase * rep )
00053 {
00054   DataRep::setPointRep ( rep );
00055   if ( rep -> name () == "Symbol" ) {
00056     rep -> setSize ( 4.0 );
00057     const vector < string > & bindings = m_projector -> getAxisBindings ();
00058 
00059     bool yes = bindings[2] != "nil";
00060     setErrorDisplay ( Axes::X, yes );
00061 
00062     yes = bindings[3] != "nil";
00063     setErrorDisplay ( Axes::Y, yes );
00064   }
00065 }
00066 
00067 bool XYPlot::acceptFunction ( int num )
00068 {
00069   return num == 1;
00070 }
00071 
00072 bool
00073 XYPlot::
00074 hasErrorDisplay () const
00075 {
00076   bool yes = true;
00077 
00078   if ( m_rep -> name () == "Symbol" ) {
00079     const vector < string > & bindings = m_projector -> getAxisBindings ();
00080     
00081     yes = bindings[2] != "nil" || bindings[3] != "nil";
00082   }
00083 
00084   return yes;
00085 }
00086 
00087 
00088 void
00089 XYPlot::
00090 setAxisBinding ( const std::string & axis, const std::string & label )
00091 {
00092   DataRep::setAxisBinding ( axis, label );
00093 
00094   NTupleProjector * projector 
00095     = dynamic_cast < NTupleProjector * > ( m_projector );
00096   unsigned int index = projector -> indexOfBindingOption ( axis );
00097 
00098   bool yes = label != "nil";
00099   if ( index == 2 ) {
00100     setErrorDisplay ( Axes::X, yes );
00101   }
00102 
00103   if ( index == 3 ) {
00104     setErrorDisplay ( Axes::Y, yes );
00105   }
00106 }
00107 
00108 void
00109 XYPlot::
00110 setAxisBindings ( const std::vector < std::string > & new_bindings )
00111 {
00112   DataRep::setAxisBindings ( new_bindings );
00113 
00114   const vector < string > & bindings = m_projector ->getAxisBindings ();
00115   bool yes = bindings[2] != "nil";
00116   setErrorDisplay ( Axes::X, yes );
00117 
00118   yes = bindings[3] != "nil";
00119   setErrorDisplay ( Axes::Y, yes );
00120 }
00121 
00122 bool
00123 XYPlot::
00124 hasAxis ( hippodraw::Axes::Type axis ) const
00125 {
00126   return axis == Axes::X || axis == Axes::Y;
00127 }
00128 
00129 bool
00130 XYPlot::
00131 hasZoomY ( ) const
00132 {
00133   return true;
00134 }

Generated for HippoDraw Class Library by doxygen