Skip to content

Commit

Permalink
For global crs option show nice user friendly name instead of proj4 s…
Browse files Browse the repository at this point in the history
…tring

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15360 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Mar 6, 2011
1 parent d666dad commit 4a96d68
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 54 deletions.
33 changes: 15 additions & 18 deletions src/app/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,17 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
{
radUseGlobalProjection->setChecked( true );
}
txtGlobalWkt->setText( settings.value( "/Projections/defaultProjectionString", GEOPROJ4 ).toString() );
QString myGlobalCrsString = settings.value( "/Projections/defaultProjectionString", GEOPROJ4 ).toString();
mGlobalCrs.createFromProj4( myGlobalCrsString );
//display the crs as friendly text rather than in wkt
leGlobalCRS->setText( mGlobalCrs.authid() + " - " + mGlobalCrs.description() );

//on the fly CRS transformation settings
grpOtfTransform->setChecked( settings.value( "/Projections/otfTransformEnabled", 0 ).toBool() );
QString myDefaultSrsString = settings.value( "/Projections/defaultOTFProjectionString", GEOPROJ4 ).toString();
mDefaultCrs.createFromProj4( myDefaultSrsString );
QString myDefaultCrsString = settings.value( "/Projections/defaultOTFProjectionString", GEOPROJ4 ).toString();
mDefaultCrs.createFromProj4( myDefaultCrsString );
//display the crs as friendly text rather than in wkt
leGlobalOtfProjString->setText( mDefaultCrs.authid() + " - " +
mDefaultCrs.description() );
leGlobalOtfProjString->setText( mDefaultCrs.authid() + " - " + mDefaultCrs.description() );

// populate combo box with ellipsoids
getEllipsoidList();
Expand Down Expand Up @@ -635,7 +638,7 @@ void QgsOptions::saveOptions()
settings.setValue( "/Projections/defaultBehaviour", "useGlobal" );
}

settings.setValue( "/Projections/defaultProjectionString", txtGlobalWkt->toPlainText() );
settings.setValue( "/Projections/defaultProjectionString", mGlobalCrs.toProj4() );

// save 'on the fly' CRS transformation settings
settings.setValue( "/Projections/otfTransformEnabled", grpOtfTransform->isChecked() );
Expand Down Expand Up @@ -748,19 +751,15 @@ void QgsOptions::on_pbnSelectProjection_clicked()
{
QSettings settings;
QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector( this );

//find out srs id of current proj4 string
QgsCoordinateReferenceSystem refSys;
if ( refSys.createFromProj4( txtGlobalWkt->toPlainText() ) )
{
mySelector->setSelectedCrsId( refSys.srsid() );
}
mySelector->setSelectedCrsId( mGlobalCrs.srsid() );

if ( mySelector->exec() )
{
//! @todo changes this control name in gui to txtGlobalProjString
txtGlobalWkt->setText( mySelector->selectedProj4String() );
QgsDebugMsg( QString( "------ Global Default Projection Selection set to ----------\n%1" ).arg( txtGlobalWkt->toPlainText() ) );
mGlobalCrs.createFromProj4( mySelector->selectedProj4String() );
leGlobalCRS->setText( mySelector->selectedProj4String() );
leGlobalCRS->setText( mGlobalCrs.authid() + " - " +
mGlobalCrs.description() );
QgsDebugMsg( QString( "------ Global Default Projection Selection set to ----------\n%1" ).arg( leGlobalCRS->text() ) );
}
else
{
Expand All @@ -774,8 +773,6 @@ void QgsOptions::on_pbnSelectOtfProjection_clicked()
{
QSettings settings;
QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector( this );

//find out srs id of current proj4 string
mySelector->setSelectedCrsId( mDefaultCrs.srsid() );

if ( mySelector->exec() )
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsoptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
private:
QStringList i18nList();
QgsCoordinateReferenceSystem mDefaultCrs;
QgsCoordinateReferenceSystem mGlobalCrs;
};

#endif // #ifndef QGSOPTIONS_H
90 changes: 54 additions & 36 deletions src/ui/qgsoptionsbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<property name="iconSize">
<size>
Expand Down Expand Up @@ -1354,87 +1354,106 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-59</y>
<width>746</width>
<height>516</height>
<y>0</y>
<width>762</width>
<height>457</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_15">
<layout class="QGridLayout" name="gridLayout_22">
<item row="0" column="0">
<widget class="QGroupBox" name="grpProjectionBehaviour">
<property name="title">
<string>Default Coordinate Reference System</string>
</property>
<layout class="QVBoxLayout">
<property name="margin">
<number>11</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>When a new layer is created, or when a layer is loaded that has no coordinate reference system (CRS)</string>
<string>When a new layer is created, or when a layer is loaded that has no Coordinate Reference System (CRS)</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<item row="1" column="0">
<widget class="QRadioButton" name="radPromptForProjection">
<property name="text">
<string>Prompt for CRS</string>
</property>
</widget>
</item>
<item>
<item row="2" column="0">
<widget class="QRadioButton" name="radUseProjectProjection">
<property name="text">
<string>Project wide default CRS will be used</string>
</property>
</widget>
</item>
<item>
<item row="3" column="0">
<widget class="QRadioButton" name="radUseGlobalProjection">
<property name="text">
<string>Global default CRS displa&amp;yed below will be used</string>
</property>
</widget>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLineEdit" name="leGlobalCRS">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbnSelectProjection">
<property name="text">
<string>Select ...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QTextBrowser" name="txtGlobalWkt"/>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="pbnSelectProjection">
<property name="text">
<string>Select Global Default ...</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="grpOtfTransform">
<property name="title">
<string>Always use 'on the fly' CRS transformation for new projects</string>
<string>Enable 'on the fly' reprojection by defaul</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLineEdit" name="leGlobalOtfProjString">
<property name="readOnly">
<layout class="QGridLayout" name="gridLayout_15">
<item row="0" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>When this opton is enabled, any new project you create will have 'on the fly' projection enabled by default and the CRS below will be used for the project.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbnSelectOtfProjection">
<property name="text">
<string>Select CRS for 'on the fly' transformation ...</string>
</property>
</widget>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QLineEdit" name="leGlobalOtfProjString">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbnSelectOtfProjection">
<property name="text">
<string>Select ...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
Expand Down Expand Up @@ -1828,7 +1847,6 @@
<tabstop>radPromptForProjection</tabstop>
<tabstop>radUseProjectProjection</tabstop>
<tabstop>radUseGlobalProjection</tabstop>
<tabstop>txtGlobalWkt</tabstop>
<tabstop>pbnSelectProjection</tabstop>
<tabstop>grpLocale</tabstop>
<tabstop>cboLocale</tabstop>
Expand Down

0 comments on commit 4a96d68

Please sign in to comment.