Skip to content

Commit

Permalink
fix #3742:
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
jef-n committed Feb 6, 2012
1 parent af71f5f commit eac3a8f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
37 changes: 32 additions & 5 deletions src/app/qgsprojectproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@


QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *parent, Qt::WFlags fl )
: QDialog( parent, fl ), mMapCanvas( mapCanvas )
: QDialog( parent, fl )
, mMapCanvas( mapCanvas )
{
setupUi( this );
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
Expand All @@ -63,9 +64,9 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
cbxProjectionEnabled->setChecked( myProjectionEnabled );
btnGrpMapUnits->setEnabled( !myProjectionEnabled );

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

///////////////////////////////////////////////////////////
// Properties stored in QgsProject
Expand Down Expand Up @@ -112,6 +113,19 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa

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

if ( mMapCanvas->currentLayer() )
{
mLayerSrsId = mMapCanvas->currentLayer()->crs().srsid();
}
else if ( mapLayers.size() > 0 )
{
mLayerSrsId = mapLayers.begin().value()->crs().srsid();
}
else
{
mLayerSrsId = mProjectSrsId;
}

twIdentifyLayers->setColumnCount( 3 );
twIdentifyLayers->horizontalHeader()->setVisible( true );
twIdentifyLayers->setHorizontalHeaderItem( 0, new QTableWidgetItem( tr( "Layer" ) ) );
Expand Down Expand Up @@ -454,6 +468,17 @@ void QgsProjectProperties::on_pbnCanvasColor_clicked()
void QgsProjectProperties::on_cbxProjectionEnabled_stateChanged( int state )
{
btnGrpMapUnits->setEnabled( state == Qt::Unchecked );

if ( state != Qt::Checked )
{
mProjectSrsId = projectionSelector->selectedCrsId();
projectionSelector->setSelectedCrsId( mLayerSrsId );
}
else
{
mLayerSrsId = projectionSelector->selectedCrsId();
projectionSelector->setSelectedCrsId( mProjectSrsId );
}
}

void QgsProjectProperties::setMapUnitsToCurrentProjection()
Expand Down Expand Up @@ -541,7 +566,9 @@ void QgsProjectProperties::on_pbnWMSAddSRS_clicked()
void QgsProjectProperties::on_pbnWMSRemoveSRS_clicked()
{
foreach( QListWidgetItem *item, mWMSList->selectedItems() )
delete item;
{
delete item;
}
}

void QgsProjectProperties::on_pbnWMSSetUsedSRS_clicked()
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgsprojectproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,7 @@ class QgsProjectProperties : public QDialog, private Ui::QgsProjectPropertiesBas
* Function to restore dialog window state
*/
void restoreState();

long mProjectSrsId;
long mLayerSrsId;
};
2 changes: 1 addition & 1 deletion src/core/qgsmaprenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ void QgsMapRenderer::setDestinationCrs( const QgsCoordinateReferenceSystem& crs
if ( *mDestCRS != crs )
{
QgsRectangle rect;
if ( hasCrsTransformEnabled() && !mExtent.isEmpty() )
if ( !mExtent.isEmpty() )
{
QgsCoordinateTransform transform( *mDestCRS, crs );
rect = transform.transformBoundingBox( mExtent );
Expand Down

0 comments on commit eac3a8f

Please sign in to comment.