mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
[FEATURE]: center map if user clicks into the map (patch 2278 provided by smizuno)
git-svn-id: http://svn.osgeo.org/qgis/trunk@13342 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
e01984c1eb
commit
cb490ae028
@ -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 )
|
||||
void QgsMapToolPan::canvasReleaseEvent( QMouseEvent * e )
|
||||
{
|
||||
if ( e->button() == Qt::LeftButton )
|
||||
{
|
||||
mDragging = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QgsMapToolPan::canvasReleaseEvent( QMouseEvent * e )
|
||||
{
|
||||
if ( mDragging && e->button() == Qt::LeftButton )
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user