Skip to content

Commit 180fc98

Browse files
author
g_j_m
committed
Improve line/area measuring behaviour when the user has been informed 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
1 parent 4598a0c commit 180fc98

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/gui/qgsmeasure.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ void QgsMeasure::activate()
7878
mRightMouseClicked = false;
7979

8080
// ensure that we have correct settings
81-
mCalc->setDefaultEllipsoid();
82-
mCalc->setProjectAsSourceSRS();
81+
updateProjection();
8382

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

@@ -125,6 +125,7 @@ QgsMeasure::~QgsMeasure()
125125

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

139140
mRightMouseClicked = false;
141+
mWrongProjectProjection = false;
140142
}
141143

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

150+
if (mWrongProjectProjection)
151+
{
152+
updateProjection();
153+
mWrongProjectProjection = false;
154+
}
155+
148156
// don't add points with the same coordinates
149157
if (mPoints.size() > 0 && point == mPoints[0])
150158
return;
@@ -325,6 +333,12 @@ void QgsMeasure::updateUi()
325333

326334
}
327335

336+
void QgsMeasure::updateProjection()
337+
{
338+
mCalc->setDefaultEllipsoid();
339+
mCalc->setProjectAsSourceSRS();
340+
}
341+
328342
//////////////////////////
329343

330344
void QgsMeasure::canvasPressEvent(QMouseEvent * e)

src/gui/qgsmeasure.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ public slots:
105105
//! shows/hides table, shows correct units
106106
void updateUi();
107107

108+
//! updates the projections we're using
109+
void updateProjection();
110+
108111
QgsMapCanvas *mMapCanvas;
109112

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

126129
//! indicates whether we've just done a right mouse click
127130
bool mRightMouseClicked;
131+
132+
//! indicates whether we've recently warned the user about having the wrong
133+
// project projection
134+
bool mWrongProjectProjection;
128135
};
129136

130137
#endif

0 commit comments

Comments
 (0)