QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_plot_axis_wheel_interaction.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 * This file is a new addition to the Qwt 7.x maintenance branch.
10 *****************************************************************************/
11
12#ifndef QWT_PLOT_AXIS_WHEEL_INTERACTION_H
13#define QWT_PLOT_AXIS_WHEEL_INTERACTION_H
14
15#include "qwt_global.h"
16#include "qwt_axis_id.h"
17
18#include <qobject.h>
19
20class QWheelEvent;
21class QEvent;
22class QWidget;
23class QwtPlot;
24class QwtScaleWidget;
25
80class QWT_EXPORT QwtPlotAxisWheelInteraction : public QObject
81{
82 Q_OBJECT
83
84public:
85 // Construct from a plot and axis id
86 explicit QwtPlotAxisWheelInteraction(QwtPlot* plot, QwtAxisId axisId);
87
88 // Construct from a scale widget (auto-derives plot and axis id)
89 explicit QwtPlotAxisWheelInteraction(QwtScaleWidget* scaleWidget);
90
91 // Destructor
93
94 // Enable or disable the interaction
95 void setEnabled(bool on);
96 // Return whether the interaction is enabled
97 bool isEnabled() const;
98
99 // ---- Zoom configuration (plain wheel by default) ----
100
101 // Set keyboard modifiers for zoom mode (default: Qt::NoModifier)
102 void setZoomModifiers(Qt::KeyboardModifiers modifiers);
103 // Return the zoom modifiers
104 Qt::KeyboardModifiers zoomModifiers() const;
105
106 // Set the zoom factor per wheel step (default: 1.2; >1 zoom in, <1 zoom out)
107 void setZoomFactor(double factor);
108 // Return the zoom factor
109 double zoomFactor() const;
110
111 // ---- Pan configuration (Ctrl+wheel by default) ----
112
113 // Set keyboard modifiers for pan mode (default: Qt::ControlModifier)
114 void setPanModifiers(Qt::KeyboardModifiers modifiers);
115 // Return the pan modifiers
116 Qt::KeyboardModifiers panModifiers() const;
117
118 // Set pixels to pan per wheel step (default: 30)
119 void setPanFactor(int pixelsPerStep);
120 // Return the pan factor in pixels
121 int panFactor() const;
122
123 // Return the observed scale widget
124 QwtScaleWidget* scaleWidget();
125 // Return the observed scale widget (const version)
126 const QwtScaleWidget* scaleWidget() const;
127
128 // Return the plot that owns the axis
129 QwtPlot* plot();
130 // Return the plot that owns the axis (const version)
131 const QwtPlot* plot() const;
132
133 // Return the axis id
134 QwtAxisId axisId() const;
135
136protected:
137 // Event filter — intercepts wheel events on the scale widget
138 virtual bool eventFilter(QObject* obj, QEvent* event) override;
139
140 // Top-level wheel handler. Override for completely custom behavior.
141 // Return true if handled (event consumed), false to pass through.
142 virtual bool handleWheelEvent(QWheelEvent* event);
143
144 // Called when zoom action is triggered. Override to customize zoom.
145 // @param factor Zoom factor (>1 zoom in, <1 zoom out)
146 // @param cursorPos Cursor position in canvas coordinates
147 virtual void wheelZoom(double factor, const QPoint& cursorPos);
148
149 // Called when pan action is triggered. Override to customize pan.
150 // @param deltaPixels Pixel offset (positive = right/down, negative = left/up)
151 virtual void wheelPan(int deltaPixels);
152
153private:
154 QWT_DECLARE_PRIVATE(QwtPlotAxisWheelInteraction)
155};
156
157#endif // QWT_PLOT_AXIS_WHEEL_INTERACTION_H
Configurable wheel interaction for a single plot axis
Definition qwt_plot_axis_wheel_interaction.h:81
A 2-D plotting widget
Definition qwt_plot.h:100
A Widget which contains a scale
Definition qwt_scale_widget.h:73