QGIS API Documentation
2.2.0-Valmiera
|
Class used to render an Atlas, iterating over geometry features. More...
#include <qgsatlascomposition.h>
Public Types | |
typedef QMap< QgsFeatureId, QVariant > | SorterKeys |
Signals | |
void | parameterChanged () |
emitted when one of the parameters changes | |
void | toggled (bool) |
emitted when atlas is enabled or disabled | |
void | statusMsgChanged (QString message) |
Is emitted when the atlas has an updated status bar message for the composer window. | |
void | coverageLayerChanged (QgsVectorLayer *layer) |
Is emitted when the coverage layer for an atlas changes. |
Public Member Functions | |
QgsAtlasComposition (QgsComposition *composition) | |
~QgsAtlasComposition () | |
bool | enabled () const |
Is the atlas generation enabled ? | |
void | setEnabled (bool e) |
QgsComposerMap * | composerMap () const |
Returns the map used by the atlas. | |
void | setComposerMap (QgsComposerMap *map) |
Sets the map used by the atlas. | |
bool | hideCoverage () const |
void | setHideCoverage (bool hide) |
bool | fixedScale () const |
Returns whether the atlas map uses a fixed scale. | |
void | setFixedScale (bool fixed) |
Sets whether the atlas map should use a fixed scale. | |
float | margin () const |
Returns the margin for the atlas map. | |
void | setMargin (float margin) |
Sets the margin for the atlas map. | |
QString | filenamePattern () const |
void | setFilenamePattern (const QString &pattern) |
QgsVectorLayer * | coverageLayer () const |
void | setCoverageLayer (QgsVectorLayer *lmap) |
bool | singleFile () const |
void | setSingleFile (bool single) |
bool | sortFeatures () const |
void | setSortFeatures (bool doSort) |
bool | sortAscending () const |
void | setSortAscending (bool ascending) |
bool | filterFeatures () const |
void | setFilterFeatures (bool doFilter) |
QString | featureFilter () const |
void | setFeatureFilter (const QString &expression) |
int | sortKeyAttributeIndex () const |
void | setSortKeyAttributeIndex (int idx) |
bool | beginRender () |
Begins the rendering. | |
void | endRender () |
Ends the rendering. | |
int | numFeatures () const |
Returns the number of features in the coverage layer. | |
void | prepareForFeature (int i) |
Prepare the atlas map for the given feature. | |
void | prepareForFeature (QgsFeature *feat) |
Prepare the atlas map for the given feature. | |
const QString & | currentFilename () const |
Returns the current filename. | |
void | writeXML (QDomElement &elem, QDomDocument &doc) const |
void | readXML (const QDomElement &elem, const QDomDocument &doc) |
QgsComposition * | composition () |
int | updateFeatures () |
Requeries the current atlas coverage layer and applies filtering and sorting. | |
void | nextFeature () |
void | prevFeature () |
void | lastFeature () |
void | firstFeature () |
QgsFeature * | currentFeature () |
Returns the current atlas feature. | |
void | prepareMap (QgsComposerMap *map) |
Recalculates the bounds of an atlas driven map. |
Private Member Functions | |
void | updateFilenameExpression () |
Updates the filename expression. | |
void | evalFeatureFilename () |
Evaluates filename for current feature. | |
void | updateAtlasMaps () |
void | computeExtent (QgsComposerMap *map) |
Private Attributes | |
QgsComposition * | mComposition |
bool | mEnabled |
bool | mHideCoverage |
QString | mFilenamePattern |
QgsVectorLayer * | mCoverageLayer |
bool | mSingleFile |
QgsCoordinateTransform | mTransform |
QString | mCurrentFilename |
bool | mSortFeatures |
bool | mSortAscending |
int | mCurrentFeatureNo |
SorterKeys | mFeatureKeys |
int | mSortKeyAttributeIdx |
bool | mFilterFeatures |
QString | mFeatureFilter |
QVector< QgsFeatureId > | mFeatureIds |
QgsFeature | mCurrentFeature |
std::auto_ptr< QgsExpression > | mFilenameExpr |
QgsRectangle | mTransformedFeatureBounds |
Class used to render an Atlas, iterating over geometry features.
prepareForFeature() modifies the atlas map's extent to zoom on the given feature. This class is used for printing, exporting to PDF and images.
Definition at line 37 of file qgsatlascomposition.h.
typedef QMap< QgsFeatureId, QVariant > QgsAtlasComposition::SorterKeys |
Definition at line 179 of file qgsatlascomposition.h.
QgsAtlasComposition::QgsAtlasComposition | ( | QgsComposition * | composition | ) |
Definition at line 31 of file qgsatlascomposition.cpp.
References QgsExpression::setSpecialColumn().
QgsAtlasComposition::~QgsAtlasComposition | ( | ) |
Definition at line 49 of file qgsatlascomposition.cpp.
bool QgsAtlasComposition::beginRender | ( | ) |
Begins the rendering.
Returns true if successful, false if no matching atlas features found.
Definition at line 259 of file qgsatlascomposition.cpp.
References mComposition, mCoverageLayer, mFeatureIds, QgsComposition::numPages(), QgsExpression::setSpecialColumn(), and updateFeatures().
Referenced by QgsComposition::setAtlasMode().
QgsComposerMap * QgsAtlasComposition::composerMap | ( | ) | const |
Returns the map used by the atlas.
Definition at line 76 of file qgsatlascomposition.cpp.
References QgsComposerMap::atlasDriven(), QgsComposition::composerItems(), and mComposition.
Referenced by fixedScale(), margin(), readXML(), setFixedScale(), and setMargin().
|
inline |
Definition at line 123 of file qgsatlascomposition.h.
|
private |
Definition at line 446 of file qgsatlascomposition.cpp.
References QgsMapLayer::crs(), QgsMapRenderer::destinationCrs(), QgsFeature::geometry(), QgsComposerMap::mapRenderer(), mCoverageLayer, mCurrentFeature, mTransform, mTransformedFeatureBounds, QgsCoordinateTransform::setDestCRS(), QgsCoordinateTransform::setSourceCrs(), and QgsGeometry::transform().
Referenced by prepareForFeature(), and prepareMap().
|
inline |
Definition at line 81 of file qgsatlascomposition.h.
Referenced by QgsComposerMap::layersToRender(), and QgsComposerLabel::QgsComposerLabel().
|
signal |
Is emitted when the coverage layer for an atlas changes.
Referenced by setCoverageLayer().
|
inline |
Returns the current atlas feature.
Must be called after prepareForFeature( i ).
Definition at line 135 of file qgsatlascomposition.h.
Referenced by QgsComposerShape::drawShapeUsingSymbol(), QgsPaperItem::paint(), and QgsComposerLabel::QgsComposerLabel().
const QString & QgsAtlasComposition::currentFilename | ( | ) | const |
Returns the current filename.
Must be called after prepareForFeature( i )
Definition at line 533 of file qgsatlascomposition.cpp.
References mCurrentFilename.
|
inline |
Is the atlas generation enabled ?
Definition at line 45 of file qgsatlascomposition.h.
Referenced by QgsComposerShape::drawShapeUsingSymbol(), and QgsPaperItem::paint().
void QgsAtlasComposition::endRender | ( | ) |
Ends the rendering.
Restores original extent
Definition at line 280 of file qgsatlascomposition.cpp.
References QgsComposition::composerItems(), mComposition, mCoverageLayer, and updateAtlasMaps().
Referenced by QgsComposition::setAtlasMode().
|
private |
Evaluates filename for current feature.
Definition at line 690 of file qgsatlascomposition.cpp.
References mCoverageLayer, mCurrentFeature, mCurrentFilename, mFilenameExpr, mFilenamePattern, mSingleFile, QgsVectorLayer::pendingFields(), and tr.
Referenced by prepareForFeature(), and updateFilenameExpression().
|
inline |
Definition at line 96 of file qgsatlascomposition.h.
|
inline |
Definition at line 78 of file qgsatlascomposition.h.
|
inline |
Definition at line 93 of file qgsatlascomposition.h.
void QgsAtlasComposition::firstFeature | ( | ) |
Definition at line 342 of file qgsatlascomposition.cpp.
References mCurrentFeatureNo, and prepareForFeature().
Referenced by updateFeatures().
bool QgsAtlasComposition::fixedScale | ( | ) | const |
Returns whether the atlas map uses a fixed scale.
Definition at line 107 of file qgsatlascomposition.cpp.
References QgsComposerMap::atlasFixedScale(), and composerMap().
Referenced by readXML().
|
inline |
Definition at line 57 of file qgsatlascomposition.h.
Referenced by QgsComposerMap::layersToRender().
void QgsAtlasComposition::lastFeature | ( | ) |
Definition at line 348 of file qgsatlascomposition.cpp.
References mCurrentFeatureNo, mFeatureIds, and prepareForFeature().
float QgsAtlasComposition::margin | ( | ) | const |
Returns the margin for the atlas map.
Definition at line 131 of file qgsatlascomposition.cpp.
References QgsComposerMap::atlasMargin(), and composerMap().
Referenced by readXML().
void QgsAtlasComposition::nextFeature | ( | ) |
Definition at line 320 of file qgsatlascomposition.cpp.
References mCurrentFeatureNo, mFeatureIds, and prepareForFeature().
int QgsAtlasComposition::numFeatures | ( | ) | const |
Returns the number of features in the coverage layer.
Definition at line 315 of file qgsatlascomposition.cpp.
References mFeatureIds.
|
signal |
emitted when one of the parameters changes
Referenced by readXML().
void QgsAtlasComposition::prepareForFeature | ( | int | i | ) |
Prepare the atlas map for the given feature.
Sets the extent and context variables
Definition at line 360 of file qgsatlascomposition.cpp.
References QgsComposerMap::atlasDriven(), QgsComposition::composerItems(), computeExtent(), evalFeatureFilename(), QgsFeature::geometry(), QgsVectorLayer::getFeatures(), QgsFeature::id(), mComposition, mCoverageLayer, mCurrentFeature, mFeatureIds, mTransformedFeatureBounds, QgsFeatureIterator::nextFeature(), prepareMap(), QgsExpression::setSpecialColumn(), statusMsgChanged(), and tr.
Referenced by firstFeature(), lastFeature(), nextFeature(), prepareForFeature(), and prevFeature().
void QgsAtlasComposition::prepareForFeature | ( | QgsFeature * | feat | ) |
Prepare the atlas map for the given feature.
Sets the extent and context variables
Definition at line 354 of file qgsatlascomposition.cpp.
References QgsFeature::id(), mFeatureIds, and prepareForFeature().
void QgsAtlasComposition::prepareMap | ( | QgsComposerMap * | map | ) |
Recalculates the bounds of an atlas driven map.
Definition at line 464 of file qgsatlascomposition.cpp.
References QgsComposerMap::atlasDriven(), QgsComposerMap::atlasFixedScale(), QgsComposerMap::atlasMargin(), computeExtent(), QgsComposerMap::extent(), QgsRectangle::height(), QgsRectangle::isEmpty(), mTransformedFeatureBounds, QgsRectangle::scale(), QgsComposerMap::setNewAtlasFeatureExtent(), QgsRectangle::width(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().
Referenced by prepareForFeature().
void QgsAtlasComposition::prevFeature | ( | ) |
Definition at line 331 of file qgsatlascomposition.cpp.
References mCurrentFeatureNo, and prepareForFeature().
void QgsAtlasComposition::readXML | ( | const QDomElement & | elem, |
const QDomDocument & | doc | ||
) |
Definition at line 575 of file qgsatlascomposition.cpp.
References QgsComposition::composerItems(), composerMap(), fixedScale(), QgsMapLayerRegistry::instance(), QgsMapLayerRegistry::mapLayers(), margin(), mComposition, mCoverageLayer, mEnabled, mFeatureFilter, mFilenamePattern, mFilterFeatures, mHideCoverage, mSingleFile, mSortAscending, mSortFeatures, mSortKeyAttributeIdx, parameterChanged(), QgsComposerMap::setAtlasDriven(), QgsComposerMap::setAtlasFixedScale(), QgsComposerMap::setAtlasMargin(), and toggled().
Referenced by QgsComposition::loadFromTemplate().
void QgsAtlasComposition::setComposerMap | ( | QgsComposerMap * | map | ) |
Sets the map used by the atlas.
Definition at line 95 of file qgsatlascomposition.cpp.
References QgsComposerMap::setAtlasDriven().
void QgsAtlasComposition::setCoverageLayer | ( | QgsVectorLayer * | lmap | ) |
Definition at line 60 of file qgsatlascomposition.cpp.
References coverageLayerChanged(), QgsFeature::geometry(), QgsVectorLayer::getFeatures(), QgsFeature::id(), mCoverageLayer, mFeatureIds, QgsFeatureIterator::nextFeature(), and QgsExpression::setSpecialColumn().
void QgsAtlasComposition::setEnabled | ( | bool | e | ) |
Definition at line 53 of file qgsatlascomposition.cpp.
References QgsComposition::AtlasOff, mComposition, mEnabled, QgsComposition::setAtlasMode(), and toggled().
|
inline |
Definition at line 97 of file qgsatlascomposition.h.
void QgsAtlasComposition::setFilenamePattern | ( | const QString & | pattern | ) |
Definition at line 658 of file qgsatlascomposition.cpp.
References mFilenamePattern, and updateFilenameExpression().
|
inline |
Definition at line 94 of file qgsatlascomposition.h.
void QgsAtlasComposition::setFixedScale | ( | bool | fixed | ) |
Sets whether the atlas map should use a fixed scale.
Definition at line 119 of file qgsatlascomposition.cpp.
References composerMap(), and QgsComposerMap::setAtlasFixedScale().
void QgsAtlasComposition::setHideCoverage | ( | bool | hide | ) |
Definition at line 645 of file qgsatlascomposition.cpp.
References QgsComposition::atlasMode(), mComposition, mHideCoverage, QgsComposition::PreviewAtlas, and updateAtlasMaps().
void QgsAtlasComposition::setMargin | ( | float | margin | ) |
Sets the margin for the atlas map.
Definition at line 143 of file qgsatlascomposition.cpp.
References composerMap(), and QgsComposerMap::setAtlasMargin().
|
inline |
Definition at line 85 of file qgsatlascomposition.h.
|
inline |
Definition at line 91 of file qgsatlascomposition.h.
|
inline |
Definition at line 88 of file qgsatlascomposition.h.
|
inline |
Definition at line 100 of file qgsatlascomposition.h.
|
inline |
Definition at line 84 of file qgsatlascomposition.h.
|
inline |
Definition at line 90 of file qgsatlascomposition.h.
|
inline |
Definition at line 87 of file qgsatlascomposition.h.
|
inline |
Definition at line 99 of file qgsatlascomposition.h.
|
signal |
Is emitted when the atlas has an updated status bar message for the composer window.
Referenced by prepareForFeature().
|
signal |
emitted when atlas is enabled or disabled
Referenced by readXML(), and setEnabled().
|
private |
Definition at line 298 of file qgsatlascomposition.cpp.
References QgsComposerMap::atlasDriven(), QgsComposerMap::cache(), QgsComposition::composerItems(), and mComposition.
Referenced by endRender(), and setHideCoverage().
int QgsAtlasComposition::updateFeatures | ( | ) |
Requeries the current atlas coverage layer and applies filtering and sorting.
Returns number of matching features. Must be called after prepareForFeature( i )
Definition at line 186 of file qgsatlascomposition.cpp.
References QgsComposition::atlasMode(), QgsFeature::attributes(), firstFeature(), QgsVectorLayer::getFeatures(), QgsFeature::id(), mComposition, mCoverageLayer, mFeatureFilter, mFeatureIds, mFeatureKeys, mFilterFeatures, mSortAscending, mSortFeatures, mSortKeyAttributeIdx, QgsFeatureIterator::nextFeature(), QgsVectorLayer::pendingFields(), QgsComposition::PreviewAtlas, QgsExpression::setSpecialColumn(), tr, and updateFilenameExpression().
Referenced by beginRender().
|
private |
Updates the filename expression.
Definition at line 664 of file qgsatlascomposition.cpp.
References QgsComposition::atlasMode(), evalFeatureFilename(), mComposition, mCoverageLayer, mFilenameExpr, mFilenamePattern, mSingleFile, QgsVectorLayer::pendingFields(), QgsComposition::PreviewAtlas, and tr.
Referenced by setFilenamePattern(), and updateFeatures().
void QgsAtlasComposition::writeXML | ( | QDomElement & | elem, |
QDomDocument & | doc | ||
) | const |
Definition at line 538 of file qgsatlascomposition.cpp.
References QgsMapLayer::id(), mCoverageLayer, mEnabled, mFeatureFilter, mFilenamePattern, mFilterFeatures, mHideCoverage, mSingleFile, mSortAscending, mSortFeatures, and mSortKeyAttributeIdx.
|
private |
Definition at line 160 of file qgsatlascomposition.h.
Referenced by beginRender(), composerMap(), endRender(), prepareForFeature(), readXML(), setEnabled(), setHideCoverage(), updateAtlasMaps(), updateFeatures(), and updateFilenameExpression().
|
private |
Definition at line 165 of file qgsatlascomposition.h.
Referenced by beginRender(), computeExtent(), endRender(), evalFeatureFilename(), prepareForFeature(), readXML(), setCoverageLayer(), updateFeatures(), updateFilenameExpression(), and writeXML().
|
private |
Definition at line 195 of file qgsatlascomposition.h.
Referenced by computeExtent(), evalFeatureFilename(), and prepareForFeature().
|
private |
Definition at line 176 of file qgsatlascomposition.h.
Referenced by firstFeature(), lastFeature(), nextFeature(), and prevFeature().
|
private |
Definition at line 169 of file qgsatlascomposition.h.
Referenced by currentFilename(), and evalFeatureFilename().
|
private |
Definition at line 162 of file qgsatlascomposition.h.
Referenced by readXML(), setEnabled(), and writeXML().
|
private |
Definition at line 190 of file qgsatlascomposition.h.
Referenced by readXML(), updateFeatures(), and writeXML().
|
private |
Definition at line 193 of file qgsatlascomposition.h.
Referenced by beginRender(), lastFeature(), nextFeature(), numFeatures(), prepareForFeature(), setCoverageLayer(), and updateFeatures().
|
private |
Definition at line 183 of file qgsatlascomposition.h.
Referenced by updateFeatures().
|
private |
Definition at line 197 of file qgsatlascomposition.h.
Referenced by evalFeatureFilename(), and updateFilenameExpression().
|
private |
Definition at line 164 of file qgsatlascomposition.h.
Referenced by evalFeatureFilename(), readXML(), setFilenamePattern(), updateFilenameExpression(), and writeXML().
|
private |
Definition at line 188 of file qgsatlascomposition.h.
Referenced by readXML(), updateFeatures(), and writeXML().
|
private |
Definition at line 163 of file qgsatlascomposition.h.
Referenced by readXML(), setHideCoverage(), and writeXML().
|
private |
Definition at line 166 of file qgsatlascomposition.h.
Referenced by evalFeatureFilename(), readXML(), updateFilenameExpression(), and writeXML().
|
private |
Definition at line 173 of file qgsatlascomposition.h.
Referenced by readXML(), updateFeatures(), and writeXML().
|
private |
Definition at line 171 of file qgsatlascomposition.h.
Referenced by readXML(), updateFeatures(), and writeXML().
|
private |
Definition at line 185 of file qgsatlascomposition.h.
Referenced by readXML(), updateFeatures(), and writeXML().
|
private |
Definition at line 168 of file qgsatlascomposition.h.
Referenced by computeExtent().
|
private |
Definition at line 200 of file qgsatlascomposition.h.
Referenced by computeExtent(), prepareForFeature(), and prepareMap().