Qwt User's Guide 6.3.0
Loading...
Searching...
No Matches
qwt_scale_engine.h
1/******************************************************************************
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
16class QwtInterval;
17class QwtTransform;
18
22class 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 intervalSize, double numSteps );
29
30 static double divideInterval( double intervalSize,
31 int numSteps, uint base );
32};
33
45class QWT_EXPORT QwtScaleEngine
46{
47 public:
55 {
57 NoAttribute = 0x00,
58
60 IncludeReference = 0x01,
61
63 Symmetric = 0x02,
64
72 Floating = 0x04,
73
75 Inverted = 0x08
76 };
77
78 Q_DECLARE_FLAGS( Attributes, Attribute )
79
80 explicit QwtScaleEngine( uint base = 10 );
81 virtual ~QwtScaleEngine();
82
83 void setBase( uint base );
84 uint base() const;
85
86 void setAttribute( Attribute, bool on = true );
87 bool testAttribute( Attribute ) const;
88
89 void setAttributes( Attributes );
90 Attributes attributes() const;
91
92 void setReference( double );
93 double reference() const;
94
95 void setMargins( double lower, double upper );
96 double lowerMargin() const;
97 double upperMargin() const;
98
107 virtual void autoScale( int maxNumSteps,
108 double& x1, double& x2, double& stepSize ) const = 0;
109
122 virtual QwtScaleDiv divideScale( double x1, double x2,
123 int maxMajorSteps, int maxMinorSteps,
124 double stepSize = 0.0 ) const = 0;
125
126 void setTransformation( QwtTransform* );
127 QwtTransform* transformation() const;
128
129 protected:
130 bool contains( const QwtInterval&, double value ) const;
131 QList< double > strip( const QList< double >&, const QwtInterval& ) const;
132
133 double divideInterval( double intervalSize, int numSteps ) const;
134
135 QwtInterval buildInterval( double value ) const;
136
137 private:
138 Q_DISABLE_COPY(QwtScaleEngine)
139
140 class PrivateData;
141 PrivateData* m_data;
142};
143
151class QWT_EXPORT QwtLinearScaleEngine : public QwtScaleEngine
152{
153 public:
154 explicit QwtLinearScaleEngine( uint base = 10 );
155 virtual ~QwtLinearScaleEngine();
156
157 virtual void autoScale( int maxNumSteps,
158 double& x1, double& x2, double& stepSize ) const QWT_OVERRIDE;
159
160 virtual QwtScaleDiv divideScale( double x1, double x2,
161 int maxMajorSteps, int maxMinorSteps,
162 double stepSize = 0.0 ) const QWT_OVERRIDE;
163
164
165 protected:
166 QwtInterval align( const QwtInterval&, double stepSize ) const;
167
168 void buildTicks(
169 const QwtInterval&, double stepSize, int maxMinorSteps,
171
172 QList< double > buildMajorTicks(
173 const QwtInterval& interval, double stepSize ) const;
174
175 void buildMinorTicks( const QList< double >& majorTicks,
176 int maxMinorSteps, double stepSize,
177 QList< double >& minorTicks, QList< double >& mediumTicks ) const;
178};
179
191class QWT_EXPORT QwtLogScaleEngine : public QwtScaleEngine
192{
193 public:
194 explicit QwtLogScaleEngine( uint base = 10 );
195 virtual ~QwtLogScaleEngine();
196
197 virtual void autoScale( int maxNumSteps,
198 double& x1, double& x2, double& stepSize ) const QWT_OVERRIDE;
199
200 virtual QwtScaleDiv divideScale( double x1, double x2,
201 int maxMajorSteps, int maxMinorSteps,
202 double stepSize = 0.0 ) const QWT_OVERRIDE;
203
204 protected:
205 QwtInterval align( const QwtInterval&, double stepSize ) const;
206
207 void buildTicks(
208 const QwtInterval&, double stepSize, int maxMinorSteps,
210
211 QList< double > buildMajorTicks(
212 const QwtInterval& interval, double stepSize ) const;
213
214 void buildMinorTicks( const QList< double >& majorTicks,
215 int maxMinorSteps, double stepSize,
216 QList< double >& minorTicks, QList< double >& mediumTicks ) const;
217};
218
219Q_DECLARE_OPERATORS_FOR_FLAGS( QwtScaleEngine::Attributes )
220
221#endif
A class representing an interval.
A scale engine for linear scales.
A scale engine for logarithmic scales.
Arithmetic including a tolerance.
A class representing a scale division.
@ NTickTypes
Number of valid tick types.
Base class for scale engines.
QFlags< Attribute > Attributes
virtual void autoScale(int maxNumSteps, double &x1, double &x2, double &stepSize) const =0
virtual QwtScaleDiv divideScale(double x1, double x2, int maxMajorSteps, int maxMinorSteps, double stepSize=0.0) const =0
Calculate a scale division.
A transformation between coordinate systems.