27#include "moc_qgslayoutviewtoolzoom.cpp"
33 mRubberBand = std::make_unique<QgsLayoutViewRectangularRubberBand>(
view );
34 mRubberBand->setBrush( QBrush( QColor( 70, 50, 255, 25 ) ) );
35 mRubberBand->setPen( QPen( QBrush( QColor( 70, 50, 255, 100 ) ), 0 ) );
40 if ( event->button() != Qt::LeftButton )
45 mRubberBand->finish();
51 mMousePressStartPos =
event->pos();
52 if ( event->modifiers() & Qt::AltModifier )
55 const double scaleFactor = 2;
57 const QRect viewportRect( 0, 0,
view()->viewport()->width(),
view()->viewport()->height() );
61 const QRectF boundsRect = visibleRect.
toRectF();
64 view()->fitInView( boundsRect, Qt::KeepAspectRatio );
83 mRubberBand->update( event->
layoutPoint(), Qt::KeyboardModifiers() );
88 if ( !
mMarqueeZoom || event->button() != Qt::LeftButton )
95 QRectF newBoundsRect = mRubberBand->finish( event->
layoutPoint() );
101 const double scaleFactor = 0.5;
103 const QRect viewportRect( 0, 0,
view()->viewport()->width(),
view()->viewport()->height() );
107 newBoundsRect = visibleRect.
toRectF();
111 view()->fitInView( newBoundsRect, Qt::KeepAspectRatio );
119 if ( !event->isAutoRepeat() )
129 if ( !event->isAutoRepeat() )
141 mRubberBand->finish();
146void QgsLayoutViewToolZoom::startMarqueeZoom( QPointF scenePoint )
150 mRubberBandStartPos = scenePoint;
151 mRubberBand->start( scenePoint, Qt::KeyboardModifiers() );
static QCursor getThemeCursor(Cursor cursor)
Helper to get a theme cursor.
A mouse event which is the result of a user interaction with a QgsLayoutView.
QPointF layoutPoint() const
Returns the event point location in layout coordinates.
A graphical widget to display and interact with QgsLayouts.
void viewChanged()
Updates associated rulers and other widgets after view extent or zoom has changed.
void emitZoomLevelChanged()
Emits the zoomLevelChanged() signal.
A rectangle specified with double values.
void scale(double scaleFactor, const QgsPointXY *c=nullptr)
Scale the rectangle around its center point.
QRectF toRectF() const
Returns a QRectF with same coordinates as the rectangle.