QWT API (中文) 7.0.1
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
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
51class QWT_EXPORT QwtScaleMap
52{
53public:
60
63
65 QwtScaleMap& operator=(const QwtScaleMap&);
67 QwtScaleMap& operator=(QwtScaleMap&&);
68
70 void setTransformation(QwtTransform*);
72 const QwtTransform* transformation() const;
73
75 void setPaintInterval(double p1, double p2);
77 void setScaleInterval(double s1, double s2);
78
80 double transform(double s) const;
82 double invTransform(double p) const;
83
85 double p1() const;
87 double p2() const;
88
90 double s1() const;
92 double s2() const;
93
95 double pDist() const;
97 double sDist() const;
98
100 static QRectF transform(const QwtScaleMap&, const QwtScaleMap&, const QRectF&);
101
103 static QRectF invTransform(const QwtScaleMap&, const QwtScaleMap&, const QRectF&);
104
106 static QPointF transform(const QwtScaleMap&, const QwtScaleMap&, const QPointF&);
107
109 static QPointF invTransform(const QwtScaleMap&, const QwtScaleMap&, const QPointF&);
110
112 static bool isLinerScale(const QwtScaleMap& sm);
113
115 bool isInverting() const;
116
117protected:
118 void swap(QwtScaleMap& other) noexcept; // 辅助
119private:
120 void updateFactor();
121
122 double m_s1, m_s2; // scale interval boundaries
123 double m_p1, m_p2; // paint device interval boundaries
124
125 double m_cnv; // conversion factor
126 double m_ts1;
127
128 QwtTransform* m_transform;
129};
130
139inline double QwtScaleMap::s1() const
140{
141 return m_s1;
142}
143
152inline double QwtScaleMap::s2() const
153{
154 return m_s2;
155}
156
165inline double QwtScaleMap::p1() const
166{
167 return m_p1;
168}
169
178inline double QwtScaleMap::p2() const
179{
180 return m_p2;
181}
182
191inline double QwtScaleMap::pDist() const
192{
193 return qAbs(m_p2 - m_p1);
194}
195
204inline double QwtScaleMap::sDist() const
205{
206 return qAbs(m_s2 - m_s1);
207}
208
223inline double QwtScaleMap::transform(double s) const
224{
225 if (m_transform)
226 s = m_transform->transform(s);
227
228 return m_p1 + (s - m_ts1) * m_cnv;
229}
230
245inline double QwtScaleMap::invTransform(double p) const
246{
247 double s = m_ts1 + (p - m_p1) / m_cnv;
248 if (m_transform)
249 s = m_transform->invTransform(s);
250
251 return s;
252}
253
255inline bool QwtScaleMap::isInverting() const
256{
257 return ((m_p1 < m_p2) != (m_s1 < m_s2));
258}
259
260#ifndef QT_NO_DEBUG_STREAM
261QWT_EXPORT QDebug operator<<(QDebug, const QwtScaleMap&);
262#endif
263
264#endif
刻度映射
Definition qwt_scale_map.h:52
bool isInverting() const
Check if the mapping direction is inverted
Definition qwt_scale_map.h:255
double pDist() const
Return distance between paint interval boundaries
Definition qwt_scale_map.h:191
double p1() const
Return first border of paint interval
Definition qwt_scale_map.h:165
double transform(double s) const
Transform a scale value to paint device coordinate
Definition qwt_scale_map.h:223
double s1() const
Return first border of scale interval
Definition qwt_scale_map.h:139
double s2() const
Return second border of scale interval
Definition qwt_scale_map.h:152
double sDist() const
Return distance between scale interval boundaries
Definition qwt_scale_map.h:204
double invTransform(double p) const
Transform a paint device coordinate to scale value
Definition qwt_scale_map.h:245
double p2() const
Return second border of paint interval
Definition qwt_scale_map.h:178
坐标系之间的变换
Definition qwt_transform.h:61
virtual double transform(double value) const =0
Transformation function
virtual double invTransform(double value) const =0
Inverse transformation function