Qwt User's Guide 6.1.0

- Main Page
- Related Pages
- Classes

All Classes Functions Variables Typedefs Enumerations Enumerator Pages
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 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 interval, double steps );
29
30 static double divideInterval( double interval,
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
79 typedef QFlags<Attribute> Attributes;
80
81 explicit QwtScaleEngine( uint base = 10 );
82 virtual ~QwtScaleEngine();
83
84 void setBase( uint base );
85 uint base() const;
86
87 void setAttribute( Attribute, bool on = true );
88 bool testAttribute( Attribute ) const;
89
90 void setAttributes( Attributes );
91 Attributes attributes() const;
92
93 void setReference( double reference );
94 double reference() const;
95
96 void setMargins( double lower, double upper );
97 double lowerMargin() const;
98 double upperMargin() const;
99
108 virtual void autoScale( int maxNumSteps,
109 double &x1, double &x2, double &stepSize ) const = 0;
110
123 virtual QwtScaleDiv divideScale( double x1, double x2,
124 int maxMajorSteps, int maxMinorSteps,
125 double stepSize = 0.0 ) const = 0;
126
127 void setTransformation( QwtTransform * );
128 QwtTransform *transformation() const;
129
130 protected:
131 bool contains( const QwtInterval &, double val ) const;
132 QList<double> strip( const QList<double>&, const QwtInterval & ) const;
133
134 double divideInterval( double interval, int numSteps ) const;
135
136 QwtInterval buildInterval( double v ) const;
137
138 private:
139 class PrivateData;
140 PrivateData *d_data;
141 };
142
150 class QWT_EXPORT QwtLinearScaleEngine: public QwtScaleEngine
151 {
152 public:
153 QwtLinearScaleEngine( uint base = 10 );
154 virtual ~QwtLinearScaleEngine();
155
156 virtual void autoScale( int maxSteps,
157 double &x1, double &x2, double &stepSize ) const;
158
159 virtual QwtScaleDiv divideScale( double x1, double x2,
160 int numMajorSteps, int numMinorSteps,
161 double stepSize = 0.0 ) const;
162
163
164 protected:
165 QwtInterval align( const QwtInterval&, double stepSize ) const;
166
167 void buildTicks(
168 const QwtInterval &, double stepSize, int maxMinSteps,
169 QList<double> ticks[QwtScaleDiv::NTickTypes] ) const;
170
171 QList<double> buildMajorTicks(
172 const QwtInterval &interval, double stepSize ) const;
173
174 void buildMinorTicks( const QList<double>& majorTicks,
175 int maxMinorSteps, double stepSize,
176 QList<double> &minorTicks, QList<double> &mediumTicks ) const;
177 };
178
190 class QWT_EXPORT QwtLogScaleEngine: public QwtScaleEngine
191 {
192 public:
193 QwtLogScaleEngine( uint base = 10 );
194 virtual ~QwtLogScaleEngine();
195
196 virtual void autoScale( int maxSteps,
197 double &x1, double &x2, double &stepSize ) const;
198
199 virtual QwtScaleDiv divideScale( double x1, double x2,
200 int numMajorSteps, int numMinorSteps,
201 double stepSize = 0.0 ) const;
202
203 protected:
204 QwtInterval align( const QwtInterval&, double stepSize ) const;
205
206 void buildTicks(
207 const QwtInterval &, double stepSize, int maxMinSteps,
208 QList<double> ticks[QwtScaleDiv::NTickTypes] ) const;
209
210 QList<double> buildMajorTicks(
211 const QwtInterval &interval, double stepSize ) const;
212
213 void buildMinorTicks( const QList<double>& majorTicks,
214 int maxMinorSteps, double stepSize,
215 QList<double> &minorTicks, QList<double> &mediumTicks ) const;
216 };
217
218 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtScaleEngine::Attributes )
219
220 #endif