PlotterBase.h
Go to the documentation of this file.
1 /* -*- mode: c++ -*- */
2 
14 #ifndef _PlotterBase_H_
15 #define _PlotterBase_H_
16 
17 #include "axes/AxesType.h"
18 #include "graphics/Rectangle.h"
19 
20 #include "pattern/Observable.h"
21 #include "pattern/Observer.h"
22 
23 namespace hippodraw {
24 
25 class AxisModelBase;
26 class AxisTick;
27 class BinToColor;
28 class Color;
29 class DataRep;
30 class NTuple;
31 class ProjectorBase;
32 class Range;
33 class RepBase;
34 class TupleCut;
35 class TransformBase;
36 class ViewBase;
37 class FontBase;
38 
56  public Observer, public Observable
57 {
58 
59 private:
60 
64  virtual void setScaling ( Axes::Type axis, bool on = true );
65 
66  void setPlotterId();
67 
68 protected:
69 
75 
78  std::string m_name;
79 
80  /* The three following fields (m_title, m_x_label, m_y_label) have
81  default values. The PlotterBase object gets them from the
82  ProjectorBase object, and the ProjectorBase object gets them
83  from the DataSource object. */
84 
86  std::string m_title;
87 
89  double m_crossX;
90 
92  double m_crossY;
93 
99 
103 
106 
109 
111  PlotterBase ();
112 
114  PlotterBase ( const std::string & name );
115 
117  PlotterBase ( const PlotterBase & plotter );
118 
120  bool hasAutoScaled () const;
121 
122 
125 
129 
133  std::vector< std::vector<double> > m_views;
134 
137 
139  static int s_plotters;
140 
141 public:
142 
145  virtual ~PlotterBase();
146 
149  virtual PlotterBase * clone() = 0;
150 
152  const std::string & name () const;
153 
157  virtual void setScaleFactor ( Axes::Type axis, double factor );
158 
161  virtual bool isAxisScaled ( Axes::Type axis ) const;
162 
166  virtual void update ( const Observable * );
167 
172  virtual void update () = 0;
173 
177  virtual bool hasNTupleBindings () const = 0;
178 
179 
183  virtual bool hasZoomY () const ;
184 
190  virtual void setBinWidth ( Axes::Type axis, double width );
191 
198  virtual void setBinWidth ( const std::string & axis, double width );
199 
203  virtual void setBinWidth ( Axes::Type axis,
204  int parameter, bool dragging );
205 
210  virtual void setOffset ( Axes::Type axis, double offset );
211 
218  virtual void setOffset ( const std::string & axis, double offset );
219 
225  virtual void setNumberOfBins ( const std::string & axis,
226  unsigned int number );
227 
233  virtual void setNumberOfBins ( Axes::Type axis,
234  unsigned int number );
235 
240  virtual AxisModelBase * getAxisModel ( Axes::Type axis ) const;
241 
245  virtual void addDataRep ( DataRep * rep );
246 
248  virtual void setActivePlot ( int index, bool redraw );
249 
252  virtual int activePlotIndex ( ) const;
253 
256  virtual int getParentDataRepIndex ( ) const;
257 
259  virtual void setParentDataRepIndex ( int index );
260 
262  virtual PlotterBase* getParentPlotter ( ) const;
263 
265  virtual void setParentPlotter( PlotterBase* plotter );
266 
268  virtual void reset ( );
269 
272  virtual ProjectorBase * activeProjector () const;
273 
277  virtual DataRep * selectedDataRep () const;
278 
283  virtual ProjectorBase * getProjector (int i) const;
284 
287  virtual int getNumDataReps() const;
288 
290  virtual DataRep * getDataRep ( int index ) const;
291 
297  virtual void removeDataRep ( DataRep * );
298 
304  virtual void prepareToDraw ();
305 
308  virtual void drawIn ( ViewBase * view ) = 0;
309 
314  virtual void drawCrossHairs ( ViewBase * view );
315 
324  virtual void setRepresentation ( RepBase * pointrep ) = 0;
325 
327  virtual RepBase * representation ( ) const = 0;
328 
334  virtual const BinToColor * getValueRep () const;
335 
339  virtual void setValueRep ( BinToColor * rep );
340 
350  virtual void setTransform ( TransformBase * );
351 
355  virtual void setFitsTransform ( const std::string & );
356 
360  virtual TransformBase * getTransform () const;
361 
364  virtual TransformBase * getFitsTransform () const;
365 
367  virtual void setAxisModel ( AxisModelBase * , Axes::Type ) = 0;
368 
372  virtual void setAutoRanging ( const std::string & axis, bool flag );
373 
378  virtual void setAutoRanging ( Axes::Type axis, bool flag );
379 
382  virtual void setAutoRanging ( bool flag );
383 
386  virtual void setReverse ( bool flag );
387 
390  virtual void setShowGrid ( bool flag );
391 
394  virtual void setBoxEdge (bool flag );
395 
398  virtual bool getBoxEdge ();
399 
402  virtual bool getShowGrid ();
403 
408  virtual bool isAutoRanging ( Axes::Type axis ) const;
409 
412  virtual bool isReverse () const;
413 
414 
419  virtual void autoScale();
420 
423  void setTitle( const std::string & title );
424 
426  const std::string & getTitle() const;
427 
436  virtual void setLabel ( const std::string & axis,
437  const std::string & label );
438 
442  virtual void setLabel ( Axes::Type, const std::string & value );
443 
447  virtual const std::string & getLabel ( Axes::Type ) const;
448 
449 
455  virtual const std::string &
456  getInternalTitle ( ) const;
457 
464  virtual const std::string &
465  getInternalLabel ( Axes::Type axis ) const;
466 
469  virtual void checkAxisScaling ();
470 
474  virtual double getBinWidth (Axes::Type axis) const;
475 
481  double getBinWidth ( const std::string & axis ) const;
482 
485  virtual double getOffset (Axes::Type axis) const;
486 
489  double getOffset ( const std::string & axis ) const;
490 
493  virtual int getNumberOfEntries () const;
494 
500  int getNumOfEntries () const;
501 
505  virtual void setErrorDisplay ( Axes::Type axis, bool ) = 0;
506 
508  virtual bool errorDisplay ( Axes::Type axis ) const = 0;
509 
522  virtual void setRange ( Axes::Type axis, const Range & range,
523  bool scaled = false, bool adjust_width = true );
524 
529  void setRange ( const std::string & axis, double low, double high );
530 
536  virtual const Range & getRange ( Axes::Type axis,
537  bool scaled ) const;
538 
540  virtual Range getDataRange ( Axes::Type axis );
541 
543  virtual double getPosRange ( Axes::Type axis ) const;
544 
548  virtual void setLowRange ( Axes::Type axis, int parm,
549  bool dragging );
550 
554  virtual void setHighRange ( Axes::Type axis, int parm,
555  bool dragging );
556 
558  virtual void setRepColor ( const Color & ) = 0;
559 
561  virtual const Color & repColor () const = 0;
562 
564  const Rect & getUserRect () const;
565 
567  const Rect & getRawRect () const;
568 
574  virtual NTuple * createPickTuple ();
575 
581  virtual void fillPickedPointFrom ( double mx, double my,
582  std::vector < double > & picked ) const;
583 
590  virtual double getZValue ( double x, double y, bool scaled = true ) const;
591 
595  virtual bool hasAxis ( Axes::Type axis ) const;
596 
598  void setCrossX ( double val );
599 
601  void setCrossY ( double val );
602 
609  virtual void addValues ( const std::vector < double > & v );
610 
618  virtual double getAspectRatio () const;
619 
624  void setAspectRatio ( double ratio );
625 
632  virtual NTuple * createNTuple () const = 0;
633 
642  virtual bool wantsPixmap ( ) const;
643 
645  virtual void setOffsets( double xoffset, double yoffset );
646 
650  virtual void setEnableZ ( bool yes = true );
651 
655  virtual void setAutoTicks ( Axes::Type axis, bool yes );
656 
659  virtual void setTicks ( Axes::Type axis,
660  const std::vector < AxisTick > & ticks );
661 
664  virtual void setAutoTicks ( const std::string &, bool on );
665 
673  virtual void setAutoTicksOnX ( bool yes );
674 
682  virtual void setTicksOnX ( const std::vector < double > & values,
683  const std::vector < std::string > & labels );
684 
687  virtual void setTicks ( const std::string & axis,
688  const std::vector < double > & values,
689  const std::vector < std::string > & labels );
690 
694  virtual double getLowRangeOnX ( ) const;
695 
700  virtual double getHighRangeOnX () const;
701 
707  virtual void matrixTranspose ( bool yes );
708 
716  virtual bool isTargetable () const;
717 
722  virtual DataRep * getTarget () const;
723 
729  virtual int indexOf ( const DataRep * rep ) const;
730 
738  void toggleActivePlot ();
739 
741  virtual int plotterId () const;
742 
749  int saveView ( const std::vector<double> & range_values );
750 
751 
760  int saveViewAtIndex(const std::vector<double>& range_values,unsigned int i );
761 
763  void setView ( int index );
764 
770  int nextView (bool stepForward=true);
771 
772 
774  int numViews () const;
775 
777  void deleteView ( int index );
778 
780  int currentView () const;
781 
786  virtual void fillCutList ( std::vector < const TupleCut * > & cuts ) const;
787 
792  virtual void setCutRangeAt ( const Range & range, unsigned int i );
793 
796  virtual void setCurrentRangeSaved( bool flag );
797 
800  virtual bool getCurrentRangeSaved( );
801 
804  virtual const std::vector <double> & getZValues();
805  virtual const std::vector <unsigned int> & getShape();
806 
809  virtual void setMinEntries( int entries );
810 
811 
814  virtual int getMinEntries ();
815 
820  virtual FontBase* labelFont ( Axes::Type axes ) const;
821 
826  virtual const FontBase * titleFont ( ) const;
827 
834  virtual bool isImageConvertable () const;
835 
837  virtual bool isTextPlotter() const;
838 
839 
841  virtual void setTopMargin( double top );
842  virtual void setBottomMargin( double bottom );
843  virtual void setLeftMargin( double left );
844  virtual void setZMargin( double z );
845  virtual double getTopMargin();
846  virtual double getBottomMargin();
847  virtual double getLeftMargin();
848  virtual double getZMargin();
849 
852  virtual void setNeedUpdate(bool isChanged);
853 
856  virtual double getScaleFactor ( Axes::Type axis ) const;
857 
858 };
859 
860 } // namespace hippodraw
861 
862 #endif // _PlotterBase_H_

Generated for HippoDraw Class Library by doxygen