@@ -59,6 +59,12 @@ QgsMeasureDialog::QgsMeasureDialog( QgsMeasureTool* tool, Qt::WFlags f )
59
59
60
60
connect ( mcbProjectionEnabled, SIGNAL ( stateChanged ( int ) ),
61
61
this , SLOT ( changeProjectionEnabledState () ) );
62
+ // Update when project wide transformation has changed
63
+ connect ( mTool ->canvas ()->mapRenderer (), SIGNAL ( hasCrsTransformEnabled ( bool ) ),
64
+ this , SLOT ( changeProjectionEnabledState () ) );
65
+ // Update when project CRS has changed
66
+ connect ( mTool ->canvas ()->mapRenderer (), SIGNAL ( destinationSrsChanged () ),
67
+ this , SLOT ( changeProjectionEnabledState () ) );
62
68
63
69
updateUi ();
64
70
}
@@ -215,7 +221,63 @@ QString QgsMeasureDialog::formatArea( double area, int decimalPlaces )
215
221
216
222
void QgsMeasureDialog::updateUi ()
217
223
{
224
+ // Only enable checkbox when project wide transformation is on
225
+ mcbProjectionEnabled->setEnabled ( mTool ->canvas ()->hasCrsTransformEnabled () );
226
+
227
+ configureDistanceArea ();
228
+
218
229
QSettings settings;
230
+
231
+ // Set tooltip to indicate how we calculate measurments
232
+ QGis::UnitType mapUnits = mTool ->canvas ()->mapUnits ();
233
+ QString mapUnitsTxt;
234
+ switch ( mapUnits )
235
+ {
236
+ case QGis::Meters:
237
+ mapUnitsTxt = " meters" ;
238
+ break ;
239
+ case QGis::Feet:
240
+ mapUnitsTxt = " feet" ;
241
+ break ;
242
+ case QGis::Degrees:
243
+ mapUnitsTxt = " degrees" ;
244
+ break ;
245
+ case QGis::UnknownUnit:
246
+ mapUnitsTxt = " -" ;
247
+ }
248
+
249
+ QString toolTip = QString ( " The calculations are based on:" );
250
+ if ( ! mTool ->canvas ()->hasCrsTransformEnabled () )
251
+ {
252
+ toolTip += QString ( " %1 Project CRS transformation is turned off, canvas units setting" ).arg ( " <br> *" );
253
+ toolTip += QString ( " is taken from project properties setting (%1)." ).arg ( mapUnitsTxt );
254
+ toolTip += QString ( " %1 Ellipsoidal calculation is not possible, as project CRS is undefined." ).arg ( " <br> *" );
255
+ }
256
+ else
257
+ {
258
+ if ( mDa .ellipsoidalEnabled () )
259
+ {
260
+ toolTip += QString ( " %1 Project CRS transformation is turned on and ellipsoidal calculation is selected. " ).arg ( " <br> *" );
261
+ toolTip += QString ( " The coordinates are transformed to the chosen ellipsoid (%1) and the result is in meters" ).arg ( mDa .ellipsoid () );
262
+ }
263
+ else
264
+ {
265
+ toolTip += QString ( " %1 Project CRS transformation is turned on but ellipsoidal calculation is not selected. " ).arg ( " <br> *" );
266
+ toolTip += QString ( " The canvas units setting is taken from the project CRS (%1)." ).arg ( mapUnitsTxt );
267
+ }
268
+ }
269
+ if ( mapUnits == QGis::Meters && settings.value ( " /qgis/measure/displayunits" , " meters" ).toString () == " feet" )
270
+ {
271
+ toolTip += QString ( " %1 Finally, the value is converted from meters to feet." ).arg ( " <br> *" );
272
+ }
273
+ else if ( mapUnits == QGis::Feet && settings.value ( " /qgis/measure/displayunits" , " meters" ).toString () == " meters" )
274
+ {
275
+ toolTip += QString ( " %1 Finally, the value is converted from feet to meters." ).arg ( " <br> *" );
276
+ }
277
+
278
+ editTotal->setToolTip ( toolTip );
279
+ mTable ->setToolTip ( toolTip );
280
+
219
281
int decimalPlaces = settings.value ( " /qgis/measure/decimalplaces" , " 3" ).toInt ();
220
282
221
283
double dummy = 1.0 ;
@@ -248,8 +310,6 @@ void QgsMeasureDialog::updateUi()
248
310
mTable ->show ();
249
311
editTotal->setText ( formatDistance ( 0 , decimalPlaces ) );
250
312
}
251
-
252
- configureDistanceArea ();
253
313
}
254
314
255
315
void QgsMeasureDialog::convertMeasurement ( double &measure, QGis::UnitType &u, bool isArea )
@@ -284,9 +344,13 @@ void QgsMeasureDialog::changeProjectionEnabledState()
284
344
// store value
285
345
QSettings settings;
286
346
if ( mcbProjectionEnabled->isChecked () )
347
+ {
287
348
settings.setValue ( " /qgis/measure/projectionEnabled" , 2 );
349
+ }
288
350
else
351
+ {
289
352
settings.setValue ( " /qgis/measure/projectionEnabled" , 0 );
353
+ }
290
354
291
355
// clear interface
292
356
mTable ->clear ();
@@ -345,5 +409,6 @@ void QgsMeasureDialog::configureDistanceArea()
345
409
QString ellipsoidId = settings.value ( " /qgis/measure/ellipsoid" , " WGS84" ).toString ();
346
410
mDa .setSourceCrs ( mTool ->canvas ()->mapRenderer ()->destinationCrs ().srsid () );
347
411
mDa .setEllipsoid ( ellipsoidId );
348
- mDa .setEllipsoidalEnabled ( mcbProjectionEnabled->isChecked () );
412
+ // Only use ellipsoidal calculation when project wide transformation is enabled.
413
+ mDa .setEllipsoidalEnabled ( mcbProjectionEnabled->isChecked () && mTool ->canvas ()->hasCrsTransformEnabled () );
349
414
}
0 commit comments