22 #include <QMouseEvent>
27 :
QgsMapTool( canvas ), mDragging( false ), mPinching( false )
37 mCanvas->ungrabGesture( Qt::PinchGesture );
42 mCanvas->grabGesture( Qt::PinchGesture );
48 mCanvas->ungrabGesture( Qt::PinchGesture );
56 if (( e->buttons() & Qt::LeftButton ) )
69 if ( e->button() == Qt::LeftButton )
97 qDebug() <<
"gesture " << event;
98 if ( QGesture *gesture = event->gesture( Qt::PinchGesture ) )
109 if ( gesture->state() == Qt::GestureFinished )
112 if ( 0.98 < gesture->totalScaleFactor() && gesture->totalScaleFactor() < 1.02 )
119 QPoint pos = gesture->centerPoint().toPoint();
120 pos =
mCanvas->mapFromGlobal( pos );
124 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 setExtent(const QgsRectangle &r)
Set the extent of the map canvas.
void refresh()
Repaints the canvas map.
Map canvas is a class for displaying all GIS data types on a canvas.
A class to represent a point geometry.
void zoomOut()
Zoom out with fixed factor.
void panAction(QMouseEvent *event)
Called when mouse is moving and pan is activated.
const QgsMapToPixel * getCoordinateTransform()
Get the current coordinate transform.
QgsRectangle extent() const
Returns the current zoom exent of the map canvas.
QgsPoint toMapPoint(double x, double y) const
void panActionEnd(QPoint releasePoint)
Ends pan action and redraws the canvas.
void scale(double scaleFactor, const QgsPoint *c=0)
Scale the rectangle around its center point.