QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
32 mCursor = QCursor( Qt::OpenHandCursor );
37 mCanvas->ungrabGesture( Qt::PinchGesture );
42 mCanvas->grabGesture( Qt::PinchGesture );
48 mCanvas->ungrabGesture( Qt::PinchGesture );
59 if ( e->button() == Qt::LeftButton )
61 mCanvas->setCursor( QCursor( Qt::ClosedHandCursor ) );
62 mCanvas->panActionStart( e->pos() );
71 if ( ( e->buttons() & Qt::LeftButton ) )
84 if ( e->button() == Qt::LeftButton )
88 mCanvas->panActionEnd( e->pos() );
97 const QgsPointXY center =
mCanvas->getCoordinateTransform()->toMapCoordinates( e->x(), e->y() );
119 if ( !QTouchDevice::devices().isEmpty() && !mPinching )
121 mCanvas->zoomWithCenter( e->x(), e->y(),
true );
127 if ( QTouchDevice::devices().isEmpty() )
130 if ( QGesture *gesture = event->gesture( Qt::PinchGesture ) )
133 pinchTriggered(
static_cast<QPinchGesture *
>( gesture ) );
138 void QgsMapToolPan::pinchTriggered( QPinchGesture *gesture )
140 if ( gesture->state() == Qt::GestureFinished )
143 if ( 0.98 < gesture->totalScaleFactor() && gesture->totalScaleFactor() < 1.02 )
150 QPoint pos = gesture->centerPoint().toPoint();
151 pos =
mCanvas->mapFromGlobal( pos );
153 const QgsPointXY center =
mCanvas->getCoordinateTransform()->toMapCoordinates( pos.x(), pos.y() );
155 r.
scale( 1 / gesture->totalScaleFactor(), ¢er );
Map canvas is a class for displaying all GIS data types on a canvas.
QgsCoordinateTransformContext transformContext
static QgsProject * instance()
Returns the QgsProject singleton instance.
A rectangle specified with double values.
void scale(double scaleFactor, const QgsPointXY *c=nullptr)
Scale the rectangle around its center point.
bool setEllipsoid(const QString &ellipsoid)
Sets the ellipsoid by its acronym.
Custom exception class for Coordinate Reference System related exceptions.
double measureLine(const QVector< QgsPointXY > &points) const
Measures the length of a line with multiple segments.
QgsUnitTypes::DistanceUnit lengthUnits() const
Returns the units of distance for length calculations made by this object.
void setSourceCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets source spatial reference system crs.
A class to represent a 2D point.
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas....
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
double bearing(const QgsPointXY &p1, const QgsPointXY &p2) const SIP_THROW(QgsCsException)
Computes the bearing (in radians) between two points.
@ MapPanOnSingleClick
A map pan interaction caused by a single click and release on the map canvas.