Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make sure main canvas is always synced to project CRS (part 1)
Fix #16337
  • Loading branch information
nyalldawson committed Mar 14, 2017
1 parent 1aee424 commit 0afc88e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
20 changes: 8 additions & 12 deletions src/app/qgisapp.cpp
Expand Up @@ -2840,9 +2840,14 @@ void QgisApp::setupConnections()
connect( mMapCanvas, &QgsMapCanvas::keyPressed,
this, &QgisApp::mapCanvas_keyPressed );

// connect renderer
connect( mMapCanvas, &QgsMapCanvas::destinationCrsChanged,
this, &QgisApp::destinationCrsChanged );
// project crs connections
connect( QgsProject::instance(), &QgsProject::crsChanged,
this, &QgisApp::updateCrsStatusBar );
connect( QgsProject::instance(), &QgsProject::crsChanged,
this, [ = ]
{
mMapCanvas->setDestinationCrs( QgsProject::instance()->crs() );
} );

// connect legend signals
connect( mLayerTreeView, SIGNAL( currentLayerChanged( QgsMapLayer * ) ),
Expand Down Expand Up @@ -4626,13 +4631,10 @@ void QgisApp::fileNew( bool promptToSaveFlag, bool forceBlank )
// set project CRS
QString defCrs = settings.value( QStringLiteral( "Projections/projectDefaultCrs" ), GEO_EPSG_CRS_AUTHID ).toString();
QgsCoordinateReferenceSystem srs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( defCrs );
mMapCanvas->setDestinationCrs( srs );
// write the projections _proj string_ to project settings
prj->setCrs( srs );
prj->setDirty( false );

updateCrsStatusBar();

/** New Empty Project Created
(before attempting to load custom project templates/filepaths) */

Expand Down Expand Up @@ -8791,7 +8793,6 @@ void QgisApp::setProjectCrsFromLayer()

QgsCoordinateReferenceSystem crs = mLayerTreeView->currentLayer()->crs();
mMapCanvas->freeze();
mMapCanvas->setDestinationCrs( crs );
QgsProject::instance()->setCrs( crs );
mMapCanvas->freeze( false );
mMapCanvas->refresh();
Expand Down Expand Up @@ -10316,11 +10317,6 @@ void QgisApp::updateCrsStatusBar()
}
}

void QgisApp::destinationCrsChanged()
{
updateCrsStatusBar();
}

// slot to update the progress bar in the status bar
void QgisApp::showProgress( int progress, int totalSteps )
{
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgisapp.h
Expand Up @@ -1204,7 +1204,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
void displayMessage( const QString &title, const QString &message, QgsMessageBar::MessageLevel level );
void removeMapToolMessage();
void updateMouseCoordinatePrecision();
void destinationCrsChanged();
// void debugHook();
//! Add a Layer Definition file
void addLayerDefinition();
Expand Down Expand Up @@ -1396,6 +1395,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow

void annotationCreated( QgsAnnotation *annotation );

void updateCrsStatusBar();

signals:

/** Emitted when a key is pressed and we want non widget sublasses to be able
Expand Down Expand Up @@ -1531,7 +1532,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
void createOverview();
void createCanvasTools();
void createMapTips();
void updateCrsStatusBar();
void createDecorations();

//! Do histogram stretch for singleband gray / multiband color rasters
Expand Down
1 change: 0 additions & 1 deletion src/app/qgsprojectproperties.cpp
Expand Up @@ -734,7 +734,6 @@ void QgsProjectProperties::apply()
{
QgsCoordinateReferenceSystem srs = projectionSelector->crs();
QgsProject::instance()->setCrs( srs );
mMapCanvas->setDestinationCrs( srs );
if ( srs.isValid() )
{
QgsDebugMsg( QString( "Selected CRS " ) + srs.description() );
Expand Down
1 change: 0 additions & 1 deletion src/gui/layertree/qgslayertreemapcanvasbridge.cpp
Expand Up @@ -170,7 +170,6 @@ void QgsLayerTreeMapCanvasBridge::setCanvasLayers()

if ( mFirstCRS.isValid() && firstLayers )
{
mCanvas->setDestinationCrs( mFirstCRS );
QgsProject::instance()->setCrs( mFirstCRS );
}

Expand Down

0 comments on commit 0afc88e

Please sign in to comment.