15#ifndef QGSRULEBASEDLABELING_H
16#define QGSRULEBASEDLABELING_H
46 typedef QList<QgsRuleBasedLabeling::Rule *>
RuleList;
47 typedef QMap<QgsRuleBasedLabeling::Rule *, QgsVectorLayerLabelProvider *>
RuleToProviderMap;
59 Rule(
QgsPalLayerSettings *settings
SIP_TRANSFER,
double maximumScale = 0,
double minimumScale = 0,
const QString &filterExp = QString(),
const QString &description = QString(),
bool elseRule =
false );
125 bool active()
const {
return mIsActive; }
132 bool isElse()
const {
return mElseRule; }
170 void setDescription(
const QString &description ) { mDescription = description; }
232 void removeChildAt(
int i );
277 void subProviderIds( QStringList &list ) const
SIP_SKIP;
300 bool requiresAdvancedEffects() const;
334 bool isScaleOK(
double scale )
const;
344 void updateElseRules();
347 Rule *mParent =
nullptr;
348 std::unique_ptr<QgsPalLayerSettings> mSettings;
349 double mMaximumScale = 0;
350 double mMinimumScale = 0;
352 QString mDescription;
353 bool mElseRule =
false;
356 bool mIsActive =
true;
358 QString mRuleKey = QUuid::createUuid().toString();
360 std::unique_ptr<QgsExpression> mFilter;
370 const Rule *rootRule() const
SIP_SKIP;
377 QString type() const override;
382 QStringList subProviders() const override;
395 bool requiresAdvancedEffects() const override;
396 void toSld( QDomNode &parent, const QVariantMap &props ) const override;
397 void multiplyOpacity(
double opacityFactor ) override;
422 bool prepare(
QgsRenderContext &context, QSet<QString> &attributeNames )
override;
430 QList<QgsAbstractLabelProvider *>
subProviders()
override;
434 std::unique_ptr<QgsRuleBasedLabeling>
mRules;
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
virtual QStringList subProviders() const
Gets list of sub-providers within the layer's labeling.
virtual void setSettings(QgsPalLayerSettings *settings, const QString &providerId=QString())=0
Set pal settings for a specific provider (takes ownership).
virtual QgsAbstractVectorLayerLabeling * clone() const =0
Returns a new copy of the object.
Class for parsing and evaluation of expressions (formerly called "search strings").
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
A geometry is the spatial representation of a feature.
The QgsLabelFeature class describes a feature that should be used within the labeling engine.
Contains settings for how a map layer will be labeled.
The class is used as a container of context for various read/write operations on other objects.
Contains information about the context of a rendering operation.
Label provider for rule based labeling.
std::unique_ptr< QgsRuleBasedLabeling > mRules
owned copy
QgsRuleBasedLabeling::RuleToProviderMap mSubProviders
label providers are owned by labeling engine
A child rule for QgsRuleBasedLabeling.
QgsRuleBasedLabeling::RuleList & children()
Returns all children rules of this rule.
void setRuleKey(const QString &key)
Override the assigned rule key (should be used just internally by rule-based labeling)
void setMaximumScale(double scale)
Sets the maximum map scale (i.e.
Rule(const Rule &rh)=delete
Rules cannot be copied.
double maximumScale() const
Returns the maximum map scale (i.e.
void setDescription(const QString &description)
Set a human readable description for this rule.
bool dependsOnScale() const
Determines if scale based labeling is active.
const QgsRuleBasedLabeling::RuleList & children() const
Returns all children rules of this rule.
QString filterExpression() const
A filter that will check if this rule applies.
QgsRuleBasedLabeling::Rule * parent()
The parent rule.
const QgsRuleBasedLabeling::Rule * parent() const
The parent rule.
bool active() const
Returns if this rule is active.
QgsPalLayerSettings * settings() const
Returns the labeling settings.
RegisterResult
The result of registering a rule.
@ Inactive
The rule is inactive.
void setActive(bool state)
Sets if this rule is active.
bool isElse() const
Check if this rule is an ELSE rule.
void setMinimumScale(double scale)
Sets the minimum map scale (i.e.
Rule & operator=(const Rule &rh)=delete
Rules cannot be copied.
void setFilterExpression(const QString &filterExp)
Set the expression used to check if a given feature shall be rendered with this rule.
double minimumScale() const
Returns the minimum map scale (i.e.
void setIsElse(bool iselse)
Sets if this rule is an ELSE rule.
QString ruleKey() const
Unique rule identifier (for identification of rule within labeling, used as provider ID)
QString description() const
A human readable description for this rule.
Rule based labeling for a vector layer.
QList< QgsRuleBasedLabeling::Rule * > RuleList
QMap< QgsRuleBasedLabeling::Rule *, QgsVectorLayerLabelProvider * > RuleToProviderMap
An interface for classes which can visit style entity (e.g.
Abstract base class for all rendered symbols.
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
Represents a vector layer which manages a vector based data sets.
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)