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
16class QPointF;
17class QRectF;
18
26class QWT_EXPORT QwtScaleMap
27{
28 public:
30 QwtScaleMap( const QwtScaleMap& );
31
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
83inline double QwtScaleMap::s1() const
84{
85 return m_s1;
86}
87
91inline double QwtScaleMap::s2() const
92{
93 return m_s2;
94}
95
99inline double QwtScaleMap::p1() const
100{
101 return m_p1;
102}
103
107inline double QwtScaleMap::p2() const
108{
109 return m_p2;
110}
111
115inline double QwtScaleMap::pDist() const
116{
117 return qAbs( m_p2 - m_p1 );
118}
119
123inline double QwtScaleMap::sDist() const
124{
125 return qAbs( m_s2 - m_s1 );
126}
127
137inline 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
154inline 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
164inline 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
A scale map.
bool isInverting() const
double pDist() const
double p1() const
double transform(double s) const
double s1() const
double s2() const
double sDist() const
double invTransform(double p) const
double p2() const
A transformation between coordinate systems.
virtual double transform(double value) const =0
virtual double invTransform(double value) const =0