33 mCursor = QCursor( Qt::OpenHandCursor );
38 mCanvas->ungrabGesture( Qt::PinchGesture );
43 mCanvas->grabGesture( Qt::PinchGesture );
49 mCanvas->ungrabGesture( Qt::PinchGesture );
55 if ( e->button() == Qt::LeftButton )
57 mCanvas->setCursor( QCursor( Qt::ClosedHandCursor ) );
67 if ( ( e->buttons() & Qt::LeftButton ) )
80 if ( e->button() == Qt::LeftButton )
107 if ( !QTouchDevice::devices().isEmpty() && !mPinching )
115 if ( QTouchDevice::devices().isEmpty() )
118 if ( QGesture *gesture = event->gesture( Qt::PinchGesture ) )
121 pinchTriggered( static_cast<QPinchGesture *>( gesture ) );
126 void QgsMapToolPan::pinchTriggered( QPinchGesture *gesture )
128 if ( gesture->state() == Qt::GestureFinished )
131 if ( 0.98 < gesture->totalScaleFactor() && gesture->totalScaleFactor() < 1.02 )
138 QPoint pos = gesture->centerPoint().toPoint();
139 pos =
mCanvas->mapFromGlobal( pos );
143 r.
scale( 1 / gesture->totalScaleFactor(), ¢er );
QgsUnitTypes::DistanceUnit lengthUnits() const
Returns the units of distance for length calculations made by this object.
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.
void panActionStart(QPoint releasePoint)
Starts a pan action.
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.
bool setEllipsoid(const QString &ellipsoid)
Sets the ellipsoid by its acronym.
Map canvas is a class for displaying all GIS data types on a canvas.
QgsCoordinateReferenceSystem destinationCrs() const
returns CRS of destination coordinate reference system
QgsRectangle extent() const
Returns the current zoom extent of the map canvas.
void zoomOut()
Zoom out with fixed factor.
QgsCoordinateTransformContext transformContext
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
A general purpose distance and area calculator, capable of performing ellipsoid based calculations...
QgsPointXY center() const
Gets map center, in geographical coordinates.
void panAction(QMouseEvent *event)
Called when mouse is moving and pan is activated.
static QgsProject * instance()
Returns the QgsProject singleton instance.
void setExtent(const QgsRectangle &r, bool magnified=false)
Sets the extent of the map canvas.
const QgsMapToPixel * getCoordinateTransform()
Gets the current coordinate transform.
void setSourceCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets source spatial reference system crs.
double bearing(const QgsPointXY &p1, const QgsPointXY &p2) const
Computes the bearing (in radians) between two points.
QgsPointXY toMapCoordinates(int x, int y) const
Transform device coordinates to map (world) coordinates.
double measureLine(const QVector< QgsPointXY > &points) const
Measures the length of a line with multiple segments.
void panActionEnd(QPoint releasePoint)
Ends pan action and redraws the canvas.