15#ifndef QGSLABELINGENGINERULE_H
16#define QGSLABELINGENGINERULE_H
107 void setMapBoundaryGeometry(
const QgsGeometry &geometry );
137 if ( sipCpp->id() ==
"minimumDistanceLabelToFeature" )
139 sipType = sipType_QgsLabelingEngineRuleMinimumDistanceLabelToFeature;
141 else if ( sipCpp->id() ==
"minimumDistanceLabelToLabel" )
143 sipType = sipType_QgsLabelingEngineRuleMinimumDistanceLabelToLabel;
145 else if ( sipCpp->id() ==
"maximumDistanceLabelToFeature" )
147 sipType = sipType_QgsLabelingEngineRuleMaximumDistanceLabelToFeature;
149 else if ( sipCpp->id() ==
"avoidLabelOverlapWithFeature" )
151 sipType = sipType_QgsLabelingEngineRuleAvoidLabelOverlapWithFeature;
174 virtual QString
id()
const = 0;
209 QString
name()
const {
return mName; }
233 void setActive(
bool active );
305 bool mIsActive =
true;
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 QgsRectangle modifyCandidateConflictSearchBoundingBox(const QgsRectangle &candidateBounds) const
Returns a (possibly expanded) bounding box to use when searching for conflicts for a candidate.
virtual void writeXml(QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context) const =0
Writes the rule properties to an XML element.
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.
QString name() const
Returns the name for this instance of the rule.
virtual ~QgsAbstractLabelingEngineRule()
virtual QgsAbstractLabelingEngineRule * clone() const =0
Creates a clone of this rule.
virtual QString displayType() const =0
Returns a user-friendly, translated string representing the rule type.
virtual QString description() const
Returns a user-friendly description of the rule.
void setName(const QString &name)
Sets the name for this instance of the 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 QString id() const =0
Returns a string uniquely identifying the rule subclass.
virtual void copyCommonProperties(QgsAbstractLabelingEngineRule *other) const
Copies common properties from this object to an other.
A geometry is the spatial representation of a feature.
Encapsulates the context for a labeling engine run.
QgsLabelingEngineContext & operator=(const QgsLabelingEngineContext &other)=delete
QgsLabelingEngineContext(const QgsLabelingEngineContext &other)=delete
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
const QgsRenderContext & renderContext() const
Returns a reference to the context's render context.
QgsLabelingEngineContext(QgsRenderContext &renderContext)
Constructor for QgsLabelingEngineContext.
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.
LabelPosition is a candidate feature label position.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)