source: ntrip/trunk/BNC/qwt/qwt_scale_map.h@ 8127

Last change on this file since 8127 was 8127, checked in by stoecker, 7 years ago

update qwt and qwtpolar, many QT5 fixes (unfinished)

File size: 3.7 KB
Line 
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_MAP_H
11#define QWT_SCALE_MAP_H
12
13#include "qwt_global.h"
14#include "qwt_transform.h"
15#include <qrect.h>
16
17#ifndef QT_NO_DEBUG_STREAM
18#include <qdebug.h>
19#endif
20
21class QRectF;
22
23/*!
24 \brief A scale map
25
26 QwtScaleMap offers transformations from the coordinate system
27 of a scale into the linear coordinate system of a paint device
28 and vice versa.
29*/
30class QWT_EXPORT QwtScaleMap
31{
32public:
33 QwtScaleMap();
34 QwtScaleMap( const QwtScaleMap& );
35
36 ~QwtScaleMap();
37
38 QwtScaleMap &operator=( const QwtScaleMap & );
39
40 void setTransformation( QwtTransform * );
41 const QwtTransform *transformation() const;
42
43 void setPaintInterval( double p1, double p2 );
44 void setScaleInterval( double s1, double s2 );
45
46 double transform( double s ) const;
47 double invTransform( double p ) const;
48
49 double p1() const;
50 double p2() const;
51
52 double s1() const;
53 double s2() const;
54
55 double pDist() const;
56 double sDist() const;
57
58 static QRectF transform( const QwtScaleMap &,
59 const QwtScaleMap &, const QRectF & );
60 static QRectF invTransform( const QwtScaleMap &,
61 const QwtScaleMap &, const QRectF & );
62
63 static QPointF transform( const QwtScaleMap &,
64 const QwtScaleMap &, const QPointF & );
65 static QPointF invTransform( const QwtScaleMap &,
66 const QwtScaleMap &, const QPointF & );
67
68 bool isInverting() const;
69
70private:
71 void updateFactor();
72
73 double d_s1, d_s2; // scale interval boundaries
74 double d_p1, d_p2; // paint device interval boundaries
75
76 double d_cnv; // conversion factor
77 double d_ts1;
78
79 QwtTransform *d_transform;
80};
81
82/*!
83 \return First border of the scale interval
84*/
85inline double QwtScaleMap::s1() const
86{
87 return d_s1;
88}
89
90/*!
91 \return Second border of the scale interval
92*/
93inline double QwtScaleMap::s2() const
94{
95 return d_s2;
96}
97
98/*!
99 \return First border of the paint interval
100*/
101inline double QwtScaleMap::p1() const
102{
103 return d_p1;
104}
105
106/*!
107 \return Second border of the paint interval
108*/
109inline double QwtScaleMap::p2() const
110{
111 return d_p2;
112}
113
114/*!
115 \return qwtAbs(p2() - p1())
116*/
117inline double QwtScaleMap::pDist() const
118{
119 return qAbs( d_p2 - d_p1 );
120}
121
122/*!
123 \return qwtAbs(s2() - s1())
124*/
125inline double QwtScaleMap::sDist() const
126{
127 return qAbs( d_s2 - d_s1 );
128}
129
130/*!
131 Transform a point related to the scale interval into an point
132 related to the interval of the paint device
133
134 \param s Value relative to the coordinates of the scale
135 \return Transformed value
136
137 \sa invTransform()
138*/
139inline double QwtScaleMap::transform( double s ) const
140{
141 if ( d_transform )
142 s = d_transform->transform( s );
143
144 return d_p1 + ( s - d_ts1 ) * d_cnv;
145}
146
147/*!
148 Transform an paint device value into a value in the
149 interval of the scale.
150
151 \param p Value relative to the coordinates of the paint device
152 \return Transformed value
153
154 \sa transform()
155*/
156inline double QwtScaleMap::invTransform( double p ) const
157{
158 double s = d_ts1 + ( p - d_p1 ) / d_cnv;
159 if ( d_transform )
160 s = d_transform->invTransform( s );
161
162 return s;
163}
164
165//! \return True, when ( p1() < p2() ) != ( s1() < s2() )
166inline bool QwtScaleMap::isInverting() const
167{
168 return ( ( d_p1 < d_p2 ) != ( d_s1 < d_s2 ) );
169}
170
171#ifndef QT_NO_DEBUG_STREAM
172QWT_EXPORT QDebug operator<<( QDebug, const QwtScaleMap & );
173#endif
174
175#endif
Note: See TracBrowser for help on using the repository browser.