QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsLabelingEngineRuleAvoidLabelOverlapWithFeature Class Reference

A labeling engine rule which prevents labels being placed overlapping features from a different layer. More...

#include <qgslabelingenginerule_impl.h>

Inheritance diagram for QgsLabelingEngineRuleAvoidLabelOverlapWithFeature:
Inheritance graph
[legend]

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.
 
QgsLabelingEngineRuleAvoidLabelOverlapWithFeatureclone () 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.
 
QgsMapLayerlabeledLayer () 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.
 
QgsVectorLayertargetLayer () 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.
 

Detailed Description

A labeling engine rule which prevents labels being placed overlapping features from a different layer.

Since
QGIS 3.40

Definition at line 386 of file qgslabelingenginerule_impl.h.

Constructor & Destructor Documentation

◆ QgsLabelingEngineRuleAvoidLabelOverlapWithFeature()

QgsLabelingEngineRuleAvoidLabelOverlapWithFeature::QgsLabelingEngineRuleAvoidLabelOverlapWithFeature ( )
default

◆ ~QgsLabelingEngineRuleAvoidLabelOverlapWithFeature()

QgsLabelingEngineRuleAvoidLabelOverlapWithFeature::~QgsLabelingEngineRuleAvoidLabelOverlapWithFeature ( )
overridedefault

Member Function Documentation

◆ candidateIsIllegal()

bool QgsLabelingEngineRuleAvoidLabelOverlapWithFeature::candidateIsIllegal ( const pal::LabelPosition candidate,
QgsLabelingEngineContext context 
) const
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.

◆ clone()

QgsLabelingEngineRuleAvoidLabelOverlapWithFeature * QgsLabelingEngineRuleAvoidLabelOverlapWithFeature::clone ( ) const
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.

◆ description()

QString QgsLabelingEngineRuleAvoidLabelOverlapWithFeature::description ( ) const
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.

◆ displayType()

QString QgsLabelingEngineRuleAvoidLabelOverlapWithFeature::displayType ( ) const
overridevirtual

Returns a user-friendly, translated string representing the rule type.

Implements QgsAbstractLabelingEngineRule.

Definition at line 511 of file qgslabelingenginerule_impl.cpp.

◆ id()

QString QgsLabelingEngineRuleAvoidLabelOverlapWithFeature::id ( ) const
overridevirtual

Returns a string uniquely identifying the rule subclass.

Implements QgsAbstractLabelingEngineRule.

Definition at line 506 of file qgslabelingenginerule_impl.cpp.

◆ labeledLayer()

QgsMapLayer * QgsLabelingEngineRuleAvoidLabelOverlapWithFeature::labeledLayer ( ) const

Returns the layer providing the labels.

See also
setLabeledLayer()

Definition at line 621 of file qgslabelingenginerule_impl.cpp.

◆ prepare()

bool QgsLabelingEngineRuleAvoidLabelOverlapWithFeature::prepare ( QgsRenderContext context)
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.

◆ readXml()

void QgsLabelingEngineRuleAvoidLabelOverlapWithFeature::readXml ( const QDomElement &  element,
const QgsReadWriteContext context 
)
overridevirtual

Reads the rule properties from an XML element.

See also
resolveReferences()
writeXml()

Implements QgsAbstractLabelingEngineRule.

Definition at line 557 of file qgslabelingenginerule_impl.cpp.

◆ resolveReferences()

void QgsLabelingEngineRuleAvoidLabelOverlapWithFeature::resolveReferences ( const QgsProject project)
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.

◆ setLabeledLayer()

void QgsLabelingEngineRuleAvoidLabelOverlapWithFeature::setLabeledLayer ( QgsMapLayer layer)

Sets the layer providing the labels.

See also
labeledLayer()

Definition at line 626 of file qgslabelingenginerule_impl.cpp.

◆ setTargetLayer()

void QgsLabelingEngineRuleAvoidLabelOverlapWithFeature::setTargetLayer ( QgsVectorLayer layer)

Sets the layer providing the features which labels must not overlap.

See also
targetLayer()

Definition at line 636 of file qgslabelingenginerule_impl.cpp.

◆ targetLayer()

QgsVectorLayer * QgsLabelingEngineRuleAvoidLabelOverlapWithFeature::targetLayer ( ) const

Returns the layer providing the features which labels must not overlap.

See also
setTargetLayer()

Definition at line 631 of file qgslabelingenginerule_impl.cpp.

◆ writeXml()

void QgsLabelingEngineRuleAvoidLabelOverlapWithFeature::writeXml ( QDomDocument &  doc,
QDomElement &  element,
const QgsReadWriteContext context 
) const
overridevirtual

Writes the rule properties to an XML element.

See also
readXml()

Implements QgsAbstractLabelingEngineRule.

Definition at line 539 of file qgslabelingenginerule_impl.cpp.


The documentation for this class was generated from the following files: