source: pacpusframework/branches/2.0-beta1/include/extlib/qwt-5.2.1/qwt_scale_engine.h@ 89

Last change on this file since 89 was 89, checked in by morasjul, 11 years ago

PACPUS 2.0 Beta deployed in new branch

Major changes:
-Add communication interface between components
-Add examples for communications interface (TestComponents)
-Move to Qt5 support

  • Property svn:executable set to *
File size: 6.3 KB
Line 
1/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *****************************************************************************/
9
10#ifndef QWT_SCALE_ENGINE_H
11#define QWT_SCALE_ENGINE_H
12
13#include "qwt_global.h"
14#include "qwt_scale_div.h"
15#include "qwt_double_interval.h"
16
17class QwtScaleTransformation;
18
19/*!
20 \brief Arithmetic including a tolerance
21*/
22class QWT_EXPORT QwtScaleArithmetic
23{
24public:
25 static int compareEps(
26 double value1, double value2, double intervalSize);
27
28 static double ceilEps(double value, double intervalSize);
29 static double floorEps(double value, double intervalSize);
30
31 static double divideEps(double interval, double steps);
32
33 static double ceil125(double x);
34 static double floor125(double x);
35};
36
37/*!
38 \brief Base class for scale engines.
39
40 A scale engine trys to find "reasonable" ranges and step sizes
41 for scales.
42
43 The layout of the scale can be varied with setAttribute().
44
45 Qwt offers implementations for logarithmic (log10)
46 and linear scales. Contributions for other types of scale engines
47 (date/time, log2 ... ) are welcome.
48*/
49
50class QWT_EXPORT QwtScaleEngine
51{
52public:
53 /*!
54 - IncludeReference\n
55 Build a scale which includes the reference() value.
56 - Symmetric\n
57 Build a scale which is symmetric to the reference() value.
58 - Floating\n
59 The endpoints of the scale are supposed to be equal the
60 outmost included values plus the specified margins (see setMargins()). If this attribute is *not* set, the endpoints of the scale will
61 be integer multiples of the step size.
62 - Inverted\n
63 Turn the scale upside down.
64
65 \sa setAttribute(), testAttribute(), reference(),
66 lowerMargin(), upperMargin()
67 */
68
69 enum Attribute
70 {
71 NoAttribute = 0,
72 IncludeReference = 1,
73 Symmetric = 2,
74 Floating = 4,
75 Inverted = 8
76 };
77
78 explicit QwtScaleEngine();
79 virtual ~QwtScaleEngine();
80
81 void setAttribute(Attribute, bool on = true);
82 bool testAttribute(Attribute) const;
83
84 void setAttributes(int);
85 int attributes() const;
86
87 void setReference(double reference);
88 double reference() const;
89
90 void setMargins(double lower, double upper);
91 double lowerMargin() const;
92 double upperMargin() const;
93
94 /*!
95 Align and divide an interval
96
97 \param maxNumSteps Max. number of steps
98 \param x1 First limit of the interval (In/Out)
99 \param x2 Second limit of the interval (In/Out)
100 \param stepSize Step size (Return value)
101 */
102 virtual void autoScale(int maxNumSteps,
103 double &x1, double &x2, double &stepSize) const = 0;
104
105 /*!
106 \brief Calculate a scale division
107
108 \param x1 First interval limit
109 \param x2 Second interval limit
110 \param maxMajSteps Maximum for the number of major steps
111 \param maxMinSteps Maximum number of minor steps
112 \param stepSize Step size. If stepSize == 0.0, the scaleEngine
113 calculates one.
114 */
115 virtual QwtScaleDiv divideScale(double x1, double x2,
116 int maxMajSteps, int maxMinSteps,
117 double stepSize = 0.0) const = 0;
118
119 //! \return a transformation
120 virtual QwtScaleTransformation *transformation() const = 0;
121
122protected:
123 bool contains(const QwtDoubleInterval &, double val) const;
124 QwtValueList strip(const QwtValueList&, const QwtDoubleInterval &) const;
125 double divideInterval(double interval, int numSteps) const;
126
127 QwtDoubleInterval buildInterval(double v) const;
128
129private:
130 class PrivateData;
131 PrivateData *d_data;
132};
133
134/*!
135 \brief A scale engine for linear scales
136
137 The step size will fit into the pattern
138 \f$\left\{ 1,2,5\right\} \cdot 10^{n}\f$, where n is an integer.
139*/
140
141class QWT_EXPORT QwtLinearScaleEngine: public QwtScaleEngine
142{
143public:
144 virtual void autoScale(int maxSteps,
145 double &x1, double &x2, double &stepSize) const;
146
147 virtual QwtScaleDiv divideScale(double x1, double x2,
148 int numMajorSteps, int numMinorSteps,
149 double stepSize = 0.0) const;
150
151 virtual QwtScaleTransformation *transformation() const;
152
153protected:
154 QwtDoubleInterval align(const QwtDoubleInterval&,
155 double stepSize) const;
156
157private:
158 void buildTicks(
159 const QwtDoubleInterval &, double stepSize, int maxMinSteps,
160 QwtValueList ticks[QwtScaleDiv::NTickTypes]) const;
161
162 void buildMinorTicks(
163 const QwtValueList& majorTicks,
164 int maxMinMark, double step,
165 QwtValueList &, QwtValueList &) const;
166
167 QwtValueList buildMajorTicks(
168 const QwtDoubleInterval &interval, double stepSize) const;
169};
170
171/*!
172 \brief A scale engine for logarithmic (base 10) scales
173
174 The step size is measured in *decades*
175 and the major step size will be adjusted to fit the pattern
176 \f$\left\{ 1,2,3,5\right\} \cdot 10^{n}\f$, where n is a natural number
177 including zero.
178
179 \warning the step size as well as the margins are measured in *decades*.
180*/
181
182class QWT_EXPORT QwtLog10ScaleEngine: public QwtScaleEngine
183{
184public:
185 virtual void autoScale(int maxSteps,
186 double &x1, double &x2, double &stepSize) const;
187
188 virtual QwtScaleDiv divideScale(double x1, double x2,
189 int numMajorSteps, int numMinorSteps,
190 double stepSize = 0.0) const;
191
192 virtual QwtScaleTransformation *transformation() const;
193
194protected:
195 QwtDoubleInterval log10(const QwtDoubleInterval&) const;
196 QwtDoubleInterval pow10(const QwtDoubleInterval&) const;
197
198private:
199 QwtDoubleInterval align(const QwtDoubleInterval&,
200 double stepSize) const;
201
202 void buildTicks(
203 const QwtDoubleInterval &, double stepSize, int maxMinSteps,
204 QwtValueList ticks[QwtScaleDiv::NTickTypes]) const;
205
206 QwtValueList buildMinorTicks(
207 const QwtValueList& majorTicks,
208 int maxMinMark, double step) const;
209
210 QwtValueList buildMajorTicks(
211 const QwtDoubleInterval &interval, double stepSize) const;
212};
213
214#endif
Note: See TracBrowser for help on using the repository browser.