15 #ifndef QGSRULEBASEDLABELING_H 16 #define QGSRULEBASEDLABELING_H 18 #include "qgis_core.h" 19 #include <QStringList> 44 typedef QList<QgsRuleBasedLabeling::Rule *>
RuleList;
45 typedef QMap<QgsRuleBasedLabeling::Rule *, QgsVectorLayerLabelProvider *>
RuleToProviderMap;
56 Rule(
QgsPalLayerSettings *settings
SIP_TRANSFER,
double maximumScale = 0,
double minimumScale = 0,
const QString &filterExp = QString(),
const QString &description = QString(),
bool elseRule =
false );
62 Rule &operator=(
const Rule &rh ) =
delete;
122 bool active()
const {
return mIsActive; }
129 bool isElse()
const {
return mElseRule; }
167 void setDescription(
const QString &description ) { mDescription = description; }
229 void removeChildAt(
int i );
273 void subProviderIds( QStringList &list )
const SIP_SKIP;
279 void prepare(
const QgsRenderContext &context, QSet<QString> &attributeNames, RuleToProviderMap &subProviders )
SIP_SKIP;
291 bool requiresAdvancedEffects()
const;
314 bool isScaleOK(
double scale )
const;
324 void updateElseRules();
327 Rule *mParent =
nullptr;
328 std::unique_ptr<QgsPalLayerSettings> mSettings;
329 double mMaximumScale = 0;
330 double mMinimumScale = 0;
332 QString mDescription;
333 bool mElseRule =
false;
336 bool mIsActive =
true;
338 QString mRuleKey = QUuid::createUuid().toString();
340 std::unique_ptr<QgsExpression> mFilter;
357 QString type()
const override;
362 QStringList subProviders()
const override;
373 void setSettings(
QgsPalLayerSettings *settings SIP_TRANSFER,
const QString &providerId = QString() )
override;
374 bool requiresAdvancedEffects()
const override;
375 void toSld( QDomNode &parent,
const QgsStringMap &props )
const override;
404 QList<QgsAbstractLabelProvider *>
subProviders()
override;
408 std::unique_ptr<QgsRuleBasedLabeling>
mRules;
415 #endif // QGSRULEBASEDLABELING_H Class for parsing and evaluation of expressions (formerly called "search strings").
The class is used as a container of context for various read/write operations on other objects...
double maximumScale() const
Returns the maximum map scale (i.e.
QgsPalLayerSettings * settings() const
Gets the labeling settings.
void setFilterExpression(const QString &filterExp)
Set the expression used to check if a given feature shall be rendered with this rule.
QgsRuleBasedLabeling::RuleToProviderMap mSubProviders
label providers are owned by labeling engine
virtual void registerFeature(const QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry=QgsGeometry())
Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels...
bool isElse() const
Check if this rule is an ELSE rule.
RegisterResult
The result of registering a rule.
bool dependsOnScale() const
Determines if scale based labeling is active.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
const Rule * rootRule() const
QString description() const
A human readable description for this rule.
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
A geometry is the spatial representation of a feature.
QString ruleKey() const
Unique rule identifier (for identification of rule within labeling, used as provider ID) ...
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QMap< QgsRuleBasedLabeling::Rule *, QgsVectorLayerLabelProvider * > RuleToProviderMap
const QgsRuleBasedLabeling::RuleList & children() const
Returns all children rules of this rule.
QMap< QString, QString > QgsStringMap
QList< QgsRuleBasedLabeling::Rule * > RuleList
virtual bool prepare(const QgsRenderContext &context, QSet< QString > &attributeNames)
Prepare for registration of features.
std::unique_ptr< QgsRuleBasedLabeling > mRules
owned copy
QgsRuleBasedLabeling::Rule * rootRule()
double minimumScale() const
Returns the minimum map scale (i.e.
QgsRuleBasedLabeling::RuleList & children()
Returns all children rules of this rule.
void setActive(bool state)
Sets if this rule is active.
void setMinimumScale(double scale)
Sets the minimum map scale (i.e.
QgsRuleBasedLabeling::Rule * parent()
The parent rule.
void setRuleKey(const QString &key)
Override the assigned rule key (should be used just internally by rule-based labeling) ...
virtual QList< QgsAbstractLabelProvider * > subProviders()
Returns list of child providers - useful if the provider needs to put labels into more layers with di...
Contains information about the context of a rendering operation.
QString filterExpression() const
A filter that will check if this rule applies.
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
bool active() const
Returns if this rule is active.
const QgsRuleBasedLabeling::Rule * parent() const
The parent rule.
void setDescription(const QString &description)
Set a human readable description for this rule.
void setIsElse(bool iselse)
Sets if this rule is an ELSE rule.
Represents a vector layer which manages a vector based data sets.
void setMaximumScale(double scale)
Sets the maximum map scale (i.e.