1 | #ifndef __AXIS_H__
|
---|
2 | #define __AXIS_H__
|
---|
3 |
|
---|
4 | #include "qwt3d_autoptr.h"
|
---|
5 | #include "qwt3d_label.h"
|
---|
6 | #include "qwt3d_scale.h"
|
---|
7 | #include "qwt3d_autoscaler.h"
|
---|
8 |
|
---|
9 | namespace Qwt3D
|
---|
10 | {
|
---|
11 |
|
---|
12 | //! Autoscalable axis with caption.
|
---|
13 | /*!
|
---|
14 | Axes are highly customizable especially in terms
|
---|
15 | of labeling and scaling.
|
---|
16 | */
|
---|
17 | class QWT3D_EXPORT Axis : public Drawable
|
---|
18 | {
|
---|
19 |
|
---|
20 | public:
|
---|
21 |
|
---|
22 | Axis(); //!< Constructs standard axis
|
---|
23 | Axis(Qwt3D::Triple beg, Qwt3D::Triple end); //!< Constructs a new axis with specified limits
|
---|
24 | virtual ~Axis(); // dtor
|
---|
25 |
|
---|
26 | virtual void draw(); //!< Draws axis
|
---|
27 |
|
---|
28 | void setPosition(const Qwt3D::Triple& beg, const Qwt3D::Triple& end); //!< Positionate axis
|
---|
29 | void position(Qwt3D::Triple& beg, Qwt3D::Triple& end) const {beg = beg_; end = end_;} //!< Returns axis' position
|
---|
30 | Qwt3D::Triple begin() const { return beg_; } //!< Returns axis' beginning position
|
---|
31 | Qwt3D::Triple end() const { return end_; } //!< Returns axis' ending position
|
---|
32 | double length() const { return (end_-beg_).length(); } //!< Returns axis' length
|
---|
33 |
|
---|
34 | void setTicLength(double majorl, double minorl); //!< Sets tics lengths in world coordinates
|
---|
35 | //! Returns tics lengths
|
---|
36 | void ticLength(double& majorl, double& minorl) const {majorl = lmaj_; minorl = lmin_;}
|
---|
37 | void setTicOrientation(double tx, double ty, double tz); //!< Sets tic orientation
|
---|
38 | void setTicOrientation(const Qwt3D::Triple& val); //!< Same function as above
|
---|
39 | Qwt3D::Triple ticOrientation() const { return orientation_;} //!< Returns tic orientation
|
---|
40 | void setSymmetricTics( bool b) { symtics_ = b;} //!< Sets two-sided tics (default is false)
|
---|
41 |
|
---|
42 | //! Sets font for axis label
|
---|
43 | void setLabelFont(QString const& family, int pointSize, int weight = QFont::Normal, bool italic = false);
|
---|
44 | void setLabelFont(QFont const& font); //!< Sets font for axis label
|
---|
45 | QFont const& labelFont() const {return labelfont_;} //!< Returns current label font
|
---|
46 |
|
---|
47 | void setLabelString(QString const& name); //!< Sets label content
|
---|
48 | void setLabelPosition(const Qwt3D::Triple& pos, Qwt3D::ANCHOR);
|
---|
49 | void setLabelColor(Qwt3D::RGBA col);
|
---|
50 | void setLabel(bool d) {drawLabel_ = d;} //!< Turns label drawing on or off
|
---|
51 | void adjustLabel(int val) {labelgap_ = val;} //!< Shifts label in device coordinates dependent on anchor;
|
---|
52 |
|
---|
53 | void setScaling(bool d) {drawTics_ = d;} //!< Turns scale drawing on or off
|
---|
54 | bool scaling() const {return drawTics_;} //!< Returns, if scale drawing is on or off
|
---|
55 | void setScale(Qwt3D::SCALETYPE);
|
---|
56 | void setScale(Scale* item);
|
---|
57 | void setNumbers(bool d) {drawNumbers_ = d;} //!< Turns number drawing on or off
|
---|
58 | bool numbers() const {return drawNumbers_;} //!< Returns, if number drawing is on or off
|
---|
59 | void setNumberColor(Qwt3D::RGBA col); //!< Sets the color for axes numbers
|
---|
60 | Qwt3D::RGBA numberColor() const {return numbercolor_;} //!< Returns the color for axes numbers
|
---|
61 | //! Sets font for numbering
|
---|
62 | void setNumberFont(QString const& family, int pointSize, int weight = QFont::Normal, bool italic = false);
|
---|
63 | void setNumberFont(QFont const&); //!< Overloaded member, works like the above function
|
---|
64 | QFont const& numberFont() const {return numberfont_;} //!< Returns current numbering font
|
---|
65 | void setNumberAnchor(Qwt3D::ANCHOR a) { scaleNumberAnchor_ = a;} //!< Sets anchor position for numbers
|
---|
66 | void adjustNumbers(int val) {numbergap_ = val;} //!< Shifts axis numbers in device coordinates dependent on anchor;
|
---|
67 |
|
---|
68 | void setAutoScale(bool val = true) {autoscale_ = val;} //!< Turns Autoscaling on or off
|
---|
69 | bool autoScale() const { return autoscale_;} //!< actual Autoscaling mode
|
---|
70 |
|
---|
71 | void setMajors(int val); //!< Requests major intervals (maybe changed, if autoscaling is present)
|
---|
72 | void setMinors(int val); //!< Requests minor intervals
|
---|
73 | int majors() const { return majorintervals_; } //!< Returns number of major intervals
|
---|
74 | int minors() const { return minorintervals_; } //!< Returns number of minor intervals
|
---|
75 | Qwt3D::TripleField const& majorPositions() const {return majorpos_;} //!< Returns positions for actual major tics (also if invisible)
|
---|
76 | Qwt3D::TripleField const& minorPositions() const {return minorpos_;} //!< Returns positions for actual minor tics (also if invisible)
|
---|
77 |
|
---|
78 | //! Sets line width for axis components
|
---|
79 | void setLineWidth(double val, double majfac = 0.9, double minfac = 0.5);
|
---|
80 | double lineWidth() const { return lineWidth_;} //!< Returns line width for axis body
|
---|
81 | double majLineWidth() const { return majLineWidth_;} //!< Returns Line width for major tics
|
---|
82 | double minLineWidth() const { return minLineWidth_;} //!< Returns Line width for minor tics
|
---|
83 |
|
---|
84 | void setLimits(double start, double stop) {start_=start; stop_=stop;} //!< Sets interval
|
---|
85 | void limits(double& start, double& stop) const {start = start_; stop = stop_;} //!< Returns axis interval
|
---|
86 | void recalculateTics(); //!< Enforces recalculation of ticmark positions
|
---|
87 |
|
---|
88 |
|
---|
89 | private:
|
---|
90 |
|
---|
91 | void init();
|
---|
92 | void drawBase();
|
---|
93 | void drawTics();
|
---|
94 | void drawTicLabel(Qwt3D::Triple Pos, int mtic);
|
---|
95 | Qwt3D::Triple drawTic(Qwt3D::Triple nadir, double length);
|
---|
96 | void drawLabel();
|
---|
97 | bool prepTicCalculation(Triple& startpoint);
|
---|
98 |
|
---|
99 | Qwt3D::Triple biggestNumberString();
|
---|
100 |
|
---|
101 |
|
---|
102 | Qwt3D::ANCHOR scaleNumberAnchor_;
|
---|
103 | Qwt3D::Label label_;
|
---|
104 | std::vector<Qwt3D::Label> markerLabel_;
|
---|
105 |
|
---|
106 | Qwt3D::Triple beg_, end_;
|
---|
107 | Qwt3D::TripleField majorpos_, minorpos_; //! vectors, holding major resp. minor tic positions;
|
---|
108 |
|
---|
109 | Qwt3D::Triple ncube_beg_, ncube_end_; //!< enclosing parallelepiped for axis numbering
|
---|
110 |
|
---|
111 | double start_, stop_, autostart_, autostop_;
|
---|
112 | double lmaj_, lmin_;
|
---|
113 | Qwt3D::Triple orientation_;
|
---|
114 |
|
---|
115 | int majorintervals_, minorintervals_;
|
---|
116 |
|
---|
117 | double lineWidth_, majLineWidth_, minLineWidth_;
|
---|
118 | bool symtics_;
|
---|
119 | bool drawNumbers_, drawTics_, drawLabel_;
|
---|
120 | bool autoscale_;
|
---|
121 | QFont numberfont_, labelfont_;
|
---|
122 | Qwt3D::RGBA numbercolor_;
|
---|
123 |
|
---|
124 | int numbergap_, labelgap_;
|
---|
125 |
|
---|
126 | Qwt3D::qwt3d_ptr<Qwt3D::Scale> scale_;
|
---|
127 | };
|
---|
128 |
|
---|
129 | } // ns
|
---|
130 |
|
---|
131 | #endif
|
---|