Qwt User's Guide 6.0.2

- Main Page
- Related Pages
- Classes

qwt_scale_engine.h
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_interval.h"
16
17 class QwtScaleTransformation;
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 interval, double steps );
29
30 static double ceil125( double x );
31 static double floor125( double x );
32 };
33
47 class QWT_EXPORT QwtScaleEngine
48 {
49 public:
56 enum Attribute
57 {
59 NoAttribute = 0x00,
60
62 IncludeReference = 0x01,
63
65 Symmetric = 0x02,
66
74 Floating = 0x04,
75
77 Inverted = 0x08
78 };
79
81 typedef QFlags<Attribute> Attributes;
82
83 explicit QwtScaleEngine();
84 virtual ~QwtScaleEngine();
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 reference );
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
120 virtual QwtScaleDiv divideScale( double x1, double x2,
121 int maxMajSteps, int maxMinSteps,
122 double stepSize = 0.0 ) const = 0;
123
125 virtual QwtScaleTransformation *transformation() const = 0;
126
127 protected:
128 bool contains( const QwtInterval &, double val ) const;
129 QList<double> strip( const QList<double>&, const QwtInterval & ) const;
130 double divideInterval( double interval, int numSteps ) const;
131
132 QwtInterval buildInterval( double v ) const;
133
134 private:
135 class PrivateData;
136 PrivateData *d_data;
137 };
138
146 class QWT_EXPORT QwtLinearScaleEngine: public QwtScaleEngine
147 {
148 public:
149 virtual void autoScale( int maxSteps,
150 double &x1, double &x2, double &stepSize ) const;
151
152 virtual QwtScaleDiv divideScale( double x1, double x2,
153 int numMajorSteps, int numMinorSteps,
154 double stepSize = 0.0 ) const;
155
156 virtual QwtScaleTransformation *transformation() const;
157
158 protected:
159 QwtInterval align( const QwtInterval&, double stepSize ) const;
160
161 void buildTicks(
162 const QwtInterval &, double stepSize, int maxMinSteps,
163 QList<double> ticks[QwtScaleDiv::NTickTypes] ) const;
164
165 QList<double> buildMajorTicks(
166 const QwtInterval &interval, double stepSize ) const;
167
168 void buildMinorTicks(
169 const QList<double>& majorTicks,
170 int maxMinMark, double step,
171 QList<double> &, QList<double> & ) const;
172 };
173
185 class QWT_EXPORT QwtLog10ScaleEngine: public QwtScaleEngine
186 {
187 public:
188 virtual void autoScale( int maxSteps,
189 double &x1, double &x2, double &stepSize ) const;
190
191 virtual QwtScaleDiv divideScale( double x1, double x2,
192 int numMajorSteps, int numMinorSteps,
193 double stepSize = 0.0 ) const;
194
195 virtual QwtScaleTransformation *transformation() const;
196
197 protected:
198 QwtInterval log10( const QwtInterval& ) const;
199 QwtInterval pow10( const QwtInterval& ) const;
200
201 QwtInterval align( const QwtInterval&, double stepSize ) const;
202
203 void buildTicks(
204 const QwtInterval &, double stepSize, int maxMinSteps,
205 QList<double> ticks[QwtScaleDiv::NTickTypes] ) const;
206
207 QList<double> buildMajorTicks(
208 const QwtInterval &interval, double stepSize ) const;
209
210 QList<double> buildMinorTicks(
211 const QList<double>& majorTicks,
212 int maxMinMark, double step ) const;
213 };
214
215 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtScaleEngine::Attributes )
216
217 #endif