Skip to content

Commit

Permalink
[composer] Refresh main map canvas when atlas preview feature changes…
Browse files Browse the repository at this point in the history
…, allows for easier customisation of maps styled using $atlasfeatureid expressions
  • Loading branch information
nyalldawson committed Jan 1, 2014
1 parent 8a11be8 commit 12eb44e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/app/composer/qgscomposer.cpp
Expand Up @@ -507,6 +507,8 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
mActionExportAtlasAsImage->setEnabled( false );
mActionExportAtlasAsSVG->setEnabled( false );
mActionExportAtlasAsPDF->setEnabled( false );
QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
connect( atlasMap, SIGNAL( toggled( bool ) ), this, SLOT( toggleAtlasControls( bool ) ) );

// Create size grip (needed by Mac OS X for QMainWindow if QStatusBar is not visible)
//should not be needed now that composer has a status bar?
Expand Down Expand Up @@ -857,6 +859,7 @@ void QgsComposer::on_mActionAtlasPreview_triggered( bool checked )
if ( checked )
{
atlasMap->firstFeature();
emit( atlasPreviewFeatureChanged() );
}
else
{
Expand All @@ -875,7 +878,7 @@ void QgsComposer::on_mActionAtlasNext_triggered()
}

atlasMap->nextFeature();

emit( atlasPreviewFeatureChanged() );
}

void QgsComposer::on_mActionAtlasPrev_triggered()
Expand All @@ -887,7 +890,7 @@ void QgsComposer::on_mActionAtlasPrev_triggered()
}

atlasMap->prevFeature();

emit( atlasPreviewFeatureChanged() );
}

void QgsComposer::on_mActionAtlasFirst_triggered()
Expand All @@ -899,6 +902,7 @@ void QgsComposer::on_mActionAtlasFirst_triggered()
}

atlasMap->firstFeature();
emit( atlasPreviewFeatureChanged() );
}

void QgsComposer::on_mActionAtlasLast_triggered()
Expand All @@ -910,6 +914,7 @@ void QgsComposer::on_mActionAtlasLast_triggered()
}

atlasMap->lastFeature();
emit( atlasPreviewFeatureChanged() );
}

QgsMapCanvas *QgsComposer::mapCanvas( void )
Expand Down
3 changes: 3 additions & 0 deletions src/app/composer/qgscomposer.h
Expand Up @@ -123,6 +123,9 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
//!Composer deletes the old composerview when loading a template
void composerWillBeRemoved( QgsComposerView* v );

//! Is emitted when the atlas preview feature changes
void atlasPreviewFeatureChanged();

public slots:
//! Zoom to full extent of the paper
void on_mActionZoomAll_triggered();
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -5048,6 +5048,7 @@ QgsComposer* QgisApp::createNewComposer( QString title )
emit composerAdded( newComposerObject->view() );
connect( newComposerObject, SIGNAL( composerAdded( QgsComposerView* ) ), this, SIGNAL( composerAdded( QgsComposerView* ) ) );
connect( newComposerObject, SIGNAL( composerWillBeRemoved( QgsComposerView* ) ), this, SIGNAL( composerWillBeRemoved( QgsComposerView* ) ) );
connect( newComposerObject, SIGNAL( atlasPreviewFeatureChanged() ), this, SLOT( refreshMapCanvas() ) );
markDirty();
return newComposerObject;
}
Expand Down Expand Up @@ -5137,6 +5138,7 @@ bool QgisApp::loadComposersFromProject( const QDomDocument& doc )
emit composerAdded( composer->view() );
connect( composer, SIGNAL( composerAdded( QgsComposerView* ) ), this, SIGNAL( composerAdded( QgsComposerView* ) ) );
connect( composer, SIGNAL( composerWillBeRemoved( QgsComposerView* ) ), this, SIGNAL( composerWillBeRemoved( QgsComposerView* ) ) );
connect( composer, SIGNAL( atlasPreviewFeatureChanged() ), this, SLOT( refreshMapCanvas() ) );
}
return true;
}
Expand Down

0 comments on commit 12eb44e

Please sign in to comment.