Skip to content

Commit

Permalink
Changed UI and added tool tip
Browse files Browse the repository at this point in the history
  • Loading branch information
homann committed Aug 23, 2012
1 parent a1db95f commit 95a032a
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 8 deletions.
71 changes: 68 additions & 3 deletions src/app/qgsmeasuredialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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() );
}
4 changes: 2 additions & 2 deletions src/app/qgsmeasuredialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 11 additions & 3 deletions src/ui/qgsprojectpropertiesbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -1156,6 +1163,7 @@
</tabstops>
<resources>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
</resources>
<connections>
<connection>
Expand Down

0 comments on commit 95a032a

Please sign in to comment.