QGIS API Documentation 3.41.0-Master (45a0abf3bec)
|
Abstract base class for labeling engine rules. More...
#include <qgslabelingenginerule.h>
Public Member Functions | |
virtual | ~QgsAbstractLabelingEngineRule () |
bool | active () const |
Returns true if the rule is active. | |
virtual void | alterCandidateCost (pal::LabelPosition *candidate, QgsLabelingEngineContext &context) const |
Provides an opportunity for the rule to alter the cost for a candidate. | |
virtual bool | candidateIsIllegal (const pal::LabelPosition *candidate, QgsLabelingEngineContext &context) const |
Returns true if a labeling candidate violates the rule and should be eliminated. | |
virtual bool | candidatesAreConflicting (const pal::LabelPosition *lp1, const pal::LabelPosition *lp2) const |
Returns true if a labeling candidate lp1 conflicts with lp2 after applying the rule. | |
virtual QgsAbstractLabelingEngineRule * | clone () const =0 |
Creates a clone of this rule. | |
virtual QString | description () const |
Returns a user-friendly description of the rule. | |
virtual QString | displayType () const =0 |
Returns a user-friendly, translated string representing the rule type. | |
virtual QString | id () const =0 |
Returns a string uniquely identifying the rule subclass. | |
virtual bool | isAvailable () const |
Returns true if the rule is available for use within the current QGIS environment. | |
virtual QgsRectangle | modifyCandidateConflictSearchBoundingBox (const QgsRectangle &candidateBounds) const |
Returns a (possibly expanded) bounding box to use when searching for conflicts for a candidate. | |
QString | name () const |
Returns the name for this instance of the rule. | |
virtual bool | prepare (QgsRenderContext &context)=0 |
Prepares the rule. | |
virtual void | readXml (const QDomElement &element, const QgsReadWriteContext &context)=0 |
Reads the rule properties from an XML element. | |
virtual void | resolveReferences (const QgsProject *project) |
Resolves reference to layers from stored layer ID. | |
void | setActive (bool active) |
Sets whether the rule is active. | |
void | setName (const QString &name) |
Sets the name for this instance of the rule. | |
virtual void | writeXml (QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context) const =0 |
Writes the rule properties to an XML element. | |
Protected Member Functions | |
virtual void | copyCommonProperties (QgsAbstractLabelingEngineRule *other) const |
Copies common properties from this object to an other. | |
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.
Definition at line 132 of file qgslabelingenginerule.h.
|
virtualdefault |
bool QgsAbstractLabelingEngineRule::active | ( | ) | const |
Returns true
if the rule is active.
Definition at line 96 of file qgslabelingenginerule.cpp.
|
virtual |
Provides an opportunity for the rule to alter the cost for a candidate.
The default implementation does nothing.
Reimplemented in QgsAbstractLabelingEngineRuleDistanceFromFeature.
Definition at line 75 of file qgslabelingenginerule.cpp.
|
virtual |
Returns true
if a labeling candidate violates the rule and should be eliminated.
The default implementation returns false
.
Reimplemented in QgsAbstractLabelingEngineRuleDistanceFromFeature, and QgsLabelingEngineRuleAvoidLabelOverlapWithFeature.
Definition at line 70 of file qgslabelingenginerule.cpp.
|
virtual |
Returns true
if a labeling candidate lp1 conflicts with lp2 after applying the rule.
The default implementation returns false
.
Reimplemented in QgsLabelingEngineRuleMinimumDistanceLabelToLabel.
Definition at line 60 of file qgslabelingenginerule.cpp.
|
pure virtual |
Creates a clone of this rule.
The caller takes ownership of the returned object.
Implemented in QgsLabelingEngineRuleMinimumDistanceLabelToFeature, QgsLabelingEngineRuleMaximumDistanceLabelToFeature, QgsLabelingEngineRuleMinimumDistanceLabelToLabel, and QgsLabelingEngineRuleAvoidLabelOverlapWithFeature.
|
protectedvirtual |
Copies common properties from this object to an other.
Reimplemented in QgsAbstractLabelingEngineRuleDistanceFromFeature.
Definition at line 80 of file qgslabelingenginerule.cpp.
|
virtual |
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.
Reimplemented in QgsLabelingEngineRuleMinimumDistanceLabelToFeature, QgsLabelingEngineRuleMaximumDistanceLabelToFeature, QgsLabelingEngineRuleMinimumDistanceLabelToLabel, and QgsLabelingEngineRuleAvoidLabelOverlapWithFeature.
Definition at line 91 of file qgslabelingenginerule.cpp.
|
pure virtual |
Returns a user-friendly, translated string representing the rule type.
Implemented in QgsLabelingEngineRuleMinimumDistanceLabelToFeature, QgsLabelingEngineRuleMaximumDistanceLabelToFeature, QgsLabelingEngineRuleMinimumDistanceLabelToLabel, and QgsLabelingEngineRuleAvoidLabelOverlapWithFeature.
|
pure virtual |
Returns a string uniquely identifying the rule subclass.
Implemented in QgsLabelingEngineRuleMinimumDistanceLabelToFeature, QgsLabelingEngineRuleMaximumDistanceLabelToFeature, QgsLabelingEngineRuleMinimumDistanceLabelToLabel, and QgsLabelingEngineRuleAvoidLabelOverlapWithFeature.
|
virtual |
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.
Reimplemented in QgsAbstractLabelingEngineRuleDistanceFromFeature, and QgsLabelingEngineRuleMinimumDistanceLabelToLabel.
Definition at line 86 of file qgslabelingenginerule.cpp.
|
virtual |
Returns a (possibly expanded) bounding box to use when searching for conflicts for a candidate.
The return value is permitted to grow the bounding box, but may NOT shrink it.
The default implementation returns the same bounds.
Reimplemented in QgsLabelingEngineRuleMinimumDistanceLabelToLabel.
Definition at line 65 of file qgslabelingenginerule.cpp.
|
inline |
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.
Definition at line 209 of file qgslabelingenginerule.h.
|
pure virtual |
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.
Implemented in QgsAbstractLabelingEngineRuleDistanceFromFeature, QgsLabelingEngineRuleMinimumDistanceLabelToLabel, and QgsLabelingEngineRuleAvoidLabelOverlapWithFeature.
|
pure virtual |
Reads the rule properties from an XML element.
Implemented in QgsAbstractLabelingEngineRuleDistanceFromFeature, QgsLabelingEngineRuleMinimumDistanceLabelToLabel, and QgsLabelingEngineRuleAvoidLabelOverlapWithFeature.
|
virtual |
Resolves reference to layers from stored layer ID.
Should be called following a call readXml().
Reimplemented in QgsAbstractLabelingEngineRuleDistanceFromFeature, QgsLabelingEngineRuleMinimumDistanceLabelToLabel, and QgsLabelingEngineRuleAvoidLabelOverlapWithFeature.
Definition at line 55 of file qgslabelingenginerule.cpp.
void QgsAbstractLabelingEngineRule::setActive | ( | bool | active | ) |
Sets whether the rule is active.
Definition at line 101 of file qgslabelingenginerule.cpp.
|
inline |
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.
Definition at line 219 of file qgslabelingenginerule.h.
|
pure virtual |
Writes the rule properties to an XML element.
Implemented in QgsAbstractLabelingEngineRuleDistanceFromFeature, QgsLabelingEngineRuleMinimumDistanceLabelToLabel, and QgsLabelingEngineRuleAvoidLabelOverlapWithFeature.