[QGIS Commit] r13342 - trunk/qgis/src/gui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Apr 21 15:21:44 EDT 2010


Author: mhugent
Date: 2010-04-21 15:21:44 -0400 (Wed, 21 Apr 2010)
New Revision: 13342

Modified:
   trunk/qgis/src/gui/qgsmaptoolpan.cpp
Log:
[FEATURE]: center map if user clicks into the map (patch 2278 provided by smizuno)

Modified: trunk/qgis/src/gui/qgsmaptoolpan.cpp
===================================================================
--- trunk/qgis/src/gui/qgsmaptoolpan.cpp	2010-04-21 02:07:00 UTC (rev 13341)
+++ trunk/qgis/src/gui/qgsmaptoolpan.cpp	2010-04-21 19:21:44 UTC (rev 13342)
@@ -17,6 +17,7 @@
 #include "qgsmaptoolpan.h"
 #include "qgsmapcanvas.h"
 #include "qgscursors.h"
+#include "qgsmaptopixel.h"
 #include <QBitmap>
 #include <QCursor>
 #include <QMouseEvent>
@@ -34,28 +35,29 @@
 
 void QgsMapToolPan::canvasMoveEvent( QMouseEvent * e )
 {
-  if ( mDragging && ( e->buttons() & Qt::LeftButton ) )
+  if (( e->buttons() & Qt::LeftButton ) )
   {
+    mDragging = true;
     // move map and other canvas items
     mCanvas->panAction( e );
   }
 }
 
-
-void QgsMapToolPan::canvasPressEvent( QMouseEvent * e )
+void QgsMapToolPan::canvasReleaseEvent( QMouseEvent * e )
 {
   if ( e->button() == Qt::LeftButton )
   {
-    mDragging = TRUE;
+    if ( mDragging )
+    {
+      mCanvas->panActionEnd( e->pos() );
+      mDragging = FALSE;
+    }
+    else // add pan to mouse cursor
+    {
+      // transform the mouse pos to map coordinates
+      QgsPoint center = mCanvas->getCoordinateTransform()->toMapPoint( e->x(), e->y() );
+      mCanvas->setExtent( QgsRectangle( center, center ) );
+      mCanvas->refresh();
+    }
   }
 }
-
-
-void QgsMapToolPan::canvasReleaseEvent( QMouseEvent * e )
-{
-  if ( mDragging && e->button() == Qt::LeftButton )
-  {
-    mCanvas->panActionEnd( e->pos() );
-    mDragging = FALSE;
-  }
-}



More information about the QGIS-commit mailing list