1863_snapmeasurement.diff
src/app/qgsmeasuretool.cpp (working copy) | ||
---|---|---|
20 | 20 |
#include "qgsmaprenderer.h" |
21 | 21 |
#include "qgsmaptopixel.h" |
22 | 22 |
#include "qgsrubberband.h" |
23 |
#include "qgsvectorlayer.h" |
|
24 |
#include "qgstolerance.h" |
|
23 | 25 | |
24 | 26 |
#include "qgsmeasuredialog.h" |
25 | 27 |
#include "qgsmeasuretool.h" |
... | ... | |
148 | 150 |
} |
149 | 151 |
} |
150 | 152 | |
151 | ||
152 | 153 |
void QgsMeasureTool::canvasMoveEvent( QMouseEvent * e ) |
153 | 154 |
{ |
154 | 155 |
if ( !mRightMouseClicked ) |
155 | 156 |
{ |
157 |
QgsVectorLayer *vl = dynamic_cast<QgsVectorLayer *>( mCanvas->currentLayer() ); |
|
156 | 158 |
QgsPoint point = mCanvas->getCoordinateTransform()->toMapCoordinates( e->pos().x(), e->pos().y() ); |
159 | ||
160 |
if ( vl ) |
|
161 |
{ |
|
162 |
vl->snapPoint( point, QgsTolerance::defaultTolerance(vl, mCanvas->mapRenderer() ) ); |
|
163 |
} |
|
164 | ||
157 | 165 |
mRubberBand->movePoint( point ); |
158 | 166 |
mDialog->mouseMove( point ); |
159 | 167 |
} |
... | ... | |
162 | 170 | |
163 | 171 |
void QgsMeasureTool::canvasReleaseEvent( QMouseEvent * e ) |
164 | 172 |
{ |
165 |
QgsPoint point = mCanvas->getCoordinateTransform()->toMapCoordinates( e->x(), e->y() ); |
|
173 |
QgsVectorLayer *vl = dynamic_cast<QgsVectorLayer *>( mCanvas->currentLayer() ); |
|
174 |
QgsPoint point = mCanvas->getCoordinateTransform()->toMapCoordinates( e->pos().x(), e->pos().y() ); |
|
166 | 175 | |
176 |
if ( vl ) |
|
177 |
{ |
|
178 |
vl->snapPoint( point, QgsTolerance::defaultTolerance(vl, mCanvas->mapRenderer() ) ); |
|
179 |
} |
|
180 | ||
167 | 181 |
if ( e->button() == Qt::RightButton && ( e->buttons() & Qt::LeftButton ) == 0 ) // restart |
168 | 182 |
{ |
169 | 183 |
if ( mRightMouseClicked ) |