Class: QgsAbstractLabelingEngineRule¶
Abstract base class for labeling engine rules.
Labeling engine rules implement custom logic to modify the labeling solution for a map render, e.g. by preventing labels being placed which violate custom constraints.
Note
QgsAbstractLabelingEngineRule
cannot be subclassed in Python. Use one of the existing
implementations of this class instead.
Added in version 3.40.
Class Hierarchy¶
Subclasses¶
Base class for labeling engine rules which prevents labels being placed too close or to far from features from a different layer. |
|
A labeling engine rule which prevents labels being placed overlapping features from a different layer. |
|
A labeling engine rule which prevents labels being placed too close to labels from a different layer. |
Methods
Returns |
|
Creates a clone of this rule. |
|
Copies common properties from this object to an other. |
|
Returns a user-friendly description of the rule. |
|
Returns a user-friendly, translated string representing the rule type. |
|
Returns a string uniquely identifying the rule subclass. |
|
Returns |
|
Returns the name for this instance of the rule. |
|
Prepares the rule. |
|
Reads the rule properties from an XML element. |
|
Resolves reference to layers from stored layer ID. |
|
Sets whether the rule is active. |
|
Sets the name for this instance of the rule. |
|
Writes the rule properties to an XML element. |
- class qgis.core.QgsAbstractLabelingEngineRule[source]¶
Bases:
object
- clone(self) QgsAbstractLabelingEngineRule | None [source]¶
Creates a clone of this rule.
The caller takes ownership of the returned object.
- Return type:
Optional[QgsAbstractLabelingEngineRule]
- copyCommonProperties(self, other: QgsAbstractLabelingEngineRule | None)[source]¶
Copies common properties from this object to an
other
.- Parameters:
other (Optional[QgsAbstractLabelingEngineRule])
- description(self) str [source]¶
Returns a user-friendly description of the rule.
This should include the rule
name()
if set, and other useful details for users to quickly identify the rule’s purpose when shown in a tooltip.The returned string may contain HTML formatting.
- Return type:
str
- displayType(self) str [source]¶
Returns a user-friendly, translated string representing the rule type.
- Return type:
str
- isAvailable(self) bool [source]¶
Returns
True
if the rule is available for use within the current QGIS environment.The base class method returns
True
.Rules can return
False
if required dependencies are not available, e.g. if a library version is too old for the rule.- Return type:
bool
- name(self) str [source]¶
Returns the name for this instance of the rule.
The name is a user-configurable value which helps them identify and describe the rule within their projects.
See also
- Return type:
str
- prepare(self, context: QgsRenderContext) bool [source]¶
Prepares the rule.
This must be called on the main render thread, prior to commencing the render operation. Thread sensitive logic (such as creation of feature sources) can be performed in this method.
- Parameters:
context (QgsRenderContext)
- Return type:
bool
- readXml(self, element: QDomElement, context: QgsReadWriteContext)[source]¶
Reads the rule properties from an XML
element
.See also
See also
- Parameters:
element (QDomElement)
context (QgsReadWriteContext)
- resolveReferences(self, project: QgsProject | None)[source]¶
Resolves reference to layers from stored layer ID.
Should be called following a call
readXml()
.- Parameters:
project (Optional[QgsProject])
- setActive(self, active: bool)[source]¶
Sets whether the rule is
active
.See also
- Parameters:
active (bool)
- setName(self, name: str | None)[source]¶
Sets the
name
for this instance of the rule.The name is a user-configurable value which helps them identify and describe the rule within their projects.
See also
- Parameters:
name (Optional[str])
- writeXml(self, doc: QDomDocument, element: QDomElement, context: QgsReadWriteContext)[source]¶
Writes the rule properties to an XML
element
.See also
- Parameters:
doc (QDomDocument)
element (QDomElement)
context (QgsReadWriteContext)