Skip to content
Permalink
Browse files

Refresh map extent when activating sync extent mode

  • Loading branch information
nyalldawson committed Mar 13, 2017
1 parent ea10cc6 commit b279900726017cb07994a7680a6373f357d6f75e
Showing with 17 additions and 6 deletions.
  1. +16 −6 src/app/qgsmapcanvasdockwidget.cpp
  2. +1 −0 src/app/qgsmapcanvasdockwidget.h
@@ -44,6 +44,7 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa

setWindowTitle( name );
mMapCanvas = new QgsMapCanvas( this );

mPanTool = new QgsMapToolPan( mMapCanvas );
mMapCanvas->setMapTool( mPanTool );

@@ -53,7 +54,11 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa

mMainWidget->layout()->addWidget( mMapCanvas );

connect( mActionSyncView, &QAction::toggled, this, &QgsMapCanvasDockWidget::syncView );
connect( mActionSyncView, &QAction::toggled, this, [ = ]( bool active )
{
syncViewExtent( mMainCanvas );
syncView( active );
} );

mMenu = new QMenu();
connect( mMenu, &QMenu::aboutToShow, this, &QgsMapCanvasDockWidget::menuAboutToShow );
@@ -212,12 +217,8 @@ void QgsMapCanvasDockWidget::syncView( bool enabled )
}
}

void QgsMapCanvasDockWidget::mapExtentChanged()
void QgsMapCanvasDockWidget::syncViewExtent( QgsMapCanvas *sourceCanvas )
{
QgsMapCanvas *sourceCanvas = qobject_cast< QgsMapCanvas * >( sender() );
if ( !sourceCanvas )
return;

// avoid infinite recursion
syncView( false );

@@ -239,6 +240,15 @@ void QgsMapCanvasDockWidget::mapExtentChanged()
syncView( true );
}

void QgsMapCanvasDockWidget::mapExtentChanged()
{
QgsMapCanvas *sourceCanvas = qobject_cast< QgsMapCanvas * >( sender() );
if ( !sourceCanvas )
return;

syncViewExtent( sourceCanvas );
}

void QgsMapCanvasDockWidget::mapCrsChanged()
{
mActionSetCrs->setText( tr( "Change Map CRS (%1)" ).arg( mMapCanvas->mapSettings().destinationCrs().isValid() ?
@@ -85,6 +85,7 @@ class APP_EXPORT QgsMapCanvasDockWidget : public QgsDockWidget, private Ui::QgsM
bool mBlockRotationUpdate = false;
bool mBlockMagnificationUpdate = false;
QgsMapToolPan *mPanTool = nullptr;
void syncViewExtent( QgsMapCanvas *sourceCanvas );
};

/**

0 comments on commit b279900

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