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.
Note
This is an abstract class, with methods which must be implemented by a subclass.
The following methods must be implemented: clone()
, displayType()
, id()
, prepare()
, readXml()
, writeXml()
Class Hierarchy¶
Subclasses¶
Base class for labeling engine rules which prevent labels being placed too close or too 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. |
Abstract Methods
Creates a clone of this rule. |
|
Returns a user-friendly, translated string representing the rule type. |
|
Returns a string uniquely identifying the rule subclass. |
|
Prepares the rule. |
|
Reads the rule properties from an XML element. |
|
Writes the rule properties to an XML element. |
Methods
Returns |
|
Returns the name for this instance of the rule. |
|
Sets whether the rule is active. |
|
Sets the name for this instance of the rule. |
Virtual Methods
In PyQGIS, only methods marked as virtual
can be safely overridden in a Python subclass of QgsAbstractLabelingEngineRule. See the FAQ for more details.
Copies common properties from this object to an other. |
|
Returns a user-friendly description of the rule. |
|
Returns |
|
Resolves reference to layers from stored layer ID. |
- class qgis.core.QgsAbstractLabelingEngineRule[source]¶
Bases:
object
- abstract clone(self) QgsAbstractLabelingEngineRule | None [source]¶
Creates a clone of this rule.
The caller takes ownership of the returned object.
- Return type:
Optional[QgsAbstractLabelingEngineRule]
- virtual copyCommonProperties(self, other: QgsAbstractLabelingEngineRule | None)[source]¶
Copies common properties from this object to an
other
.- Parameters:
other (Optional[QgsAbstractLabelingEngineRule])
- virtual 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
- abstract displayType(self) str [source]¶
Returns a user-friendly, translated string representing the rule type.
- Return type:
str
- abstract id(self) str [source]¶
Returns a string uniquely identifying the rule subclass.
- Return type:
str
- virtual 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
- abstract 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
- abstract readXml(self, element: QDomElement, context: QgsReadWriteContext)[source]¶
Reads the rule properties from an XML
element
.See also
See also
- Parameters:
element (QDomElement)
context (QgsReadWriteContext)
- virtual 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])
- abstract 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)