Class: QgsStyleEntityVisitorInterface¶
An interface for classes which can visit style entity (e.g. symbol) nodes (using the visitor pattern).
Added in version 3.10.
Enums
Describes the types of nodes which may be visited by the visitor. |
Virtual Methods
In PyQGIS, only methods marked as virtual
can be safely overridden in a Python subclass of QgsStyleEntityVisitorInterface. See the FAQ for more details.
Called when the visitor will visit a style entity. |
|
Called when the visitor starts visiting a node. |
|
Called when the visitor stops visiting a node. |
- class qgis.core.QgsStyleEntityVisitorInterface[source]¶
Bases:
object
- class Node¶
Bases:
object
Contains information relating to a node (i.e. a group of symbols or other nodes) being visited.
- description: str¶
A string describing the node. The actual value of
description
will vary depending on the node being visited. E.g for a rule based renderer, the identifier will be a rule label. For a project, node identifiers will be layer names.
- identifier: str¶
A string identifying the node. The actual value of
identifier
will vary depending on the node being visited. E.g for a rule based renderer, the identifier will be a rule ID. For a project, node identifiers will be layer IDs.
- class NodeType(*values)¶
Bases:
IntEnum
Describes the types of nodes which may be visited by the visitor.
Project
: QGIS Project nodeLayer
: Map layerSymbolRule
: Rule based symbology or label child ruleLayouts
: Layout collectionPrintLayout
: An individual print layoutLayoutItem
: Individual item in a print layoutReport
: A QGIS print reportReportHeader
: Report header sectionReportFooter
: Report footer sectionReportSection
: Report sub sectionAnnotations
: Annotations collectionAnnotation
: An individual annotation
- Annotation = 11¶
- Annotations = 10¶
- Layer = 1¶
- LayoutItem = 5¶
- Layouts = 3¶
- PrintLayout = 4¶
- Project = 0¶
- Report = 6¶
- ReportHeader = 7¶
- ReportSection = 9¶
- SymbolRule = 2¶
- class StyleLeaf¶
Bases:
object
Contains information relating to the style entity currently being visited.
- description: str¶
A string describing the style entity. The actual value of
description
will vary depending on the class being visited. E.g for a categorized renderer, the description will be the category label associated with the symbol, for a print layout, it will be the name of the layout in the project.This may be blank if no description is associated with a style entity, e.g. when a renderer has a single symbol only.
This value may be a generic, translated value in some cases, e.g. “Grid” or “Overview”.
- entity: QgsStyleEntityInterface¶
Reference to style entity being visited.
- identifier: str¶
A string identifying the style entity. The actual value of
identifier
will vary depending on the class being visited. E.g for a categorized renderer, the identifier will be the category ID associated with the symbol.This may be blank if no identifier is required, e.g. when a renderer has a single symbol only.
Note that in some cases where a specific identifier is not available, a generic, untranslated one may be used (e.g. “overview”, “grid”).
- virtual visit(self, entity: QgsStyleEntityVisitorInterface.StyleLeaf) bool [source]¶
Called when the visitor will visit a style
entity
.Subclasses should return
False
to abort further visitations, orTrue
to continue visiting after processing this entity.- Parameters:
- Return type:
bool
- virtual visitEnter(self, node: QgsStyleEntityVisitorInterface.Node) bool [source]¶
Called when the visitor starts visiting a
node
.Subclasses should return
False
if they do NOT want to visit this particular node - e.g. if the node type is QgsStyleEntityVisitorInterface.NodeType.Layouts and they do not wish to visit layout objects. In this case the visitor will not process the node, and will move to the next available node instead. ReturnTrue
to proceed with visiting the node.The default implementation returns
True
.- Parameters:
- Return type:
bool
- virtual visitExit(self, node: QgsStyleEntityVisitorInterface.Node) bool [source]¶
Called when the visitor stops visiting a
node
.Subclasses should return
False
to abort further visitations, orTrue
to continue visiting other nodes.The default implementation returns
True
.- Parameters:
- Return type:
bool