21 #include <QMouseEvent> 23 #include <qwt/qwt_plot.h> 24 #include <qwt/qwt_plot_canvas.h> 25 #include <qwt/qwt_scale_div.h> 36 QwtPlotMagnifier(canvas),
48 double fx = std::fabs(xFactor);
49 double fy = std::fabs(yFactor);
51 if ((fx == 1.0) && (fy == 1.0))
54 bool doReplot =
false;
55 bool autoReplot = plot()->autoReplot();
57 plot()->setAutoReplot(
false);
59 #if QWT_VERSION >= 0x060100 60 const QwtScaleDiv& xScaleDiv = plot()->axisScaleDiv(QwtPlot::xBottom);
61 const QwtScaleDiv& yScaleDiv = plot()->axisScaleDiv(QwtPlot::yLeft);
63 const QwtScaleDiv& xScaleDiv = *plot()->axisScaleDiv(QwtPlot::xBottom);
64 const QwtScaleDiv& yScaleDiv = *plot()->axisScaleDiv(QwtPlot::yLeft);
67 #if QWT_VERSION < 0x060100 68 if (xScaleDiv.isValid())
71 double center = xScaleDiv.lowerBound()+0.5*xScaleDiv.range();
72 double width = xScaleDiv.range()*fx;
74 plot()->setAxisScale(QwtPlot::xBottom, center-0.5*width,
79 #if QWT_VERSION < 0x060100 80 if (yScaleDiv.isValid())
83 double center = yScaleDiv.lowerBound()+0.5*yScaleDiv.range();
84 double width = yScaleDiv.range()*fy;
86 plot()->setAxisScale(QwtPlot::yLeft, center-0.5*width,
91 plot()->setAutoReplot(autoReplot);
98 QwtPlotMagnifier::widgetMousePressEvent(event);
100 #if QWT_VERSION >= 0x060100 101 Qt::MouseButton button;
102 Qt::KeyboardModifiers buttonState;
104 int button, buttonState;
107 getMouseButton(button, buttonState);
109 if (event->button() != button || !parentWidget())
112 if ((event->modifiers() & Qt::KeyboardModifierMask) !=
113 (
int)(buttonState & Qt::KeyboardModifierMask))
150 QwtPlotMagnifier::widgetMouseReleaseEvent(event);
void widgetMouseMoveEvent(QMouseEvent *event)
void rescale(double xFactor, double yFactor)
PlotMagnifier(QwtPlotCanvas *canvas)
void widgetMouseReleaseEvent(QMouseEvent *event)
void widgetMousePressEvent(QMouseEvent *event)