15#ifndef QGSLABELINGENGINERULEIMPL_H
16#define QGSLABELINGENGINERULEIMPL_H
138 double cost()
const {
return mCost; }
172 double mDistance = 5;
181 double mDistanceMapUnits = 0;
182 std::unique_ptr< QgsAbstractFeatureSource > mTargetLayerSource;
183 std::unique_ptr< QgsSpatialIndex > mIndex;
184 bool mInitialized =
false;
201 QString
id() const override;
205 SIP_PYOBJECT __repr__();
207 const QString str = QStringLiteral(
"<QgsLabelingEngineRuleMinimumDistanceLabelToFeature: %1>" ).arg( sipCpp->name() );
208 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
231 QString
id() const override;
236 SIP_PYOBJECT __repr__();
238 const QString str = QStringLiteral(
"<QgsLabelingEngineRuleMaximumDistanceLabelToFeature: %1>" ).arg( sipCpp->name() );
239 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
263 QString
id() const override;
275 SIP_PYOBJECT __repr__();
277 const QString str = QStringLiteral(
"<QgsLabelingEngineRuleMinimumDistanceLabelToLabel: %1>" ).arg( sipCpp->name() );
278 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
371 double mDistance = 5;
376 double mDistanceMapUnits = 0;
393 QString
id() const override;
403 SIP_PYOBJECT __repr__();
405 const QString str = QStringLiteral(
"<QgsLabelingEngineRuleAvoidLabelOverlapWithFeature: %1>" ).arg( sipCpp->name() );
406 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
448 std::unique_ptr< QgsAbstractFeatureSource > mTargetLayerSource;
449 std::unique_ptr< QgsSpatialIndex > mIndex;
450 bool mInitialized =
false;
RenderUnit
Rendering size units.
@ Millimeters
Millimeters.
~QgsAbstractLabelingEngineRuleDistanceFromFeature() override
void setTargetLayer(QgsVectorLayer *layer)
Sets the layer providing the features which labels must be distant from (or close to).
Qgis::RenderUnit distanceUnit() const
Returns the units for the distance between labels and the features from the targetLayer().
QgsAbstractLabelingEngineRuleDistanceFromFeature()
const QgsMapUnitScale & distanceUnitScale() const
Returns the scaling 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().
double distance() const
Returns the acceptable distance threshold between labels and the features from the targetLayer().
void setCost(double cost)
Sets the penalty cost incurred when the rule is violated.
QgsVectorLayer * targetLayer() const
Returns the layer providing the features which labels must be distant from (or close to).
void setDistanceUnit(Qgis::RenderUnit unit)
Sets the unit for the distance between labels and the features from the targetLayer().
void setLabeledLayer(QgsMapLayer *layer)
Sets the layer providing the labels.
double cost() const
Returns 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().
QgsMapLayer * labeledLayer() const
Returns the layer providing the labels.
bool mMustBeDistant
true if labels must be distant from features, false if they must be close
Abstract base class for labeling engine rules.
virtual bool prepare(QgsRenderContext &context)=0
Prepares the rule.
virtual void alterCandidateCost(pal::LabelPosition *candidate, QgsLabelingEngineContext &context) const
Provides an opportunity for the rule to alter the cost for a candidate.
virtual void resolveReferences(const QgsProject *project)
Resolves reference to layers from stored layer ID.
virtual bool isAvailable() const
Returns true if the rule is available for use within the current QGIS environment.
virtual void readXml(const QDomElement &element, const QgsReadWriteContext &context)=0
Reads the rule properties from an XML element.
virtual void writeXml(QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context) const =0
Writes the rule properties to an XML element.
virtual QgsAbstractLabelingEngineRule * clone() const =0
Creates a clone of this rule.
virtual bool candidateIsIllegal(const pal::LabelPosition *candidate, QgsLabelingEngineContext &context) const
Returns true if a labeling candidate violates the rule and should be eliminated.
virtual void copyCommonProperties(QgsAbstractLabelingEngineRule *other) const
Copies common properties from this object to an other.
Encapsulates the context for a labeling engine run.
void readXml(const QDomElement &element, const QgsReadWriteContext &context) override
Reads the rule properties from an XML element.
void writeXml(QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context) const override
Writes the rule properties to an XML element.
QgsLabelingEngineRuleAvoidLabelOverlapWithFeature()
QString displayType() const override
Returns a user-friendly, translated string representing the rule type.
bool prepare(QgsRenderContext &context) override
Prepares the rule.
void setTargetLayer(QgsVectorLayer *layer)
Sets the layer providing the features which labels must not overlap.
QString description() const override
Returns a user-friendly description of the rule.
void setLabeledLayer(QgsMapLayer *layer)
Sets the layer providing the labels.
QgsMapLayer * labeledLayer() const
Returns the layer providing the labels.
void resolveReferences(const QgsProject *project) override
Resolves reference to layers from stored layer ID.
bool candidateIsIllegal(const pal::LabelPosition *candidate, QgsLabelingEngineContext &context) const override
Returns true if a labeling candidate violates the rule and should be eliminated.
QgsVectorLayer * targetLayer() const
Returns the layer providing the features which labels must not overlap.
~QgsLabelingEngineRuleAvoidLabelOverlapWithFeature() override
~QgsLabelingEngineRuleMaximumDistanceLabelToFeature() override
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.
QgsLabelingEngineRuleMaximumDistanceLabelToFeature()
QgsLabelingEngineRuleMinimumDistanceLabelToFeature()
QString description() const override
Returns a user-friendly description of the rule.
~QgsLabelingEngineRuleMinimumDistanceLabelToFeature() override
QString displayType() const override
Returns a user-friendly, translated string representing the rule type.
A labeling engine rule which prevents labels being placed too close to labels from a different layer.
double distance() const
Returns the minimum permitted distance between labels from the labeledLayer() and the labels from the...
const QgsMapUnitScale & distanceUnitScale() const
Returns the scaling for the distance between labels from the labeledLayer() and the labels from the t...
void setDistanceUnit(Qgis::RenderUnit unit)
Sets the unit for the distance between labels from the labeledLayer() and the labels from the targetL...
QgsMapLayer * labeledLayer() 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.
void setLabeledLayer(QgsMapLayer *layer)
Sets the layer providing the labels.
void writeXml(QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context) const override
Writes the rule properties to an XML element.
void resolveReferences(const QgsProject *project) override
Resolves reference to layers from stored layer ID.
QgsMapLayer * targetLayer() const
Returns the layer providing the labels which labels must be distant from.
void readXml(const QDomElement &element, const QgsReadWriteContext &context) override
Reads the rule properties from an XML element.
void setDistance(double distance)
Sets the minimum permitted distance between labels from the labeledLayer() and the labels from the ta...
QString displayType() const override
Returns a user-friendly, translated string representing the rule type.
QString description() const override
Returns a user-friendly description of the rule.
void setTargetLayer(QgsMapLayer *layer)
Sets the layer providing the labels which labels must be distant from.
Qgis::RenderUnit distanceUnit() const
Returns the units for the distance between labels from the labeledLayer() and the labels from the tar...
QgsLabelingEngineRuleMinimumDistanceLabelToLabel()
~QgsLabelingEngineRuleMinimumDistanceLabelToLabel() override
bool prepare(QgsRenderContext &context) override
Prepares the rule.
bool isAvailable() const override
Returns true if the rule is available for use within the current QGIS environment.
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.
void setDistanceUnitScale(const QgsMapUnitScale &scale)
Sets the scale for the distance between labels from the labeledLayer() and the labels from the target...
Base class for all map layer types.
Struct for storing maximum and minimum scales for measurements in map units.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
A container for the context for various read/write operations on objects.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
A spatial index for QgsFeature objects.
Represents a vector layer which manages a vector based dataset.
LabelPosition is a candidate feature label position.
_LayerRef< QgsMapLayer > QgsMapLayerRef
_LayerRef< QgsVectorLayer > QgsVectorLayerRef