[QGIS Commit] r15344 - in trunk/qgis/src: app ui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Mar 5 16:51:46 EST 2011
Author: timlinux
Date: 2011-03-05 13:51:45 -0800 (Sat, 05 Mar 2011)
New Revision: 15344
Modified:
trunk/qgis/src/app/qgisapp.cpp
trunk/qgis/src/app/qgsoptions.cpp
trunk/qgis/src/app/qgsoptions.h
trunk/qgis/src/ui/qgsoptionsbase.ui
Log:
Applied patch for #363 from Alex Bruy to enable on the fly projection by default.
Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp 2011-03-05 17:30:50 UTC (rev 15343)
+++ trunk/qgis/src/app/qgisapp.cpp 2011-03-05 21:51:45 UTC (rev 15344)
@@ -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;
}
Modified: trunk/qgis/src/app/qgsoptions.cpp
===================================================================
--- trunk/qgis/src/app/qgsoptions.cpp 2011-03-05 17:30:50 UTC (rev 15343)
+++ trunk/qgis/src/app/qgsoptions.cpp 2011-03-05 21:51:45 UTC (rev 15344)
@@ -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()
Modified: trunk/qgis/src/app/qgsoptions.h
===================================================================
--- trunk/qgis/src/app/qgsoptions.h 2011-03-05 17:30:50 UTC (rev 15343)
+++ trunk/qgis/src/app/qgsoptions.h 2011-03-05 21:51:45 UTC (rev 15344)
@@ -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
Modified: trunk/qgis/src/ui/qgsoptionsbase.ui
===================================================================
--- trunk/qgis/src/ui/qgsoptionsbase.ui 2011-03-05 17:30:50 UTC (rev 15343)
+++ trunk/qgis/src/ui/qgsoptionsbase.ui 2011-03-05 21:51:45 UTC (rev 15344)
@@ -60,8 +60,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>744</width>
- <height>817</height>
+ <width>746</width>
+ <height>862</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_12">
@@ -499,8 +499,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>666</width>
- <height>466</height>
+ <width>746</width>
+ <height>481</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_8">
@@ -670,8 +670,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>612</width>
- <height>469</height>
+ <width>746</width>
+ <height>500</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_4">
@@ -950,8 +950,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>310</width>
- <height>86</height>
+ <width>762</width>
+ <height>457</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_10">
@@ -1025,8 +1025,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>838</width>
- <height>432</height>
+ <width>837</width>
+ <height>454</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_13">
@@ -1354,9 +1354,9 @@
<property name="geometry">
<rect>
<x>0</x>
- <y>0</y>
- <width>416</width>
- <height>568</height>
+ <y>-59</y>
+ <width>746</width>
+ <height>516</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_15">
@@ -1414,17 +1414,30 @@
</widget>
</item>
<item row="3" column="0">
- <spacer>
- <property name="orientation">
- <enum>Qt::Vertical</enum>
+ <widget class="QGroupBox" name="grpOtfTransform">
+ <property name="title">
+ <string>Always use 'on the fly' CRS transformation for new projects</string>
</property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>51</width>
- <height>135</height>
- </size>
+ <property name="checkable">
+ <bool>true</bool>
</property>
- </spacer>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <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 CRS for 'on the fly' transformation ...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</item>
</layout>
</widget>
@@ -1451,8 +1464,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>519</width>
- <height>567</height>
+ <width>746</width>
+ <height>551</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_17">
@@ -1542,8 +1555,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>407</width>
- <height>508</height>
+ <width>746</width>
+ <height>548</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_20">
More information about the QGIS-commit
mailing list