Qwt User's Guide 6.2.0

qwt_scale_engine.h
1 /******************************************************************************
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
16 class QwtInterval;
17 class QwtTransform;
18
22 class QWT_EXPORT QwtScaleArithmetic
23 {
24 public:
25 static double ceilEps( double value, double intervalSize );
26 static double floorEps( double value, double intervalSize );
27
28 static double divideEps( double intervalSize, double numSteps );
29
30 static double divideInterval( double intervalSize,
31 int numSteps, uint base );
32 };
33
45 class QWT_EXPORT QwtScaleEngine
46 {
47 public:
54 enum Attribute
55 {
57 NoAttribute = 0x00,
58
60 IncludeReference = 0x01,
61
63 Symmetric = 0x02,
64
72 Floating = 0x04,
73
75 Inverted = 0x08
76 };
77
78 Q_DECLARE_FLAGS( Attributes, Attribute )
79
80 explicit QwtScaleEngine( uint base = 10 );
81 virtual ~QwtScaleEngine();
82
83 void setBase( uint base );
84 uint base() const;
85
86 void setAttribute( Attribute, bool on = true );
87 bool testAttribute( Attribute ) const;
88
89 void setAttributes( Attributes );
90 Attributes attributes() const;
91
92 void setReference( double );
93 double reference() const;
94
95 void setMargins( double lower, double upper );
96 double lowerMargin() const;
97 double upperMargin() const;
98
107 virtual void autoScale( int maxNumSteps,
108 double& x1, double& x2, double& stepSize ) const = 0;
109
122 virtual QwtScaleDiv divideScale( double x1, double x2,
123 int maxMajorSteps, int maxMinorSteps,
124 double stepSize = 0.0 ) const = 0;
125
126 void setTransformation( QwtTransform* );
127 QwtTransform* transformation() const;
128
129 protected:
130 bool contains( const QwtInterval&, double value ) const;
131 QList< double > strip( const QList< double >&, const QwtInterval& ) const;
132
133 double divideInterval( double intervalSize, int numSteps ) const;
134
135 QwtInterval buildInterval( double value ) const;
136
137 private:
138 Q_DISABLE_COPY(QwtScaleEngine)
139
140 class PrivateData;
141 PrivateData* m_data;
142 };
143
151 class QWT_EXPORT QwtLinearScaleEngine : public QwtScaleEngine
152 {
153 public:
154 explicit QwtLinearScaleEngine( uint base = 10 );
155 virtual ~QwtLinearScaleEngine();
156
157 virtual void autoScale( int maxNumSteps,
158 double& x1, double& x2, double& stepSize ) const QWT_OVERRIDE;
159
160 virtual QwtScaleDiv divideScale( double x1, double x2,
161 int maxMajorSteps, int maxMinorSteps,
162 double stepSize = 0.0 ) const QWT_OVERRIDE;
163
164
165 protected:
166 QwtInterval align( const QwtInterval&, double stepSize ) const;
167
168 void buildTicks(
169 const QwtInterval&, double stepSize, int maxMinorSteps,
170 QList< double > ticks[QwtScaleDiv::NTickTypes] ) const;
171
172 QList< double > buildMajorTicks(
173 const QwtInterval& interval, double stepSize ) const;
174
175 void buildMinorTicks( const QList< double >& majorTicks,
176 int maxMinorSteps, double stepSize,
177 QList< double >& minorTicks, QList< double >& mediumTicks ) const;
178 };
179
191 class QWT_EXPORT QwtLogScaleEngine : public QwtScaleEngine
192 {
193 public:
194 explicit QwtLogScaleEngine( uint base = 10 );
195 virtual ~QwtLogScaleEngine();
196
197 virtual void autoScale( int maxNumSteps,
198 double& x1, double& x2, double& stepSize ) const QWT_OVERRIDE;
199
200 virtual QwtScaleDiv divideScale( double x1, double x2,
201 int maxMajorSteps, int maxMinorSteps,
202 double stepSize = 0.0 ) const QWT_OVERRIDE;
203
204 protected:
205 QwtInterval align( const QwtInterval&, double stepSize ) const;
206
207 void buildTicks(
208 const QwtInterval&, double stepSize, int maxMinorSteps,
209 QList< double > ticks[QwtScaleDiv::NTickTypes] ) const;
210
211 QList< double > buildMajorTicks(
212 const QwtInterval& interval, double stepSize ) const;
213
214 void buildMinorTicks( const QList< double >& majorTicks,
215 int maxMinorSteps, double stepSize,
216 QList< double >& minorTicks, QList< double >& mediumTicks ) const;
217 };
218
219 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtScaleEngine::Attributes )
220
221 #endif
QList< double >
QwtInterval
A class representing an interval.
Definition: qwt_interval.h:23
QwtLinearScaleEngine
A scale engine for linear scales.
Definition: qwt_scale_engine.h:152
QwtLogScaleEngine
A scale engine for logarithmic scales.
Definition: qwt_scale_engine.h:192
QwtScaleArithmetic
Arithmetic including a tolerance.
Definition: qwt_scale_engine.h:23
QwtScaleDiv
A class representing a scale division.
Definition: qwt_scale_div.h:34
QwtScaleDiv::NTickTypes
@ NTickTypes
Number of valid tick types.
Definition: qwt_scale_div.h:52
QwtScaleEngine
Base class for scale engines.
Definition: qwt_scale_engine.h:46
QwtScaleEngine::Attributes
QFlags< Attribute > Attributes
Definition: qwt_scale_engine.h:78
QwtScaleEngine::Attribute
Attribute
Definition: qwt_scale_engine.h:55
QwtScaleEngine::autoScale
virtual void autoScale(int maxNumSteps, double &x1, double &x2, double &stepSize) const =0
QwtScaleEngine::divideScale
virtual QwtScaleDiv divideScale(double x1, double x2, int maxMajorSteps, int maxMinorSteps, double stepSize=0.0) const =0
Calculate a scale division.
QwtTransform
A transformation between coordinate systems.
Definition: qwt_transform.h:36