PlotterBase.h
Go to the documentation of this file.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 setScaleFactor ( Axes::Type axis, double factor );
00065
00069 virtual void setScaling ( Axes::Type axis, bool on = true );
00070
00071 void setPlotterId();
00072
00073 protected:
00074
00079 double m_aspect_ratio;
00080
00083 std::string m_name;
00084
00085
00086
00087
00088
00089
00091 std::string m_title;
00092
00094 double m_crossX;
00095
00097 double m_crossY;
00098
00103 Rect m_user_rect;
00104
00107 Rect m_raw_rect;
00108
00110 PlotterBase* m_parent_plotter;
00111
00113 int m_parent_datarep_index;
00114
00116 PlotterBase ();
00117
00119 PlotterBase ( const std::string & name );
00120
00122 PlotterBase ( const PlotterBase & plotter );
00123
00125 bool hasAutoScaled () const;
00126
00127
00129 bool current_range_saved;
00130
00133 int m_plotterId;
00134
00138 std::vector< std::vector<double> > m_views;
00139
00141 int m_currentView;
00142
00144 static int s_plotters;
00145
00146 public:
00147
00150 virtual ~PlotterBase();
00151
00154 virtual PlotterBase * clone() = 0;
00155
00157 const std::string & name () const;
00158
00162 virtual void update ( const Observable * );
00163
00168 virtual void update () = 0;
00169
00173 virtual bool hasNTupleBindings () const = 0;
00174
00175
00179 virtual bool hasZoomY () const ;
00180
00186 virtual void setBinWidth ( Axes::Type axis, double width );
00187
00194 virtual void setBinWidth ( const std::string & axis, double width );
00195
00199 virtual void setBinWidth ( Axes::Type axis,
00200 int parameter, bool dragging );
00201
00206 virtual void setOffset ( Axes::Type axis, double offset );
00207
00214 virtual void setOffset ( const std::string & axis, double offset );
00215
00221 virtual void setNumberOfBins ( const std::string & axis,
00222 unsigned int number );
00223
00229 virtual void setNumberOfBins ( Axes::Type axis,
00230 unsigned int number );
00231
00236 virtual AxisModelBase * getAxisModel ( Axes::Type axis ) const;
00237
00241 virtual void addDataRep ( DataRep * rep );
00242
00244 virtual void setActivePlot ( int index, bool redraw );
00245
00248 virtual int activePlotIndex ( ) const;
00249
00252 virtual int getParentDataRepIndex ( ) const;
00253
00255 virtual void setParentDataRepIndex ( int index );
00256
00258 virtual PlotterBase* getParentPlotter ( ) const;
00259
00261 virtual void setParentPlotter( PlotterBase* plotter );
00262
00264 virtual void reset ( );
00265
00268 virtual ProjectorBase * activeProjector () const;
00269
00273 virtual DataRep * selectedDataRep () const;
00274
00279 virtual ProjectorBase * getProjector (int i) const;
00280
00283 virtual int getNumDataReps() const;
00284
00286 virtual DataRep * getDataRep ( int index ) const;
00287
00293 virtual void removeDataRep ( DataRep * );
00294
00300 virtual void prepareToDraw ();
00301
00304 virtual void drawIn ( ViewBase * view ) = 0;
00305
00310 virtual void drawCrossHairs ( ViewBase * view );
00311
00320 virtual void setRepresentation ( RepBase * pointrep ) = 0;
00321
00323 virtual RepBase * representation ( ) const = 0;
00324
00330 virtual const BinToColor * getValueRep () const;
00331
00335 virtual void setValueRep ( BinToColor * rep );
00336
00346 virtual void setTransform ( TransformBase * );
00347
00351 virtual void setFitsTransform ( const std::string & );
00352
00356 virtual TransformBase * getTransform () const;
00357
00360 virtual TransformBase * getFitsTransform () const;
00361
00363 virtual void setAxisModel ( AxisModelBase * , Axes::Type ) = 0;
00364
00368 virtual void setAutoRanging ( const std::string & axis, bool flag );
00369
00374 virtual void setAutoRanging ( Axes::Type axis, bool flag );
00375
00378 virtual void setAutoRanging ( bool flag );
00379
00382 virtual void setReverse ( bool flag );
00383
00386 virtual void setShowGrid ( bool flag );
00387
00390 virtual void setBoxEdge (bool flag );
00391
00394 virtual bool getBoxEdge ();
00395
00398 virtual bool getShowGrid ();
00399
00404 virtual bool isAutoRanging ( Axes::Type axis ) const;
00405
00408 virtual bool isReverse () const;
00409
00410
00415 virtual void autoScale();
00416
00419 void setTitle( const std::string & title );
00420
00422 const std::string & getTitle() const;
00423
00432 virtual void setLabel ( const std::string & axis,
00433 const std::string & label );
00434
00438 virtual void setLabel ( Axes::Type, const std::string & value );
00439
00443 virtual const std::string & getLabel ( Axes::Type ) const;
00444
00445
00451 virtual const std::string &
00452 getInternalTitle ( ) const;
00453
00460 virtual const std::string &
00461 getInternalLabel ( Axes::Type axis ) const;
00462
00465 virtual void checkAxisScaling ();
00466
00470 virtual double getBinWidth (Axes::Type axis) const;
00471
00477 double getBinWidth ( const std::string & axis ) const;
00478
00481 virtual double getOffset (Axes::Type axis) const;
00482
00485 double getOffset ( const std::string & axis ) const;
00486
00489 virtual int getNumberOfEntries () const;
00490
00496 int getNumOfEntries () const;
00497
00501 virtual void setErrorDisplay ( Axes::Type axis, bool ) = 0;
00502
00504 virtual bool errorDisplay ( Axes::Type axis ) const = 0;
00505
00518 virtual void setRange ( Axes::Type axis, const Range & range,
00519 bool scaled = false, bool adjust_width = true );
00520
00525 void setRange ( const std::string & axis, double low, double high );
00526
00532 virtual const Range & getRange ( Axes::Type axis,
00533 bool scaled ) const;
00534
00536 virtual Range getDataRange ( Axes::Type axis );
00537
00539 virtual double getPosRange ( Axes::Type axis ) const;
00540
00544 virtual void setLowRange ( Axes::Type axis, int parm,
00545 bool dragging );
00546
00550 virtual void setHighRange ( Axes::Type axis, int parm,
00551 bool dragging );
00552
00554 virtual void setRepColor ( const Color & ) = 0;
00555
00557 virtual const Color & repColor () const = 0;
00558
00560 const Rect & getUserRect () const;
00561
00563 const Rect & getRawRect () const;
00564
00570 virtual NTuple * createPickTuple ();
00571
00577 virtual void fillPickedPointFrom ( double mx, double my,
00578 std::vector < double > & picked ) const;
00579
00586 virtual double getZValue ( double x, double y, bool scaled = true ) const;
00587
00591 virtual bool hasAxis ( Axes::Type axis ) const;
00592
00594 void setCrossX ( double val );
00595
00597 void setCrossY ( double val );
00598
00605 virtual void addValues ( const std::vector < double > & v );
00606
00614 virtual double getAspectRatio () const;
00615
00620 void setAspectRatio ( double ratio );
00621
00628 virtual NTuple * createNTuple () const = 0;
00629
00638 virtual bool wantsPixmap ( ) const;
00639
00641 virtual void setOffsets( double xoffset, double yoffset );
00642
00646 virtual void setEnableZ ( bool yes = true );
00647
00651 virtual void setAutoTicks ( Axes::Type axis, bool yes );
00652
00655 virtual void setTicks ( Axes::Type axis,
00656 const std::vector < AxisTick > & ticks );
00657
00660 virtual void setAutoTicks ( const std::string &, bool on );
00661
00669 virtual void setAutoTicksOnX ( bool yes );
00670
00678 virtual void setTicksOnX ( const std::vector < double > & values,
00679 const std::vector < std::string > & labels );
00680
00683 virtual void setTicks ( const std::string & axis,
00684 const std::vector < double > & values,
00685 const std::vector < std::string > & labels );
00686
00690 virtual double getLowRangeOnX ( ) const;
00691
00696 virtual double getHighRangeOnX () const;
00697
00703 virtual void matrixTranspose ( bool yes );
00704
00712 virtual bool isTargetable () const;
00713
00718 virtual DataRep * getTarget () const;
00719
00725 virtual int indexOf ( const DataRep * rep ) const;
00726
00734 void toggleActivePlot ();
00735
00737 virtual int plotterId () const;
00738
00745 int saveView ( const std::vector<double> & range_values );
00746
00747
00756 int saveViewAtIndex(const std::vector<double>& range_values,unsigned int i );
00757
00759 void setView ( int index );
00760
00766 int nextView (bool stepForward=true);
00767
00768
00770 int numViews () const;
00771
00773 void deleteView ( int index );
00774
00776 int currentView () const;
00777
00782 virtual void fillCutList ( std::vector < const TupleCut * > & cuts ) const;
00783
00788 virtual void setCutRangeAt ( const Range & range, unsigned int i );
00789
00792 virtual void setCurrentRangeSaved( bool flag );
00793
00796 virtual bool getCurrentRangeSaved( );
00797
00800 virtual const std::vector <double> & getZValues();
00801 virtual const std::vector <unsigned int> & getShape();
00802
00805 virtual void setMinEntries( int entries );
00806
00807
00810 virtual int getMinEntries ();
00811
00816 virtual FontBase* labelFont ( Axes::Type axes ) const;
00817
00822 virtual const FontBase * titleFont ( ) const;
00823
00830 virtual bool isImageConvertable () const;
00831
00833 virtual bool isTextPlotter() const;
00834
00835
00837 virtual void setTopMargin( double top );
00838 virtual void setBottomMargin( double bottom );
00839 virtual void setLeftMargin( double left );
00840 virtual void setZMargin( double z );
00841 virtual double getTopMargin();
00842 virtual double getBottomMargin();
00843 virtual double getLeftMargin();
00844 virtual double getZMargin();
00845
00848 virtual void setNeedUpdate(bool isChanged);
00849
00850 };
00851
00852 }
00853
00854 #endif // _PlotterBase_H_