~l3on/ubuntu/oneiric/qwt/fix-921430

« back to all changes in this revision

Viewing changes to qwt-5.0.1/src/qwt_scale_engine.h

  • Committer: Bazaar Package Importer
  • Author(s): Fathi Boudra
  • Date: 2007-10-05 15:20:41 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071005152041-qmybqh4fj9jejyo2
Tags: 5.0.2-2
* Handle nostrip build option. (Closes: #437877)
* Build libqwt5-doc package in binary-indep target. (Closes: #443110)

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 
19
 
/*!
20
 
  \brief Arithmetic including a tolerance
21
 
*/
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
 
 
37
 
/*!
38
 
  \brief Base class for scale engines.
39
 
 
40
 
  A scale engine trys to find "reasonable" ranges and step sizes
41
 
  for scales. 
42
 
 
43
 
  The layout of the scale can be varied with setOptions().
44
 
 
45
 
  Qwt offers implementations for logarithmic (log10) 
46
 
  and linear scales. Contributions for other types of scale engines 
47
 
  (date/time, log2 ... ) are welcome.
48
 
*/
49
 
 
50
 
class QWT_EXPORT QwtScaleEngine
51
 
{
52
 
public:
53
 
    //! see QwtScaleEngine::setOption, testOption
54
 
    enum Attribute
55
 
    {
56
 
        NoAttribute = 0,
57
 
        IncludeReference = 1, 
58
 
        Symmetric = 2, 
59
 
        Floating = 4,
60
 
        Inverted = 8 
61
 
    };
62
 
 
63
 
    explicit QwtScaleEngine();
64
 
    virtual ~QwtScaleEngine();
65
 
 
66
 
    void setAttribute(Attribute, bool on = true);
67
 
    bool testAttribute(Attribute) const;
68
 
 
69
 
    void setAttributes(int);
70
 
    int attributes() const;
71
 
 
72
 
    void setReference(double reference);
73
 
    double reference() const;
74
 
 
75
 
    void setMargins(double m1, double m2);
76
 
    double loMargin() const;
77
 
    double hiMargin() const;
78
 
 
79
 
    /*!
80
 
      Align and divide an interval 
81
 
 
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)
86
 
    */  
87
 
    virtual void autoScale(int maxNumSteps, 
88
 
        double &x1, double &x2, double &stepSize) const = 0;
89
 
 
90
 
    /*!
91
 
      \brief Calculate a scale division
92
 
 
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
98
 
                   calculates one.
99
 
    */
100
 
    virtual QwtScaleDiv divideScale(double x1, double x2,
101
 
        int maxMajSteps, int maxMinSteps, 
102
 
        double stepSize = 0.0) const = 0;
103
 
 
104
 
    //! \return a transformation
105
 
    virtual QwtScaleTransformation *transformation() const = 0;
106
 
 
107
 
protected:
108
 
    bool contains(const QwtDoubleInterval &, double val) const;
109
 
    QwtValueList strip(const QwtValueList&, const QwtDoubleInterval &) const;
110
 
    double divideInterval(double interval, int numSteps) const;
111
 
 
112
 
    QwtDoubleInterval buildInterval(double v) const;
113
 
 
114
 
private:
115
 
    class PrivateData;
116
 
    PrivateData *d_data;
117
 
};
118
 
 
119
 
/*!
120
 
  \brief A scale engine for linear scales
121
 
 
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.
124
 
*/
125
 
 
126
 
class QWT_EXPORT QwtLinearScaleEngine: public QwtScaleEngine
127
 
{
128
 
public:
129
 
    virtual void autoScale(int maxSteps, 
130
 
        double &x1, double &x2, double &stepSize) const;
131
 
 
132
 
    virtual QwtScaleDiv divideScale(double x1, double x2,
133
 
        int numMajorSteps, int numMinorSteps,
134
 
        double stepSize = 0.0) const;
135
 
 
136
 
    virtual QwtScaleTransformation *transformation() const;
137
 
 
138
 
protected:
139
 
    QwtDoubleInterval align(const QwtDoubleInterval&,
140
 
        double stepSize) const;
141
 
 
142
 
private:
143
 
    void buildTicks(
144
 
        const QwtDoubleInterval &, double stepSize, int maxMinSteps,
145
 
        QwtValueList ticks[QwtScaleDiv::NTickTypes]) const;
146
 
 
147
 
    void buildMinorTicks(
148
 
        const QwtValueList& majorTicks,
149
 
        int maxMinMark, double step,
150
 
        QwtValueList &, QwtValueList &) const;
151
 
 
152
 
    QwtValueList buildMajorTicks(
153
 
        const QwtDoubleInterval &interval, double stepSize) const;
154
 
};
155
 
 
156
 
/*!
157
 
  \brief A scale engine for logarithmic (base 10) scales
158
 
 
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
162
 
  including zero.
163
 
 
164
 
  \warning the step size as well as the margins are measured in *decades*.
165
 
*/
166
 
 
167
 
class QWT_EXPORT QwtLog10ScaleEngine: public QwtScaleEngine
168
 
{
169
 
public:
170
 
    virtual void autoScale(int maxSteps, 
171
 
        double &x1, double &x2, double &stepSize) const;
172
 
 
173
 
    virtual QwtScaleDiv divideScale(double x1, double x2,
174
 
        int numMajorSteps, int numMinorSteps,
175
 
        double stepSize = 0.0) const;
176
 
 
177
 
    virtual QwtScaleTransformation *transformation() const;
178
 
 
179
 
protected:
180
 
    QwtDoubleInterval log10(const QwtDoubleInterval&) const;
181
 
    QwtDoubleInterval pow10(const QwtDoubleInterval&) const;
182
 
 
183
 
private:
184
 
    QwtDoubleInterval align(const QwtDoubleInterval&,
185
 
        double stepSize) const;
186
 
 
187
 
    void buildTicks(
188
 
        const QwtDoubleInterval &, double stepSize, int maxMinSteps,
189
 
        QwtValueList ticks[QwtScaleDiv::NTickTypes]) const;
190
 
 
191
 
    QwtValueList buildMinorTicks(
192
 
        const QwtValueList& majorTicks,
193
 
        int maxMinMark, double step) const;
194
 
 
195
 
    QwtValueList buildMajorTicks(
196
 
        const QwtDoubleInterval &interval, double stepSize) const;
197
 
};
198
 
 
199
 
#endif