Skip to content

Commit e6e0eed

Browse files
author
mhugent
committed
change map unit in project dialog when user selects a new crs
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13619 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 86963c3 commit e6e0eed

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

‎src/app/qgsprojectproperties.cpp‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
4949
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
5050
connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) );
5151
connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) );
52+
connect( projectionSelector, SIGNAL( sridSelected( QString ) ), this, SLOT( setMapUnitsToCurrentProjection() ) );
5253

5354
///////////////////////////////////////////////////////////
5455
// Properties stored in map canvas's QgsMapRenderer
@@ -531,6 +532,34 @@ void QgsProjectProperties::on_cbxProjectionEnabled_stateChanged( int state )
531532
btnGrpMapUnits->setEnabled( state == Qt::Unchecked );
532533
}
533534

535+
void QgsProjectProperties::setMapUnitsToCurrentProjection()
536+
{
537+
long myCRSID = projectionSelector->selectedCrsId();
538+
if ( myCRSID )
539+
{
540+
QgsCoordinateReferenceSystem srs( myCRSID, QgsCoordinateReferenceSystem::InternalCrsId );
541+
//set radio button to crs map unit type
542+
QGis::UnitType units = srs.mapUnits();
543+
switch ( units )
544+
{
545+
case QGis::Meters:
546+
radMeters->setChecked( true );
547+
break;
548+
case QGis::Feet:
549+
radFeet->setChecked( true );
550+
break;
551+
case QGis::Degrees:
552+
radDecimalDegrees->setChecked( true );
553+
break;
554+
case QGis::DegreesMinutesSeconds:
555+
radDMS->setChecked( true );
556+
break;
557+
default:
558+
break;
559+
}
560+
}
561+
}
562+
534563
/*!
535564
* Function to save dialog window state
536565
*/

‎src/app/qgsprojectproperties.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ class QgsProjectProperties : public QDialog, private Ui::QgsProjectPropertiesBas
102102

103103
void on_cbxProjectionEnabled_stateChanged( int state );
104104

105+
/*!
106+
* If user changes the CRS, set the corresponding map units
107+
*/
108+
void setMapUnitsToCurrentProjection();
109+
105110
signals:
106111
//! Signal used to inform listeners that the mouse display precision may have changed
107112
void displayPrecisionChanged();

0 commit comments

Comments
 (0)