[89] | 1 | #ifndef qwt3d_scale_h__2004_06_02_22_02_begin_guarded_code
|
---|
| 2 | #define qwt3d_scale_h__2004_06_02_22_02_begin_guarded_code
|
---|
| 3 |
|
---|
| 4 | #include <qstring.h>
|
---|
| 5 | #include "qwt3d_types.h"
|
---|
| 6 | #include "qwt3d_autoscaler.h"
|
---|
| 7 | #include "qwt3d_autoptr.h"
|
---|
| 8 |
|
---|
| 9 | namespace Qwt3D
|
---|
| 10 | {
|
---|
| 11 |
|
---|
| 12 | /*!
|
---|
| 13 | The class encapsulates non-visual scales.
|
---|
| 14 | She is utilized by Axis and also collaborates closely with AutoScaler.
|
---|
| 15 | A Scale allows control over all aspects of tic generation including
|
---|
| 16 | arbitrary transformations of tic values into corresponding strings.
|
---|
| 17 | The strings contain what eventually will be shown as tic labels.\n
|
---|
| 18 | Standard linear and logarithmic scales have been integrated yet into the Axis
|
---|
| 19 | interface. User-defined axes can be derived from Scale, LinearScale et al.
|
---|
| 20 | */
|
---|
| 21 | class QWT3D_EXPORT Scale
|
---|
| 22 | {
|
---|
| 23 | friend class Axis;
|
---|
| 24 | friend class qwt3d_ptr<Scale>;
|
---|
| 25 |
|
---|
| 26 | protected:
|
---|
| 27 | Scale();
|
---|
| 28 | virtual ~Scale(){}
|
---|
| 29 | virtual QString ticLabel(unsigned int idx) const;
|
---|
| 30 |
|
---|
| 31 | virtual void setLimits(double start, double stop);
|
---|
| 32 | virtual void setMajors(int val) {majorintervals_p=val;} //!< Sets number of major intervals
|
---|
| 33 | virtual void setMinors(int val) {minorintervals_p=val;} //!< Sets number of minor intervals per major interval
|
---|
| 34 | virtual void setMajorLimits(double start, double stop);
|
---|
| 35 |
|
---|
| 36 | int majors() const {return majorintervals_p;} //!< Returns major intervals
|
---|
| 37 | int minors() const {return minorintervals_p;} //!< Returns minor intervals
|
---|
| 38 |
|
---|
| 39 | //! Derived classes should return a new heap based object here.
|
---|
| 40 | virtual Scale* clone() const = 0;
|
---|
| 41 | //! This function should setup the 2 vectors for major and minor positions;
|
---|
| 42 | virtual void calculate() = 0;
|
---|
| 43 | virtual int autoscale(double& a, double& b, double start, double stop, int ivals);
|
---|
| 44 |
|
---|
| 45 | std::vector<double> majors_p, minors_p;
|
---|
| 46 | double start_p, stop_p;
|
---|
| 47 | int majorintervals_p, minorintervals_p;
|
---|
| 48 | double mstart_p, mstop_p;
|
---|
| 49 |
|
---|
| 50 | private:
|
---|
| 51 | void destroy() const {delete this;} //!< Used by qwt3d_ptr
|
---|
| 52 | };
|
---|
| 53 |
|
---|
| 54 | //! The standard (1:1) mapping class for axis numbering
|
---|
| 55 | class QWT3D_EXPORT LinearScale : public Scale
|
---|
| 56 | {
|
---|
| 57 | friend class Axis;
|
---|
| 58 | friend class qwt3d_ptr<Scale>;
|
---|
| 59 | protected:
|
---|
| 60 | int autoscale(double& a, double& b, double start, double stop, int ivals);
|
---|
| 61 | //! Returns a new heap based object utilized from qwt3d_ptr
|
---|
| 62 | Scale* clone() const {return new LinearScale(*this);}
|
---|
| 63 | void calculate();
|
---|
| 64 | LinearAutoScaler autoscaler_p;
|
---|
| 65 | };
|
---|
| 66 |
|
---|
| 67 | //! log10 scale
|
---|
| 68 | class QWT3D_EXPORT LogScale : public Scale
|
---|
| 69 | {
|
---|
| 70 | friend class Axis;
|
---|
| 71 | friend class qwt3d_ptr<Scale>;
|
---|
| 72 | protected:
|
---|
| 73 | QString ticLabel(unsigned int idx) const;
|
---|
| 74 | void setMinors(int val);
|
---|
| 75 | //! Standard ctor
|
---|
| 76 | LogScale();
|
---|
| 77 | //! Returns a new heap based object utilized from qwt3d_ptr
|
---|
| 78 | Scale* clone() const {return new LogScale;}
|
---|
| 79 | void calculate();
|
---|
| 80 | private:
|
---|
| 81 | void setupCounter(double& k, int& step);
|
---|
| 82 | };
|
---|
| 83 |
|
---|
| 84 | } // namespace Qwt3D
|
---|
| 85 |
|
---|
| 86 |
|
---|
| 87 | #endif /* include guarded */
|
---|