From 95a032a75aa59ee8613d5536c120b3ce6faefa66 Mon Sep 17 00:00:00 2001 From: Magnus Homann Date: Tue, 21 Aug 2012 02:23:43 +0200 Subject: [PATCH] Changed UI and added tool tip --- src/app/qgsmeasuredialog.cpp | 71 ++++++++++++++++++++++++++++-- src/app/qgsmeasuredialog.h | 4 +- src/ui/qgsprojectpropertiesbase.ui | 14 ++++-- 3 files changed, 81 insertions(+), 8 deletions(-) diff --git a/src/app/qgsmeasuredialog.cpp b/src/app/qgsmeasuredialog.cpp index f8a36aed902..bc3c08d63b1 100644 --- a/src/app/qgsmeasuredialog.cpp +++ b/src/app/qgsmeasuredialog.cpp @@ -59,6 +59,12 @@ QgsMeasureDialog::QgsMeasureDialog( QgsMeasureTool* tool, Qt::WFlags f ) connect( mcbProjectionEnabled, SIGNAL( stateChanged( int ) ), this, SLOT( changeProjectionEnabledState() ) ); + // Update when project wide transformation has changed + connect( mTool->canvas()->mapRenderer(), SIGNAL( hasCrsTransformEnabled( bool ) ), + this, SLOT( changeProjectionEnabledState() ) ); + // Update when project CRS has changed + connect( mTool->canvas()->mapRenderer(), SIGNAL( destinationSrsChanged() ), + this, SLOT( changeProjectionEnabledState() ) ); updateUi(); } @@ -215,7 +221,63 @@ QString QgsMeasureDialog::formatArea( double area, int decimalPlaces ) void QgsMeasureDialog::updateUi() { + // Only enable checkbox when project wide transformation is on + mcbProjectionEnabled->setEnabled( mTool->canvas()->hasCrsTransformEnabled() ); + + configureDistanceArea(); + QSettings settings; + + // Set tooltip to indicate how we calculate measurments + QGis::UnitType mapUnits = mTool->canvas()->mapUnits(); + QString mapUnitsTxt; + switch ( mapUnits ) + { + case QGis::Meters: + mapUnitsTxt = "meters"; + break; + case QGis::Feet: + mapUnitsTxt = "feet"; + break; + case QGis::Degrees: + mapUnitsTxt = "degrees"; + break; + case QGis::UnknownUnit: + mapUnitsTxt = "-"; + } + + QString toolTip = QString( "The calculations are based on:" ); + if ( ! mTool->canvas()->hasCrsTransformEnabled() ) + { + toolTip += QString( "%1 Project CRS transformation is turned off, canvas units setting" ).arg( "
*" ); + toolTip += QString( "is taken from project properties setting (%1)." ).arg( mapUnitsTxt ); + toolTip += QString( "%1 Ellipsoidal calculation is not possible, as project CRS is undefined." ).arg( "
*" ); + } + else + { + if ( mDa.ellipsoidalEnabled() ) + { + toolTip += QString( "%1 Project CRS transformation is turned on and ellipsoidal calculation is selected. " ).arg( "
*" ); + toolTip += QString( "The coordinates are transformed to the chosen ellipsoid (%1) and the result is in meters" ).arg( mDa.ellipsoid() ); + } + else + { + toolTip += QString( "%1 Project CRS transformation is turned on but ellipsoidal calculation is not selected. " ).arg( "
*" ); + toolTip += QString( "The canvas units setting is taken from the project CRS (%1)." ).arg( mapUnitsTxt ); + } + } + if ( mapUnits == QGis::Meters && settings.value( "/qgis/measure/displayunits", "meters" ).toString() == "feet" ) + { + toolTip += QString( "%1 Finally, the value is converted from meters to feet." ).arg( "
*" ); + } + else if ( mapUnits == QGis::Feet && settings.value( "/qgis/measure/displayunits", "meters" ).toString() == "meters" ) + { + toolTip += QString( "%1 Finally, the value is converted from feet to meters." ).arg( "
*" ); + } + + editTotal->setToolTip( toolTip ); + mTable->setToolTip( toolTip ); + int decimalPlaces = settings.value( "/qgis/measure/decimalplaces", "3" ).toInt(); double dummy = 1.0; @@ -248,8 +310,6 @@ void QgsMeasureDialog::updateUi() mTable->show(); editTotal->setText( formatDistance( 0, decimalPlaces ) ); } - - configureDistanceArea(); } void QgsMeasureDialog::convertMeasurement( double &measure, QGis::UnitType &u, bool isArea ) @@ -284,9 +344,13 @@ void QgsMeasureDialog::changeProjectionEnabledState() // store value QSettings settings; if ( mcbProjectionEnabled->isChecked() ) + { settings.setValue( "/qgis/measure/projectionEnabled", 2 ); + } else + { settings.setValue( "/qgis/measure/projectionEnabled", 0 ); + } // clear interface mTable->clear(); @@ -345,5 +409,6 @@ void QgsMeasureDialog::configureDistanceArea() QString ellipsoidId = settings.value( "/qgis/measure/ellipsoid", "WGS84" ).toString(); mDa.setSourceCrs( mTool->canvas()->mapRenderer()->destinationCrs().srsid() ); mDa.setEllipsoid( ellipsoidId ); - mDa.setEllipsoidalEnabled( mcbProjectionEnabled->isChecked() ); + // Only use ellipsoidal calculation when project wide transformation is enabled. + mDa.setEllipsoidalEnabled( mcbProjectionEnabled->isChecked() && mTool->canvas()->hasCrsTransformEnabled() ); } diff --git a/src/app/qgsmeasuredialog.h b/src/app/qgsmeasuredialog.h index 472acc908a7..4a79010015f 100644 --- a/src/app/qgsmeasuredialog.h +++ b/src/app/qgsmeasuredialog.h @@ -62,8 +62,8 @@ class QgsMeasureDialog : public QDialog, private Ui::QgsMeasureBase //! Show the help for the dialog void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); } - private slots: - //! on change state projection enable + + //! on change state projection/ellipsoid enable void changeProjectionEnabledState(); private: diff --git a/src/ui/qgsprojectpropertiesbase.ui b/src/ui/qgsprojectpropertiesbase.ui index e1fd9103757..461940f3d67 100644 --- a/src/ui/qgsprojectpropertiesbase.ui +++ b/src/ui/qgsprojectpropertiesbase.ui @@ -193,8 +193,15 @@ + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Used when CRS transformation is turned off.</span></p></body></html> + - Layer units + Canvas units @@ -780,8 +787,8 @@ 0 0 - 660 - 792 + 583 + 671 @@ -1156,6 +1163,7 @@ +