16 #ifndef QGSRULEBASEDRENDERER_H
17 #define QGSRULEBASEDRENDERER_H
19 #include "qgis_core.h"
98 QList<QgsRuleBasedRenderer::RenderJob *>
jobs;
105 for (
auto it = rh.
jobs.constBegin(); it != rh.
jobs.constEnd(); ++it )
113 : zIndex( other.zIndex ), jobs()
115 for (
auto it = other.
jobs.constBegin(); it != other.
jobs.constEnd(); ++it )
127 typedef QList<QgsRuleBasedRenderer::Rule *>
RuleList;
152 const QString &label = QString(),
const QString &description = QString(),
bool elseRule =
false );
165 QString
dump(
int indent = 0 )
const;
176 bool needsGeometry()
const;
200 bool isScaleOK(
double scale )
const;
203 QString
label()
const {
return mLabel; }
250 bool active()
const {
return mIsActive; }
266 void setLabel(
const QString &label ) { mLabel = label; }
291 void setFilterExpression(
const QString &filterExp );
298 void setDescription(
const QString &description ) { mDescription = description; }
310 void toSld( QDomDocument &doc, QDomElement &element, QVariantMap props ) const;
317 QDomElement save( QDomDocument &doc,
QgsSymbolMap &symbolMap ) const;
323 QSet<
int> collectZLevels();
329 void setNormZLevels( const QMap<
int,
int> &zLevelsToNormLevels )
SIP_SKIP;
412 void removeChildAt(
int i );
431 void setIsElse(
bool iselse );
438 bool isElse()
const {
return mElseRule; }
459 Rule *mParent =
nullptr;
460 std::unique_ptr< QgsSymbol > mSymbol;
461 double mMaximumScale = 0;
462 double mMinimumScale = 0;
463 QString mFilterExp, mLabel, mDescription;
464 bool mElseRule =
false;
467 bool mIsActive =
true;
472 std::unique_ptr< QgsExpression > mFilter;
474 QSet<int> mSymbolNormZLevels;
481 void updateElseRules();
507 QSet<QString> usedAttributes( const
QgsRenderContext &context ) const override;
509 bool filterNeedsGeometry() const override;
513 void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props = QVariantMap() ) const override;
520 bool legendSymbolItemsCheckable() const override;
521 bool legendSymbolItemChecked( const QString &key ) override;
522 void checkLegendSymbolItem( const QString &key,
bool state = true ) override;
526 QString dump() const override;
558 static
void convertToDataDefinedSymbology(
QgsSymbol *symbol, const QString &sizeScaleField, const QString &rotationField = QString() );
Custom exception class for Coordinate Reference System related exceptions.
Class for parsing and evaluation of expressions (formerly called "search strings").
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
virtual QgsLegendSymbolList legendSymbolItems() const
Returns a list of symbology items for the legend.
virtual QgsSymbolList symbols(QgsRenderContext &context) const
Returns list of symbols used by the renderer.
virtual QgsSymbol * symbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const =0
To be overridden.
virtual QString dump() const
Returns debug information about this renderer.
@ ScaleDependent
Depends on scale if feature will be rendered (rule based )
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const =0
Returns a list of attributes required by this renderer.
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
virtual bool renderFeature(const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false) SIP_THROW(QgsCsException)
Render a feature using this renderer in the given context.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Container of fields for a vector layer.
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.
This class keeps data about a rules for rule-based renderer.
QString ruleKey() const
Unique rule identifier (for identification of rule within renderer)
void setDescription(const QString &description)
Set a human readable description for this rule.
bool dependsOnScale() const
RenderResult
The result of rendering a rule.
@ Inactive
The rule is inactive.
double maximumScale() const
Returns the maximum map scale (i.e.
bool isElse() const
Check if this rule is an ELSE rule.
QgsRuleBasedRenderer::Rule * parent()
The parent rule.
void setMaximumScale(double scale)
Sets the maximum map scale (i.e.
void setActive(bool state)
Sets if this rule is active.
Rule(const Rule &rh)=delete
Rules cannot be copied.
QgsExpression * filter() const
A filter that will check if this rule applies.
double minimumScale() const
Returns the minimum map scale (i.e.
QString description() const
A human readable description for this rule.
void setMinimumScale(double scale)
Sets the minimum map scale (i.e.
void setLabel(const QString &label)
void setRuleKey(const QString &key)
Override the assigned rule key (should be used just internally by rule-based renderer)
QString filterExpression() const
A filter that will check if this rule applies.
bool active() const
Returns if this rule is active.
Rule & operator=(const Rule &rh)=delete
Rules cannot be copied.
QList< QgsRuleBasedRenderer::RenderLevel > RenderQueue
Rendering queue: a list of rendering levels.
QgsRuleBasedRenderer::Rule * rootRule()
QList< QgsRuleBasedRenderer::Rule * > RuleList
An interface for classes which can visit style entity (e.g.
Abstract base class for all rendered symbols.
Represents a vector layer which manages a vector based data sets.
Handles storage of information regarding WKB types and their properties.
QList< QgsLegendSymbolItem > QgsLegendSymbolList
QMap< QString, QgsSymbol * > QgsSymbolMap
QList< QgsSymbol * > QgsSymbolList
Feature for rendering by a QgsRuleBasedRenderer.
FeatureToRender(const QgsFeature &_f, int _flags)
A QgsRuleBasedRenderer rendering job, consisting of a feature to be rendered with a particular symbol...
QgsRuleBasedRenderer::FeatureToRender & ftr
Feature to render.
RenderJob(QgsRuleBasedRenderer::FeatureToRender &_ftr, QgsSymbol *_s)
Render level: a list of jobs to be drawn at particular level for a QgsRuleBasedRenderer.
QList< QgsRuleBasedRenderer::RenderJob * > jobs
List of jobs to render, owned by this object.
RenderLevel(const QgsRuleBasedRenderer::RenderLevel &other)
QgsRuleBasedRenderer::RenderLevel & operator=(const QgsRuleBasedRenderer::RenderLevel &rh)