source: ntrip/trunk/BNC/qwt/qwt_scale_engine.h@ 10573

Last change on this file since 10573 was 9383, checked in by stoecker, 4 years ago

update to qwt verion 6.1.1 to fix build with newer Qt5

File size: 6.1 KB
RevLine 
[4271]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
[8127]17class QwtTransform;
[4271]18
19/*!
20 \brief Arithmetic including a tolerance
21*/
22class QWT_EXPORT QwtScaleArithmetic
23{
24public:
25 static double ceilEps( double value, double intervalSize );
26 static double floorEps( double value, double intervalSize );
27
[9383]28 static double divideEps( double intervalSize, double numSteps );
[4271]29
[9383]30 static double divideInterval( double intervalSize,
[8127]31 int numSteps, uint base );
[4271]32};
33
34/*!
35 \brief Base class for scale engines.
36
37 A scale engine tries to find "reasonable" ranges and step sizes
38 for scales.
39
40 The layout of the scale can be varied with setAttribute().
41
[9383]42 Qwt offers implementations for logarithmic and linear scales.
[4271]43*/
44
45class QWT_EXPORT QwtScaleEngine
46{
47public:
[9383]48 /*!
[4271]49 Layout attributes
50 \sa setAttribute(), testAttribute(), reference(),
51 lowerMargin(), upperMargin()
52 */
53
54 enum Attribute
55 {
56 //! No attributes
57 NoAttribute = 0x00,
58
59 //! Build a scale which includes the reference() value.
60 IncludeReference = 0x01,
61
62 //! Build a scale which is symmetric to the reference() value.
63 Symmetric = 0x02,
64
65 /*!
66 The endpoints of the scale are supposed to be equal the
[9383]67 outmost included values plus the specified margins
[4271]68 (see setMargins()).
69 If this attribute is *not* set, the endpoints of the scale will
70 be integer multiples of the step size.
71 */
72 Floating = 0x04,
73
74 //! Turn the scale upside down.
75 Inverted = 0x08
76 };
77
78 //! Layout attributes
79 typedef QFlags<Attribute> Attributes;
80
[8127]81 explicit QwtScaleEngine( uint base = 10 );
[4271]82 virtual ~QwtScaleEngine();
83
[8127]84 void setBase( uint base );
85 uint base() const;
86
[4271]87 void setAttribute( Attribute, bool on = true );
88 bool testAttribute( Attribute ) const;
89
90 void setAttributes( Attributes );
91 Attributes attributes() const;
92
[9383]93 void setReference( double );
[4271]94 double reference() const;
95
96 void setMargins( double lower, double upper );
97 double lowerMargin() const;
98 double upperMargin() const;
99
100 /*!
101 Align and divide an interval
102
103 \param maxNumSteps Max. number of steps
104 \param x1 First limit of the interval (In/Out)
105 \param x2 Second limit of the interval (In/Out)
106 \param stepSize Step size (Return value)
107 */
108 virtual void autoScale( int maxNumSteps,
109 double &x1, double &x2, double &stepSize ) const = 0;
110
111 /*!
112 \brief Calculate a scale division
113
114 \param x1 First interval limit
115 \param x2 Second interval limit
[8127]116 \param maxMajorSteps Maximum for the number of major steps
117 \param maxMinorSteps Maximum number of minor steps
[4271]118 \param stepSize Step size. If stepSize == 0.0, the scaleEngine
119 calculates one.
[8127]120
121 \return Calculated scale division
[4271]122 */
123 virtual QwtScaleDiv divideScale( double x1, double x2,
[8127]124 int maxMajorSteps, int maxMinorSteps,
[4271]125 double stepSize = 0.0 ) const = 0;
126
[8127]127 void setTransformation( QwtTransform * );
128 QwtTransform *transformation() const;
[4271]129
130protected:
[9383]131 bool contains( const QwtInterval &, double value ) const;
[4271]132 QList<double> strip( const QList<double>&, const QwtInterval & ) const;
[8127]133
[9383]134 double divideInterval( double intervalSize, int numSteps ) const;
[4271]135
[9383]136 QwtInterval buildInterval( double value ) const;
[4271]137
138private:
139 class PrivateData;
140 PrivateData *d_data;
141};
142
143/*!
144 \brief A scale engine for linear scales
145
146 The step size will fit into the pattern
147 \f$\left\{ 1,2,5\right\} \cdot 10^{n}\f$, where n is an integer.
148*/
149
150class QWT_EXPORT QwtLinearScaleEngine: public QwtScaleEngine
151{
152public:
[8127]153 QwtLinearScaleEngine( uint base = 10 );
154 virtual ~QwtLinearScaleEngine();
155
[9383]156 virtual void autoScale( int maxNumSteps,
[4271]157 double &x1, double &x2, double &stepSize ) const;
158
159 virtual QwtScaleDiv divideScale( double x1, double x2,
[9383]160 int maxMajorSteps, int maxMinorSteps,
161 double stepSize = 0.0 ) const;
[4271]162
163
164protected:
165 QwtInterval align( const QwtInterval&, double stepSize ) const;
166
167 void buildTicks(
[9383]168 const QwtInterval &, double stepSize, int maxMinorSteps,
[4271]169 QList<double> ticks[QwtScaleDiv::NTickTypes] ) const;
170
171 QList<double> buildMajorTicks(
172 const QwtInterval &interval, double stepSize ) const;
173
[8127]174 void buildMinorTicks( const QList<double>& majorTicks,
175 int maxMinorSteps, double stepSize,
176 QList<double> &minorTicks, QList<double> &mediumTicks ) const;
[4271]177};
178
179/*!
[8127]180 \brief A scale engine for logarithmic scales
[4271]181
182 The step size is measured in *decades*
183 and the major step size will be adjusted to fit the pattern
184 \f$\left\{ 1,2,3,5\right\} \cdot 10^{n}\f$, where n is a natural number
185 including zero.
186
187 \warning the step size as well as the margins are measured in *decades*.
188*/
189
[8127]190class QWT_EXPORT QwtLogScaleEngine: public QwtScaleEngine
[4271]191{
192public:
[8127]193 QwtLogScaleEngine( uint base = 10 );
194 virtual ~QwtLogScaleEngine();
195
[9383]196 virtual void autoScale( int maxNumSteps,
[4271]197 double &x1, double &x2, double &stepSize ) const;
198
199 virtual QwtScaleDiv divideScale( double x1, double x2,
[9383]200 int maxMajorSteps, int maxMinorSteps,
[4271]201 double stepSize = 0.0 ) const;
202
203protected:
204 QwtInterval align( const QwtInterval&, double stepSize ) const;
205
206 void buildTicks(
[9383]207 const QwtInterval &, double stepSize, int maxMinorSteps,
[4271]208 QList<double> ticks[QwtScaleDiv::NTickTypes] ) const;
209
210 QList<double> buildMajorTicks(
211 const QwtInterval &interval, double stepSize ) const;
212
[8127]213 void buildMinorTicks( const QList<double>& majorTicks,
214 int maxMinorSteps, double stepSize,
215 QList<double> &minorTicks, QList<double> &mediumTicks ) const;
[4271]216};
217
218Q_DECLARE_OPERATORS_FOR_FLAGS( QwtScaleEngine::Attributes )
219
220#endif
Note: See TracBrowser for help on using the repository browser.