Skip to content
Permalink
Browse files

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 0afc88e07f4d526279f5ac640bc386c562b71d99
Showing with 10 additions and 16 deletions.
  1. +8 −12 src/app/qgisapp.cpp
  2. +2 −2 src/app/qgisapp.h
  3. +0 −1 src/app/qgsprojectproperties.cpp
  4. +0 −1 src/gui/layertree/qgslayertreemapcanvasbridge.cpp
@@ -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 * ) ),
@@ -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) */

@@ -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();
@@ -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 )
{
@@ -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();
@@ -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
@@ -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
@@ -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() );
@@ -170,7 +170,6 @@ void QgsLayerTreeMapCanvasBridge::setCanvasLayers()

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

0 comments on commit 0afc88e

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