Skip to content
Permalink
Browse files

Changed UI and added tool tip

  • Loading branch information
homann committed Aug 23, 2012
1 parent a1db95f commit 95a032a75aa59ee8613d5536c120b3ce6faefa66
Showing with 81 additions and 8 deletions.
  1. +68 −3 src/app/qgsmeasuredialog.cpp
  2. +2 −2 src/app/qgsmeasuredialog.h
  3. +11 −3 src/ui/qgsprojectpropertiesbase.ui
@@ -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( "<br> *" );
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( "<br> *" );
}
else
{
if ( mDa.ellipsoidalEnabled() )
{
toolTip += QString( "%1 Project CRS transformation is turned on and ellipsoidal calculation is selected. " ).arg( "<br> *" );
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( "<br> *" );
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( "<br> *" );
}
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( "<br> *" );
}

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() );
}
@@ -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:
@@ -193,8 +193,15 @@
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="btnGrpMapUnits">
<property name="toolTip">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;Used when CRS transformation is turned off.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="title">
<string>Layer units</string>
<string>Canvas units</string>
</property>
<layout class="QGridLayout" name="gridLayout_27">
<item row="0" column="0">
@@ -780,8 +787,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>660</width>
<height>792</height>
<width>583</width>
<height>671</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
@@ -1156,6 +1163,7 @@
</tabstops>
<resources>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
</resources>
<connections>
<connection>

0 comments on commit 95a032a

Please sign in to comment.
You can’t perform that action at this time.