Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FEATURE]: center map if user clicks into the map (patch 2278 provide…
…d by smizuno)

git-svn-id: http://svn.osgeo.org/qgis/trunk@13342 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Apr 21, 2010
1 parent e01984c commit cb490ae
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/gui/qgsmaptoolpan.cpp
Expand Up @@ -17,6 +17,7 @@
#include "qgsmaptoolpan.h"
#include "qgsmapcanvas.h"
#include "qgscursors.h"
#include "qgsmaptopixel.h"
#include <QBitmap>
#include <QCursor>
#include <QMouseEvent>
Expand All @@ -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 cb490ae

Please sign in to comment.