Skip to content

Commit eac3a8f

Browse files
committedFeb 6, 2012
fix #3742:
- after CRS changes reproject canvas extent regardless of OTFR - toggling OTFR off, switches the project CRS to the current layer CRS (or first layer, if no layer is active). - toggling OTFR also saves the previous CRS setting and restores the previous selected CRS.
1 parent af71f5f commit eac3a8f

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed
 

‎src/app/qgsprojectproperties.cpp

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141

4242

4343
QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *parent, Qt::WFlags fl )
44-
: QDialog( parent, fl ), mMapCanvas( mapCanvas )
44+
: QDialog( parent, fl )
45+
, mMapCanvas( mapCanvas )
4546
{
4647
setupUi( this );
4748
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
@@ -63,9 +64,9 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
6364
cbxProjectionEnabled->setChecked( myProjectionEnabled );
6465
btnGrpMapUnits->setEnabled( !myProjectionEnabled );
6566

66-
long myCRSID = myRenderer->destinationCrs().srsid();
67-
QgsDebugMsg( "Read project CRSID: " + QString::number( myCRSID ) );
68-
projectionSelector->setSelectedCrsId( myCRSID );
67+
mProjectSrsId = myRenderer->destinationCrs().srsid();
68+
QgsDebugMsg( "Read project CRSID: " + QString::number( mProjectSrsId ) );
69+
projectionSelector->setSelectedCrsId( mProjectSrsId );
6970

7071
///////////////////////////////////////////////////////////
7172
// Properties stored in QgsProject
@@ -112,6 +113,19 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
112113

113114
const QMap<QString, QgsMapLayer*> &mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
114115

116+
if ( mMapCanvas->currentLayer() )
117+
{
118+
mLayerSrsId = mMapCanvas->currentLayer()->crs().srsid();
119+
}
120+
else if ( mapLayers.size() > 0 )
121+
{
122+
mLayerSrsId = mapLayers.begin().value()->crs().srsid();
123+
}
124+
else
125+
{
126+
mLayerSrsId = mProjectSrsId;
127+
}
128+
115129
twIdentifyLayers->setColumnCount( 3 );
116130
twIdentifyLayers->horizontalHeader()->setVisible( true );
117131
twIdentifyLayers->setHorizontalHeaderItem( 0, new QTableWidgetItem( tr( "Layer" ) ) );
@@ -454,6 +468,17 @@ void QgsProjectProperties::on_pbnCanvasColor_clicked()
454468
void QgsProjectProperties::on_cbxProjectionEnabled_stateChanged( int state )
455469
{
456470
btnGrpMapUnits->setEnabled( state == Qt::Unchecked );
471+
472+
if ( state != Qt::Checked )
473+
{
474+
mProjectSrsId = projectionSelector->selectedCrsId();
475+
projectionSelector->setSelectedCrsId( mLayerSrsId );
476+
}
477+
else
478+
{
479+
mLayerSrsId = projectionSelector->selectedCrsId();
480+
projectionSelector->setSelectedCrsId( mProjectSrsId );
481+
}
457482
}
458483

459484
void QgsProjectProperties::setMapUnitsToCurrentProjection()
@@ -541,7 +566,9 @@ void QgsProjectProperties::on_pbnWMSAddSRS_clicked()
541566
void QgsProjectProperties::on_pbnWMSRemoveSRS_clicked()
542567
{
543568
foreach( QListWidgetItem *item, mWMSList->selectedItems() )
544-
delete item;
569+
{
570+
delete item;
571+
}
545572
}
546573

547574
void QgsProjectProperties::on_pbnWMSSetUsedSRS_clicked()

‎src/app/qgsprojectproperties.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,7 @@ class QgsProjectProperties : public QDialog, private Ui::QgsProjectPropertiesBas
123123
* Function to restore dialog window state
124124
*/
125125
void restoreState();
126+
127+
long mProjectSrsId;
128+
long mLayerSrsId;
126129
};

‎src/core/qgsmaprenderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ void QgsMapRenderer::setDestinationCrs( const QgsCoordinateReferenceSystem& crs
683683
if ( *mDestCRS != crs )
684684
{
685685
QgsRectangle rect;
686-
if ( hasCrsTransformEnabled() && !mExtent.isEmpty() )
686+
if ( !mExtent.isEmpty() )
687687
{
688688
QgsCoordinateTransform transform( *mDestCRS, crs );
689689
rect = transform.transformBoundingBox( mExtent );

0 commit comments

Comments
 (0)
Please sign in to comment.