QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
| Public 成员函数 | Protected 成员函数 | 所有成员列表
QwtPlotAxisWheelInteraction类 参考

Configurable wheel interaction for a single plot axis 更多...

#include <qwt_plot_axis_wheel_interaction.h>

类 QwtPlotAxisWheelInteraction 继承关系图:

class  PrivateData
 

Public 成员函数

 QwtPlotAxisWheelInteraction (QwtPlot *plot, QwtAxisId axisId)
 Constructor from plot and axis id
 
 QwtPlotAxisWheelInteraction (QwtScaleWidget *scaleWidget)
 
void setEnabled (bool on)
 Enable or disable the interaction
 
bool isEnabled () const
 Return whether the interaction is enabled
 
void setZoomModifiers (Qt::KeyboardModifiers modifiers)
 Set keyboard modifiers for zoom mode
 
Qt::KeyboardModifiers zoomModifiers () const
 Return the zoom modifiers
 
void setZoomFactor (double factor)
 Set the zoom factor per wheel step
 
double zoomFactor () const
 Return the zoom factor
 
void setPanModifiers (Qt::KeyboardModifiers modifiers)
 Set keyboard modifiers for pan mode
 
Qt::KeyboardModifiers panModifiers () const
 Return the pan modifiers
 
void setPanFactor (int pixelsPerStep)
 Set the pan distance per wheel step
 
int panFactor () const
 Return the pan factor in pixels
 
QwtScaleWidgetscaleWidget ()
 Return the observed scale widget
 
const QwtScaleWidgetscaleWidget () const
 Return the observed scale widget (const version)
 
QwtPlotplot ()
 Return the plot that owns the axis
 
const QwtPlotplot () const
 Return the plot that owns the axis (const version)
 
QwtAxisId axisId () const
 Return the axis id
 

Protected 成员函数

virtual bool eventFilter (QObject *obj, QEvent *event) override
 Event filter for wheel events on the scale widget
 
virtual bool handleWheelEvent (QWheelEvent *event)
 Handle a wheel event on the scale widget
 
virtual void wheelZoom (double factor, const QPoint &cursorPos)
 Perform a zoom on the axis
 
virtual void wheelPan (int deltaPixels)
 Perform a pan on the axis
 

详细描述

Configurable wheel interaction for a single plot axis

QwtPlotAxisWheelInteraction installs an event filter on a QwtScaleWidget (the axis tick area) and provides two configurable wheel actions:

Unlike the built-in QwtPlotScaleEventDispatcher (which hardcodes wheel=zoom and requires the axis to be clicked/selected first), this class:

When the modifier matches zoom or pan, the event is consumed (return true) so the dispatcher does not also process it. When the modifier matches neither, the event is passed through to the dispatcher for default handling.

Typical usage:

// Plain wheel zooms XBottom at cursor; Ctrl+wheel pans it
// Customize: Shift+wheel zooms YLeft, plain wheel pans
ix->setZoomModifiers(Qt::ShiftModifier);
ix->setPanModifiers(Qt::NoModifier);
Configurable wheel interaction for a single plot axis
Definition qwt_plot_axis_wheel_interaction.h:81
QwtPlot * plot()
Return the plot that owns the axis
Definition qwt_plot_axis_wheel_interaction.cpp:261
@ XBottom
X axis below the canvas
Definition qwt_axis.h:51
@ YLeft
Y axis left of the canvas
Definition qwt_axis.h:45

Inheritance example:

class CenterZoom : public QwtPlotAxisWheelInteraction {
public:
protected:
void wheelZoom(double factor, const QPoint&) override {
// Zoom centered on axis midpoint instead of cursor
const QwtScaleMap m = plot()->canvasMap(axisId());
const int mid = static_cast<int>((m.p1() + m.p2()) / 2);
QwtPlotAxisWheelInteraction::wheelZoom(factor, QPoint(mid, 0));
}
};
QwtPlotAxisWheelInteraction(QwtPlot *plot, QwtAxisId axisId)
Constructor from plot and axis id
Definition qwt_plot_axis_wheel_interaction.cpp:63
virtual void wheelZoom(double factor, const QPoint &cursorPos)
Perform a zoom on the axis
Definition qwt_plot_axis_wheel_interaction.cpp:363
A scale map
Definition qwt_scale_map.h:44
Q_DECL_CONSTEXPR double p2() const noexcept
Return second border of paint interval
Definition qwt_scale_map.h:79
Q_DECL_CONSTEXPR double p1() const noexcept
Return first border of paint interval
Definition qwt_scale_map.h:77
参见
QwtPlotScaleEventDispatcher, QwtPlot::zoomAxis(), QwtPlot::panAxis()

构造及析构函数说明

◆ QwtPlotAxisWheelInteraction()

QwtPlotAxisWheelInteraction::QwtPlotAxisWheelInteraction ( QwtPlot plot,
QwtAxisId  axisId 
)
explicit

Constructor from plot and axis id

参数
[in]plotThe plot that owns the axis
[in]axisIdThe axis to attach the interaction to

The event filter is installed on the QwtScaleWidget for the given axis. The interaction is enabled by default.

Constructor from a scale widget

参数
[in]scaleWidgetThe axis scale widget to observe

The plot and axis id are auto-derived from the scale widget's parent (which must be a QwtPlot) using QwtPlotScaleEventDispatcher::findAxisIdByScaleWidget().

Destructor

成员函数说明

◆ axisId()

QwtAxisId QwtPlotAxisWheelInteraction::axisId ( ) const

Return the axis id

返回
Axis identifier

◆ eventFilter()

bool QwtPlotAxisWheelInteraction::eventFilter ( QObject *  obj,
QEvent *  event 
)
overrideprotectedvirtual

