QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
QgsLabelingEngineRuleMinimumDistanceLabelToLabel Class Reference

A labeling engine rule which prevents labels being placed too close to labels from a different layer. More...

#include <qgslabelingenginerule_impl.h>

Inheritance diagram for QgsLabelingEngineRuleMinimumDistanceLabelToLabel:

Public Member Functions

 QgsLabelingEngineRuleMinimumDistanceLabelToLabel ()
 ~QgsLabelingEngineRuleMinimumDistanceLabelToLabel () override
bool candidatesAreConflicting (const pal::LabelPosition *lp1, const pal::LabelPosition *lp2) const override
 Returns true if a labeling candidate lp1 conflicts with lp2 after applying the rule.
QgsLabelingEngineRuleMinimumDistanceLabelToLabelclone () 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.
double distance () const
 Returns the minimum permitted distance between labels from the labeledLayer() and the labels from the targetLayer().
Qgis::RenderUnit distanceUnit () const
 Returns the units for the distance between labels from the labeledLayer() and the labels from the targetLayer().
const QgsMapUnitScaledistanceUnitScale () const
 Returns the scaling for the distance between labels from the labeledLayer() and the labels from the targetLayer().
QString id () const override
 Returns a string uniquely identifying the rule subclass.
bool isAvailable () const override
 Returns true if the rule is available for use within the current QGIS environment.
QgsMapLayerlabeledLayer () const
 Returns the layer providing the labels.
QgsRectangle modifyCandidateConflictSearchBoundingBox (const QgsRectangle &candidateBounds) const override
 Returns a (possibly expanded) bounding box to use when searching for conflicts for a candidate.
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 setDistance (double distance)
 Sets the minimum permitted distance between labels from the labeledLayer() and the labels from the targetLayer().
void setDistanceUnit (Qgis::RenderUnit unit)
 Sets the unit for the distance between labels from the labeledLayer() and the labels from the targetLayer().
void setDistanceUnitScale (const QgsMapUnitScale &scale)
 Sets the scale for the distance between labels from the labeledLayer() and the labels from the targetLayer().
void setLabeledLayer (QgsMapLayer *layer)
 Sets the layer providing the labels.
void setTargetLayer (QgsMapLayer *layer)
 Sets the layer providing the labels which labels must be distant from.
QgsMapLayertargetLayer () const
 Returns the layer providing the labels which labels must be distant from.
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 candidateIsIllegal (const pal::LabelPosition *candidate, QgsLabelingEngineContext &context) const
 Returns true if a labeling candidate violates the rule and should be eliminated.
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 too close to labels from a different layer.

Since
QGIS 3.40

Definition at line 260 of file qgslabelingenginerule_impl.h.

Constructor & Destructor Documentation

◆ QgsLabelingEngineRuleMinimumDistanceLabelToLabel()

QgsLabelingEngineRuleMinimumDistanceLabelToLabel::QgsLabelingEngineRuleMinimumDistanceLabelToLabel ( )
default

◆ ~QgsLabelingEngineRuleMinimumDistanceLabelToLabel()

QgsLabelingEngineRuleMinimumDistanceLabelToLabel::~QgsLabelingEngineRuleMinimumDistanceLabelToLabel ( )
overridedefault

Member Function Documentation

◆ candidatesAreConflicting()

bool QgsLabelingEngineRuleMinimumDistanceLabelToLabel::candidatesAreConflicting ( const pal::LabelPosition * lp1,
const pal::LabelPosition * lp2 ) const
overridevirtual

Returns true if a labeling candidate lp1 conflicts with lp2 after applying the rule.

The default implementation returns false.

Reimplemented from QgsAbstractLabelingEngineRule.

Definition at line 442 of file qgslabelingenginerule_impl.cpp.

◆ clone()

QgsLabelingEngineRuleMinimumDistanceLabelToLabel * QgsLabelingEngineRuleMinimumDistanceLabelToLabel::clone ( ) const
overridevirtual

Creates a clone of this rule.

The caller takes ownership of the returned object.

Implements QgsAbstractLabelingEngineRule.

Definition at line 335 of file qgslabelingenginerule_impl.cpp.

◆ description()

QString QgsLabelingEngineRuleMinimumDistanceLabelToLabel::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 357 of file qgslabelingenginerule_impl.cpp.

◆ displayType()

QString QgsLabelingEngineRuleMinimumDistanceLabelToLabel::displayType ( ) const
overridevirtual

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

Implements QgsAbstractLabelingEngineRule.

Definition at line 352 of file qgslabelingenginerule_impl.cpp.

◆ distance()

double QgsLabelingEngineRuleMinimumDistanceLabelToLabel::distance ( ) const
inline

Returns the minimum permitted distance between labels from the labeledLayer() and the labels from the targetLayer().

