QGIS API Documentation
2.12.0-Lyon
|
This class keeps data about a rules for rule-based renderer. More...
#include <qgsrulebasedrendererv2.h>
Public Types | |
enum | RenderResult { Filtered = 0, Inactive, Rendered } |
The result of rendering a rule. More... | |
Public Member Functions | |
Rule (QgsSymbolV2 *symbol, int scaleMinDenom=0, int scaleMaxDenom=0, const QString &filterExp=QString(), const QString &label=QString(), const QString &description=QString(), bool elseRule=false) | |
Constructor takes ownership of the symbol. More... | |
~Rule () | |
bool | active () const |
Returns if this rule is active. More... | |
void | appendChild (Rule *rule) |
add child rule, take ownership, sets this as parent More... | |
bool | checkState () const |
RuleList & | children () |
Return all children rules of this rule. More... | |
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 |
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... | |
Rule * | findRuleByKey (const QString &key) |
Try to find a rule given its unique key. More... | |
void | insertChild (int i, 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=0) 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 |
QgsLegendSymbolList | legendSymbolItems (double scaleDenominator=-1, const QString &rule="") |
QgsLegendSymbolListV2 | legendSymbolItemsV2 (int currentLevel=-1) const |
Rule * | parent () |
The parent rule. More... | |
void | removeChild (Rule *rule) |
delete child rule More... | |
void | removeChildAt (int i) |
delete child rule More... | |
RenderResult | renderFeature (FeatureToRender &featToRender, QgsRenderContext &context, 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... | |
RuleList | rulesForFeature (QgsFeature &feat, QgsRenderContext *context=0) |
tell which rules will be used to render the feature More... | |
QDomElement | save (QDomDocument &doc, QgsSymbolV2Map &symbolMap) |
int | scaleMaxDenom () const |
int | scaleMinDenom () const |
void | setActive (bool state) |
Sets if this rule is active. More... | |
void | setCheckState (bool state) |
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 | 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 | setScaleMaxDenom (int scaleMaxDenom) |
Set the maximum denominator for which this rule shall apply. More... | |
void | setScaleMinDenom (int scaleMinDenom) |
Set the minimum denominator for which this rule shall apply. More... | |
void | setSymbol (QgsSymbolV2 *sym) |
set a new symbol (or NULL). Deletes old symbol. More... | |
Q_DECL_DEPRECATED bool | startRender (QgsRenderContext &context, const QgsFields &fields) |
prepare the rule for rendering and its children (build active children array) 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... | |
QgsSymbolV2 * | symbol () |
QgsSymbolV2List | symbols (const QgsRenderContext &context=QgsRenderContext()) |
QgsSymbolV2List | symbolsForFeature (QgsFeature &feat, QgsRenderContext *context=0) |
tell which symbols will be used to render the feature More... | |
void | takeChild (Rule *rule) |
take child rule out, set parent as null More... | |
Rule * | takeChildAt (int i) |
take child rule out, set parent as null More... | |
void | toSld (QDomDocument &doc, QDomElement &element, QgsStringMap props) |
void | updateElseRules () |
Check which child rules are else rules and update the internal list of else rules. More... | |
QSet< QString > | usedAttributes () |
Return the attributes used to evaluate the expression of this rule. More... | |
bool | willRenderFeature (QgsFeature &feat, QgsRenderContext *context=0) |
only tell whether a feature will be rendered without actually rendering it More... | |
Static Public Member Functions | |
static Rule * | create (QDomElement &ruleElem, QgsSymbolV2Map &symbolMap) |
Create a rule from an XML definition. More... | |
static Rule * | createFromSld (QDomElement &element, QGis::GeometryType geomType) |
Protected Member Functions | |
void | initFilter () |
Protected Attributes | |
RuleList | mActiveChildren |
RuleList | mChildren |
QString | mDescription |
bool | mElseRule |
RuleList | mElseRules |
QgsExpression * | mFilter |
QString | mFilterExp |
bool | mIsActive |
QString | mLabel |
Rule * | mParent |
QString | mRuleKey |
int | mScaleMaxDenom |
int | mScaleMinDenom |
QgsSymbolV2 * | mSymbol |
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 84 of file qgsrulebasedrendererv2.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 88 of file qgsrulebasedrendererv2.h.
QgsRuleBasedRendererV2::Rule::Rule | ( | QgsSymbolV2 * | symbol, |
int | scaleMinDenom = 0 , |
||
int | scaleMaxDenom = 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 qgsrulebasedrendererv2.cpp.
QgsRuleBasedRendererV2::Rule::~Rule | ( | ) |
Definition at line 50 of file qgsrulebasedrendererv2.cpp.
|
inline |
Returns if this rule is active.
Definition at line 171 of file qgsrulebasedrendererv2.h.
void QgsRuleBasedRendererV2::Rule::appendChild | ( | Rule * | rule | ) |
add child rule, take ownership, sets this as parent
Definition at line 76 of file qgsrulebasedrendererv2.cpp.
|
inline |
Definition at line 165 of file qgsrulebasedrendererv2.h.
|
inline |
Return all children rules of this rule.
Definition at line 287 of file qgsrulebasedrendererv2.h.
QgsRuleBasedRendererV2::Rule * QgsRuleBasedRendererV2::Rule::clone | ( | ) | const |
clone this rule, return new instance
Definition at line 260 of file qgsrulebasedrendererv2.cpp.
QSet< int > QgsRuleBasedRendererV2::Rule::collectZLevels | ( | ) |
get all used z-levels from this rule and children
Definition at line 465 of file qgsrulebasedrendererv2.cpp.
|
static |
Create a rule from an XML definition.
ruleElem | The XML rule element |
symbolMap | Symbol map |
Definition at line 623 of file qgsrulebasedrendererv2.cpp.
|
static |
Definition at line 670 of file qgsrulebasedrendererv2.cpp.
|
inline |
Definition at line 140 of file qgsrulebasedrendererv2.h.
|
inline |
Returns all children, grand-children, grand-grand-children, grand-gra...
you get it
Definition at line 294 of file qgsrulebasedrendererv2.h.
|
inline |
A human readable description for this rule.
Definition at line 161 of file qgsrulebasedrendererv2.h.
QString QgsRuleBasedRendererV2::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 147 of file qgsrulebasedrendererv2.cpp.
|
inline |
A filter that will check if this rule applies.
Definition at line 148 of file qgsrulebasedrendererv2.h.
|
inline |
A filter that will check if this rule applies.
Definition at line 154 of file qgsrulebasedrendererv2.h.
QgsRuleBasedRendererV2::Rule * QgsRuleBasedRendererV2::Rule::findRuleByKey | ( | const QString & | key | ) |
Try to find a rule given its unique key.
Definition at line 120 of file qgsrulebasedrendererv2.cpp.
|
protected |
Definition at line 58 of file qgsrulebasedrendererv2.cpp.
void QgsRuleBasedRendererV2::Rule::insertChild | ( | int | i, |
Rule * | rule | ||
) |
add child rule, take ownership, sets this as parent
Definition at line 83 of file qgsrulebasedrendererv2.cpp.
|
inline |
Check if this rule is an ELSE rule.
Definition at line 344 of file qgsrulebasedrendererv2.h.
bool QgsRuleBasedRendererV2::Rule::isFilterOK | ( | QgsFeature & | f, |
QgsRenderContext * | context = 0 |
||
) | 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 237 of file qgsrulebasedrendererv2.cpp.
bool QgsRuleBasedRendererV2::Rule::isScaleOK | ( | double | scale | ) | const |
Check if this rule applies for a given scale.
scale | The scale to check. If set to 0, it will always return true. |
Definition at line 247 of file qgsrulebasedrendererv2.cpp.
|
inline |
Definition at line 139 of file qgsrulebasedrendererv2.h.
QgsLegendSymbolList QgsRuleBasedRendererV2::Rule::legendSymbolItems | ( | double | scaleDenominator = -1 , |
const QString & | rule = "" |
||
) |
Definition at line 203 of file qgsrulebasedrendererv2.cpp.
QgsLegendSymbolListV2 QgsRuleBasedRendererV2::Rule::legendSymbolItemsV2 | ( | int | currentLevel = -1 | ) | const |
Definition at line 220 of file qgsrulebasedrendererv2.cpp.
|
inline |
void QgsRuleBasedRendererV2::Rule::removeChild | ( | Rule * | rule | ) |
delete child rule
Definition at line 90 of file qgsrulebasedrendererv2.cpp.
void QgsRuleBasedRendererV2::Rule::removeChildAt | ( | int | i | ) |
delete child rule
Definition at line 97 of file qgsrulebasedrendererv2.cpp.
QgsRuleBasedRendererV2::Rule::RenderResult QgsRuleBasedRendererV2::Rule::renderFeature | ( | QgsRuleBasedRendererV2::FeatureToRender & | featToRender, |
QgsRenderContext & | context, | ||
QgsRuleBasedRendererV2::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 509 of file qgsrulebasedrendererv2.cpp.
|
inline |
Unique rule identifier (for identification of rule within renderer)
Definition at line 175 of file qgsrulebasedrendererv2.h.
QgsRuleBasedRendererV2::RuleList QgsRuleBasedRendererV2::Rule::rulesForFeature | ( | QgsFeature & | feat, |
QgsRenderContext * | context = 0 |
||
) |
tell which rules will be used to render the feature
Definition at line 591 of file qgsrulebasedrendererv2.cpp.
QDomElement QgsRuleBasedRendererV2::Rule::save | ( | QDomDocument & | doc, |
QgsSymbolV2Map & | symbolMap | ||
) |
Definition at line 271 of file qgsrulebasedrendererv2.cpp.
|
inline |
Definition at line 142 of file qgsrulebasedrendererv2.h.
|
inline |
Definition at line 141 of file qgsrulebasedrendererv2.h.
|
inline |
Sets if this rule is active.
state | Determines if the rule should be activated or deactivated |
Definition at line 222 of file qgsrulebasedrendererv2.h.
|
inline |
Definition at line 216 of file qgsrulebasedrendererv2.h.
|
inline |
Set a human readable description for this rule.
description | Description |
Definition at line 212 of file qgsrulebasedrendererv2.h.
|
inline |
Set the expression used to check if a given feature shall be rendered with this rule.
filterExp | An expression |
Definition at line 205 of file qgsrulebasedrendererv2.h.
|
inline |
Sets if this rule is an ELSE rule.
iselse | If true, this rule is an ELSE rule |
Definition at line 337 of file qgsrulebasedrendererv2.h.
|
inline |
Definition at line 182 of file qgsrulebasedrendererv2.h.
void QgsRuleBasedRendererV2::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 489 of file qgsrulebasedrendererv2.cpp.
|
inline |
Override the assigned rule key (should be used just internally by rule-based renderer)
Definition at line 178 of file qgsrulebasedrendererv2.h.
|
inline |
Set the maximum denominator for which this rule shall apply.
E.g. 100'000 if it shall be evaluated between 1:1000 and 1:100'000 Set to 0 to disable the maximum check
scaleMaxDenom | maximum scale denominator for this rule |
Definition at line 198 of file qgsrulebasedrendererv2.h.
|
inline |
Set the minimum denominator for which this rule shall apply.
E.g. 1000 if it shall be evaluated between 1:1000 and 1:100'000 Set to 0 to disable the minimum check
scaleMinDenom | The minimum scale denominator for this rule |
Definition at line 190 of file qgsrulebasedrendererv2.h.
void QgsRuleBasedRendererV2::Rule::setSymbol | ( | QgsSymbolV2 * | sym | ) |
set a new symbol (or NULL). Deletes old symbol.
Definition at line 197 of file qgsrulebasedrendererv2.cpp.
bool QgsRuleBasedRendererV2::Rule::startRender | ( | QgsRenderContext & | context, |
const QgsFields & | fields | ||
) |
prepare the rule for rendering and its children (build active children array)
Definition at line 395 of file qgsrulebasedrendererv2.cpp.
bool QgsRuleBasedRendererV2::Rule::startRender | ( | QgsRenderContext & | context, |
const QgsFields & | fields, | ||
QString & | filter | ||
) |
prepare the rule for rendering and its children (build active children array)
Definition at line 401 of file qgsrulebasedrendererv2.cpp.
void QgsRuleBasedRendererV2::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 608 of file qgsrulebasedrendererv2.cpp.
|
inline |
Definition at line 138 of file qgsrulebasedrendererv2.h.
QgsSymbolV2List QgsRuleBasedRendererV2::Rule::symbols | ( | const QgsRenderContext & | context = QgsRenderContext() | ) |
Definition at line 183 of file qgsrulebasedrendererv2.cpp.
QgsSymbolV2List QgsRuleBasedRendererV2::Rule::symbolsForFeature | ( | QgsFeature & | feat, |
QgsRenderContext * | context = 0 |
||
) |
tell which symbols will be used to render the feature
Definition at line 575 of file qgsrulebasedrendererv2.cpp.
void QgsRuleBasedRendererV2::Rule::takeChild | ( | Rule * | rule | ) |
take child rule out, set parent as null
Definition at line 105 of file qgsrulebasedrendererv2.cpp.
QgsRuleBasedRendererV2::Rule * QgsRuleBasedRendererV2::Rule::takeChildAt | ( | int | i | ) |
take child rule out, set parent as null
Definition at line 112 of file qgsrulebasedrendererv2.cpp.
void QgsRuleBasedRendererV2::Rule::toSld | ( | QDomDocument & | doc, |
QDomElement & | element, | ||
QgsStringMap | props | ||
) |
Definition at line 303 of file qgsrulebasedrendererv2.cpp.
void QgsRuleBasedRendererV2::Rule::updateElseRules | ( | ) |
Check which child rules are else rules and update the internal list of else rules.
TODO QGIS 3: Does this need to be public?
Definition at line 136 of file qgsrulebasedrendererv2.cpp.
Return the attributes used to evaluate the expression of this rule.
Definition at line 165 of file qgsrulebasedrendererv2.cpp.
bool QgsRuleBasedRendererV2::Rule::willRenderFeature | ( | QgsFeature & | feat, |
QgsRenderContext * | context = 0 |
||
) |
only tell whether a feature will be rendered without actually rendering it
Definition at line 559 of file qgsrulebasedrendererv2.cpp.
|
protected |
Definition at line 364 of file qgsrulebasedrendererv2.h.
|
protected |
Definition at line 354 of file qgsrulebasedrendererv2.h.
|
protected |
Definition at line 352 of file qgsrulebasedrendererv2.h.
|
protected |
Definition at line 353 of file qgsrulebasedrendererv2.h.
|
protected |
Definition at line 355 of file qgsrulebasedrendererv2.h.
|
protected |
Definition at line 361 of file qgsrulebasedrendererv2.h.
|
protected |
Definition at line 352 of file qgsrulebasedrendererv2.h.
|
protected |
Definition at line 356 of file qgsrulebasedrendererv2.h.
|
protected |
Definition at line 352 of file qgsrulebasedrendererv2.h.
|
protected |
Definition at line 349 of file qgsrulebasedrendererv2.h.
|
protected |
Definition at line 358 of file qgsrulebasedrendererv2.h.
|
protected |
Definition at line 351 of file qgsrulebasedrendererv2.h.
|
protected |
Definition at line 351 of file qgsrulebasedrendererv2.h.
|
protected |
Definition at line 350 of file qgsrulebasedrendererv2.h.
|
protected |
Definition at line 363 of file qgsrulebasedrendererv2.h.