00001 // -*- mode:c++ -*- 00002 00018 class AxisModelBase; 00019 class RepBase; 00020 class ViewBase; 00021 00022 class PlotterBase : Observer, Observable 00023 { 00024 %TypeHeaderCode 00025 #include "plotters/PlotterBase.h" 00026 %End 00027 00028 00029 public: 00032 virtual ~PlotterBase(); 00033 00036 const std::string & name () const; 00037 00038 PlotterBase ( const std::string & ); 00039 virtual PlotterBase * clone () = 0; 00040 00045 virtual void update () = 0; 00046 00050 virtual void update ( const Observable * ); 00051 00054 virtual void setTitle ( const std::string & ); 00055 00057 const std::string & getTitle() const; 00058 00067 void setLabel ( const std::string &, const std::string & ); 00068 00069 // /** Sets the label of the specified @a axis to @a value. The 00070 // implementation in this base class does nothing. 00071 // */ 00072 // virtual void setLabel ( hippodraw::Axes::Type, const std::string & ); 00073 00074 // /** Returns the label for the specified axis. The implementation in 00075 // this base class returns an empty string. 00076 // */ 00077 // virtual const std::string & getLabel ( hippodraw::Axes::Type ) const; 00078 00079 // /** Returns the internal label. The internal label is either the 00080 // string set y a client, or one of @em %x, @em %y, or @em %z for 00081 // the corresponding axis. The implementation in this base class 00082 // returns an empty string. 00083 // */ 00084 // virtual const std::string & 00085 // getInternalLabel ( hippodraw::Axes::Type ) const; 00086 00087 // /** Sets the display of the error bars on or off. 00088 // @todo Remove this function when no longer in use. 00089 // */ 00090 // virtual void setErrorDisplay ( hippodraw::Axes::Type , bool ) = 0; 00091 00092 // /** Returns the state of error bar display on specified @a axis. */ 00093 // virtual bool errorDisplay ( hippodraw::Axes::Type ) const = 0; 00094 00095 // /** @brief Sets the range on the specified axis. 00096 00097 // Sets the Range on the axis @a axis to @a range. The 00098 // TransformBase object contained by this object may ajust the 00099 // range to fall within its limits. If @a scaled is @c true, then 00100 // the Range object's value is a scaled range, otherwise it is the 00101 // true range. if @a adjust_width is @c true, the bin width, if 00102 // applicable, is adjusts so one has the same number of bins after 00103 // the range is set, otherwise, the bin width is not changed. The 00104 // implementation in this base class does nothing. 00105 00106 // @bug Setting an range to 0, 100M on plot with empty NTuple causes 00107 // unknown exception. Probably calculating too many bins. 00108 00109 // */ 00110 // virtual void setRange ( hippodraw::Axes::Type , const Range & , 00111 // bool = false, bool = true ); 00112 00117 void setRange ( const std::string &, double, double ); 00118 00119 // /** Returns the range on the specified axis. Returns the range of 00120 // the data being plotted on the axis @a axis. If @a scaled is @c 00121 // true, uses the scaled range. @sa AxisModelBase::getRange. The 00122 // implemenation in this base class returns an empty Range. 00123 // */ 00124 // virtual const Range & getRange ( hippodraw::Axes::Type , bool ) const; 00125 00126 // /** Returns the smallest positive number from the data. */ 00127 // virtual double getPosRange ( hippodraw::Axes::Type ) const; 00128 00129 // /** Sets the low end of the Range of data displayed. The 00130 // implementation in this base class does nothing. 00131 // */ 00132 // virtual void setLowRange ( hippodraw::Axes::Type , int , bool ); 00133 00134 // /** Sets the high end of the Range of data displayed. The 00135 // implementation is this base class does nothing. 00136 // */ 00137 // virtual void setHighRange ( hippodraw::Axes::Type , int , bool ); 00138 00139 00145 virtual void setNumberOfBins ( const std::string &, unsigned int ); 00146 00147 // /** Sets the number of bins. Sets the number of bins of the 00148 // contained ProjectorBase objects to @a number along the axis @a 00149 // axis. The implementation in this class does nothing. @sa 00150 // ProbjectorBase::setNumberOfBins. 00151 // */ 00152 // virtual void setNumberOfBins ( hippodraw::Axes::Type axis, 00153 // unsigned int ); 00154 00155 00156 // /** Sets the offset. Sets the edges of the bins to be offset from 00157 // its current value by the amount @a offset along the axis @a 00158 // axis. The implementation in this class does nothing. 00159 // */ 00160 // virtual void setOffset ( hippodraw::Axes::Type , double ); 00161 00168 virtual void setOffset ( const std::string & , double ); 00169 00170 virtual void setOffset ( const std::string, double ); 00171 00172 virtual void setOffsets ( double, double ); 00173 00182 virtual bool wantsPixmap ( ) const; 00183 00184 00187 virtual double getLowRangeOnX ( ); 00192 virtual double getHighRangeOnX ( ); 00193 00199 virtual void matrixTranspose ( bool ); 00200 00201 00202 // /** Sets the bin width. Sets the bin width of the contained 00203 // ProjectorBase objects to @a width along axis @a axis. The 00204 // implementation in this class does nothing. The @sa 00205 // PrjectorBase::setBinWidth. 00206 // */ 00207 // virtual void setBinWidth ( hippodraw::Axes::Type , double ); 00208 00215 virtual void setBinWidth ( const std::string &, double ); 00216 00222 virtual double getBinWidth ( const std::string & ); 00223 00224 // /** Returns the bin width. The implementation in the base class 00225 // does nothing. It is declared as a convenience to the developer 00226 // since bin width is a common attribute. */ 00227 // virtual double getBinWidth (hippodraw::Axes::Type ) const; 00228 00229 // /** Returns the offset on designated axis, similarly to 00230 // getBinWidth. */ 00231 // virtual double getOffset (hippodraw::Axes::Type ) const; 00232 00235 double getOffset ( const std::string & ) const; 00236 00237 // /** Returns the number of entries in the contained DataRep. 00238 // */ 00239 // virtual int getNumOfEntries () const; 00240 00246 int getNumOfEntries () const; 00247 00248 00251 virtual void checkAxisScaling (); 00252 00256 virtual void setAutoRanging ( const std::string &, bool ); 00257 00258 // /** Sets the auto-ranging. Sets auto-ranging status for the @a axis 00259 // to @a flag and auto-ranges all axis which has that status 00260 // set. The implementation in this base class does nothing. 00261 // */ 00262 // virtual void setAutoRanging ( hippodraw::Axes::Type , bool ); 00263 00266 virtual void setAutoRanging ( bool ); 00267 00268 00273 virtual void addValues ( const std::vector < double > & ) = 0; 00274 00277 virtual int getNumDataReps () const = 0; 00279 virtual DataRep * getDataRep ( int ) = 0; 00280 00286 virtual void removeDataRep ( DataRep * ); 00287 00290 virtual void drawIn ( ViewBase * ) = 0; 00291 00296 virtual void drawCrossHairs ( ViewBase * ); 00297 00304 virtual NTuple * createNTuple () const = 0 /Factory/; 00305 00309 virtual void setEnableZ ( bool = true ); 00310 00311 // /** Sets automatic generation of axis ticks. This base class does 00312 // nothing. Derived classes may interpret this function. 00313 // */ 00314 // virtual void setAutoTicks ( hippodraw::Axes::Type , bool ); 00315 00316 // /** Sets the ticks for the specified axis. 00317 // */ 00318 // virtual void setTicks ( hippodraw::Axes::Type , 00319 // const std::vector < AxisTick > & ); 00320 00323 virtual void setAutoTicks ( const std::string &, bool ); 00324 00332 virtual void setAutoTicksOnX ( bool ); 00333 00341 virtual void setTicksOnX ( const std::vector < double > &, 00342 const std::vector < std::string > & ); 00343 00346 virtual void setTicks ( const std::string & , 00347 const std::vector < double > & , 00348 const std::vector < std::string > & ); 00349 00350 virtual void setNumberOfBins ( const std::string, unsigned int ); 00351 00352 00360 virtual double getAspectRatio () const; 00361 00366 void setAspectRatio ( double ); 00367 00368 // /** Returns the AxisModelBase derived class for the specified @a 00369 // axis. The implementation in this base class returns a null 00370 // pointer. 00371 // */ 00372 // virtual AxisModelBase * getAxisModel ( hippodraw::Axes::Type ) const; 00373 00377 virtual void addDataRep ( DataRep * ); 00378 00379 00381 virtual void setActivePlot ( int , bool ); 00382 00385 virtual int activePlotIndex ( ) const; 00386 00389 virtual int getParentDataRepIndex ( ) const; 00390 00392 virtual void setParentDataRepIndex ( int ); 00393 00395 virtual PlotterBase* getParentPlotter ( ) const; 00396 00398 virtual void setParentPlotter( PlotterBase* ); 00399 00401 virtual void reset ( ); 00402 00403 // /** Returns the active projector. That is, the one that should 00404 // receive commands to it. */ 00405 // virtual ProjectorBase * activeProjector () const; 00406 00410 virtual DataRep * selectedDataRep () const; 00411 00412 // /** Returns the projector at index @a i. 00413 00414 // @todo Remove this method when no longer used. 00415 // */ 00416 // virtual ProjectorBase * getProjector (int ) const; 00417 00418 // /** Returns the value to color represenatation. If the Z value is 00419 // represented graphically, then return the object that controls 00420 // the binary value to graphic attribute. This base class 00421 // implementation returns a null pointer. 00422 // */ 00423 // virtual const BinToColor * getValueRep () const; 00424 00425 // /** Sets the object that will do the value to color transform, if 00426 // any. The implemenation is this base class does nothing. 00427 // */ 00428 // virtual void setValueRep ( BinToColor * ); 00429 00430 // /** Sets the transform object. A copy of the transform object is 00431 // made by calling TransformBase#clone(), and the previous 00432 // transform object is deleted. By doing it this way, a controller 00433 // in an application does not need to keep track of how many 00434 // references to a particular transform object are active. Derived 00435 // classes may override this function in order to check if the 00436 // concrete type of transform object is one appropriate for them. 00437 // @sa #m_transform. The implementation in this base class does 00438 // nothing. 00439 // */ 00440 // virtual void setTransform ( TransformBase * ); 00441 00442 // /** Returns the transform object used by the plotter. @sa 00443 // #m_transform. The implementation in this base class returns a 00444 // null pointer. 00445 // */ 00446 // virtual TransformBase * getTransform () const; 00447 00448 // /** Sets the AxisModel on the specified axis. */ 00449 // virtual void setAxisModel ( AxisModelBase * , hippodraw::Axes::Type ) = 0; 00450 00451 // /** Returns @c true if auto-ranging is enabled, otherwise returns @c 00452 // false. The implemenation in this base class always returns 00453 // false. 00454 // */ 00455 // virtual bool isAutoRanging ( hippodraw::Axes::Type ) const; 00456 00461 virtual void autoScale(); 00462 00463 // /** Returns the data space rectangle. */ 00464 // const HippoRectangle & getUserRect () const; 00465 00466 // /** Returns the margin space where drawing takes place. */ 00467 // HippoRectangle getMarginRect () const; 00468 00474 virtual void marginToUserXY ( double , double , bool , 00475 double & , double & ) const = 0; 00476 00482 virtual NTuple * createPickTuple () /Factory/; 00483 00489 virtual void fillPickedPoint ( double , double , 00490 std::vector < double > & ) const; 00491 00493 virtual float userToMarginColor ( double ) const; 00494 00501 virtual double getZValue ( double , double , bool = true ) const; 00502 00503 // /** Returns @c true if the plotter has an axis of specified type. 00504 // The implementation in this base class always returns #c false. 00505 // */ 00506 // virtual bool hasAxis ( hippodraw::Axes::Type ) const; 00507 00509 void setCrossX ( double ); 00510 00512 void setCrossY ( double ); 00513 00521 virtual bool isTargetable () const; 00522 00527 virtual DataRep * getTarget () const; 00528 00534 virtual int indexOf ( const DataRep * ) const; 00535 00543 void toggleActivePlot (); 00544 00546 virtual int plotterId () const; 00547 00548 00549 00550 // private to hide from Doxygen 00551 private: 00552 // Declare the pure virtual functions to keep SIP happy 00553 00557 virtual bool hasNTupleBindings () const = 0; 00558 00563 virtual void setRepresentation ( RepBase * ) = 0; 00564 00566 virtual RepBase * representation ( ) const = 0; 00567 00569 virtual void setRepColor ( const Color & ) = 0; 00570 00572 virtual const Color & repColor () const = 0; 00573 00575 virtual float userToMarginX ( double ) const = 0; 00576 00578 virtual float userToMarginY ( double ) const = 0; 00579 00582 virtual float userToInvertedMarginY ( double ) const = 0; 00583 00584 virtual bool hasZAxis() const = 0; 00585 00586 };