32 mCursor = QCursor( Qt::OpenHandCursor );
37 mCanvas->ungrabGesture( Qt::PinchGesture );
42 mCanvas->grabGesture( Qt::PinchGesture );
48 mCanvas->ungrabGesture( Qt::PinchGesture );
54 if ( e->button() == Qt::LeftButton )
55 mCanvas->setCursor( QCursor( Qt::ClosedHandCursor ) );
63 if ( ( e->buttons() & Qt::LeftButton ) )
76 if ( e->button() == Qt::LeftButton )
97 if ( !QTouchDevice::devices().isEmpty() && !mPinching )
105 if ( QTouchDevice::devices().isEmpty() )
108 qDebug() <<
"gesture " << event;
109 if ( QGesture *gesture = event->gesture( Qt::PinchGesture ) )
112 pinchTriggered( static_cast<QPinchGesture *>( gesture ) );
117 void QgsMapToolPan::pinchTriggered( QPinchGesture *gesture )
119 if ( gesture->state() == Qt::GestureFinished )
122 if ( 0.98 < gesture->totalScaleFactor() && gesture->totalScaleFactor() < 1.02 )
129 QPoint pos = gesture->centerPoint().toPoint();
130 pos =
mCanvas->mapFromGlobal( pos );
134 r.
scale( 1 / gesture->totalScaleFactor(), ¢er );
A rectangle specified with double values.
void zoomWithCenter(int x, int y, bool zoomIn)
Zooms in/out with a given center.
void setCenter(const QgsPointXY ¢er)
Set the center of the map canvas, in geographical coordinates.
A class to represent a 2D point.
void scale(double scaleFactor, const QgsPointXY *c=nullptr)
Scale the rectangle around its center point.
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
void refresh()
Repaints the canvas map.
Map canvas is a class for displaying all GIS data types on a canvas.
QgsRectangle extent() const
Returns the current zoom extent of the map canvas.
void zoomOut()
Zoom out with fixed factor.
void panAction(QMouseEvent *event)
Called when mouse is moving and pan is activated.
void setExtent(const QgsRectangle &r, bool magnified=false)
Sets the extent of the map canvas.
const QgsMapToPixel * getCoordinateTransform()
Gets the current coordinate transform.
QgsPointXY toMapCoordinates(int x, int y) const
Transform device coordinates to map (world) coordinates.
void panActionEnd(QPoint releasePoint)
Ends pan action and redraws the canvas.