Skip to content
Permalink
Browse files

[composer] Refresh refetches atlas feature from provider, more remova…

…l of duplicate map redraws
  • Loading branch information
nyalldawson committed Sep 30, 2014
1 parent f23e38d commit fb7415c3ff1ab5bf926b6278d9b48cb068ca4b52
@@ -175,9 +175,11 @@ public:
int numFeatures() const;

/**Prepare the atlas map for the given feature. Sets the extent and context variables
* @param i feature number
* @param updateMaps set to true to redraw maps and recalculate their extent
* @returns true if feature was successfully prepared
*/
bool prepareForFeature( const int i );
bool prepareForFeature( const int i, const bool updateMaps = true );

/**Prepare the atlas map for the given feature. Sets the extent and context variables
* @returns true if feature was successfully prepared
@@ -212,17 +214,24 @@ public:
number of matching features. Must be called after prepareForFeature( i ) */
int updateFeatures();

void nextFeature();
void prevFeature();
void lastFeature();
void firstFeature();

/** Returns the current atlas feature. Must be called after prepareForFeature( i ). */
QgsFeature* currentFeature();

/** Recalculates the bounds of an atlas driven map */
void prepareMap( QgsComposerMap* map );

public slots:

/**Refreshes the current atlas feature, by refetching its attributes from the vector layer provider
* @note added in QGIS 2.5
*/
void refreshFeature();

void nextFeature();
void prevFeature();
void lastFeature();
void firstFeature();

signals:
/** emitted when one of the parameters changes */
void parameterChanged();
16 src/app/composer/qgscomposer.cpp 100644 → 100755
@@ -1119,16 +1119,14 @@ void QgsComposer::on_mActionRefreshView_triggered()
return;
}

//refresh preview of all composer maps
QMap<QgsComposerItem*, QWidget*>::iterator it = mItemWidgetMap.begin();
for ( ; it != mItemWidgetMap.end(); ++it )
//refresh atlas feature first, to update attributes
if ( mComposition->atlasMode() == QgsComposition::PreviewAtlas )
{
QgsComposerMap* map = dynamic_cast<QgsComposerMap*>( it.key() );
if ( map && !map->isDrawing() )
{
map->cache();
map->update();
}
//block signals from atlas, since the later call to mComposition->refreshItems() will
//also trigger items to refresh atlas dependant properties
mComposition->atlasComposition().blockSignals( true );
mComposition->atlasComposition().refreshFeature();
mComposition->atlasComposition().blockSignals( false );
}

mComposition->refreshItems();
@@ -378,7 +378,12 @@ bool QgsAtlasComposition::prepareForFeature( const QgsFeature * feat )
return prepareForFeature( featureI );
}

bool QgsAtlasComposition::prepareForFeature( const int featureI )
void QgsAtlasComposition::refreshFeature()
{
prepareForFeature( mCurrentFeatureNo, false );
}

bool QgsAtlasComposition::prepareForFeature( const int featureI, const bool updateMaps )
{
if ( !mCoverageLayer )
{
@@ -417,6 +422,12 @@ bool QgsAtlasComposition::prepareForFeature( const int featureI )
return true;
}

if ( !updateMaps )
{
//nothing more to do
return true;
}

//update composer maps

//build a list of atlas-enabled composer maps
@@ -204,9 +204,11 @@ class CORE_EXPORT QgsAtlasComposition : public QObject
int numFeatures() const;

/**Prepare the atlas map for the given feature. Sets the extent and context variables
* @param i feature number
* @param updateMaps set to true to redraw maps and recalculate their extent
* @returns true if feature was successfully prepared
*/
bool prepareForFeature( const int i );
bool prepareForFeature( const int i, const bool updateMaps = true );

/**Prepare the atlas map for the given feature. Sets the extent and context variables
* @returns true if feature was successfully prepared
@@ -241,17 +243,24 @@ class CORE_EXPORT QgsAtlasComposition : public QObject
number of matching features. Must be called after prepareForFeature( i ) */
int updateFeatures();

void nextFeature();
void prevFeature();
void lastFeature();
void firstFeature();

/** Returns the current atlas feature. Must be called after prepareForFeature( i ). */
QgsFeature* currentFeature() { return &mCurrentFeature; }

/** Recalculates the bounds of an atlas driven map */
void prepareMap( QgsComposerMap* map );

public slots:

/**Refreshes the current atlas feature, by refetching its attributes from the vector layer provider
* @note added in QGIS 2.5
*/
void refreshFeature();

void nextFeature();
void prevFeature();
void lastFeature();
void firstFeature();

signals:
/** emitted when one of the parameters changes */
void parameterChanged();

0 comments on commit fb7415c

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