Skip to content

Commit 16d90f2

Browse files
author
g_j_m
committed
Fix for ticket #398 (measuring needs a way to stop measuring without
immediately starting again) git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6153 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 78fc31a commit 16d90f2

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/gui/qgsmeasure.cpp

+15-3
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,15 @@ QgsMeasure::QgsMeasure(bool measureArea, QgsMapCanvas *mc, Qt::WFlags f)
6161
mRubberBand = new QgsRubberBand(mMapCanvas, mMeasureArea);
6262

6363
mCanvas->setCursor(Qt::CrossCursor);
64+
65+
mRightMouseClicked = false;
6466
}
6567

6668
void QgsMeasure::activate()
6769
{
6870
restorePosition();
6971
QgsMapTool::activate();
72+
mRightMouseClicked = false;
7073
}
7174

7275
void QgsMeasure::deactivate()
@@ -100,6 +103,8 @@ void QgsMeasure::restart(void )
100103
updateUi();
101104

102105
mRubberBand->reset(mMeasureArea);
106+
107+
mRightMouseClicked = false;
103108
}
104109

105110
void QgsMeasure::addPoint(QgsPoint &point)
@@ -307,8 +312,11 @@ void QgsMeasure::canvasPressEvent(QMouseEvent * e)
307312

308313
void QgsMeasure::canvasMoveEvent(QMouseEvent * e)
309314
{
310-
QgsPoint point = mCanvas->getCoordinateTransform()->toMapCoordinates(e->pos().x(), e->pos().y());
311-
mouseMove(point);
315+
if (!mRightMouseClicked)
316+
{
317+
QgsPoint point = mCanvas->getCoordinateTransform()->toMapCoordinates(e->pos().x(), e->pos().y());
318+
mouseMove(point);
319+
}
312320
}
313321

314322

@@ -318,11 +326,15 @@ void QgsMeasure::canvasReleaseEvent(QMouseEvent * e)
318326

319327
if(e->button() == Qt::RightButton && (e->state() & Qt::LeftButton) == 0) // restart
320328
{
321-
restart();
329+
if (mRightMouseClicked)
330+
restart();
331+
else
332+
mRightMouseClicked = true;
322333
}
323334
else if (e->button() == Qt::LeftButton)
324335
{
325336
addPoint(point);
326337
show();
327338
}
339+
328340
}

src/gui/qgsmeasure.h

+3
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ public slots:
122122

123123
//! indicates whether we're measuring distances or areas
124124
bool mMeasureArea;
125+
126+
//! indicates whether we've just done a right mouse click
127+
bool mRightMouseClicked;
125128
};
126129

127130
#endif

0 commit comments

Comments
 (0)