28 mRubberBand->setBrush( QBrush( QColor( 70, 50, 255, 25 ) ) );
29 mRubberBand->setPen( QPen( QBrush( QColor( 70, 50, 255, 100 ) ), 0 ) );
34 if ( event->button() != Qt::LeftButton )
40 mMousePressStartPos =
event->pos();
41 if ( event->modifiers() & Qt::AltModifier )
44 double scaleFactor = 2;
46 QRect viewportRect( 0, 0,
view()->viewport()->width(),
view()->viewport()->height() );
49 visibleRect.
scale( scaleFactor, event->
layoutPoint().x(),
event->layoutPoint().y() );
50 QRectF boundsRect = visibleRect.
toRectF();
53 view()->fitInView( boundsRect, Qt::KeepAspectRatio );
72 mRubberBand->update( event->
layoutPoint(), nullptr );
77 if ( !
mMarqueeZoom || event->button() != Qt::LeftButton )
84 QRectF newBoundsRect = mRubberBand->finish( event->
layoutPoint() );
90 double scaleFactor = 0.5;
92 QRect viewportRect( 0, 0,
view()->viewport()->width(),
view()->viewport()->height() );
95 visibleRect.
scale( scaleFactor, event->
layoutPoint().x(),
event->layoutPoint().y() );
96 newBoundsRect = visibleRect.
toRectF();
100 view()->fitInView( newBoundsRect, Qt::KeepAspectRatio );
108 if ( !event->isAutoRepeat() )
111 view()->viewport()->setCursor( ( event->modifiers() & Qt::AltModifier ) ?
121 if ( !event->isAutoRepeat() )
124 view()->viewport()->setCursor( ( event->modifiers() & Qt::AltModifier ) ?
136 mRubberBand->finish();
141 void QgsLayoutViewToolZoom::startMarqueeZoom( QPointF scenePoint )
145 mRubberBandStartPos = scenePoint;
146 mRubberBand->start( scenePoint,
nullptr );
A rectangle specified with double values.
A graphical widget to display and interact with QgsLayouts.
void scale(double scaleFactor, const QgsPointXY *c=nullptr)
Scale the rectangle around its center point.
A QgsLayoutViewMouseEvent is the result of a user interaction with the mouse on a QgsLayoutView...
QPointF layoutPoint() const
Returns the event point location in layout coordinates.
QgsLayoutViewRectangularRubberBand is rectangular rubber band for use within QgsLayoutView widgets...
QRectF toRectF() const
Returns a QRectF with same coordinates as the rectangle.
void viewChanged()
Updates associated rulers and other widgets after view extent or zoom has changed.
static QCursor getThemeCursor(Cursor cursor)
Helper to get a theme cursor.
void emitZoomLevelChanged()
Emits the zoomLevelChanged() signal.