00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "qgsmaptoolpan.h"
00018 #include "qgsmapcanvas.h"
00019 #include "qgscursors.h"
00020 #include "qgsmaptopixel.h"
00021 #include <QBitmap>
00022 #include <QCursor>
00023 #include <QMouseEvent>
00024
00025
00026 QgsMapToolPan::QgsMapToolPan( QgsMapCanvas* canvas )
00027 : QgsMapTool( canvas ), mDragging( false )
00028 {
00029
00030 QBitmap panBmp = QBitmap::fromData( QSize( 16, 16 ), pan_bits );
00031 QBitmap panBmpMask = QBitmap::fromData( QSize( 16, 16 ), pan_mask_bits );
00032 mCursor = QCursor( panBmp, panBmpMask, 5, 5 );
00033 }
00034
00035
00036 void QgsMapToolPan::canvasMoveEvent( QMouseEvent * e )
00037 {
00038 if (( e->buttons() & Qt::LeftButton ) )
00039 {
00040 mDragging = true;
00041
00042 mCanvas->panAction( e );
00043 }
00044 }
00045
00046 void QgsMapToolPan::canvasReleaseEvent( QMouseEvent * e )
00047 {
00048 if ( e->button() == Qt::LeftButton )
00049 {
00050 if ( mDragging )
00051 {
00052 mCanvas->panActionEnd( e->pos() );
00053 mDragging = false;
00054 }
00055 else
00056 {
00057
00058 QgsPoint center = mCanvas->getCoordinateTransform()->toMapPoint( e->x(), e->y() );
00059 mCanvas->setExtent( QgsRectangle( center, center ) );
00060 mCanvas->refresh();
00061 }
00062 }
00063 }