QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_plot_rescaler.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_PLOT_RESCALER_H
28#define QWT_PLOT_RESCALER_H
29
30#include "qwt_global.h"
31#include "qwt_plot.h"
32
33#include <qobject.h>
34
35class QwtPlot;
36class QwtInterval;
37class QResizeEvent;
38
46class QWT_EXPORT QwtPlotRescaler : public QObject
47{
48 Q_OBJECT
49
50public:
59 {
67
77
83 Fitting
84 };
85
93 {
96
99
101 ExpandBoth
102 };
103
104 // Constructs a rescaler for the given canvas with specified reference axis and policy
105 explicit QwtPlotRescaler(QWidget* canvas, QwtAxisId referenceAxis = QwtAxis::XBottom, RescalePolicy = Expanding);
106
107 // Destructs the rescaler
108 ~QwtPlotRescaler() override;
109
110 // Enable or disable the rescaler
111 void setEnabled(bool);
112 // Check if the rescaler is enabled
113 bool isEnabled() const;
114
115 // Set the rescale policy
116 void setRescalePolicy(RescalePolicy);
117 // Get the rescale policy
118 RescalePolicy rescalePolicy() const;
119
120 // Set the expanding direction for all axes
121 void setExpandingDirection(ExpandingDirection);
122 // Set the expanding direction for a specific axis
123 void setExpandingDirection(QwtAxisId, ExpandingDirection);
124 // Get the expanding direction for a specific axis
125 ExpandingDirection expandingDirection(QwtAxisId) const;
126
127 // Set the reference axis
128 void setReferenceAxis(QwtAxisId);
129 // Get the reference axis
130 QwtAxisId referenceAxis() const;
131
132 // Set the aspect ratio for all axes
133 void setAspectRatio(double ratio);
134 // Set the aspect ratio for a specific axis
135 void setAspectRatio(QwtAxisId, double ratio);
136 // Get the aspect ratio for a specific axis
137 double aspectRatio(QwtAxisId) const;
138
139 // Set the interval hint for a specific axis
140 void setIntervalHint(QwtAxisId, const QwtInterval&);
141 // Get the interval hint for a specific axis
142 QwtInterval intervalHint(QwtAxisId) const;
143
144 // Get the canvas widget
145 QWidget* canvas();
146 // Get the canvas widget (const version)
147 const QWidget* canvas() const;
148
149 // Get the plot widget
150 QwtPlot* plot();
151 // Get the plot widget (const version)
152 const QwtPlot* plot() const;
153
154 // Event filter for the plot canvas
155 virtual bool eventFilter(QObject*, QEvent*) override;
156
157 // Rescale the plot axes
158 void rescale() const;
159
160protected:
161 // Handle canvas resize events
162 virtual void canvasResizeEvent(QResizeEvent*);
163
164 // Rescale the axes with old and new sizes
165 virtual void rescale(const QSize& oldSize, const QSize& newSize) const;
166 // Expand a scale interval
167 virtual QwtInterval expandScale(QwtAxisId, const QSize& oldSize, const QSize& newSize) const;
168
169 // Sync a scale to the reference axis
170 virtual QwtInterval syncScale(QwtAxisId, const QwtInterval& reference, const QSize& size) const;
171
172 // Update the axes scales
173 virtual void updateScales(QwtInterval intervals[ QwtAxis::AxisPositions ]) const;
174
175 // Get the orientation of an axis
176 Qt::Orientation orientation(QwtAxisId) const;
177 // Get the normalized interval of an axis
178 QwtInterval interval(QwtAxisId) const;
179 // Expand an interval by the specified width
180 QwtInterval expandInterval(const QwtInterval&, double width, ExpandingDirection) const;
181
182private:
183 // Calculate the pixel distance for an axis
184 double pixelDist(QwtAxisId, const QSize&) const;
185
186 class AxisData;
187 QWT_DECLARE_PRIVATE(QwtPlotRescaler)
188};
189
190#endif
A class representing an interval
Definition qwt_interval.h:39
QwtPlotRescaler takes care of fixed aspect ratios for plot scales
Definition qwt_plot_rescaler.h:47
ExpandingDirection
Expanding directions
Definition qwt_plot_rescaler.h:93
@ ExpandUp
The upper limit of the scale is adjusted
Definition qwt_plot_rescaler.h:95
@ ExpandDown
The lower limit of the scale is adjusted
Definition qwt_plot_rescaler.h:98
RescalePolicy
Rescale policies
Definition qwt_plot_rescaler.h:59
@ Fixed
Definition qwt_plot_rescaler.h:66
@ Expanding
Definition qwt_plot_rescaler.h:76
A 2-D plotting widget
Definition qwt_plot.h:99
@ XBottom
X axis below the canvas
Definition qwt_axis.h:51