Skip to content
Permalink
Browse files

[FEATURE]: center map if user clicks into the map (patch 2278 provide…

…d by smizuno)

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13342 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Apr 21, 2010
1 parent 09042fb commit ceec7bd113219a7d2424b0c9e1bc35b3bd5bdf02
Showing with 16 additions and 14 deletions.
  1. +16 −14 src/gui/qgsmaptoolpan.cpp
@@ -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 @@ QgsMapToolPan::QgsMapToolPan( QgsMapCanvas* canvas )

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 )
{
if ( e->button() == Qt::LeftButton )
{
mDragging = TRUE;
}
}


void QgsMapToolPan::canvasReleaseEvent( QMouseEvent * e )
{
if ( mDragging && e->button() == Qt::LeftButton )
if ( e->button() == Qt::LeftButton )
{
mCanvas->panActionEnd( e->pos() );
mDragging = FALSE;
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();
}
}
}

0 comments on commit ceec7bd

Please sign in to comment.
You can’t perform that action at this time.