QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
|
A labeling engine rule which prevents labels being placed overlapping features from a different layer. More...
#include <qgslabelingenginerule_impl.h>
Public Member Functions | |
QgsLabelingEngineRuleAvoidLabelOverlapWithFeature () | |
~QgsLabelingEngineRuleAvoidLabelOverlapWithFeature () override | |
bool | candidateIsIllegal (const pal::LabelPosition *candidate, QgsLabelingEngineContext &context) const override |
Returns true if a labeling candidate violates the rule and should be eliminated. | |
QgsLabelingEngineRuleAvoidLabelOverlapWithFeature * | clone () const override |
Creates a clone of this rule. | |
QString | description () const override |
Returns a user-friendly description of the rule. | |
QString | displayType () const override |
Returns a user-friendly, translated string representing the rule type. | |
QString | id () const override |
Returns a string uniquely identifying the rule subclass. | |
QgsMapLayer * | labeledLayer () const |
Returns the layer providing the labels. | |
bool | prepare (QgsRenderContext &context) override |
Prepares the rule. | |
void | readXml (const QDomElement &element, const QgsReadWriteContext &context) override |
Reads the rule properties from an XML element. | |
void | resolveReferences (const QgsProject *project) override |
Resolves reference to layers from stored layer ID. | |
void | setLabeledLayer (QgsMapLayer *layer) |
Sets the layer providing the labels. | |
void | setTargetLayer (QgsVectorLayer *layer) |
Sets the layer providing the features which labels must not overlap. | |
QgsVectorLayer * | targetLayer () const |
Returns the layer providing the features which labels must not overlap. | |
void | writeXml (QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context) const override |
Writes the rule properties to an XML element. | |
Public Member Functions inherited from QgsAbstractLabelingEngineRule | |
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 | 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 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. | |
void | setActive (bool active) |
Sets whether the rule is active. | |
void | setName (const QString &name) |
Sets the name for this instance of the rule. | |
Additional Inherited Members | |
Protected Member Functions inherited from QgsAbstractLabelingEngineRule | |
virtual void | copyCommonProperties (QgsAbstractLabelingEngineRule *other) const |
Copies common properties from this object to an other. | |
A labeling engine rule which prevents labels being placed overlapping features from a different layer.
Definition at line 386 of file qgslabelingenginerule_impl.h.
|
default |
|
overridedefault |
|
overridevirtual |
Returns true
if a labeling candidate violates the rule and should be eliminated.
The default implementation returns false
.
Reimplemented from QgsAbstractLabelingEngineRule.
Definition at line 581 of file qgslabelingenginerule_impl.cpp.
|
overridevirtual |
Creates a clone of this rule.
The caller takes ownership of the returned object.
Implements QgsAbstractLabelingEngineRule.
Definition at line 497 of file qgslabelingenginerule_impl.cpp.
|
overridevirtual |
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 from QgsAbstractLabelingEngineRule.
Definition at line 516 of file qgslabelingenginerule_impl.cpp.
|
overridevirtual |
Returns a user-friendly, translated string representing the rule type.
Implements QgsAbstractLabelingEngineRule.
Definition at line 511 of file qgslabelingenginerule_impl.cpp.
|
overridevirtual |
Returns a string uniquely identifying the rule subclass.
Implements QgsAbstractLabelingEngineRule.
Definition at line 506 of file qgslabelingenginerule_impl.cpp.
QgsMapLayer * QgsLabelingEngineRuleAvoidLabelOverlapWithFeature::labeledLayer | ( | ) | const |
Returns the layer providing the labels.
Definition at line 621 of file qgslabelingenginerule_impl.cpp.
|
overridevirtual |
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.
Implements QgsAbstractLabelingEngineRule.
Definition at line 529 of file qgslabelingenginerule_impl.cpp.
|
overridevirtual |
Reads the rule properties from an XML element.
Implements QgsAbstractLabelingEngineRule.
Definition at line 557 of file qgslabelingenginerule_impl.cpp.
|
overridevirtual |
Resolves reference to layers from stored layer ID.
Should be called following a call readXml().
Reimplemented from QgsAbstractLabelingEngineRule.
Definition at line 575 of file qgslabelingenginerule_impl.cpp.
void QgsLabelingEngineRuleAvoidLabelOverlapWithFeature::setLabeledLayer | ( | QgsMapLayer * | layer | ) |
Sets the layer providing the labels.
Definition at line 626 of file qgslabelingenginerule_impl.cpp.
void QgsLabelingEngineRuleAvoidLabelOverlapWithFeature::setTargetLayer | ( | QgsVectorLayer * | layer | ) |
Sets the layer providing the features which labels must not overlap.
Definition at line 636 of file qgslabelingenginerule_impl.cpp.
QgsVectorLayer * QgsLabelingEngineRuleAvoidLabelOverlapWithFeature::targetLayer | ( | ) | const |
Returns the layer providing the features which labels must not overlap.
Definition at line 631 of file qgslabelingenginerule_impl.cpp.
|
overridevirtual |
Writes the rule properties to an XML element.
Implements QgsAbstractLabelingEngineRule.
Definition at line 539 of file qgslabelingenginerule_impl.cpp.