QWT API (中文) 7.0.1
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_plot_canvas_zoomer.h
1/******************************************************************************
2 * Qwt Widget Library
3 * Copyright (C) 2024 ChenZongYan <czy.t@163.com>
4 *****************************************************************************/
5#ifndef QWT_PLOT_CANVAS_ZOOMER_H
6#define QWT_PLOT_CANVAS_ZOOMER_H
7#include "qwt_global.h"
8#include "qwt_canvas_picker.h"
9#include "qwt_axis_id.h"
10#include "qwt_interval.h"
11#include <QPointer>
12// Qt
13class QSizeF;
14template< typename T >
15class QStack;
16// Qwt
17class QwtPlot;
18
28struct QWT_EXPORT QwtPlotCanvasZoomState
29{
30public:
31 // Default constructor
33
34 // Constructor with plot and axis intervals
36 const QwtInterval& yLeft,
37 const QwtInterval& yRight,
38 const QwtInterval& xBottom,
39 const QwtInterval& xTop);
40
41 // Create zoom state from current plot axis ranges
42 static QwtPlotCanvasZoomState fromPlot(QwtPlot* plot);
43
44 // Apply this zoom state to the associated plot
45 void apply() const;
46
47 // Check if two zoom states are equal
48 bool operator==(const QwtPlotCanvasZoomState& other) const;
49
50 // Check if two zoom states are not equal
51 bool operator!=(const QwtPlotCanvasZoomState& other) const;
52
53 // Check if this zoom state is valid (has an associated plot)
54 bool isValid() const;
55
56public:
57 QPointer< QwtPlot > plot;
58 QwtInterval axisInterval[ QwtAxis::AxisPositions ];
59};
60Q_DECLARE_METATYPE(QwtPlotCanvasZoomState)
61
62
113class QWT_EXPORT QwtPlotCanvasZoomer : public QwtCanvasPicker
114{
115 Q_OBJECT
116 QWT_DECLARE_PRIVATE(QwtPlotCanvasZoomer)
117public:
118 // Constructor
119 explicit QwtPlotCanvasZoomer(QWidget* canvas, bool doReplot = true);
120
121 // Destructor
122 virtual ~QwtPlotCanvasZoomer();
123
124 // Set zoom base to current axis ranges, min zoom size is calculated based on this
125 virtual void setZoomBase(bool doReplot = true);
126
127 // Enable or disable automatic replot after zoom operations
128 void setAutoReplot(bool on = true);
129
130 // Check if automatic replot is enabled
131 bool isAutoReplot() const;
132
133 // Get the base zoom state (initial unzoomed state)
134 QList< QwtPlotCanvasZoomState > zoomBase() const;
135
136 // Get the current zoom state
137 QList< QwtPlotCanvasZoomState > zoomState() const;
138
139 // Set maximum number of zoom levels in the stack, -1 for unlimited
140 void setMaxStackDepth(int);
141
142 // Get maximum stack depth
143 int maxStackDepth() const;
144
145 // Get the zoom stack containing all zoom states
146 const QStack< QList< QwtPlotCanvasZoomState > >& zoomStack() const;
147
148 // Get the current zoom state index in the stack
149 uint zoomStateIndex() const;
150
151public Q_SLOTS:
152 // Navigate in the zoom stack by offset (negative = zoom out, positive = zoom in)
153 virtual void zoom(int offset);
154
155 // Append a new zoom state to the stack
156 virtual void appendZoom(const QList< QwtPlotCanvasZoomState >& rect);
157
158Q_SIGNALS:
171
172protected:
173 virtual void rescale();
174
175 virtual void widgetMouseReleaseEvent(QMouseEvent*) override;
176 virtual void widgetKeyPressEvent(QKeyEvent*) override;
177
178 virtual void begin() override;
179 virtual bool end(bool ok = true) override;
180 virtual bool accept(QPolygon&) const override;
181
182private:
183 void init(bool doReplot);
184
185 QList< QwtPlotCanvasZoomState > canvasRectToZoomStateList(const QRect& pixelRect) const;
186 QwtPlotCanvasZoomState canvasRectToZoomState(QwtPlot* plt, const QRect& pixelRect) const;
187 void moveCurrentState(double dx, double dy);
188};
189
190#endif // QWTCANVASZOOMER_H
Definition qwt_dyngrid_layout.h:33
Definition qwt_plot_axis_zoomer.h:35
专门针对 canvas 的 picker 基类
Definition qwt_canvas_picker.h:29
表示区间的类
Definition qwt_interval.h:45
QwtPlotCanvasZoomer 为绘图画布的所有坐标轴提供缩放功能
Definition qwt_plot_canvas_zoomer.h:114
void zoomed(const QList< QwtPlotCanvasZoomState > &state)
当绘图被放大或缩小时发出的信号
二维绘图部件
Definition qwt_plot.h:138
存储所有四个坐标轴缩放状态的结构体
Definition qwt_plot_canvas_zoomer.h:29