Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

PlotterBase.h

Go to the documentation of this file.
00001 /* -*- mode: c++ -*- */
00002 
00014 #ifndef _PlotterBase_H_
00015 #define _PlotterBase_H_
00016 
00017 #include "axes/AxesType.h"
00018 #include "graphics/Rectangle.h"
00019 
00020 #include "pattern/Observable.h"
00021 #include "pattern/Observer.h"
00022 
00023 class AxisModelBase;
00024 class AxisTick;
00025 class BinToColor;
00026 class Color;
00027 class DataRep;
00028 class NTuple;
00029 class ProjectorBase;
00030 class Range;
00031 class RepBase;
00032 class TupleCut;
00033 class TransformBase;
00034 class ViewBase;
00035 
00057 class MDL_HIPPOPLOT_API PlotterBase :
00058   public hippodraw::Observer, public Observable
00059 {
00060 
00061 private:
00062 
00066   virtual void setScaleFactor ( hippodraw::Axes::Type  axis, double factor );
00067 
00071   virtual void setScaling ( hippodraw::Axes::Type  axis, bool on = true );
00072 
00073    void setPlotterId();
00074 
00075 protected:
00076   
00081   double m_aspect_ratio;
00082   
00085   std::string m_name;
00086   
00087   /* The three following fields (m_title, m_x_label, m_y_label) have
00088       default values. The PlotterBase object gets them from the
00089       ProjectorBase object, and the ProjectorBase object gets them
00090       from the NTuple object. */
00091   
00093   std::string m_title;
00094   
00096   double m_crossX;
00097   
00099   double m_crossY;
00100   
00104   HippoRectangle    m_margin_rect; 
00105   
00108   HippoRectangle    m_user_rect;
00109 
00111   PlotterBase* m_parent_plotter;
00112   
00114   int m_parent_datarep_index;
00115 
00117    PlotterBase ();
00118 
00120   PlotterBase ( const std::string & name );
00121 
00123   PlotterBase ( const PlotterBase & plotter );
00124 
00126   bool hasAutoScaled () const;
00127 
00128 
00130   bool current_range_saved;
00131 
00134    int m_plotterId;
00135 
00139    std::vector< std::vector<double> > m_views;
00140 
00142    int m_currentView;
00143 
00145    static int s_plotters;
00146 
00147 public:
00148 
00151   virtual ~PlotterBase();
00152 
00155   virtual PlotterBase * clone() = 0;
00156 
00158   const std::string & name () const;
00159 
00163   virtual void  update ( const Observable * );
00164 
00169   virtual void update () = 0;
00170 
00174   virtual bool hasNTupleBindings () const = 0;
00175 
00176 
00180   virtual bool hasZoomY () const ;
00181 
00187   virtual void setBinWidth ( hippodraw::Axes::Type axis, double width );
00188 
00195   virtual void setBinWidth ( const std::string & axis, double width );
00196 
00201   virtual void setOffset ( hippodraw::Axes::Type axis, double offset );
00202 
00209   virtual void setOffset ( const std::string & axis, double offset );
00210 
00216   virtual void setNumberOfBins ( const std::string & axis, 
00217                                  unsigned int number );
00218 
00224   virtual void setNumberOfBins ( hippodraw::Axes::Type axis, 
00225                                  unsigned int number );
00226 
00231   virtual AxisModelBase * getAxisModel ( hippodraw::Axes::Type axis ) const;
00232 
00236   virtual void addDataRep ( DataRep * rep );
00237 
00239   virtual void setActivePlot ( int index, bool redraw );
00240 
00243   virtual int activePlotIndex ( ) const;
00244   
00247   virtual int getParentDataRepIndex ( ) const;
00248   
00250   virtual void setParentDataRepIndex ( int index );
00251 
00253   virtual PlotterBase* getParentPlotter ( ) const;
00254   
00256   virtual void setParentPlotter( PlotterBase* plotter );
00257   
00259   virtual void reset ( );
00260 
00263   virtual ProjectorBase * activeProjector () const;
00264   
00268   virtual DataRep * selectedDataRep () const;
00269 
00274   virtual ProjectorBase * getProjector (int i) const;
00275 
00278   virtual int getNumDataReps() const;
00279 
00281   virtual DataRep * getDataRep ( int index ) const;
00282 
00288   virtual void removeDataRep ( DataRep * );
00289 
00292   virtual void drawIn ( ViewBase * view ) = 0;
00293 
00298   virtual void drawCrossHairs ( ViewBase * view );
00299 
00308   virtual void setRepresentation ( RepBase * pointrep ) = 0;
00309 
00311   virtual RepBase * representation ( ) const = 0;
00312 
00318   virtual const BinToColor * getValueRep () const;
00319 
00323   virtual void setValueRep ( BinToColor * rep );
00324 
00334   virtual void setTransform ( TransformBase * );
00335 
00339   virtual TransformBase * getTransform () const;
00340 
00342   virtual void setAxisModel ( AxisModelBase * , hippodraw::Axes::Type ) = 0;
00343 
00347   virtual void setAutoRanging ( const std::string &  axis, bool flag );
00348 
00353   virtual void setAutoRanging ( hippodraw::Axes::Type axis, bool flag );
00354 
00357   virtual void setAutoRanging ( bool flag );
00358 
00363   virtual bool isAutoRanging ( hippodraw::Axes::Type axis ) const;
00364 
00369   virtual void autoScale();
00370 
00373   void setTitle( const std::string & title );
00374 
00376   const std::string & getTitle() const;
00377 
00386   virtual void setLabel ( const std::string & axis, 
00387                           const std::string & label );
00388 
00392   virtual void setLabel ( hippodraw::Axes::Type, const std::string & value );
00393 
00397   virtual const std::string & getLabel ( hippodraw::Axes::Type ) const;
00398 
00399 
00405   virtual const std::string &
00406   getInternalTitle ( ) const;
00407 
00414   virtual const std::string &
00415   getInternalLabel ( hippodraw::Axes::Type axis ) const;
00416 
00419   virtual void checkAxisScaling ();
00420 
00424   virtual double getBinWidth (hippodraw::Axes::Type axis) const;
00425 
00431   double getBinWidth ( const std::string & axis ) const;
00432 
00435   virtual double getOffset (hippodraw::Axes::Type axis) const;
00436 
00439   double getOffset ( const std::string & axis ) const;
00440 
00443   virtual int getNumberOfEntries () const;
00444 
00450   int getNumOfEntries () const;
00451 
00455   virtual void setErrorDisplay ( hippodraw::Axes::Type axis, bool ) = 0;
00456 
00458   virtual bool errorDisplay ( hippodraw::Axes::Type axis ) const = 0;
00459 
00475   virtual void setRange ( hippodraw::Axes::Type axis, const Range & range,
00476                           bool scaled = false, bool adjust_width = true );
00477 
00482   void setRange ( const std::string & axis, double low, double high );
00483 
00489   virtual const Range & getRange ( hippodraw::Axes::Type axis, 
00490                                    bool scaled ) const;
00491 
00493   virtual double getPosRange ( hippodraw::Axes::Type axis ) const;
00494 
00498   virtual void setLowRange ( hippodraw::Axes::Type axis, int parm, 
00499                              bool dragging );
00500 
00504   virtual void setHighRange ( hippodraw::Axes::Type axis, int parm, 
00505                               bool dragging );
00506 
00508   virtual void setRepColor ( const Color & ) = 0;
00509 
00511   virtual const Color & repColor () const = 0;
00512 
00514   const HippoRectangle & getUserRect () const;
00515 
00517   HippoRectangle getMarginRect () const;
00518 
00520   virtual float userToMarginX ( double x ) const = 0;
00521 
00523   virtual float userToMarginY ( double x ) const = 0;
00524 
00527   virtual float userToInvertedMarginY ( double y ) const = 0;
00528 
00534   virtual void marginToUserXY ( double mx, double my, bool scaled, 
00535                                 double & ux, double & uy ) const = 0;
00536 
00542   virtual NTuple * createPickTuple ();
00543 
00549   virtual void fillPickedPoint ( double mx, double my, 
00550                                  std::vector < double > & picked ) const;
00551 
00553   virtual float userToMarginColor ( double c ) const;
00554 
00561   virtual double getZValue ( double x, double y, bool scaled = true ) const;
00562 
00566   virtual bool hasAxis ( hippodraw::Axes::Type axis ) const;
00567 
00569   void setCrossX ( double val );
00570 
00572   void setCrossY ( double val );
00573 
00580   virtual void addValues ( const std::vector < double > & v );
00581 
00589   virtual double getAspectRatio () const;
00590 
00595   void setAspectRatio ( double ratio );
00596 
00603   virtual NTuple * createNTuple () const = 0;
00604 
00613   virtual bool wantsPixmap ( ) const;
00614 
00616   virtual void setOffsets( double xoffset, double yoffset );
00617 
00621   virtual void setEnableZ ( bool yes = true );
00622 
00626   virtual void setAutoTicks ( hippodraw::Axes::Type axis, bool yes );
00627 
00630   virtual void setTicks ( hippodraw::Axes::Type axis, 
00631                           const std::vector < AxisTick > & ticks );
00632 
00635   virtual void setAutoTicks ( const std::string &, bool on );
00636 
00644   virtual void setAutoTicksOnX ( bool yes );
00645 
00653   virtual void setTicksOnX ( const std::vector < double > & values,
00654                              const std::vector < std::string > & labels );
00655 
00658   virtual void setTicks ( const std::string & axis,
00659                           const std::vector < double > & values,
00660                           const std::vector < std::string > & labels );
00661 
00665   virtual double getLowRangeOnX ( ) const;
00666 
00671   virtual double getHighRangeOnX () const;
00672 
00678   virtual void matrixTranspose ( bool yes );
00679 
00687   virtual bool isTargetable () const;
00688 
00693   virtual DataRep * getTarget () const;
00694 
00700   virtual int indexOf ( const DataRep * rep ) const;
00701 
00709   void toggleActivePlot ();
00710 
00712    virtual int plotterId () const;
00713 
00720    int saveView ( const std::vector<double> & range_values );
00721 
00722   
00731  int saveViewAtIndex(const std::vector<double>& range_values,unsigned int i ); 
00732 
00734    void setView ( int index );
00735 
00741    int nextView (bool stepForward=true);
00742 
00743 
00745    int numViews () const;
00746 
00748    void deleteView ( int index );
00749 
00751    int currentView () const;
00752 
00757   virtual void fillCutList ( std::vector < const TupleCut * > & cuts ) const;
00758 
00763   virtual void setCutRangeAt ( const Range & range, unsigned int i );
00764 
00767   virtual void setCurrentRangeSaved( bool flag );
00768 
00771   virtual bool getCurrentRangeSaved( );
00772 
00773 
00774 };
00775 
00776 #endif // _PlotterBase_H_

Generated for HippoDraw-1.14.8.5 by doxygen 1.4.3