28#include "moc_qgsmodelviewtoolzoom.cpp"
34 mRubberBand = std::make_unique<QgsModelViewRectangularRubberBand>(
view );
35 mRubberBand->setBrush( QBrush( QColor( 70, 50, 255, 25 ) ) );
36 mRubberBand->setPen( QPen( QBrush( QColor( 70, 50, 255, 100 ) ), 0 ) );
41 if ( event->button() != Qt::LeftButton )
47 mMousePressStartPos =
event->pos();
48 if ( event->modifiers() & Qt::AltModifier )
51 const double scaleFactor = 2;
53 const QRect viewportRect( 0, 0,
view()->viewport()->width(),
view()->viewport()->height() );
57 const QRectF boundsRect = visibleRect.
toRectF();
60 view()->fitInView( boundsRect, Qt::KeepAspectRatio );
77 mRubberBand->update( event->
modelPoint(), Qt::KeyboardModifiers() );
82 if ( !
mMarqueeZoom || event->button() != Qt::LeftButton )
89 QRectF newBoundsRect = mRubberBand->finish( event->
modelPoint() );
95 const double scaleFactor = 0.5;
97 const QRect viewportRect( 0, 0,
view()->viewport()->width(),
view()->viewport()->height() );
101 newBoundsRect = visibleRect.
toRectF();
105 view()->fitInView( newBoundsRect, Qt::KeepAspectRatio );
111 if ( !event->isAutoRepeat() )
121 if ( !event->isAutoRepeat() )
133 mRubberBand->finish();
138void QgsModelViewToolZoom::startMarqueeZoom( QPointF scenePoint )
142 mRubberBandStartPos = scenePoint;
143 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 QgsModelGraphicsView.
QPointF modelPoint() const
Returns the event point location in model coordinates.
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.