Event filter for wheel events on the scale widget

参数
[in]objObject receiving the event (should be the scale widget)
[in]eventEvent
返回
true when the wheel event was handled (consumed), false otherwise
参见
handleWheelEvent()

◆ handleWheelEvent()

bool QwtPlotAxisWheelInteraction::handleWheelEvent ( QWheelEvent *  event)
protectedvirtual

Handle a wheel event on the scale widget

The wheel delta is read via qwt::compat::wheelEventDelta() for Qt5/Qt6 compatibility. When the current modifiers match the zoom modifiers, wheelZoom() is called. When they match the pan modifiers, wheelPan() is called. Otherwise the event is passed through (return false) so the QwtPlotScaleEventDispatcher can handle it.

参数
[in]eventWheel event
返回
true if the event was handled, false if modifiers matched neither zoom nor pan mode

◆ isEnabled()

bool QwtPlotAxisWheelInteraction::isEnabled ( ) const

Return whether the interaction is enabled

返回
true when enabled, false otherwise
参见
setEnabled()

◆ panFactor()

int QwtPlotAxisWheelInteraction::panFactor ( ) const

Return the pan factor in pixels

返回
Pixels per wheel step
参见
setPanFactor()

◆ panModifiers()

Qt::KeyboardModifiers QwtPlotAxisWheelInteraction::panModifiers ( ) const

Return the pan modifiers

返回
Keyboard modifiers for pan mode
参见
setPanModifiers()

◆ plot() [1/2]

QwtPlot * QwtPlotAxisWheelInteraction::plot ( )

Return the plot that owns the axis

返回
Pointer to the QwtPlot widget

◆ plot() [2/2]

const QwtPlot * QwtPlotAxisWheelInteraction::plot ( ) const

Return the plot that owns the axis (const version)

返回
Const pointer to the QwtPlot widget

◆ scaleWidget() [1/2]

QwtScaleWidget * QwtPlotAxisWheelInteraction::scaleWidget ( )

Return the observed scale widget

返回
Pointer to the scale widget

◆ scaleWidget() [2/2]

const QwtScaleWidget * QwtPlotAxisWheelInteraction::scaleWidget ( ) const

Return the observed scale widget (const version)

返回
Const pointer to the scale widget

◆ setEnabled()

void QwtPlotAxisWheelInteraction::setEnabled ( bool  on)

Enable or disable the interaction

When enabled, an event filter is installed on the observed scale widget to intercept wheel events before they reach the QwtPlotScaleEventDispatcher. When disabled, the filter is removed and the dispatcher regains full control.

参数
[in]ontrue to enable, false to disable
参见
isEnabled(), eventFilter()

◆ setPanFactor()

void QwtPlotAxisWheelInteraction::setPanFactor ( int  pixelsPerStep)

Set the pan distance per wheel step

参数
[in]pixelsPerStepNumber of pixels to pan per wheel notch (default: 30)
参见
panFactor()

◆ setPanModifiers()

void QwtPlotAxisWheelInteraction::setPanModifiers ( Qt::KeyboardModifiers  modifiers)

Set keyboard modifiers for pan mode

When the wheel is rotated with these modifiers on the scale widget, the axis is panned. The default is Qt::ControlModifier.

参数
[in]modifiersKeyboard modifiers
参见
panModifiers()

◆ setZoomFactor()

void QwtPlotAxisWheelInteraction::setZoomFactor ( double  factor)

Set the zoom factor per wheel step

Values > 1 zoom in (range shrinks), values < 1 zoom out (range expands). The default is 1.2. For multi-step wheels the factor is compounded: pow(zoomFactor, abs(delta/120)).

参数
[in]factorZoom factor
参见
zoomFactor()

◆ setZoomModifiers()

void QwtPlotAxisWheelInteraction::setZoomModifiers ( Qt::KeyboardModifiers  modifiers)

Set keyboard modifiers for zoom mode

When the wheel is rotated with these modifiers on the scale widget, the axis is zoomed. The default is Qt::NoModifier (plain wheel).

参数
[in]modifiersKeyboard modifiers
参见
zoomModifiers()

◆ wheelPan()

void QwtPlotAxisWheelInteraction::wheelPan ( int  deltaPixels)
protectedvirtual

Perform a pan on the axis

Default implementation calls QwtPlot::panAxis() with the given pixel delta, then replotAll(). Auto-replot is temporarily disabled to avoid redundant repaints.

Override this method to customize pan behavior, e.g. invert direction or add momentum.

参数
[in]deltaPixelsPixel offset (positive = right/down, negative = left/up)

◆ wheelZoom()

void QwtPlotAxisWheelInteraction::wheelZoom ( double  factor,
const QPoint &  cursorPos 
)
protectedvirtual

Perform a zoom on the axis

Default implementation calls QwtPlot::zoomAxis() with the given factor and cursor position, then replotAll(). Auto-replot is temporarily disabled to avoid redundant repaints.

Override this method to customize zoom behavior, e.g. zoom centered on the axis midpoint instead of the cursor position.

参数
[in]factorZoom factor (>1 zoom in, <1 zoom out)
[in]cursorPosCursor position in canvas coordinates

◆ zoomFactor()

double QwtPlotAxisWheelInteraction::zoomFactor ( ) const

Return the zoom factor

返回
Zoom factor
参见
setZoomFactor()

◆ zoomModifiers()

Qt::KeyboardModifiers QwtPlotAxisWheelInteraction::zoomModifiers ( ) const

Return the zoom modifiers

返回
Keyboard modifiers for zoom mode
参见
setZoomModifiers()

该类的文档由以下文件生成: