17#include "moc_qgslayoutviewtoolzoom.cpp"
29 mRubberBand->setBrush( QBrush( QColor( 70, 50, 255, 25 ) ) );
30 mRubberBand->setPen( QPen( QBrush( QColor( 70, 50, 255, 100 ) ), 0 ) );
35 if ( event->button() != Qt::LeftButton )
40 mRubberBand->finish();
46 mMousePressStartPos =
event->pos();
47 if ( event->modifiers() & Qt::AltModifier )
50 const double scaleFactor = 2;
52 const QRect viewportRect( 0, 0,
view()->viewport()->width(),
view()->viewport()->height() );
56 const QRectF boundsRect = visibleRect.
toRectF();
59 view()->fitInView( boundsRect, Qt::KeepAspectRatio );
78 mRubberBand->update( event->
layoutPoint(), Qt::KeyboardModifiers() );
83 if ( !
mMarqueeZoom || event->button() != Qt::LeftButton )
90 QRectF newBoundsRect = mRubberBand->finish( event->
layoutPoint() );
96 const double scaleFactor = 0.5;
98 const QRect viewportRect( 0, 0,
view()->viewport()->width(),
view()->viewport()->height() );
102 newBoundsRect = visibleRect.
toRectF();
106 view()->fitInView( newBoundsRect, Qt::KeepAspectRatio );
114 if ( !event->isAutoRepeat() )
117 view()->viewport()->setCursor( ( event->modifiers() & Qt::AltModifier ) ?
127 if ( !event->isAutoRepeat() )
130 view()->viewport()->setCursor( ( event->modifiers() & Qt::AltModifier ) ?
142 mRubberBand->finish();
147void QgsLayoutViewToolZoom::startMarqueeZoom( QPointF scenePoint )
151 mRubberBandStartPos = scenePoint;
152 mRubberBand->start( scenePoint, Qt::KeyboardModifiers() );
static QCursor getThemeCursor(Cursor cursor)
Helper to get a theme cursor.
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.
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.