Index: src/app/qgsoptions.cpp
===================================================================
--- src/app/qgsoptions.cpp (revision 15331)
+++ src/app/qgsoptions.cpp (working copy)
@@ -191,6 +191,10 @@
txtGlobalWkt->setText( settings.value( "/Projections/defaultProjectionString", GEOPROJ4 ).toString() );
+ //on the fly CRS transformation settings
+ grpOtfTransform->setChecked( settings.value( "/Projections/otfTransformEnabled", 0 ).toBool() );
+ leGlobalOtfProjString->setText( settings.value( "/Projections/defaultOTFProjectionString", GEOPROJ4 ).toString() );
+
// populate combo box with ellipsoids
getEllipsoidList();
QString myEllipsoidId = settings.value( "/qgis/measure/ellipsoid", "WGS84" ).toString();
@@ -631,6 +635,10 @@
settings.setValue( "/Projections/defaultProjectionString", txtGlobalWkt->toPlainText() );
+ // save 'on the fly' CRS transformation settings
+ settings.setValue( "/Projections/otfTransformEnabled", grpOtfTransform->isChecked() );
+ settings.setValue( "/Projections/defaultOTFProjectionString", leGlobalOtfProjString->text() );
+
settings.setValue( "/qgis/measure/ellipsoid", getEllipsoidAcronym( cmbEllipsoid->currentText() ) );
if ( radFeet->isChecked() )
@@ -760,6 +768,30 @@
}
+void QgsOptions::on_pbnSelectOtfProjection_clicked()
+{
+ QSettings settings;
+ QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector( this );
+
+ //find out srs id of current proj4 string
+ QgsCoordinateReferenceSystem refSys;
+ if ( refSys.createFromProj4( leGlobalOtfProjString->text() ) )
+ {
+ mySelector->setSelectedCrsId( refSys.srsid() );
+ }
+
+ if ( mySelector->exec() )
+ {
+ leGlobalOtfProjString->setText( mySelector->selectedProj4String() );
+ QgsDebugMsg( QString( "------ Global OTF Projection Selection set to ----------\n%1" ).arg( leGlobalOtfProjString->text() ) );
+ }
+ else
+ {
+ QgsDebugMsg( "------ Global OTF Projection Selection change cancelled ----------" );
+ QApplication::restoreOverrideCursor();
+ }
+}
+
// Return state of the visibility flag for newly added layers. If
bool QgsOptions::newVisible()
Index: src/app/qgsoptions.h
===================================================================
--- src/app/qgsoptions.h (revision 15331)
+++ src/app/qgsoptions.h (working copy)
@@ -50,6 +50,8 @@
public slots:
//! Slot called when user chooses to change the project wide projection.
void on_pbnSelectProjection_clicked();
+ //! Slot called when user chooses to change the default 'on the fly' projection.
+ void on_pbnSelectOtfProjection_clicked();
void saveOptions();
//! Slot to change the theme this is handled when the user
// activates or highlights a theme name in the drop-down list
@@ -125,12 +127,7 @@
QString getEllipsoidName( QString theEllipsoidAcronym );
private:
- //
QStringList i18nList();
-
- //!Default proj4 string used for new layers added that have no projection
- QString mGlobalProj4String;
-
};
#endif // #ifndef QGSOPTIONS_H
Index: src/app/qgisapp.cpp
===================================================================
--- src/app/qgisapp.cpp (revision 15331)
+++ src/app/qgisapp.cpp (working copy)
@@ -3256,7 +3256,28 @@
mMapCanvas->refresh();
mMapCanvas->clearExtentHistory();
- mMapCanvas->mapRenderer()->setProjectionsEnabled( false );
+ // enable OTF CRS transformation if necessary
+ if ( settings.value( "/Projections/otfTransformEnabled", 0 ).toBool() )
+ {
+ QgsMapRenderer* myRenderer = mMapCanvas->mapRenderer();
+ QString projString = settings.value( "/Projections/defaultOTFProjectionString", GEOPROJ4 ).toString();
+ QgsCoordinateReferenceSystem srs;
+ srs.createFromProj4( projString );
+ myRenderer->setProjectionsEnabled( true );
+ myRenderer->setDestinationSrs( srs );
+ // write the projections _proj string_ to project settings
+ prj->writeEntry( "SpatialRefSys", "/ProjectCRSProj4String", projString );
+ prj->dirty( false );
+ if ( srs.mapUnits() != QGis::UnknownUnit )
+ {
+ myRenderer->setMapUnits( srs.mapUnits() );
+ }
+ mOnTheFlyProjectionStatusButton->setIcon( getThemeIcon( "mIconProjectionEnabled.png" ) );
+ }
+ else
+ {
+ mMapCanvas->mapRenderer()->setProjectionsEnabled( false );
+ }
// set the initial map tool
mMapCanvas->setMapTool( mMapTools.mPan );
@@ -5506,8 +5527,31 @@
int action = mySettings.value( "/qgis/wheel_action", 0 ).toInt();
double zoomFactor = mySettings.value( "/qgis/zoom_factor", 2 ).toDouble();
mMapCanvas->setWheelAction(( QgsMapCanvas::WheelAction ) action, zoomFactor );
- }
+ //apply OTF CRS transformation if necessary
+ if ( mySettings.value( "/Projections/otfTransformEnabled", 0 ).toBool() )
+ {
+ QgsMapRenderer* myRenderer = mMapCanvas->mapRenderer();
+ QString projString = mySettings.value( "/Projections/defaultOTFProjectionString", GEOPROJ4 ).toString();
+ QgsCoordinateReferenceSystem srs;
+ srs.createFromProj4( projString );
+ myRenderer->setProjectionsEnabled( true );
+ myRenderer->setDestinationSrs( srs );
+ // write the projections _proj string_ to project settings
+ QgsProject::instance()->writeEntry( "SpatialRefSys", "/ProjectCRSProj4String", projString );
+ if ( srs.mapUnits() != QGis::UnknownUnit )
+ {
+ myRenderer->setMapUnits( srs.mapUnits() );
+ }
+ }
+ else
+ {
+ QgsMapRenderer* myRenderer = mMapCanvas->mapRenderer();
+ myRenderer->setProjectionsEnabled( false );
+ }
+ mMapCanvas->refresh();
+ }
+
delete optionsDialog;
}
Index: src/ui/qgsoptionsbase.ui
===================================================================
--- src/ui/qgsoptionsbase.ui (revision 15331)
+++ src/ui/qgsoptionsbase.ui (working copy)
@@ -61,7 +61,7 @@
0
0
744
- 817
+ 806
@@ -499,8 +499,8 @@
0
0
- 666
- 466
+ 589
+ 499
@@ -670,8 +670,8 @@
0
0
- 612
- 469
+ 509
+ 471
@@ -950,8 +950,8 @@
0
0
- 310
- 86
+ 258
+ 88
@@ -1025,8 +1025,8 @@
0
0
- 838
- 432
+ 714
+ 441
@@ -1355,8 +1355,8 @@
0
0
- 416
- 568
+ 365
+ 667
@@ -1413,7 +1413,7 @@
- -
+
-
Qt::Vertical
@@ -1426,6 +1426,32 @@
+ -
+
+
+ Always use 'on the fly' CRS transformation
+
+
+ true
+
+
+
-
+
+
+ true
+
+
+
+ -
+
+
+ Select CRS for 'on the fly' transformation ...
+
+
+
+
+
+
@@ -1452,7 +1478,7 @@
0
0
519
- 567
+ 555
@@ -1542,8 +1568,8 @@
0
0
- 407
- 508
+ 337
+ 545