4 #include <QApplication> 33 factor = qAbs(1.0 / factor);
36 if (plt ==
nullptr || factor == 1.0)
41 bool doReplot =
false;
49 for (
int i = 0; i < 2; i++)
51 double temp_factor = factor;
52 if (i == 1 && axis ==
X_AXIS)
56 if (i == 0 && axis ==
Y_AXIS)
61 int axisId = axis_list[i];
67 double v1 = scaleMap.
s1();
68 double v2 = scaleMap.
s2();
71 if (axisId == QwtPlot::yLeft)
83 const double width = (v2 - v1);
84 const double ratio = (v2 -
center) / (width);
86 v1 = center - width * temp_factor * (1 - ratio);
87 v2 = center + width * temp_factor * (ratio);
107 new_rect.setLeft(v1);
108 new_rect.setRight(v2);
112 new_rect.setBottom(v1);
virtual void widgetMousePressEvent(QMouseEvent *)
virtual void rescale(double factor) override
QwtPlotMagnifier provides zooming, by magnifying in steps.
virtual void widgetWheelEvent(QWheelEvent *)
QPointF invTransform(QPoint pos)
void setAutoReplot(bool=true)
Set or reset the autoReplot option.
virtual void widgetMousePressEvent(QMouseEvent *event) override
double _upper_bounds[QwtPlot::axisCnt]
Y axis left of the canvas.
QwtPlot * plot()
Return plot widget, containing the observed plot canvas.
double _lower_bounds[QwtPlot::axisCnt]
virtual void widgetWheelEvent(QWheelEvent *event) override
virtual ~PlotMagnifier() override
bool isAxisEnabled(int axis) const
virtual QwtScaleMap canvasMap(int axisId) const
void rescaled(QRectF new_size)
const QwtTransform * transformation() const
Get the transformation.
double invTransform(double p) const
void setAxisScale(int axisId, double min, double max, double stepSize=0)
Disable autoscaling and specify a fixed scale for a selected axis.
void setAxisLimits(int axis, double lower, double upper)
PlotMagnifier(QWidget *canvas)
double transform(double s) const