Skip to content
Permalink
Browse files

[FEATURE] add snapping to current layer in measure dialog (apply #1863)

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11480 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Aug 22, 2009
1 parent 3209fa6 commit 3f6c58cbfa5b2bc4271d0be29c4d4c568d409cec
Showing with 16 additions and 2 deletions.
  1. +16 −2 src/app/qgsmeasuretool.cpp
@@ -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"
@@ -133,12 +135,18 @@ void QgsMeasureTool::canvasPressEvent( QMouseEvent * e )
}
}


void QgsMeasureTool::canvasMoveEvent( QMouseEvent * e )
{
if ( !mRightMouseClicked )
{
QgsVectorLayer *vl = dynamic_cast<QgsVectorLayer *>( 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 );
}
@@ -147,7 +155,13 @@ void QgsMeasureTool::canvasMoveEvent( QMouseEvent * e )

void QgsMeasureTool::canvasReleaseEvent( QMouseEvent * e )
{
QgsPoint point = mCanvas->getCoordinateTransform()->toMapCoordinates( e->x(), e->y() );
QgsVectorLayer *vl = dynamic_cast<QgsVectorLayer *>( 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
{

0 comments on commit 3f6c58c

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