Skip to content

Commit

Permalink
Improve line/area measuring behaviour when the user has been informed…
Browse files Browse the repository at this point in the history
… that

they are probably using the wrong projection for the map canvas


git-svn-id: http://svn.osgeo.org/qgis/branches/Release-0_8_0@6396 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Jan 6, 2007
1 parent 4598a0c commit 180fc98
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/gui/qgsmeasure.cpp
Expand Up @@ -78,8 +78,7 @@ void QgsMeasure::activate()
mRightMouseClicked = false;

// ensure that we have correct settings
mCalc->setDefaultEllipsoid();
mCalc->setProjectAsSourceSRS();
updateProjection();

// If we suspect that they have data that is projected, yet the
// map SRS is set to a geographic one, warn them.
Expand All @@ -98,6 +97,7 @@ void QgsMeasure::activate()
"system using the <tt>Settings:Project Properties</tt> menu."),
QMessageBox::Ok,
QMessageBox::NoButton);
mWrongProjectProjection = true;
}
}

Expand Down Expand Up @@ -125,6 +125,7 @@ QgsMeasure::~QgsMeasure()

void QgsMeasure::restart(void )
{
updateProjection();
mPoints.resize(0);
// Set one cell row where to update current distance
// If measuring area, the table doesn't get shown
Expand All @@ -137,6 +138,7 @@ void QgsMeasure::restart(void )
mRubberBand->reset(mMeasureArea);

mRightMouseClicked = false;
mWrongProjectProjection = false;
}

void QgsMeasure::addPoint(QgsPoint &point)
Expand All @@ -145,6 +147,12 @@ void QgsMeasure::addPoint(QgsPoint &point)
std::cout << "QgsMeasure::addPoint" << point.x() << ", " << point.y() << std::endl;
#endif

if (mWrongProjectProjection)
{
updateProjection();
mWrongProjectProjection = false;
}

// don't add points with the same coordinates
if (mPoints.size() > 0 && point == mPoints[0])
return;
Expand Down Expand Up @@ -325,6 +333,12 @@ void QgsMeasure::updateUi()

}

void QgsMeasure::updateProjection()
{
mCalc->setDefaultEllipsoid();
mCalc->setProjectAsSourceSRS();
}

//////////////////////////

void QgsMeasure::canvasPressEvent(QMouseEvent * e)
Expand Down
7 changes: 7 additions & 0 deletions src/gui/qgsmeasure.h
Expand Up @@ -105,6 +105,9 @@ public slots:
//! shows/hides table, shows correct units
void updateUi();

//! updates the projections we're using
void updateProjection();

QgsMapCanvas *mMapCanvas;

//! distance/area calculator
Expand All @@ -125,6 +128,10 @@ public slots:

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

//! indicates whether we've recently warned the user about having the wrong
// project projection
bool mWrongProjectProjection;
};

#endif

0 comments on commit 180fc98

Please sign in to comment.