00001
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 namespace hippodraw {
00024
00025 class AxisModelBase;
00026 class AxisTick;
00027 class BinToColor;
00028 class Color;
00029 class DataRep;
00030 class NTuple;
00031 class ProjectorBase;
00032 class Range;
00033 class RepBase;
00034 class TupleCut;
00035 class TransformBase;
00036 class ViewBase;
00037 class FontBase;
00038
00055 class MDL_HIPPOPLOT_API PlotterBase :
00056 public Observer, public Observable
00057 {
00058
00059 private:
00060
00064 virtual void setScaling ( Axes::Type axis, bool on = true );
00065
00066 void setPlotterId();
00067
00068 protected:
00069
00074 double m_aspect_ratio;
00075
00078 std::string m_name;
00079
00080
00081
00082
00083
00084
00086 std::string m_title;
00087
00089 double m_crossX;
00090
00092 double m_crossY;
00093
00098 Rect m_user_rect;
00099
00102 Rect m_raw_rect;
00103
00105 PlotterBase* m_parent_plotter;
00106
00108 int m_parent_datarep_index;
00109
00111 PlotterBase ();
00112
00114 PlotterBase ( const std::string & name );
00115
00117 PlotterBase ( const PlotterBase & plotter );
00118
00120 bool hasAutoScaled () const;
00121
00122
00124 bool current_range_saved;
00125
00128 int m_plotterId;
00129
00133 std::vector< std::vector<double> > m_views;
00134
00136 int m_currentView;
00137
00139 static int s_plotters;
00140
00141 public:
00142
00145 virtual ~PlotterBase();
00146
00149 virtual PlotterBase * clone() = 0;
00150
00152 const std::string & name () const;
00153
00157 virtual void setScaleFactor ( Axes::Type axis, double factor );
00158
00161 virtual bool isAxisScaled ( Axes::Type axis ) const;
00162
00166 virtual void update ( const Observable * );
00167
00172 virtual void update () = 0;
00173
00177 virtual bool hasNTupleBindings () const = 0;
00178
00179
00183 virtual bool hasZoomY () const ;
00184
00190 virtual void setBinWidth ( Axes::Type axis, double width );
00191
00198 virtual void setBinWidth ( const std::string & axis, double width );
00199
00203 virtual void setBinWidth ( Axes::Type axis,
00204 int parameter, bool dragging );
00205
00210 virtual void setOffset ( Axes::Type axis, double offset );
00211
00218 virtual void setOffset ( const std::string & axis, double offset );
00219
00225 virtual void setNumberOfBins ( const std::string & axis,
00226 unsigned int number );
00227
00233 virtual void setNumberOfBins ( Axes::Type axis,
00234 unsigned int number );
00235
00240 virtual AxisModelBase * getAxisModel ( Axes::Type axis ) const;
00241
00245 virtual void addDataRep ( DataRep * rep );
00246
00248 virtual void setActivePlot ( int index, bool redraw );
00249
00252 virtual int activePlotIndex ( ) const;
00253
00256 virtual int getParentDataRepIndex ( ) const;
00257
00259 virtual void setParentDataRepIndex ( int index );
00260
00262 virtual PlotterBase* getParentPlotter ( ) const;
00263
00265 virtual void setParentPlotter( PlotterBase* plotter );
00266
00268 virtual void reset ( );
00269
00272 virtual ProjectorBase * activeProjector () const;
00273
00277 virtual DataRep * selectedDataRep () const;
00278
00283 virtual ProjectorBase * getProjector (int i) const;
00284
00287 virtual int getNumDataReps() const;
00288
00290 virtual DataRep * getDataRep ( int index ) const;
00291
00297 virtual void removeDataRep ( DataRep * );
00298
00304 virtual void prepareToDraw ();
00305
00308 virtual void drawIn ( ViewBase * view ) = 0;
00309
00314 virtual void drawCrossHairs ( ViewBase * view );
00315
00324 virtual void setRepresentation ( RepBase * pointrep ) = 0;
00325
00327 virtual RepBase * representation ( ) const = 0;
00328
00334 virtual const BinToColor * getValueRep () const;
00335
00339 virtual void setValueRep ( BinToColor * rep );
00340
00350 virtual void setTransform ( TransformBase * );
00351
00355 virtual void setFitsTransform ( const std::string & );
00356
00360 virtual TransformBase * getTransform () const;
00361
00364 virtual TransformBase * getFitsTransform () const;
00365
00367 virtual void setAxisModel ( AxisModelBase * , Axes::Type ) = 0;
00368
00372 virtual void setAutoRanging ( const std::string & axis, bool flag );
00373
00378 virtual void setAutoRanging ( Axes::Type axis, bool flag );
00379
00382 virtual void setAutoRanging ( bool flag );
00383
00386 virtual void setReverse ( bool flag );
00387
00390 virtual void setShowGrid ( bool flag );
00391
00394 virtual void setBoxEdge (bool flag );
00395
00398 virtual bool getBoxEdge ();
00399
00402 virtual bool getShowGrid ();
00403
00408 virtual bool isAutoRanging ( Axes::Type axis ) const;
00409
00412 virtual bool isReverse () const;
00413
00414
00419 virtual void autoScale();
00420
00423 void setTitle( const std::string & title );
00424
00426 const std::string & getTitle() const;
00427
00436 virtual void setLabel ( const std::string & axis,
00437 const std::string & label );
00438
00442 virtual void setLabel ( Axes::Type, const std::string & value );
00443
00447 virtual const std::string & getLabel ( Axes::Type ) const;
00448
00449
00455 virtual const std::string &
00456 getInternalTitle ( ) const;
00457
00464 virtual const std::string &
00465 getInternalLabel ( Axes::Type axis ) const;
00466
00469 virtual void checkAxisScaling ();
00470
00474 virtual double getBinWidth (Axes::Type axis) const;
00475
00481 double getBinWidth ( const std::string & axis ) const;
00482
00485 virtual double getOffset (Axes::Type axis) const;
00486
00489 double getOffset ( const std::string & axis ) const;
00490
00493 virtual int getNumberOfEntries () const;
00494
00500 int getNumOfEntries () const;
00501
00505 virtual void setErrorDisplay ( Axes::Type axis, bool ) = 0;
00506
00508 virtual bool errorDisplay ( Axes::Type axis ) const = 0;
00509
00522 virtual void setRange ( Axes::Type axis, const Range & range,
00523 bool scaled = false, bool adjust_width = true );
00524
00529 void setRange ( const std::string & axis, double low, double high );
00530
00536 virtual const Range & getRange ( Axes::Type axis,
00537 bool scaled ) const;
00538
00540 virtual Range getDataRange ( Axes::Type axis );
00541
00543 virtual double getPosRange ( Axes::Type axis ) const;
00544
00548 virtual void setLowRange ( Axes::Type axis, int parm,
00549 bool dragging );
00550
00554 virtual void setHighRange ( Axes::Type axis, int parm,
00555 bool dragging );
00556
00558 virtual void setRepColor ( const Color & ) = 0;
00559
00561 virtual const Color & repColor () const = 0;
00562
00564 const Rect & getUserRect () const;
00565
00567 const Rect & getRawRect () const;
00568
00574 virtual NTuple * createPickTuple ();
00575
00581 virtual void fillPickedPointFrom ( double mx, double my,
00582 std::vector < double > & picked ) const;
00583
00590 virtual double getZValue ( double x, double y, bool scaled = true ) const;
00591
00595 virtual bool hasAxis ( Axes::Type axis ) const;
00596
00598 void setCrossX ( double val );
00599
00601 void setCrossY ( double val );
00602
00609 virtual void addValues ( const std::vector < double > & v );
00610
00618 virtual double getAspectRatio () const;
00619
00624 void setAspectRatio ( double ratio );
00625
00632 virtual NTuple * createNTuple () const = 0;
00633
00642 virtual bool wantsPixmap ( ) const;
00643
00645 virtual void setOffsets( double xoffset, double yoffset );
00646
00650 virtual void setEnableZ ( bool yes = true );
00651
00655 virtual void setAutoTicks ( Axes::Type axis, bool yes );
00656
00659 virtual void setTicks ( Axes::Type axis,
00660 const std::vector < AxisTick > & ticks );
00661
00664 virtual void setAutoTicks ( const std::string &, bool on );
00665
00673 virtual void setAutoTicksOnX ( bool yes );
00674
00682 virtual void setTicksOnX ( const std::vector < double > & values,
00683 const std::vector < std::string > & labels );
00684
00687 virtual void setTicks ( const std::string & axis,
00688 const std::vector < double > & values,
00689 const std::vector < std::string > & labels );
00690
00694 virtual double getLowRangeOnX ( ) const;
00695
00700 virtual double getHighRangeOnX () const;
00701
00707 virtual void matrixTranspose ( bool yes );
00708
00716 virtual bool isTargetable () const;
00717
00722 virtual DataRep * getTarget () const;
00723
00729 virtual int indexOf ( const DataRep * rep ) const;
00730
00738 void toggleActivePlot ();
00739
00741 virtual int plotterId () const;
00742
00749 int saveView ( const std::vector<double> & range_values );
00750
00751
00760 int saveViewAtIndex(const std::vector<double>& range_values,unsigned int i );
00761
00763 void setView ( int index );
00764
00770 int nextView (bool stepForward=true);
00771
00772
00774 int numViews () const;
00775
00777 void deleteView ( int index );
00778
00780 int currentView () const;
00781
00786 virtual void fillCutList ( std::vector < const TupleCut * > & cuts ) const;
00787
00792 virtual void setCutRangeAt ( const Range & range, unsigned int i );
00793
00796 virtual void setCurrentRangeSaved( bool flag );
00797
00800 virtual bool getCurrentRangeSaved( );
00801
00804 virtual const std::vector <double> & getZValues();
00805 virtual const std::vector <unsigned int> & getShape();
00806
00809 virtual void setMinEntries( int entries );
00810
00811
00814 virtual int getMinEntries ();
00815
00820 virtual FontBase* labelFont ( Axes::Type axes ) const;
00821
00826 virtual const FontBase * titleFont ( ) const;
00827
00834 virtual bool isImageConvertable () const;
00835
00837 virtual bool isTextPlotter() const;
00838
00839
00841 virtual void setTopMargin( double top );
00842 virtual void setBottomMargin( double bottom );
00843 virtual void setLeftMargin( double left );
00844 virtual void setZMargin( double z );
00845 virtual double getTopMargin();
00846 virtual double getBottomMargin();
00847 virtual double getLeftMargin();
00848 virtual double getZMargin();
00849
00852 virtual void setNeedUpdate(bool isChanged);
00853
00856 virtual double getScaleFactor ( Axes::Type axis ) const;
00857
00858 };
00859
00860 }
00861
00862 #endif // _PlotterBase_H_