QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
|
Base class for labeling engine rules which prevents labels being placed too close or to far from features from a different layer. More...
#include <qgslabelingenginerule_impl.h>
Public Member Functions | |
QgsAbstractLabelingEngineRuleDistanceFromFeature () | |
~QgsAbstractLabelingEngineRuleDistanceFromFeature () override | |
void | alterCandidateCost (pal::LabelPosition *candidate, QgsLabelingEngineContext &context) const override |
Provides an opportunity for the rule to alter the cost for a candidate. | |
bool | candidateIsIllegal (const pal::LabelPosition *candidate, QgsLabelingEngineContext &context) const override |
Returns true if a labeling candidate violates the rule and should be eliminated. | |
double | cost () const |
Returns the penalty cost incurred when the rule is violated. | |
double | distance () const |
Returns the acceptable distance threshold between labels and the features from the targetLayer(). | |
Qgis::RenderUnit | distanceUnit () const |
Returns the units for the distance between labels and the features from the targetLayer(). | |
const QgsMapUnitScale & | distanceUnitScale () const |
Returns the scaling for the distance between labels and the features from the targetLayer(). | |
bool | isAvailable () const override |
Returns true if the rule is available for use within the current QGIS environment. | |
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 | setCost (double cost) |
Sets the penalty cost incurred when the rule is violated. | |
void | setDistance (double distance) |
Sets the acceptable distance threshold between labels and the features from the targetLayer(). | |
void | setDistanceUnit (Qgis::RenderUnit unit) |
Sets the unit for the distance between labels and the features from the targetLayer(). | |
void | setDistanceUnitScale (const QgsMapUnitScale &scale) |
Sets the scale for the distance between labels and the features from the targetLayer(). | |
void | setLabeledLayer (QgsMapLayer *layer) |
Sets the layer providing the labels. | |
void | setTargetLayer (QgsVectorLayer *layer) |
Sets the layer providing the features which labels must be distant from (or close to). | |
QgsVectorLayer * | targetLayer () const |
Returns the layer providing the features which labels must be distant from (or close to). | |
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 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 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. | |
Protected Member Functions | |
void | copyCommonProperties (QgsAbstractLabelingEngineRule *other) const override |
Copies common properties from this object to an other. | |
Protected Attributes | |
bool | mMustBeDistant = true |
true if labels must be distant from features, false if they must be close | |
Base class for labeling engine rules which prevents labels being placed too close or to far from features from a different layer.
Definition at line 34 of file qgslabelingenginerule_impl.h.
|
default |
|
overridedefault |
|
overridevirtual |
Provides an opportunity for the rule to alter the cost for a candidate.
The default implementation does nothing.
Reimplemented from QgsAbstractLabelingEngineRule.
Definition at line 117 of file qgslabelingenginerule_impl.cpp.
|
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 100 of file qgslabelingenginerule_impl.cpp.
|
overrideprotectedvirtual |
Copies common properties from this object to an other.
Reimplemented from QgsAbstractLabelingEngineRule.
Definition at line 168 of file qgslabelingenginerule_impl.cpp.
|
inline |
Returns the penalty cost incurred when the rule is violated.
This is a value between 0 and 10, where 10 indicates that the rule must never be violated, and 1-9 = nice to have if possible, where higher numbers will try harder to avoid violating the rule.
Definition at line 138 of file qgslabelingenginerule_impl.h.
|
inline |
Returns the acceptable distance threshold between labels and the features from the targetLayer().
Definition at line 83 of file qgslabelingenginerule_impl.h.
|
inline |
Returns the units for the distance between labels and the features from the targetLayer().
Definition at line 101 of file qgslabelingenginerule_impl.h.
|
inline |
Returns the scaling for the distance between labels and the features from the targetLayer().
Definition at line 119 of file qgslabelingenginerule_impl.h.
|
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 139 of file qgslabelingenginerule_impl.cpp.
QgsMapLayer * QgsAbstractLabelingEngineRuleDistanceFromFeature::labeledLayer | ( | ) | const |
Returns the layer providing the labels.
Definition at line 148 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 36 of file qgslabelingenginerule_impl.cpp.
|
overridevirtual |
Reads the rule properties from an XML element.
Implements QgsAbstractLabelingEngineRule.
Definition at line 71 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 94 of file qgslabelingenginerule_impl.cpp.
|
inline |
Sets the penalty cost incurred when the rule is violated.
This is a value between 0 and 10, where 10 indicates that the rule must never be violated, and 1-9 = nice to have if possible, where higher numbers will try harder to avoid violating the rule.
Definition at line 148 of file qgslabelingenginerule_impl.h.
|
inline |
Sets the acceptable distance threshold between labels and the features from the targetLayer().
Definition at line 92 of file qgslabelingenginerule_impl.h.
|
inline |
Sets the unit for the distance between labels and the features from the targetLayer().
Definition at line 110 of file qgslabelingenginerule_impl.h.
|
inline |
Sets the scale for the distance between labels and the features from the targetLayer().
Definition at line 128 of file qgslabelingenginerule_impl.h.
void QgsAbstractLabelingEngineRuleDistanceFromFeature::setLabeledLayer | ( | QgsMapLayer * | layer | ) |
Sets the layer providing the labels.
Definition at line 153 of file qgslabelingenginerule_impl.cpp.
void QgsAbstractLabelingEngineRuleDistanceFromFeature::setTargetLayer | ( | QgsVectorLayer * | layer | ) |
Sets the layer providing the features which labels must be distant from (or close to).
Definition at line 163 of file qgslabelingenginerule_impl.cpp.
QgsVectorLayer * QgsAbstractLabelingEngineRuleDistanceFromFeature::targetLayer | ( | ) | const |
Returns the layer providing the features which labels must be distant from (or close to).
Definition at line 158 of file qgslabelingenginerule_impl.cpp.
|
overridevirtual |
Writes the rule properties to an XML element.
Implements QgsAbstractLabelingEngineRule.
Definition at line 48 of file qgslabelingenginerule_impl.cpp.
|
protected |
true
if labels must be distant from features, false
if they must be close
Definition at line 155 of file qgslabelingenginerule_impl.h.