See also
setDistance()
distanceUnit()

Definition at line 321 of file qgslabelingenginerule_impl.h.

◆ distanceUnit()

Qgis::RenderUnit QgsLabelingEngineRuleMinimumDistanceLabelToLabel::distanceUnit ( ) const
inline

Returns the units for the distance between labels from the labeledLayer() and the labels from the targetLayer().

See also
setDistanceUnit()
distance()

Definition at line 339 of file qgslabelingenginerule_impl.h.

◆ distanceUnitScale()

const QgsMapUnitScale & QgsLabelingEngineRuleMinimumDistanceLabelToLabel::distanceUnitScale ( ) const
inline

Returns the scaling for the distance between labels from the labeledLayer() and the labels from the targetLayer().

See also
setDistanceUnitScale()
distance()

Definition at line 357 of file qgslabelingenginerule_impl.h.

◆ id()

QString QgsLabelingEngineRuleMinimumDistanceLabelToLabel::id ( ) const
overridevirtual

Returns a string uniquely identifying the rule subclass.

Implements QgsAbstractLabelingEngineRule.

Definition at line 347 of file qgslabelingenginerule_impl.cpp.

◆ isAvailable()

bool QgsLabelingEngineRuleMinimumDistanceLabelToLabel::isAvailable ( ) const
overridevirtual

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 from QgsAbstractLabelingEngineRule.

Definition at line 372 of file qgslabelingenginerule_impl.cpp.

◆ labeledLayer()

QgsMapLayer * QgsLabelingEngineRuleMinimumDistanceLabelToLabel::labeledLayer ( ) const

Returns the layer providing the labels.

See also
setLabeledLayer()

Definition at line 475 of file qgslabelingenginerule_impl.cpp.

◆ modifyCandidateConflictSearchBoundingBox()

QgsRectangle QgsLabelingEngineRuleMinimumDistanceLabelToLabel::modifyCandidateConflictSearchBoundingBox ( const QgsRectangle & candidateBounds) const
overridevirtual

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 from QgsAbstractLabelingEngineRule.

Definition at line 437 of file qgslabelingenginerule_impl.cpp.

◆ prepare()

bool QgsLabelingEngineRuleMinimumDistanceLabelToLabel::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 431 of file qgslabelingenginerule_impl.cpp.

◆ readXml()

void QgsLabelingEngineRuleMinimumDistanceLabelToLabel::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 403 of file qgslabelingenginerule_impl.cpp.

◆ resolveReferences()

void QgsLabelingEngineRuleMinimumDistanceLabelToLabel::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 425 of file qgslabelingenginerule_impl.cpp.

◆ setDistance()

void QgsLabelingEngineRuleMinimumDistanceLabelToLabel::setDistance ( double distance)
inline

Sets the minimum permitted distance between labels from the labeledLayer() and the labels from the targetLayer().

See also
distance()
setDistanceUnit()

Definition at line 330 of file qgslabelingenginerule_impl.h.

◆ setDistanceUnit()

void QgsLabelingEngineRuleMinimumDistanceLabelToLabel::setDistanceUnit ( Qgis::RenderUnit unit)
inline

Sets the unit for the distance between labels from the labeledLayer() and the labels from the targetLayer().

See also
distanceUnit()
setDistance()

Definition at line 348 of file qgslabelingenginerule_impl.h.

◆ setDistanceUnitScale()

void QgsLabelingEngineRuleMinimumDistanceLabelToLabel::setDistanceUnitScale ( const QgsMapUnitScale & scale)
inline

Sets the scale for the distance between labels from the labeledLayer() and the labels from the targetLayer().

See also
distanceUnitScale()
setDistance()

Definition at line 366 of file qgslabelingenginerule_impl.h.

◆ setLabeledLayer()

void QgsLabelingEngineRuleMinimumDistanceLabelToLabel::setLabeledLayer ( QgsMapLayer * layer)

Sets the layer providing the labels.

See also
labeledLayer()

Definition at line 480 of file qgslabelingenginerule_impl.cpp.

◆ setTargetLayer()

void QgsLabelingEngineRuleMinimumDistanceLabelToLabel::setTargetLayer ( QgsMapLayer * layer)

Sets the layer providing the labels which labels must be distant from.

See also
targetLayer()

Definition at line 490 of file qgslabelingenginerule_impl.cpp.

◆ targetLayer()

QgsMapLayer * QgsLabelingEngineRuleMinimumDistanceLabelToLabel::targetLayer ( ) const

Returns the layer providing the labels which labels must be distant from.

See also
setTargetLayer()

Definition at line 485 of file qgslabelingenginerule_impl.cpp.

◆ writeXml()

void QgsLabelingEngineRuleMinimumDistanceLabelToLabel::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 381 of file qgslabelingenginerule_impl.cpp.


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