Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix for ticket #398 (measuring needs a way to stop measuring without
immediately starting again)


git-svn-id: http://svn.osgeo.org/qgis/trunk@6153 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Nov 30, 2006
1 parent b2a13cf commit 1b0ed3c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/gui/qgsmeasure.cpp
Expand Up @@ -61,12 +61,15 @@ QgsMeasure::QgsMeasure(bool measureArea, QgsMapCanvas *mc, Qt::WFlags f)
mRubberBand = new QgsRubberBand(mMapCanvas, mMeasureArea);

mCanvas->setCursor(Qt::CrossCursor);

mRightMouseClicked = false;
}

void QgsMeasure::activate()
{
restorePosition();
QgsMapTool::activate();
mRightMouseClicked = false;
}

void QgsMeasure::deactivate()
Expand Down Expand Up @@ -100,6 +103,8 @@ void QgsMeasure::restart(void )
updateUi();

mRubberBand->reset(mMeasureArea);

mRightMouseClicked = false;
}

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

void QgsMeasure::canvasMoveEvent(QMouseEvent * e)
{
QgsPoint point = mCanvas->getCoordinateTransform()->toMapCoordinates(e->pos().x(), e->pos().y());
mouseMove(point);
if (!mRightMouseClicked)
{
QgsPoint point = mCanvas->getCoordinateTransform()->toMapCoordinates(e->pos().x(), e->pos().y());
mouseMove(point);
}
}


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

if(e->button() == Qt::RightButton && (e->state() & Qt::LeftButton) == 0) // restart
{
restart();
if (mRightMouseClicked)
restart();
else
mRightMouseClicked = true;
}
else if (e->button() == Qt::LeftButton)
{
addPoint(point);
show();
}

}
3 changes: 3 additions & 0 deletions src/gui/qgsmeasure.h
Expand Up @@ -122,6 +122,9 @@ public slots:

//! indicates whether we're measuring distances or areas
bool mMeasureArea;

//! indicates whether we've just done a right mouse click
bool mRightMouseClicked;
};

#endif

0 comments on commit 1b0ed3c

Please sign in to comment.