1
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
3
* Copyright (C) 1997 Josef Wilgen
4
* Copyright (C) 2002 Uwe Rathmann
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
*****************************************************************************/
10
#ifndef QWT_SCALE_ENGINE_H
11
#define QWT_SCALE_ENGINE_H
13
#include "qwt_global.h"
14
#include "qwt_scale_div.h"
15
#include "qwt_double_interval.h"
17
class QwtScaleTransformation;
20
\brief Arithmetic including a tolerance
22
class QWT_EXPORT QwtScaleArithmetic
25
static int compareEps(
26
double value1, double value2, double intervalSize);
28
static double ceilEps(double value, double intervalSize);
29
static double floorEps(double value, double intervalSize);
31
static double divideEps(double interval, double steps);
33
static double ceil125(double x);
34
static double floor125(double x);
38
\brief Base class for scale engines.
40
A scale engine trys to find "reasonable" ranges and step sizes
43
The layout of the scale can be varied with setOptions().
45
Qwt offers implementations for logarithmic (log10)
46
and linear scales. Contributions for other types of scale engines
47
(date/time, log2 ... ) are welcome.
50
class QWT_EXPORT QwtScaleEngine
53
//! see QwtScaleEngine::setOption, testOption
63
explicit QwtScaleEngine();
64
virtual ~QwtScaleEngine();
66
void setAttribute(Attribute, bool on = true);
67
bool testAttribute(Attribute) const;
69
void setAttributes(int);
70
int attributes() const;
72
void setReference(double reference);
73
double reference() const;
75
void setMargins(double m1, double m2);
76
double loMargin() const;
77
double hiMargin() const;
80
Align and divide an interval
82
\param maxNumSteps Max. number of steps
83
\param x1 First limit of the interval (In/Out)
84
\param x2 Second limit of the interval (In/Out)
85
\param stepSize Step size (Return value)
87
virtual void autoScale(int maxNumSteps,
88
double &x1, double &x2, double &stepSize) const = 0;
91
\brief Calculate a scale division
93
\param x1 First interval limit
94
\param x2 Second interval limit
95
\param maxMajSteps Maximum for the number of major steps
96
\param maxMinSteps Maximum number of minor steps
97
\param stepSize Step size. If stepSize == 0.0, the scaleEngine
100
virtual QwtScaleDiv divideScale(double x1, double x2,
101
int maxMajSteps, int maxMinSteps,
102
double stepSize = 0.0) const = 0;
104
//! \return a transformation
105
virtual QwtScaleTransformation *transformation() const = 0;
108
bool contains(const QwtDoubleInterval &, double val) const;
109
QwtValueList strip(const QwtValueList&, const QwtDoubleInterval &) const;
110
double divideInterval(double interval, int numSteps) const;
112
QwtDoubleInterval buildInterval(double v) const;
120
\brief A scale engine for linear scales
122
The step size will fit into the pattern
123
\f$\left\{ 1,2,5\right\} \cdot 10^{n}\f$, where n is an integer.
126
class QWT_EXPORT QwtLinearScaleEngine: public QwtScaleEngine
129
virtual void autoScale(int maxSteps,
130
double &x1, double &x2, double &stepSize) const;
132
virtual QwtScaleDiv divideScale(double x1, double x2,
133
int numMajorSteps, int numMinorSteps,
134
double stepSize = 0.0) const;
136
virtual QwtScaleTransformation *transformation() const;
139
QwtDoubleInterval align(const QwtDoubleInterval&,
140
double stepSize) const;
144
const QwtDoubleInterval &, double stepSize, int maxMinSteps,
145
QwtValueList ticks[QwtScaleDiv::NTickTypes]) const;
147
void buildMinorTicks(
148
const QwtValueList& majorTicks,
149
int maxMinMark, double step,
150
QwtValueList &, QwtValueList &) const;
152
QwtValueList buildMajorTicks(
153
const QwtDoubleInterval &interval, double stepSize) const;
157
\brief A scale engine for logarithmic (base 10) scales
159
The step size is measured in *decades*
160
and the major step size will be adjusted to fit the pattern
161
\f$\left\{ 1,2,3,5\right\} \cdot 10^{n}\f$, where n is a natural number
164
\warning the step size as well as the margins are measured in *decades*.
167
class QWT_EXPORT QwtLog10ScaleEngine: public QwtScaleEngine
170
virtual void autoScale(int maxSteps,
171
double &x1, double &x2, double &stepSize) const;
173
virtual QwtScaleDiv divideScale(double x1, double x2,
174
int numMajorSteps, int numMinorSteps,
175
double stepSize = 0.0) const;
177
virtual QwtScaleTransformation *transformation() const;
180
QwtDoubleInterval log10(const QwtDoubleInterval&) const;
181
QwtDoubleInterval pow10(const QwtDoubleInterval&) const;
184
QwtDoubleInterval align(const QwtDoubleInterval&,
185
double stepSize) const;
188
const QwtDoubleInterval &, double stepSize, int maxMinSteps,
189
QwtValueList ticks[QwtScaleDiv::NTickTypes]) const;
191
QwtValueList buildMinorTicks(
192
const QwtValueList& majorTicks,
193
int maxMinMark, double step) const;
195
QwtValueList buildMajorTicks(
196
const QwtDoubleInterval &interval, double stepSize) const;