Skip to content

Commit

Permalink
Ensure main canvas is refreshed when atlas preview feature changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 5, 2018
1 parent 3332118 commit 2281dc0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 33 deletions.
36 changes: 6 additions & 30 deletions src/app/layout/qgslayoutdesignerdialog.cpp
Expand Up @@ -1938,9 +1938,6 @@ void QgsLayoutDesignerDialog::atlasPreviewTriggered( bool checked )
{
QgisApp::instance()->mapCanvas()->stopRendering();
atlas->first();
#if 0 //TODO
emit atlasPreviewFeatureChanged();
#endif
}
}
else
Expand Down Expand Up @@ -1981,9 +1978,6 @@ void QgsLayoutDesignerDialog::atlasPageComboEditingFinished()
QgisApp::instance()->mapCanvas()->stopRendering();
loadAtlasPredefinedScalesFromProject();
atlas->seekTo( page - 1 );
#if 0 //TODO
emit atlasPreviewFeatureChanged();
#endif
}
}

Expand All @@ -1996,12 +1990,7 @@ void QgsLayoutDesignerDialog::atlasNext()
QgisApp::instance()->mapCanvas()->stopRendering();

loadAtlasPredefinedScalesFromProject();
if ( printAtlas->next() )
{
#if 0 //TODO
emit atlasPreviewFeatureChanged();
#endif
}
printAtlas->next();
}

void QgsLayoutDesignerDialog::atlasPrevious()
Expand All @@ -2013,12 +2002,7 @@ void QgsLayoutDesignerDialog::atlasPrevious()
QgisApp::instance()->mapCanvas()->stopRendering();

loadAtlasPredefinedScalesFromProject();
if ( printAtlas->previous() )
{
#if 0 //TODO
emit atlasPreviewFeatureChanged();
#endif
}
printAtlas->previous();
}

void QgsLayoutDesignerDialog::atlasFirst()
Expand All @@ -2030,12 +2014,7 @@ void QgsLayoutDesignerDialog::atlasFirst()
QgisApp::instance()->mapCanvas()->stopRendering();

loadAtlasPredefinedScalesFromProject();
if ( printAtlas->first() )
{
#if 0 //TODO
emit atlasPreviewFeatureChanged();
#endif
}
printAtlas->first();
}

void QgsLayoutDesignerDialog::atlasLast()
Expand All @@ -2047,12 +2026,7 @@ void QgsLayoutDesignerDialog::atlasLast()
QgisApp::instance()->mapCanvas()->stopRendering();

loadAtlasPredefinedScalesFromProject();
if ( printAtlas->last() )
{
#if 0 //TODO
emit atlasPreviewFeatureChanged();
#endif
}
printAtlas->last();
}

void QgsLayoutDesignerDialog::printAtlas()
Expand Down Expand Up @@ -3478,6 +3452,8 @@ void QgsLayoutDesignerDialog::atlasFeatureChanged( const QgsFeature &feature )
mapCanvas->expressionContextScope().addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "atlas_feature" ), QVariant::fromValue( feature ), true ) );
mapCanvas->expressionContextScope().addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "atlas_featureid" ), feature.id(), true ) );
mapCanvas->expressionContextScope().addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "atlas_geometry" ), QVariant::fromValue( feature.geometry() ), true ) );
mapCanvas->stopRendering();
mapCanvas->refreshAllLayers();
}

void QgsLayoutDesignerDialog::loadAtlasPredefinedScalesFromProject()
Expand Down
3 changes: 0 additions & 3 deletions src/app/qgisapp.cpp
Expand Up @@ -7487,9 +7487,6 @@ QgsLayoutDesignerDialog *QgisApp::openLayoutDesignerDialog( QgsMasterLayoutInter

newDesigner->open();
emit layoutDesignerOpened( newDesigner->iface() );
#if 0 //TODO
connect( newDesigner, &QgsLayoutDesignerDialog::atlasPreviewFeatureChanged, this, &QgisApp::refreshMapCanvas );
#endif

return newDesigner;
}
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -696,6 +696,7 @@ void QgsMapCanvas::stopRendering()
mJob->cancelWithoutBlocking();
mJob = nullptr;
}
stopPreviewJobs();
}

//the format defaults to "PNG" if not specified
Expand Down

0 comments on commit 2281dc0

Please sign in to comment.