Skip to content

Commit 95a032a

Browse files
committedAug 23, 2012
Changed UI and added tool tip
1 parent a1db95f commit 95a032a

File tree

3 files changed

+81
-8
lines changed

3 files changed

+81
-8
lines changed
 

‎src/app/qgsmeasuredialog.cpp

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ QgsMeasureDialog::QgsMeasureDialog( QgsMeasureTool* tool, Qt::WFlags f )
5959

6060
connect( mcbProjectionEnabled, SIGNAL( stateChanged( int ) ),
6161
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() ) );
6268

6369
updateUi();
6470
}
@@ -215,7 +221,63 @@ QString QgsMeasureDialog::formatArea( double area, int decimalPlaces )
215221

216222
void QgsMeasureDialog::updateUi()
217223
{
224+
// Only enable checkbox when project wide transformation is on
225+
mcbProjectionEnabled->setEnabled( mTool->canvas()->hasCrsTransformEnabled() );
226+
227+
configureDistanceArea();
228+
218229
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+
219281
int decimalPlaces = settings.value( "/qgis/measure/decimalplaces", "3" ).toInt();
220282

221283
double dummy = 1.0;
@@ -248,8 +310,6 @@ void QgsMeasureDialog::updateUi()
248310
mTable->show();
249311
editTotal->setText( formatDistance( 0, decimalPlaces ) );
250312
}
251-
252-
configureDistanceArea();
253313
}
254314

255315
void QgsMeasureDialog::convertMeasurement( double &measure, QGis::UnitType &u, bool isArea )
@@ -284,9 +344,13 @@ void QgsMeasureDialog::changeProjectionEnabledState()
284344
// store value
285345
QSettings settings;
286346
if ( mcbProjectionEnabled->isChecked() )
347+
{
287348
settings.setValue( "/qgis/measure/projectionEnabled", 2 );
349+
}
288350
else
351+
{
289352
settings.setValue( "/qgis/measure/projectionEnabled", 0 );
353+
}
290354

291355
// clear interface
292356
mTable->clear();
@@ -345,5 +409,6 @@ void QgsMeasureDialog::configureDistanceArea()
345409
QString ellipsoidId = settings.value( "/qgis/measure/ellipsoid", "WGS84" ).toString();
346410
mDa.setSourceCrs( mTool->canvas()->mapRenderer()->destinationCrs().srsid() );
347411
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() );
349414
}

‎src/app/qgsmeasuredialog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ class QgsMeasureDialog : public QDialog, private Ui::QgsMeasureBase
6262

6363
//! Show the help for the dialog
6464
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
65-
private slots:
66-
//! on change state projection enable
65+
66+
//! on change state projection/ellipsoid enable
6767
void changeProjectionEnabledState();
6868

6969
private:

‎src/ui/qgsprojectpropertiesbase.ui

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,15 @@
193193
</item>
194194
<item row="1" column="0">
195195
<widget class="QGroupBox" name="btnGrpMapUnits">
196+
<property name="toolTip">
197+
<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;
198+
&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;
199+
p, li { white-space: pre-wrap; }
200+
&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;
201+
&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>
202+
</property>
196203
<property name="title">
197-
<string>Layer units</string>
204+
<string>Canvas units</string>
198205
</property>
199206
<layout class="QGridLayout" name="gridLayout_27">
200207
<item row="0" column="0">
@@ -780,8 +787,8 @@
780787
<rect>
781788
<x>0</x>
782789
<y>0</y>
783-
<width>660</width>
784-
<height>792</height>
790+
<width>583</width>
791+
<height>671</height>
785792
</rect>
786793
</property>
787794
<layout class="QGridLayout" name="gridLayout">
@@ -1156,6 +1163,7 @@
11561163
</tabstops>
11571164
<resources>
11581165
<include location="../../images/images.qrc"/>
1166+
<include location="../../images/images.qrc"/>
11591167
</resources>
11601168
<connections>
11611169
<connection>

0 commit comments

Comments
 (0)
Please sign in to comment.