Index: src/app/qgsmeasuretool.cpp =================================================================== --- src/app/qgsmeasuretool.cpp (revision 11278) +++ src/app/qgsmeasuretool.cpp (working copy) @@ -20,6 +20,8 @@ #include "qgsmaprenderer.h" #include "qgsmaptopixel.h" #include "qgsrubberband.h" +#include "qgsvectorlayer.h" +#include "qgstolerance.h" #include "qgsmeasuredialog.h" #include "qgsmeasuretool.h" @@ -148,12 +150,18 @@ } } - void QgsMeasureTool::canvasMoveEvent( QMouseEvent * e ) { if ( !mRightMouseClicked ) { + QgsVectorLayer *vl = dynamic_cast( mCanvas->currentLayer() ); QgsPoint point = mCanvas->getCoordinateTransform()->toMapCoordinates( e->pos().x(), e->pos().y() ); + + if ( vl ) + { + vl->snapPoint( point, QgsTolerance::defaultTolerance(vl, mCanvas->mapRenderer() ) ); + } + mRubberBand->movePoint( point ); mDialog->mouseMove( point ); } @@ -162,8 +170,14 @@ void QgsMeasureTool::canvasReleaseEvent( QMouseEvent * e ) { - QgsPoint point = mCanvas->getCoordinateTransform()->toMapCoordinates( e->x(), e->y() ); + QgsVectorLayer *vl = dynamic_cast( mCanvas->currentLayer() ); + QgsPoint point = mCanvas->getCoordinateTransform()->toMapCoordinates( e->pos().x(), e->pos().y() ); + if ( vl ) + { + vl->snapPoint( point, QgsTolerance::defaultTolerance(vl, mCanvas->mapRenderer() ) ); + } + if ( e->button() == Qt::RightButton && ( e->buttons() & Qt::LeftButton ) == 0 ) // restart { if ( mRightMouseClicked )