Skip to content

Commit 5329ad5

Browse files
vmoram-kuhn
authored andcommitted
- fix #7441
- reset unit settings to original ones when deactivating OTF projection - added OTF status (on/off) to mesuredialog title - resets prefered units and selected srs - when OTF transfo is deselected, this resets the units value to the original ones
1 parent fef175b commit 5329ad5

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

src/app/qgsmeasuredialog.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ void QgsMeasureDialog::updateUi()
222222
toolTip += "<br> * " + tr( "Project CRS transformation is turned off." ) + " ";
223223
toolTip += tr( "Canvas units setting is taken from project properties setting (%1)." ).arg( QGis::tr( mCanvasUnits ) );
224224
toolTip += "<br> * " + tr( "Ellipsoidal calculation is not possible, as project CRS is undefined." );
225+
setWindowTitle( tr("Measure (OTF off)"));
225226
}
226227
else
227228
{
@@ -235,6 +236,7 @@ void QgsMeasureDialog::updateUi()
235236
toolTip += "<br> * " + tr( "Project CRS transformation is turned on but ellipsoidal calculation is not selected." );
236237
toolTip += "<br> * " + tr( "The canvas units setting is taken from the project CRS (%1)." ).arg( QGis::tr( mCanvasUnits ) );
237238
}
239+
setWindowTitle( tr("Measure (OTF on)"));
238240
}
239241

240242
if (( mCanvasUnits == QGis::Meters && mDisplayUnits == QGis::Feet ) || ( mCanvasUnits == QGis::Feet && mDisplayUnits == QGis::Meters ) )

src/app/qgsprojectproperties.cpp

+26-3
Original file line numberDiff line numberDiff line change
@@ -814,12 +814,35 @@ void QgsProjectProperties::on_cbxProjectionEnabled_toggled( bool onFlyEnabled )
814814
QString unitsOnFlyState = tr( "Canvas units (CRS transformation: %1)" );
815815
if ( !onFlyEnabled )
816816
{
817-
if ( !mProjectSrsId )
817+
// reset projection to default
818+
const QMap<QString, QgsMapLayer*> &mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
819+
820+
if ( mMapCanvas->currentLayer() )
821+
{
822+
mLayerSrsId = mMapCanvas->currentLayer()->crs().srsid();
823+
}
824+
else if ( mapLayers.size() > 0 )
818825
{
819-
mProjectSrsId = projectionSelector->selectedCrsId();
826+
mLayerSrsId = mapLayers.begin().value()->crs().srsid();
820827
}
828+
else
829+
{
830+
mLayerSrsId = mProjectSrsId;
831+
}
832+
mProjectSrsId = mLayerSrsId;
821833
projectionSelector->setSelectedCrsId( mLayerSrsId );
822834

835+
QgsCoordinateReferenceSystem srs( mLayerSrsId, QgsCoordinateReferenceSystem::InternalCrsId );
836+
//set radio button to crs map unit type
837+
QGis::UnitType units = srs.mapUnits();
838+
839+
radMeters->setChecked( units == QGis::Meters );
840+
radFeet->setChecked( units == QGis::Feet );
841+
radDegrees->setChecked( units == QGis::Degrees );
842+
843+
// unset ellipsoid
844+
mEllipsoidIndex = 0;
845+
823846
btnGrpMeasureEllipsoid->setTitle( measureOnFlyState.arg( tr( "OFF" ) ) );
824847
btnGrpMapUnits->setTitle( unitsOnFlyState.arg( tr( "OFF" ) ) );
825848
}
@@ -1452,7 +1475,6 @@ void QgsProjectProperties::updateEllipsoidUI( int newIndex )
14521475
leSemiMajor->setToolTip( tr( "Select %1 from pull-down menu to adjust radii" ).arg( tr( "Parameters:" ) ) );
14531476
leSemiMinor->setToolTip( tr( "Select %1 from pull-down menu to adjust radii" ).arg( tr( "Parameters:" ) ) );
14541477
}
1455-
cmbEllipsoid->setCurrentIndex( mEllipsoidIndex ); // Not always necessary
14561478
if ( mEllipsoidList[ mEllipsoidIndex ].acronym != GEO_NONE )
14571479
{
14581480
leSemiMajor->setText( QLocale::system().toString( myMajor, 'f', 3 ) );
@@ -1464,4 +1486,5 @@ void QgsProjectProperties::updateEllipsoidUI( int newIndex )
14641486
cmbEllipsoid->setEnabled( false );
14651487
cmbEllipsoid->setToolTip( tr( "Can only use ellipsoidal calculations when CRS transformation is enabled" ) );
14661488
}
1489+
cmbEllipsoid->setCurrentIndex( mEllipsoidIndex ); // Not always necessary
14671490
}

0 commit comments

Comments
 (0)