QGIS API Documentation
3.0.2-Girona (307d082)
|
This class keeps data about a rules for rule-based renderer. More...
#include <qgsrulebasedrenderer.h>
Public Types | |
enum | RenderResult { Filtered = 0, Inactive, Rendered } |
The result of rendering a rule. More... | |
Public Member Functions | |
Rule (QgsSymbol *symbol, int maximumScale=0, int minimumScale=0, const QString &filterExp=QString(), const QString &label=QString(), const QString &description=QString(), bool elseRule=false) | |
Constructor takes ownership of the symbol. More... | |
Rule (const Rule &rh)=delete | |
Rules cannot be copied. More... | |
~Rule () | |
bool | active () const |
Returns if this rule is active. More... | |
void | appendChild (QgsRuleBasedRenderer::Rule *rule) |
add child rule, take ownership, sets this as parent More... | |
QgsRuleBasedRenderer::RuleList & | children () |
Return all children rules of this rule. More... | |
QgsRuleBasedRenderer::Rule * | clone () const |
clone this rule, return new instance More... | |
QSet< int > | collectZLevels () |
get all used z-levels from this rule and children More... | |
bool | dependsOnScale () const |
QgsRuleBasedRenderer::RuleList | descendants () const |
Returns all children, grand-children, grand-grand-children, grand-gra... More... | |
QString | description () const |
A human readable description for this rule. More... | |
QString | dump (int indent=0) const |
Dump for debug purpose. More... | |
QgsExpression * | filter () const |
A filter that will check if this rule applies. More... | |
QString | filterExpression () const |
A filter that will check if this rule applies. More... | |
QgsRuleBasedRenderer::Rule * | findRuleByKey (const QString &key) |
Try to find a rule given its unique key. More... | |
void | insertChild (int i, QgsRuleBasedRenderer::Rule *rule) |
add child rule, take ownership, sets this as parent More... | |
bool | isElse () |
Check if this rule is an ELSE rule. More... | |
bool | isFilterOK (QgsFeature &f, QgsRenderContext *context=nullptr) const |
Check if a given feature shall be rendered by this rule. More... | |
bool | isScaleOK (double scale) const |
Check if this rule applies for a given scale. More... | |
QString | label () const |
QSet< QString > | legendKeysForFeature (QgsFeature &feat, QgsRenderContext *context=nullptr) |
Returns which legend keys match the feature. More... | |
QgsLegendSymbolList | legendSymbolItems (int currentLevel=-1) const |
double | maximumScale () const |
Returns the maximum map scale (i.e. More... | |
double | minimumScale () const |
Returns the minimum map scale (i.e. More... | |
bool | needsGeometry () const |
Returns true if this rule or one of its chilren needs the geometry to be applied. More... | |
Rule & | operator= (const Rule &rh)=delete |
Rules cannot be copied. More... | |
QgsRuleBasedRenderer::Rule * | parent () |
The parent rule. More... | |
void | removeChild (QgsRuleBasedRenderer::Rule *rule) |
delete child rule More... | |
void | removeChildAt (int i) |
delete child rule More... | |
QgsRuleBasedRenderer::Rule::RenderResult | renderFeature (QgsRuleBasedRenderer::FeatureToRender &featToRender, QgsRenderContext &context, QgsRuleBasedRenderer::RenderQueue &renderQueue) |
Render a given feature, will recursively call subclasses and only render if the constraints apply. More... | |
QString | ruleKey () const |
Unique rule identifier (for identification of rule within renderer) More... | |
QgsRuleBasedRenderer::RuleList | rulesForFeature (QgsFeature &feat, QgsRenderContext *context=nullptr) |
tell which rules will be used to render the feature More... | |
QDomElement | save (QDomDocument &doc, QgsSymbolMap &symbolMap) const |
void | setActive (bool state) |
Sets if this rule is active. More... | |
void | setDescription (const QString &description) |
Set a human readable description for this rule. More... | |
void | setFilterExpression (const QString &filterExp) |
Set the expression used to check if a given feature shall be rendered with this rule. More... | |
void | setIsElse (bool iselse) |
Sets if this rule is an ELSE rule. More... | |
void | setLabel (const QString &label) |
void | setMaximumScale (double scale) |
Sets the maximum map scale (i.e. More... | |
void | setMinimumScale (double scale) |
Sets the minimum map scale (i.e. More... | |
void | setNormZLevels (const QMap< int, int > &zLevelsToNormLevels) |
assign normalized z-levels [0..N-1] for this rule's symbol for quick access during rendering More... | |
void | setRuleKey (const QString &key) |
Override the assigned rule key (should be used just internally by rule-based renderer) More... | |
void | setSymbol (QgsSymbol *sym) |
set a new symbol (or NULL). Deletes old symbol. More... | |
bool | startRender (QgsRenderContext &context, const QgsFields &fields, QString &filter) |
prepare the rule for rendering and its children (build active children array) More... | |
void | stopRender (QgsRenderContext &context) |
Stop a rendering process. More... | |
QgsSymbol * | symbol () |
QgsSymbolList | symbols (const QgsRenderContext &context=QgsRenderContext()) const |
QgsSymbolList | symbolsForFeature (QgsFeature &feat, QgsRenderContext *context=nullptr) |
tell which symbols will be used to render the feature More... | |
QgsRuleBasedRenderer::Rule * | takeChild (QgsRuleBasedRenderer::Rule *rule) |
take child rule out, set parent as null More... | |
QgsRuleBasedRenderer::Rule * | takeChildAt (int i) |
take child rule out, set parent as null More... | |
void | toSld (QDomDocument &doc, QDomElement &element, QgsStringMap props) const |
QSet< QString > | usedAttributes (const QgsRenderContext &context) const |
Return the attributes used to evaluate the expression of this rule. More... | |
bool | willRenderFeature (QgsFeature &feat, QgsRenderContext *context=nullptr) |
only tell whether a feature will be rendered without actually rendering it More... | |
Static Public Member Functions | |
static QgsRuleBasedRenderer::Rule * | create (QDomElement &ruleElem, QgsSymbolMap &symbolMap) |
Create a rule from an XML definition. More... | |
static QgsRuleBasedRenderer::Rule * | createFromSld (QDomElement &element, QgsWkbTypes::GeometryType geomType) |
Create a rule from the SLD provided in element and for the specified geometry type. More... | |
Protected Member Functions | |
void | initFilter () |
Protected Attributes | |
RuleList | mActiveChildren |
RuleList | mChildren |
QString | mDescription |
bool | mElseRule |
RuleList | mElseRules |
QgsExpression * | mFilter = nullptr |
QString | mFilterExp |
bool | mIsActive |
QString | mLabel |
double | mMaximumScale = 0 |
double | mMinimumScale = 0 |
Rule * | mParent |
QString | mRuleKey |
QgsSymbol * | mSymbol = nullptr |
QSet< int > | mSymbolNormZLevels |
This class keeps data about a rules for rule-based renderer.
A rule consists of a symbol, filter expression and range of scales. If filter is empty, it matches all features. If scale range has both values zero, it matches all scales. If one of the min/max scale denominators is zero, there is no lower/upper bound for scales. A rule matches if both filter and scale range match.
Definition at line 118 of file qgsrulebasedrenderer.h.
The result of rendering a rule.
Enumerator | |
---|---|
Filtered | The rule does not apply. |
Inactive | The rule is inactive. |
Rendered | Something was rendered. |
Definition at line 122 of file qgsrulebasedrenderer.h.
QgsRuleBasedRenderer::Rule::Rule | ( | QgsSymbol * | symbol, |
int | maximumScale = 0 , |
||
int | minimumScale = 0 , |
||
const QString & | filterExp = QString() , |
||
const QString & | label = QString() , |
||
const QString & | description = QString() , |
||
bool | elseRule = false |
||
) |
Constructor takes ownership of the symbol.
Definition at line 38 of file qgsrulebasedrenderer.cpp.
QgsRuleBasedRenderer::Rule::~Rule | ( | ) |
Definition at line 57 of file qgsrulebasedrenderer.cpp.
|
delete |
Rules cannot be copied.
|
inline |
Returns if this rule is active.
Definition at line 229 of file qgsrulebasedrenderer.h.
void QgsRuleBasedRenderer::Rule::appendChild | ( | QgsRuleBasedRenderer::Rule * | rule | ) |
add child rule, take ownership, sets this as parent
Definition at line 87 of file qgsrulebasedrenderer.cpp.
|
inline |
Return all children rules of this rule.
Definition at line 357 of file qgsrulebasedrenderer.h.
QgsRuleBasedRenderer::Rule * QgsRuleBasedRenderer::Rule::clone | ( | ) | const |
clone this rule, return new instance
Definition at line 279 of file qgsrulebasedrenderer.cpp.
QSet< int > QgsRuleBasedRenderer::Rule::collectZLevels | ( | ) |
get all used z-levels from this rule and children
Definition at line 454 of file qgsrulebasedrenderer.cpp.
|
static |
Create a rule from an XML definition.
ruleElem | The XML rule element |
symbolMap | Symbol map |
Definition at line 621 of file qgsrulebasedrenderer.cpp.
|
static |
Create a rule from the SLD provided in element and for the specified geometry type.
Definition at line 668 of file qgsrulebasedrenderer.cpp.
|
inline |
Definition at line 183 of file qgsrulebasedrenderer.h.
|
inline |
Returns all children, grand-children, grand-grand-children, grand-gra...
you get it
Definition at line 364 of file qgsrulebasedrenderer.h.
|
inline |
A human readable description for this rule.
Definition at line 222 of file qgsrulebasedrenderer.h.
QString QgsRuleBasedRenderer::Rule::dump | ( | int | indent = 0 | ) | const |
Dump for debug purpose.
indent | How many characters to indent. Will increase by two with every of the recursive calls |
Definition at line 165 of file qgsrulebasedrenderer.cpp.
|
inline |
A filter that will check if this rule applies.
Definition at line 209 of file qgsrulebasedrenderer.h.
|
inline |
A filter that will check if this rule applies.
Definition at line 215 of file qgsrulebasedrenderer.h.
QgsRuleBasedRenderer::Rule * QgsRuleBasedRenderer::Rule::findRuleByKey | ( | const QString & | key | ) |
Try to find a rule given its unique key.
Definition at line 130 of file qgsrulebasedrenderer.cpp.
|
protected |
Definition at line 65 of file qgsrulebasedrenderer.cpp.
void QgsRuleBasedRenderer::Rule::insertChild | ( | int | i, |
QgsRuleBasedRenderer::Rule * | rule | ||
) |
add child rule, take ownership, sets this as parent
Definition at line 94 of file qgsrulebasedrenderer.cpp.
|
inline |
Check if this rule is an ELSE rule.
Definition at line 409 of file qgsrulebasedrenderer.h.
bool QgsRuleBasedRenderer::Rule::isFilterOK | ( | QgsFeature & | f, |
QgsRenderContext * | context = nullptr |
||
) | const |
Check if a given feature shall be rendered by this rule.
f | The feature to test |
context | The context in which the rendering happens |
Definition at line 256 of file qgsrulebasedrenderer.cpp.
bool QgsRuleBasedRenderer::Rule::isScaleOK | ( | double | scale | ) | const |
Check if this rule applies for a given scale.
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. If set to 0, it will always return true.
Definition at line 266 of file qgsrulebasedrenderer.cpp.
|
inline |
Definition at line 182 of file qgsrulebasedrenderer.h.
QSet< QString > QgsRuleBasedRenderer::Rule::legendKeysForFeature | ( | QgsFeature & | feat, |
QgsRenderContext * | context = nullptr |
||
) |
Returns which legend keys match the feature.
Definition at line 577 of file qgsrulebasedrenderer.cpp.
QgsLegendSymbolList QgsRuleBasedRenderer::Rule::legendSymbolItems | ( | int | currentLevel = -1 | ) | const |
Definition at line 239 of file qgsrulebasedrenderer.cpp.
|
inline |
Returns the maximum map scale (i.e.
most "zoomed in" scale) at which the rule will be active. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. A scale of 0 indicates no maximum scale visibility.
Definition at line 193 of file qgsrulebasedrenderer.h.
|
inline |
Returns the minimum map scale (i.e.
most "zoomed out" scale) at which the rule will be active. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. A scale of 0 indicates no minimum scale visibility.
Definition at line 203 of file qgsrulebasedrenderer.h.
bool QgsRuleBasedRenderer::Rule::needsGeometry | ( | ) | const |
Returns true if this rule or one of its chilren needs the geometry to be applied.
Definition at line 200 of file qgsrulebasedrenderer.cpp.
|
inline |
void QgsRuleBasedRenderer::Rule::removeChild | ( | QgsRuleBasedRenderer::Rule * | rule | ) |
delete child rule
Definition at line 101 of file qgsrulebasedrenderer.cpp.
void QgsRuleBasedRenderer::Rule::removeChildAt | ( | int | i | ) |
delete child rule
Definition at line 108 of file qgsrulebasedrenderer.cpp.
QgsRuleBasedRenderer::Rule::RenderResult QgsRuleBasedRenderer::Rule::renderFeature | ( | QgsRuleBasedRenderer::FeatureToRender & | featToRender, |
QgsRenderContext & | context, | ||
QgsRuleBasedRenderer::RenderQueue & | renderQueue | ||
) |
Render a given feature, will recursively call subclasses and only render if the constraints apply.
featToRender | The feature to render |
context | The rendering context |
renderQueue | The rendering queue to which the feature should be added |
Definition at line 497 of file qgsrulebasedrenderer.cpp.
|
inline |
Unique rule identifier (for identification of rule within renderer)
Definition at line 235 of file qgsrulebasedrenderer.h.
QgsRuleBasedRenderer::RuleList QgsRuleBasedRenderer::Rule::rulesForFeature | ( | QgsFeature & | feat, |
QgsRenderContext * | context = nullptr |
||
) |
tell which rules will be used to render the feature
Definition at line 591 of file qgsrulebasedrenderer.cpp.
QDomElement QgsRuleBasedRenderer::Rule::save | ( | QDomDocument & | doc, |
QgsSymbolMap & | symbolMap | ||
) | const |
Definition at line 290 of file qgsrulebasedrenderer.cpp.
|
inline |
Sets if this rule is active.
state | Determines if the rule should be activated or deactivated |
Definition at line 283 of file qgsrulebasedrenderer.h.
|
inline |
Set a human readable description for this rule.
description | Description |
Definition at line 277 of file qgsrulebasedrenderer.h.
void QgsRuleBasedRenderer::Rule::setFilterExpression | ( | const QString & | filterExp | ) |
Set the expression used to check if a given feature shall be rendered with this rule.
filterExp | An expression |
Definition at line 233 of file qgsrulebasedrenderer.cpp.
void QgsRuleBasedRenderer::Rule::setIsElse | ( | bool | iselse | ) |
Sets if this rule is an ELSE rule.
iselse | If true, this rule is an ELSE rule |
Definition at line 156 of file qgsrulebasedrenderer.cpp.
|
inline |
Definition at line 245 of file qgsrulebasedrenderer.h.
|
inline |
Sets the maximum map scale (i.e.
most "zoomed in" scale) at which the rule will be active. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. A scale of 0 indicates no maximum scale visibility.
Definition at line 263 of file qgsrulebasedrenderer.h.
|
inline |
Sets the minimum map scale (i.e.
most "zoomed out" scale) at which the rule will be active. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. A scale of 0 indicates no minimum scale visibility.
Definition at line 254 of file qgsrulebasedrenderer.h.
void QgsRuleBasedRenderer::Rule::setNormZLevels | ( | const QMap< int, int > & | zLevelsToNormLevels | ) |
assign normalized z-levels [0..N-1] for this rule's symbol for quick access during rendering
Definition at line 478 of file qgsrulebasedrenderer.cpp.
|
inline |
Override the assigned rule key (should be used just internally by rule-based renderer)
Definition at line 241 of file qgsrulebasedrenderer.h.
void QgsRuleBasedRenderer::Rule::setSymbol | ( | QgsSymbol * | sym | ) |
set a new symbol (or NULL). Deletes old symbol.
Definition at line 227 of file qgsrulebasedrenderer.cpp.
bool QgsRuleBasedRenderer::Rule::startRender | ( | QgsRenderContext & | context, |
const QgsFields & | fields, | ||
QString & | filter | ||
) |
prepare the rule for rendering and its children (build active children array)
Definition at line 383 of file qgsrulebasedrenderer.cpp.
void QgsRuleBasedRenderer::Rule::stopRender | ( | QgsRenderContext & | context | ) |
Stop a rendering process.
Used to clean up the internal state of this rule
context | The rendering context |
Definition at line 607 of file qgsrulebasedrenderer.cpp.
|
inline |
Definition at line 181 of file qgsrulebasedrenderer.h.
QgsSymbolList QgsRuleBasedRenderer::Rule::symbols | ( | const QgsRenderContext & | context = QgsRenderContext() | ) | const |
Definition at line 214 of file qgsrulebasedrenderer.cpp.
QgsSymbolList QgsRuleBasedRenderer::Rule::symbolsForFeature | ( | QgsFeature & | feat, |
QgsRenderContext * | context = nullptr |
||
) |
tell which symbols will be used to render the feature
Definition at line 562 of file qgsrulebasedrenderer.cpp.
QgsRuleBasedRenderer::Rule * QgsRuleBasedRenderer::Rule::takeChild | ( | QgsRuleBasedRenderer::Rule * | rule | ) |
take child rule out, set parent as null
Definition at line 114 of file qgsrulebasedrenderer.cpp.
QgsRuleBasedRenderer::Rule * QgsRuleBasedRenderer::Rule::takeChildAt | ( | int | i | ) |
take child rule out, set parent as null
Definition at line 122 of file qgsrulebasedrenderer.cpp.
void QgsRuleBasedRenderer::Rule::toSld | ( | QDomDocument & | doc, |
QDomElement & | element, | ||
QgsStringMap | props | ||
) | const |
Definition at line 321 of file qgsrulebasedrenderer.cpp.
QSet< QString > QgsRuleBasedRenderer::Rule::usedAttributes | ( | const QgsRenderContext & | context | ) | const |
Return the attributes used to evaluate the expression of this rule.
Definition at line 183 of file qgsrulebasedrenderer.cpp.
bool QgsRuleBasedRenderer::Rule::willRenderFeature | ( | QgsFeature & | feat, |
QgsRenderContext * | context = nullptr |
||
) |
only tell whether a feature will be rendered without actually rendering it
Definition at line 547 of file qgsrulebasedrenderer.cpp.
|
protected |
Definition at line 430 of file qgsrulebasedrenderer.h.
|
protected |
Definition at line 420 of file qgsrulebasedrenderer.h.
|
protected |
Definition at line 418 of file qgsrulebasedrenderer.h.
|
protected |
Definition at line 419 of file qgsrulebasedrenderer.h.
|
protected |
Definition at line 421 of file qgsrulebasedrenderer.h.
|
protected |
Definition at line 427 of file qgsrulebasedrenderer.h.
|
protected |
Definition at line 418 of file qgsrulebasedrenderer.h.
|
protected |
Definition at line 422 of file qgsrulebasedrenderer.h.
|
protected |
Definition at line 418 of file qgsrulebasedrenderer.h.
|
protected |
Definition at line 416 of file qgsrulebasedrenderer.h.
|
protected |
Definition at line 417 of file qgsrulebasedrenderer.h.
|
protected |
Definition at line 414 of file qgsrulebasedrenderer.h.
|
protected |
Definition at line 424 of file qgsrulebasedrenderer.h.
|
protected |
Definition at line 415 of file qgsrulebasedrenderer.h.
|
protected |
Definition at line 429 of file qgsrulebasedrenderer.h.