19#include "moc_qgsmaptoolpan.cpp"
32 mCursor = QCursor( Qt::OpenHandCursor );
38 mCanvas->ungrabGesture( Qt::PinchGesture );
43 mCanvas->grabGesture( Qt::PinchGesture );
49 mCanvas->ungrabGesture( Qt::PinchGesture );
60 if ( e->button() == Qt::LeftButton )
62 mCanvas->setCursor( QCursor( Qt::ClosedHandCursor ) );
63 mCanvas->panActionStart( e->pos() );
72 if ( ( e->buttons() & Qt::LeftButton ) )
85 if ( e->button() == Qt::LeftButton )
89 mCanvas->panActionEnd( e->pos() );
98 const QgsPointXY center =
mCanvas->getCoordinateTransform()->toMapCoordinates( e->x(), e->y() );
122 mCanvas->zoomWithCenter( e->x(), e->y(),
true );
128 if ( QGesture *gesture = event->gesture( Qt::PinchGesture ) )
131 pinchTriggered(
static_cast<QPinchGesture *
>( gesture ) );
136void QgsMapToolPan::pinchTriggered( QPinchGesture *gesture )
138 if ( gesture->state() == Qt::GestureFinished )
141 if ( 0.98 < gesture->totalScaleFactor() && gesture->totalScaleFactor() < 1.02 )
148 QPoint pos = gesture->centerPoint().toPoint();
149 pos =
mCanvas->mapFromGlobal( pos );
151 const QgsPointXY center =
mCanvas->getCoordinateTransform()->toMapCoordinates( pos.x(), pos.y() );
153 r.
scale( 1 / gesture->totalScaleFactor(), ¢er );
Custom exception class for Coordinate Reference System related exceptions.
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
double bearing(const QgsPointXY &p1, const QgsPointXY &p2) const
Computes the bearing (in radians) between two points.
double measureLine(const QVector< QgsPointXY > &points) const
Measures the length of a line with multiple segments.
void setSourceCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets source spatial reference system crs.
Qgis::DistanceUnit lengthUnits() const
Returns the units of distance for length calculations made by this object.
bool setEllipsoid(const QString &ellipsoid)
Sets the ellipsoid by its acronym.
@ MapPanOnSingleClick
A map pan interaction caused by a single click and release on the map canvas.
Map canvas is a class for displaying all GIS data types on a canvas.
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
A class to represent a 2D point.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsCoordinateTransformContext transformContext
A rectangle specified with double values.
void scale(double scaleFactor, const QgsPointXY *c=nullptr)
Scale the rectangle around its center point.