Qwt User's Guide: qwt_scale_engine.h Source File

Qwt User's Guide 5.2.3

- 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_double_interval.h"
16
17 class QwtScaleTransformation;
18
22 class QWT_EXPORT QwtScaleArithmetic
23 {
24 public:
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
50 class QWT_EXPORT QwtScaleEngine
51 {
52 public:
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
102 virtual void autoScale(int maxNumSteps,
103 double &x1, double &x2, double &stepSize) const = 0;
104
115 virtual QwtScaleDiv divideScale(double x1, double x2,
116 int maxMajSteps, int maxMinSteps,
117 double stepSize = 0.0) const = 0;
118
120 virtual QwtScaleTransformation *transformation() const = 0;
121
122 protected:
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
129 private:
130 class PrivateData;
131 PrivateData *d_data;
132 };
133
141 class QWT_EXPORT QwtLinearScaleEngine: public QwtScaleEngine
142 {
143 public:
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
153 protected:
154 QwtDoubleInterval align(const QwtDoubleInterval&,
155 double stepSize) const;
156
157 private:
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
182 class QWT_EXPORT QwtLog10ScaleEngine: public QwtScaleEngine
183 {
184 public:
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
194 protected:
195 QwtDoubleInterval log10(const QwtDoubleInterval&) const;
196 QwtDoubleInterval pow10(const QwtDoubleInterval&) const;
197
198 private:
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