QGIS API Documentation
3.22.4-Białowieża (ce8e65e95e)
|
Class used to render QgsLayout as an atlas, by iterating over the features from an associated vector layer. More...
#include <qgslayoutatlas.h>
Public Slots | |
bool | first () |
Seeks to the first feature, returning false if no feature was found. More... | |
bool | last () |
Seeks to the last feature, returning false if no feature was found. More... | |
bool | next () override |
bool | previous () |
Iterates to the previous feature, returning false if no previous feature exists. More... | |
void | refreshCurrentFeature () |
Refreshes the current atlas feature, by refetching its attributes from the vector layer provider. More... | |
bool | seekTo (const QgsFeature &feature) |
Seeks to the specified feature. More... | |
bool | seekTo (int feature) |
Seeks to the specified feature number. More... | |
Signals | |
void | changed () |
Emitted when one of the atlas parameters changes. More... | |
void | coverageLayerChanged (QgsVectorLayer *layer) |
Emitted when the coverage layer for the atlas changes. More... | |
void | featureChanged (const QgsFeature &feature) |
Emitted when the current atlas feature changes. More... | |
void | messagePushed (const QString &message) |
Emitted when the atlas has an updated status bar message. More... | |
void | numberFeaturesChanged (int numFeatures) |
Emitted when the number of features for the atlas changes. More... | |
void | renderBegun () |
Emitted when atlas rendering has begun. More... | |
void | renderEnded () |
Emitted when atlas rendering has ended. More... | |
void | toggled (bool) |
Emitted when atlas is enabled or disabled. More... | |
Public Member Functions | |
QgsLayoutAtlas (QgsLayout *layout) | |
Constructor for new QgsLayoutAtlas. More... | |
bool | beginRender () override |
Called when rendering begins, before iteration commences. More... | |
int | count () const override |
Returns the number of features to iterate over. More... | |
QgsVectorLayer * | coverageLayer () const |
Returns the coverage layer used for the atlas features. More... | |
QgsExpressionContext | createExpressionContext () const override |
This method needs to be reimplemented in all classes which implement this interface and return an expression context. More... | |
int | currentFeatureNumber () const |
Returns the current feature number, where a value of 0 corresponds to the first feature. More... | |
QString | currentFilename () const |
Returns the current feature filename. More... | |
bool | enabled () const |
Returns whether the atlas generation is enabled. More... | |
bool | endRender () override |
Ends the render, performing any required cleanup tasks. More... | |
QString | filenameExpression () const |
Returns the filename expression used for generating output filenames for each atlas page. More... | |
QString | filePath (const QString &baseFilePath, const QString &extension) override |
Returns the file path for the current feature, based on a specified base file path and extension. More... | |
QString | filterExpression () const |
Returns the expression used for filtering features in the coverage layer. More... | |
bool | filterFeatures () const |
Returns true if features should be filtered in the coverage layer. More... | |
bool | hideCoverage () const |
Returns true if the atlas is set to hide the coverage layer. More... | |
const QgsLayout * | layout () const |
Returns the atlas' layout. More... | |
QgsLayout * | layout () override |
Returns the layout associated with the iterator. More... | |
QString | nameForPage (int page) const |
Returns the calculated name for a specified atlas page number. More... | |
QString | pageNameExpression () const |
Returns the expression (or field name) used for calculating the page name. More... | |
bool | readXml (const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context) override |
Sets the objects's state from a DOM element. More... | |
void | setCoverageLayer (QgsVectorLayer *layer) |
Sets the coverage layer to use for the atlas features. More... | |
void | setEnabled (bool enabled) |
Sets whether the atlas is enabled. More... | |
bool | setFilenameExpression (const QString &expression, QString &errorString) |
Sets the filename expression used for generating output filenames for each atlas page. More... | |
bool | setFilterExpression (const QString &expression, QString &errorString) |
Sets the expression used for filtering features in the coverage layer. More... | |
void | setFilterFeatures (bool filtered) |
Sets whether features should be filtered in the coverage layer. More... | |
void | setHideCoverage (bool hide) |
Sets whether the coverage layer should be hidden in map items in the layouts. More... | |
void | setPageNameExpression (const QString &expression) |
Sets the expression (or field name) used for calculating the page name. More... | |
void | setSortAscending (bool ascending) |
Sets whether features should be sorted in an ascending order. More... | |
void | setSortExpression (const QString &expression) |
Sets the expression (or field name) to use for sorting features. More... | |
void | setSortFeatures (bool enabled) |
Sets whether features should be sorted in the atlas. More... | |
bool | sortAscending () const |
Returns true if features should be sorted in an ascending order. More... | |
QString | sortExpression () const |
Returns the expression (or field name) to use for sorting features. More... | |
bool | sortFeatures () const |
Returns true if features should be sorted in the atlas. More... | |
QString | stringType () const override |
Returns the object type as a string. More... | |
int | updateFeatures () |
Requeries the current atlas coverage layer and applies filtering and sorting. More... | |
bool | writeXml (QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context) const override |
Stores the objects's state in a DOM element. More... | |
Public Member Functions inherited from QgsAbstractLayoutIterator | |
virtual | ~QgsAbstractLayoutIterator ()=default |
virtual bool | next ()=0 |
Iterates to next feature, returning false if no more features exist to iterate over. More... | |
Public Member Functions inherited from QgsLayoutSerializableObject | |
QgsAbstractLayoutUndoCommand * | createCommand (const QString &text, int id, QUndoCommand *parent=nullptr) override |
Creates a new layout undo command with the specified text and parent. More... | |
Public Member Functions inherited from QgsLayoutUndoObjectInterface | |
virtual | ~QgsLayoutUndoObjectInterface ()=default |
Destructor for QgsLayoutUndoObjectInterface. More... | |
Public Member Functions inherited from QgsExpressionContextGenerator | |
virtual | ~QgsExpressionContextGenerator ()=default |
Friends | |
class | AtlasFeatureSorter |
Class used to render QgsLayout as an atlas, by iterating over the features from an associated vector layer.
QgsLayoutAtlas implement the QgsAbstractLayoutIterator interface, allowing them to be used directly with QgsLayoutExporter to automatically output all pages from the atlas.
For QgsPrintLayout layouts, it is not necessary to manually construct a QgsLayoutAtlas object. Instead, the atlas attached to the print layout should be used. This can be retrieved by calling QgsPrintLayout::atlas().
Definition at line 41 of file qgslayoutatlas.h.
QgsLayoutAtlas::QgsLayoutAtlas | ( | QgsLayout * | layout | ) |
Constructor for new QgsLayoutAtlas.
Definition at line 29 of file qgslayoutatlas.cpp.
|
overridevirtual |
Called when rendering begins, before iteration commences.
Returns true
if successful, false
if no iteration is available or required.
Implements QgsAbstractLayoutIterator.
Definition at line 376 of file qgslayoutatlas.cpp.
|
signal |
Emitted when one of the atlas parameters changes.
|
overridevirtual |
Returns the number of features to iterate over.
Implements QgsAbstractLayoutIterator.
Definition at line 401 of file qgslayoutatlas.cpp.
|
inline |
Returns the coverage layer used for the atlas features.
Definition at line 116 of file qgslayoutatlas.h.
|
signal |
Emitted when the coverage layer for the atlas changes.
|
overridevirtual |
This method needs to be reimplemented in all classes which implement this interface and return an expression context.
Implements QgsExpressionContextGenerator.
Definition at line 508 of file qgslayoutatlas.cpp.
|
inline |
Returns the current feature number, where a value of 0 corresponds to the first feature.
Definition at line 254 of file qgslayoutatlas.h.
QString QgsLayoutAtlas::currentFilename | ( | ) | const |
Returns the current feature filename.
Definition at line 503 of file qgslayoutatlas.cpp.
|
inline |
Returns whether the atlas generation is enabled.
Definition at line 67 of file qgslayoutatlas.h.
|
overridevirtual |
Ends the render, performing any required cleanup tasks.
Implements QgsAbstractLayoutIterator.
Definition at line 394 of file qgslayoutatlas.cpp.
|
signal |
Emitted when the current atlas feature changes.
|
inline |
Returns the filename expression used for generating output filenames for each atlas page.
Definition at line 93 of file qgslayoutatlas.h.
|
overridevirtual |
Returns the file path for the current feature, based on a specified base file path and extension.
Implements QgsAbstractLayoutIterator.
Definition at line 406 of file qgslayoutatlas.cpp.
|
inline |
Returns the expression used for filtering features in the coverage layer.
This property has no effect is filterFeatures() is false
.
Definition at line 225 of file qgslayoutatlas.h.
|
inline |
Returns true
if features should be filtered in the coverage layer.
Definition at line 208 of file qgslayoutatlas.h.
|
slot |
Seeks to the first feature, returning false
if no feature was found.
Definition at line 439 of file qgslayoutatlas.cpp.
|
inline |
Returns true
if the atlas is set to hide the coverage layer.
Definition at line 79 of file qgslayoutatlas.h.
|
slot |
Seeks to the last feature, returning false
if no feature was found.
Definition at line 444 of file qgslayoutatlas.cpp.
const QgsLayout * QgsLayoutAtlas::layout | ( | ) | const |
Returns the atlas' layout.
Definition at line 52 of file qgslayoutatlas.cpp.
|
overridevirtual |
Returns the layout associated with the iterator.
Implements QgsAbstractLayoutIterator.
Definition at line 47 of file qgslayoutatlas.cpp.
|
signal |
Emitted when the atlas has an updated status bar message.
QString QgsLayoutAtlas::nameForPage | ( | int | page | ) | const |
Returns the calculated name for a specified atlas page number.
Page numbers start at 0.
Definition at line 177 of file qgslayoutatlas.cpp.
|
overrideslot |
Definition at line 417 of file qgslayoutatlas.cpp.
|
signal |
Emitted when the number of features for the atlas changes.
|
inline |
Returns the expression (or field name) used for calculating the page name.
Definition at line 129 of file qgslayoutatlas.h.
|
slot |
|
overridevirtual |
Sets the objects's state from a DOM element.
element is the DOM node corresponding to the object.
Implements QgsLayoutSerializableObject.
Definition at line 95 of file qgslayoutatlas.cpp.
|
slot |
Refreshes the current atlas feature, by refetching its attributes from the vector layer provider.
Definition at line 476 of file qgslayoutatlas.cpp.
|
signal |
Emitted when atlas rendering has begun.
|
signal |
Emitted when atlas rendering has ended.
|
slot |
Seeks to the specified feature.
Definition at line 454 of file qgslayoutatlas.cpp.
|
slot |
Seeks to the specified feature number.
Definition at line 449 of file qgslayoutatlas.cpp.
void QgsLayoutAtlas::setCoverageLayer | ( | QgsVectorLayer * | layer | ) |
Sets the coverage layer to use for the atlas features.
Definition at line 157 of file qgslayoutatlas.cpp.
void QgsLayoutAtlas::setEnabled | ( | bool | enabled | ) |
Sets whether the atlas is enabled.
Definition at line 126 of file qgslayoutatlas.cpp.
bool QgsLayoutAtlas::setFilenameExpression | ( | const QString & | expression, |
QString & | errorString | ||
) |
Sets the filename expression used for generating output filenames for each atlas page.
If an invalid expression is passed, false
will be returned and errorString will be set to the expression error.
Definition at line 492 of file qgslayoutatlas.cpp.
bool QgsLayoutAtlas::setFilterExpression | ( | const QString & | expression, |
QString & | errorString | ||
) |
Sets the expression used for filtering features in the coverage layer.
This property has no effect is filterFeatures() is false
.
If an invalid expression is passed, false
will be returned and errorString will be set to the expression error.
Definition at line 221 of file qgslayoutatlas.cpp.
void QgsLayoutAtlas::setFilterFeatures | ( | bool | filtered | ) |
Sets whether features should be filtered in the coverage layer.
Definition at line 212 of file qgslayoutatlas.cpp.
void QgsLayoutAtlas::setHideCoverage | ( | bool | hide | ) |
Sets whether the coverage layer should be hidden in map items in the layouts.
Definition at line 481 of file qgslayoutatlas.cpp.
void QgsLayoutAtlas::setPageNameExpression | ( | const QString & | expression | ) |
Sets the expression (or field name) used for calculating the page name.
Definition at line 168 of file qgslayoutatlas.cpp.
void QgsLayoutAtlas::setSortAscending | ( | bool | ascending | ) |
Sets whether features should be sorted in an ascending order.
This property has no effect is sortFeatures() is false
.
Definition at line 194 of file qgslayoutatlas.cpp.
void QgsLayoutAtlas::setSortExpression | ( | const QString & | expression | ) |
Sets the expression (or field name) to use for sorting features.
This property has no effect is sortFeatures() is false
.
Definition at line 203 of file qgslayoutatlas.cpp.
void QgsLayoutAtlas::setSortFeatures | ( | bool | enabled | ) |
Sets whether features should be sorted in the atlas.
Definition at line 185 of file qgslayoutatlas.cpp.
|
inline |
Returns true
if features should be sorted in an ascending order.
This property has no effect is sortFeatures() is false
.
Definition at line 168 of file qgslayoutatlas.h.
|
inline |
Returns the expression (or field name) to use for sorting features.
This property has no effect is sortFeatures() is false
.
Definition at line 190 of file qgslayoutatlas.h.
|
inline |
Returns true
if features should be sorted in the atlas.
Definition at line 149 of file qgslayoutatlas.h.
|
overridevirtual |
Returns the object type as a string.
This string must be a unique, single word, character only representation of the item type, eg "LayoutScaleBar"
Implements QgsLayoutSerializableObject.
Definition at line 42 of file qgslayoutatlas.cpp.
|
signal |
Emitted when atlas is enabled or disabled.
int QgsLayoutAtlas::updateFeatures | ( | ) |
Requeries the current atlas coverage layer and applies filtering and sorting.
Returns number of matching features.
Definition at line 262 of file qgslayoutatlas.cpp.
|
overridevirtual |
Stores the objects's state in a DOM element.
The parentElement should refer to the parent layout's DOM element.
Implements QgsLayoutSerializableObject.
Definition at line 57 of file qgslayoutatlas.cpp.
|
friend |
Definition at line 397 of file qgslayoutatlas.h.