Skip to content
Permalink
Browse files

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.
  • Loading branch information
jef-n committed Feb 6, 2012
1 parent af71f5f commit eac3a8ff4d37ec6c192af6bf4795fa2ab6d17502
Showing with 36 additions and 6 deletions.
  1. +32 −5 src/app/qgsprojectproperties.cpp
  2. +3 −0 src/app/qgsprojectproperties.h
  3. +1 −1 src/core/qgsmaprenderer.cpp
@@ -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() ) );
@@ -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
@@ -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" ) ) );
@@ -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()
@@ -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()
@@ -123,4 +123,7 @@ class QgsProjectProperties : public QDialog, private Ui::QgsProjectPropertiesBas
* Function to restore dialog window state
*/
void restoreState();

long mProjectSrsId;
long mLayerSrsId;
};
@@ -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 );

0 comments on commit eac3a8f

Please sign in to comment.
You can’t perform that action at this time.