QWT 7.0.1
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 * Modified by ChenZongYan in 2024 <czy.t@163.com>
10 * Summary of major modifications (see ChangeLog.md for full history):
11 * 1. CMake build system & C++11 throughout.
12 * 2. Core panner/ zoomer refactored:
13 * - QwtPanner → QwtCachePanner (pixmap-cache version)
14 * - New real-time QwtPlotPanner derived from QwtPicker.
15 * 3. Zoomer supports multi-axis.
16 * 4. Parasite-plot framework:
17 * - QwtFigure, QwtPlotParasiteLayout, QwtPlotTransparentCanvas,
18 * - QwtPlotScaleEventDispatcher, built-in pan/zoom on axis.
19 * 5. New picker: QwtPlotSeriesDataPicker (works with date axis).
20 * 6. Raster & color-map extensions:
21 * - QwtGridRasterData (2-D table + interpolation)
22 * - QwtLinearColorMap::stopColors(), stopPos() API rename.
23 * 7. Bar-chart: expose pen/brush control.
24 * 8. Amalgamated build: single QwtPlot.h / QwtPlot.cpp pair in src-amalgamate.
25 *****************************************************************************/
26
27#ifndef QWT_SCALE_MAP_H
28#define QWT_SCALE_MAP_H
29
30#include "qwt_global.h"
31#include "qwt_transform.h"
32
33class QPointF;
34class QRectF;
35
43class QWT_EXPORT QwtScaleMap
44{
45public:
48 // 新增移动语义
50
52
53 QwtScaleMap& operator=(const QwtScaleMap&);
54 QwtScaleMap& operator=(QwtScaleMap&&);
55
56 void setTransformation(QwtTransform*);
57 const QwtTransform* transformation() const;
58
59 void setPaintInterval(double p1, double p2);
60 void setScaleInterval(double s1, double s2);
61
62 double transform(double s) const;
63 double invTransform(double p) const;
64
65 double p1() const;
66 double p2() const;
67
68 double s1() const;
69 double s2() const;
70
71 double pDist() const;
72 double sDist() const;
73
74 static QRectF transform(const QwtScaleMap&, const QwtScaleMap&, const QRectF&);
75
76 static QRectF invTransform(const QwtScaleMap&, const QwtScaleMap&, const QRectF&);
77
78 static QPointF transform(const QwtScaleMap&, const QwtScaleMap&, const QPointF&);
79
80 static QPointF invTransform(const QwtScaleMap&, const QwtScaleMap&, const QPointF&);
81
82 // 是否为线性坐标轴
83 static bool isLinerScale(const QwtScaleMap& sm);
84
85 bool isInverting() const;
86
87protected:
88 void swap(QwtScaleMap& other) noexcept; // 辅助
89private:
90 void updateFactor();
91
92 double m_s1, m_s2; // scale interval boundaries
93 double m_p1, m_p2; // paint device interval boundaries
94
95 double m_cnv; // conversion factor
96 double m_ts1;
97
98 QwtTransform* m_transform;
99};
100
104inline double QwtScaleMap::s1() const
105{
106 return m_s1;
107}
108
112inline double QwtScaleMap::s2() const
113{
114 return m_s2;
115}
116
120inline double QwtScaleMap::p1() const
121{
122 return m_p1;
123}
124
128inline double QwtScaleMap::p2() const
129{
130 return m_p2;
131}
132
136inline double QwtScaleMap::pDist() const
137{
138 return qAbs(m_p2 - m_p1);
139}
140
144inline double QwtScaleMap::sDist() const
145{
146 return qAbs(m_s2 - m_s1);
147}
148
158inline double QwtScaleMap::transform(double s) const
159{
160 if (m_transform)
161 s = m_transform->transform(s);
162
163 return m_p1 + (s - m_ts1) * m_cnv;
164}
165
175inline double QwtScaleMap::invTransform(double p) const
176{
177 double s = m_ts1 + (p - m_p1) / m_cnv;
178 if (m_transform)
179 s = m_transform->invTransform(s);
180
181 return s;
182}
183
185inline bool QwtScaleMap::isInverting() const
186{
187 return ((m_p1 < m_p2) != (m_s1 < m_s2));
188}
189
190#ifndef QT_NO_DEBUG_STREAM
191QWT_EXPORT QDebug operator<<(QDebug, const QwtScaleMap&);
192#endif
193
194#endif
A scale map.
Definition qwt_scale_map.h:44
bool isInverting() const
Definition qwt_scale_map.h:185
double pDist() const
Definition qwt_scale_map.h:136
double p1() const
Definition qwt_scale_map.h:120
double transform(double s) const
Transform a point related to the scale interval into an point related to the interval of the paint de...
Definition qwt_scale_map.h:158
double s1() const
Definition qwt_scale_map.h:104
double s2() const
Definition qwt_scale_map.h:112
double sDist() const
Definition qwt_scale_map.h:144
double invTransform(double p) const
Transform an paint device value into a value in the interval of the scale.
Definition qwt_scale_map.h:175
double p2() const
Definition qwt_scale_map.h:128
A transformation between coordinate systems.
Definition qwt_transform.h:53
virtual double transform(double value) const =0
Transformation function.
virtual double invTransform(double value) const =0
Inverse transformation function.