15#ifndef QGSLABELINGENGINERULEIMPL_H
16#define QGSLABELINGENGINERULEIMPL_H
138 double cost()
const {
return mCost; }
155 bool mMustBeDistant =
true;
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;
202 QString displayType() const override;
203 QString description() 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;
232 QString displayType() const override;
233 QString description() 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;
264 QString displayType() const override;
265 QString description() const override;
266 bool isAvailable() const override;
267 void writeXml( QDomDocument &doc, QDomElement &element, const
QgsReadWriteContext &context ) const override;
269 void resolveReferences( const
QgsProject *project ) override;
272 bool candidatesAreConflicting( const
pal::LabelPosition *lp1, const
pal::LabelPosition *lp2 ) const override
SIP_SKIP;
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;
394 QString displayType() const override;
395 QString description() const override;
397 void writeXml( QDomDocument &doc, QDomElement &element, const
QgsReadWriteContext &context ) const override;
399 void resolveReferences( const
QgsProject *project ) 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.
Base class for labeling engine rules which prevents labels being placed too close or to far from feat...
~QgsAbstractLabelingEngineRuleDistanceFromFeature() override
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.
void setDistanceUnit(Qgis::RenderUnit unit)
Sets the unit for the distance between labels and the features from the targetLayer().
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().
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.
A labeling engine rule which prevents labels being placed overlapping features from a different layer...
QgsLabelingEngineRuleAvoidLabelOverlapWithFeature()
~QgsLabelingEngineRuleAvoidLabelOverlapWithFeature() override
A labeling engine rule which prevents labels being placed too far from features from a different laye...
~QgsLabelingEngineRuleMaximumDistanceLabelToFeature() override
A labeling engine rule which prevents labels being placed too close to features from a different laye...
QgsLabelingEngineRuleMinimumDistanceLabelToFeature()
~QgsLabelingEngineRuleMinimumDistanceLabelToFeature() override
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...
void setDistance(double distance)
Sets the minimum permitted distance between labels from the labeledLayer() and the labels from the ta...
Qgis::RenderUnit distanceUnit() const
Returns the units for the distance between labels from the labeledLayer() and the labels from the tar...
QgsLabelingEngineRuleMinimumDistanceLabelToLabel()
~QgsLabelingEngineRuleMinimumDistanceLabelToLabel() override
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,...
The class is used as a container of context for various read/write operations on other 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 data sets.
LabelPosition is a candidate feature label position.