Skip to content
Permalink
Browse files

[layouts] Don't refresh the map canvas multiple times during atlas ex…

…ports

Fixes #30144
  • Loading branch information
nyalldawson committed May 26, 2020
1 parent 38673f5 commit 57519e9faa95fbfe6196134d9128caee48cb4b84
Showing with 37 additions and 1 deletion.
  1. +33 −1 src/app/layout/qgslayoutdesignerdialog.cpp
  2. +4 −0 src/app/layout/qgslayoutdesignerdialog.h
@@ -259,6 +259,30 @@ static bool cmpByText_( QAction *a, QAction *b )
}


class QgsAtlasExportGuard
{
public:

QgsAtlasExportGuard( QgsLayoutDesignerDialog *dialog )
: mDialog( dialog )
{
mDialog->mIsExportingAtlas = true;
}

~QgsAtlasExportGuard()
{
mDialog->mIsExportingAtlas = false;

// need to update the GUI to reflect the final atlas feature
mDialog->atlasFeatureChanged( mDialog->currentLayout()->reportContext().feature() );
}

private:
QgsLayoutDesignerDialog *mDialog = nullptr;

};


QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFlags flags )
: QMainWindow( parent, flags )
, mInterface( new QgsAppLayoutDesignerInterface( this ) )
@@ -2764,6 +2788,7 @@ void QgsLayoutDesignerDialog::exportAtlasToRaster()

mView->setPaintingEnabled( false );
QgsTemporaryCursorOverride cursorOverride( Qt::BusyCursor );
QgsAtlasExportGuard exportingAtlas( this );

QString error;
std::unique_ptr< QgsFeedback > feedback = qgis::make_unique< QgsFeedback >();
@@ -2928,6 +2953,7 @@ void QgsLayoutDesignerDialog::exportAtlasToSvg()

mView->setPaintingEnabled( false );
QgsTemporaryCursorOverride cursorOverride( Qt::BusyCursor );
QgsAtlasExportGuard exportingAtlas( this );

QString error;
std::unique_ptr< QgsFeedback > feedback = qgis::make_unique< QgsFeedback >();
@@ -3148,6 +3174,8 @@ void QgsLayoutDesignerDialog::exportAtlasToPdf()

mView->setPaintingEnabled( false );
QgsTemporaryCursorOverride cursorOverride( Qt::BusyCursor );
QgsAtlasExportGuard exportingAtlas( this );

pdfSettings.rasterizeWholeImage = mLayout->customProperty( QStringLiteral( "rasterize" ), false ).toBool();

QString error;
@@ -3284,6 +3312,7 @@ void QgsLayoutDesignerDialog::exportReportToRaster()

mView->setPaintingEnabled( false );
QgsTemporaryCursorOverride cursorOverride( Qt::BusyCursor );
QgsAtlasExportGuard exportingAtlas( this );

QString error;
std::unique_ptr< QgsFeedback > feedback = qgis::make_unique< QgsFeedback >();
@@ -3400,6 +3429,7 @@ void QgsLayoutDesignerDialog::exportReportToSvg()

mView->setPaintingEnabled( false );
QgsTemporaryCursorOverride cursorOverride( Qt::BusyCursor );
QgsAtlasExportGuard exportingAtlas( this );

QString error;
std::unique_ptr< QgsFeedback > feedback = qgis::make_unique< QgsFeedback >();
@@ -3533,6 +3563,7 @@ void QgsLayoutDesignerDialog::exportReportToPdf()

mView->setPaintingEnabled( false );
QgsTemporaryCursorOverride cursorOverride( Qt::BusyCursor );
QgsAtlasExportGuard exportingAtlas( this );

pdfSettings.rasterizeWholeImage = rasterize;

@@ -4427,7 +4458,8 @@ void QgsLayoutDesignerDialog::updateAtlasPageComboBox( int pageCount )

void QgsLayoutDesignerDialog::atlasFeatureChanged( const QgsFeature &feature )
{
//TODO - this should be disabled during an export
if ( mIsExportingAtlas )
return;

QgsPrintLayout *printLayout = qobject_cast< QgsPrintLayout *>( mLayout );
if ( !printLayout )
@@ -488,6 +488,8 @@ class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerB

QgsLayoutGuideWidget *mGuideWidget = nullptr;

bool mIsExportingAtlas = false;

//! Save window state
void saveWindowState();

@@ -559,6 +561,8 @@ class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerB

//! update default action of toolbutton
void toolButtonActionTriggered( QAction * );

friend class QgsAtlasExportGuard;
};

#endif // QGSLAYOUTDESIGNERDIALOG_H

0 comments on commit 57519e9

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