Qwt User's Guide 6.3.0

Loading...
Searching...
No Matches
qwt_scale_map.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_MAP_H
11#define QWT_SCALE_MAP_H
12
13#include "qwt_global.h"
14#include "qwt_transform.h"
15
16 class QPointF;
17 class QRectF;
18
26 class QWT_EXPORT QwtScaleMap
27{
28 public:
29 QwtScaleMap();
30 QwtScaleMap( const QwtScaleMap& );
31
32 ~QwtScaleMap();
33
34 QwtScaleMap& operator=( const QwtScaleMap& );
35
36 void setTransformation( QwtTransform* );
37 const QwtTransform* transformation() const;
38
39 void setPaintInterval( double p1, double p2 );
40 void setScaleInterval( double s1, double s2 );
41
42 double transform( double s ) const;
43 double invTransform( double p ) const;
44
45 double p1() const;
46 double p2() const;
47
48 double s1() const;
49 double s2() const;
50
51 double pDist() const;
52 double sDist() const;
53
54 static QRectF transform( const QwtScaleMap&,
55 const QwtScaleMap&, const QRectF& );
56
57 static QRectF invTransform( const QwtScaleMap&,
58 const QwtScaleMap&, const QRectF& );
59
60 static QPointF transform( const QwtScaleMap&,
61 const QwtScaleMap&, const QPointF& );
62
63 static QPointF invTransform( const QwtScaleMap&,
64 const QwtScaleMap&, const QPointF& );
65
66 bool isInverting() const;
67
68 private:
69 void updateFactor();
70
71 double m_s1, m_s2; // scale interval boundaries
72 double m_p1, m_p2; // paint device interval boundaries
73
74 double m_cnv; // conversion factor
75 double m_ts1;
76
77 QwtTransform* m_transform;
78};
79
83 inline double QwtScaleMap::s1() const
84{
85 return m_s1;
86}
87
91 inline double QwtScaleMap::s2() const
92{
93 return m_s2;
94}
95
99 inline double QwtScaleMap::p1() const
100{
101 return m_p1;
102}
103
107 inline double QwtScaleMap::p2() const
108{
109 return m_p2;
110}
111
115 inline double QwtScaleMap::pDist() const
116{
117 return qAbs( m_p2 - m_p1 );
118}
119
123 inline double QwtScaleMap::sDist() const
124{
125 return qAbs( m_s2 - m_s1 );
126}
127
137 inline double QwtScaleMap::transform( double s ) const
138{
139 if ( m_transform )
140 s = m_transform->transform( s );
141
142 return m_p1 + ( s - m_ts1 ) * m_cnv;
143}
144
154 inline double QwtScaleMap::invTransform( double p ) const
155{
156 double s = m_ts1 + ( p - m_p1 ) / m_cnv;
157 if ( m_transform )
158 s = m_transform->invTransform( s );
159
160 return s;
161}
162
164 inline bool QwtScaleMap::isInverting() const
165{
166 return ( ( m_p1 < m_p2 ) != ( m_s1 < m_s2 ) );
167}
168
169#ifndef QT_NO_DEBUG_STREAM
170QWT_EXPORT QDebug operator<<( QDebug, const QwtScaleMap& );
171#endif
172
173#endif
QwtScaleMap
A scale map.
Definition qwt_scale_map.h:27
QwtScaleMap::isInverting
bool isInverting() const
Definition qwt_scale_map.h:164
QwtScaleMap::pDist
double pDist() const
Definition qwt_scale_map.h:115
QwtScaleMap::p1
double p1() const
Definition qwt_scale_map.h:99
QwtScaleMap::transform
double transform(double s) const
Definition qwt_scale_map.h:137
QwtScaleMap::s1
double s1() const
Definition qwt_scale_map.h:83
QwtScaleMap::s2
double s2() const
Definition qwt_scale_map.h:91
QwtScaleMap::sDist
double sDist() const
Definition qwt_scale_map.h:123
QwtScaleMap::invTransform
double invTransform(double p) const
Definition qwt_scale_map.h:154
QwtScaleMap::p2
double p2() const
Definition qwt_scale_map.h:107
QwtTransform
A transformation between coordinate systems.
Definition qwt_transform.h:36
QwtTransform::transform
virtual double transform(double value) const =0
QwtTransform::invTransform
virtual double invTransform(double value) const =0