3 #include <QApplication> 10 :
QwtPlotZoomer(canvas, true), _mouse_pressed(false), _zoom_enabled(false), _keep_aspect_ratio(true)
47 QString theme = settings.value(
"Preferences::theme",
"light").toString();
48 QPixmap pixmap(tr(
":/style_%1/zoom_in.png").
arg(theme));
49 QCursor zoom_cursor(pixmap.scaled(24, 24));
54 QPen pen(
parentWidget()->palette().foreground().color(), 1, Qt::DashLine);
56 QApplication::setOverrideCursor(zoom_cursor);
63 QApplication::restoreOverrideCursor();
81 QApplication::restoreOverrideCursor();
86 QRect rect = QRect(pa[0], pa[
int(pa.count()) - 1]);
102 const QRectF cr =
canvas()->contentsRect();
103 const double canvas_ratio = cr.width() / cr.height();
104 const double zoom_ratio = zoomRect.width() / zoomRect.height();
106 if (zoom_ratio < canvas_ratio)
108 double new_width = zoomRect.height() * canvas_ratio;
109 double increment = new_width - zoomRect.width();
110 rect.setWidth(new_width);
111 rect.moveLeft(rect.left() - 0.5 * increment);
115 double new_height = zoomRect.width() / canvas_ratio;
116 double increment = new_height - zoomRect.height();
117 rect.setHeight(new_height);
118 rect.moveTop(rect.top() - 0.5 * increment);
A pattern for mouse events.
virtual void zoom(const QRectF &)
Zoom in.
virtual QSizeF minZoomSize() const override
Limit zooming by a minimum rectangle.
void setRubberBand(RubberBand)
QWidget * parentWidget()
Return the parent widget, where the selection happens.
void setTrackerMode(DisplayMode)
Set the display mode of the tracker.
QRectF invTransform(const QRect &) const
virtual void widgetMouseMoveEvent(QMouseEvent *)
bool mouseMatch(MousePatternCode, const QMouseEvent *) const
Compare a mouse event with an event pattern.
virtual bool accept(QPolygon &) const override
Check and correct a selected rectangle.
detail::named_arg< Char, T > arg(const Char *name, const T &arg)
virtual void widgetMouseMoveEvent(QMouseEvent *event) override
QwtPlotZoomer provides stacked zooming for a plot widget.
A rectangle ( only for QwtPickerMachine::RectSelection )
virtual void zoom(const QRectF &rect) override
Zoom in.
virtual void widgetMouseReleaseEvent(QMouseEvent *)
virtual bool accept(QPolygon &) const QWT_OVERRIDE
Check and correct a selected rectangle.
virtual void widgetMouseReleaseEvent(QMouseEvent *event) override
const QVector< MousePattern > & mousePattern() const
void setRubberBandPen(const QPen &)
virtual void widgetMousePressEvent(QMouseEvent *event) override
virtual void widgetMousePressEvent(QMouseEvent *)