QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsRuleBasedRendererV2::Rule Class Reference

This class keeps data about a rules for rule-based renderer. More...

#include <qgsrulebasedrendererv2.h>

Public Member Functions

 Rule (QgsSymbolV2 *symbol, int scaleMinDenom=0, int scaleMaxDenom=0, QString filterExp=QString(), QString label=QString(), QString description=QString(), bool elseRule=false)
 Constructor takes ownership of the symbol. More...
 
 ~Rule ()
 
QString dump (int offset=0) const
 
QSet< QString > usedAttributes ()
 
QgsSymbolV2List symbols ()
 
QgsLegendSymbolList legendSymbolItems (double scaleDenominator=-1, QString rule="")
 
QgsLegendSymbolListV2 legendSymbolItemsV2 (int currentLevel=-1) const
 
bool isFilterOK (QgsFeature &f) const
 
bool isScaleOK (double scale) const
 
QgsSymbolV2symbol ()
 
QString label () const
 
bool dependsOnScale () const
 
int scaleMinDenom () const
 
int scaleMaxDenom () const
 
QgsExpressionfilter () const
 
QString filterExpression () const
 
QString description () const
 
bool checkState () const
 
QString ruleKey () const
 Unique rule identifier (for identification of rule within renderer) More...
 
void setRuleKey (const QString &key)
 Override the assigned rule key (should be used just internally by rule-based renderer) More...
 
void setSymbol (QgsSymbolV2 *sym)
 set a new symbol (or NULL). Deletes old symbol. More...
 
void setLabel (QString label)
 
void setScaleMinDenom (int scaleMinDenom)
 
void setScaleMaxDenom (int scaleMaxDenom)
 
void setFilterExpression (QString filterExp)
 
void setDescription (QString description)
 
void setCheckState (bool state)
 
Ruleclone () const
 clone this rule, return new instance More...
 
void toSld (QDomDocument &doc, QDomElement &element, QgsStringMap props)
 
QDomElement save (QDomDocument &doc, QgsSymbolV2Map &symbolMap)
 
bool startRender (QgsRenderContext &context, const QgsFields &fields)
 prepare the rule for rendering and its children (build active children array) More...
 
QSet< int > collectZLevels ()
 get all used z-levels from this rule and children 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...
 
bool renderFeature (FeatureToRender &featToRender, QgsRenderContext &context, RenderQueue &renderQueue)
 
bool willRenderFeature (QgsFeature &feat)
 only tell whether a feature will be rendered without actually rendering it More...
 
QgsSymbolV2List symbolsForFeature (QgsFeature &feat)
 tell which symbols will be used to render the feature More...
 
RuleList rulesForFeature (QgsFeature &feat)
 tell which rules will be used to render the feature More...
 
void stopRender (QgsRenderContext &context)
 
RuleListchildren ()
 
RuleList descendants () const
 
Ruleparent ()
 
void appendChild (Rule *rule)
 add child rule, take ownership, sets this as parent More...
 
void insertChild (int i, Rule *rule)
 add child rule, take ownership, sets this as parent More...
 
void removeChild (Rule *rule)
 delete child rule More...
 
void removeChildAt (int i)
 delete child rule More...
 
void takeChild (Rule *rule)
 take child rule out, set parent as null More...
 
RuletakeChildAt (int i)
 take child rule out, set parent as null More...
 
RulefindRuleByKey (QString key)
 Try to find a rule given its unique key. More...
 
void updateElseRules ()
 
void setIsElse (bool iselse)
 
bool isElse ()
 

Static Public Member Functions

static RulecreateFromSld (QDomElement &element, QGis::GeometryType geomType)
 
static Rulecreate (QDomElement &ruleElem, QgsSymbolV2Map &symbolMap)
 

Protected Member Functions

void initFilter ()
 

Protected Attributes

RulemParent
 
QgsSymbolV2mSymbol
 
int mScaleMinDenom
 
int mScaleMaxDenom
 
QString mFilterExp
 
QString mLabel
 
QString mDescription
 
bool mElseRule
 
RuleList mChildren
 
RuleList mElseRules
 
bool mCheckState
 
QString mRuleKey
 
QgsExpressionmFilter
 
QList< int > mSymbolNormZLevels
 
RuleList mActiveChildren
 

Detailed Description

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.

Constructor & Destructor Documentation

QgsRuleBasedRendererV2::Rule::Rule ( QgsSymbolV2 symbol,
int  scaleMinDenom = 0,
int  scaleMaxDenom = 0,
QString  filterExp = QString(),
QString  label = QString(),
QString  description = QString(),
bool  elseRule = false 
)

Constructor takes ownership of the symbol.

QgsRuleBasedRendererV2::Rule::~Rule ( )

Member Function Documentation

void QgsRuleBasedRendererV2::Rule::appendChild ( Rule rule)

add child rule, take ownership, sets this as parent

bool QgsRuleBasedRendererV2::Rule::checkState ( ) const
inline
Note
added in 2.6
RuleList& QgsRuleBasedRendererV2::Rule::children ( )
inline
QgsRuleBasedRendererV2::Rule * QgsRuleBasedRendererV2::Rule::clone ( ) const

clone this rule, return new instance

QSet< int > QgsRuleBasedRendererV2::Rule::collectZLevels ( )

get all used z-levels from this rule and children

QgsRuleBasedRendererV2::Rule * QgsRuleBasedRendererV2::Rule::create ( QDomElement &  ruleElem,
QgsSymbolV2Map symbolMap 
)
static
QgsRuleBasedRendererV2::Rule * QgsRuleBasedRendererV2::Rule::createFromSld ( QDomElement &  element,
QGis::GeometryType  geomType 
)
static
bool QgsRuleBasedRendererV2::Rule::dependsOnScale ( ) const
inline
RuleList QgsRuleBasedRendererV2::Rule::descendants ( ) const
inline
QString QgsRuleBasedRendererV2::Rule::description ( ) const
inline
QString QgsRuleBasedRendererV2::Rule::dump ( int  offset = 0) const
QgsExpression* QgsRuleBasedRendererV2::Rule::filter ( ) const
inline
QString QgsRuleBasedRendererV2::Rule::filterExpression ( ) const
inline
QgsRuleBasedRendererV2::Rule * QgsRuleBasedRendererV2::Rule::findRuleByKey ( QString  key)

Try to find a rule given its unique key.

Note
added in 2.6
void QgsRuleBasedRendererV2::Rule::initFilter ( )
protected
void QgsRuleBasedRendererV2::Rule::insertChild ( int  i,
Rule rule 
)

add child rule, take ownership, sets this as parent

bool QgsRuleBasedRendererV2::Rule::isElse ( )
inline
bool QgsRuleBasedRendererV2::Rule::isFilterOK ( QgsFeature f) const
bool QgsRuleBasedRendererV2::Rule::isScaleOK ( double  scale) const
QString QgsRuleBasedRendererV2::Rule::label ( ) const
inline
QgsLegendSymbolList QgsRuleBasedRendererV2::Rule::legendSymbolItems ( double  scaleDenominator = -1,
QString  rule = "" 
)
Note
not available in python bindings
QgsLegendSymbolListV2 QgsRuleBasedRendererV2::Rule::legendSymbolItemsV2 ( int  currentLevel = -1) const
Note
added in 2.6
Rule* QgsRuleBasedRendererV2::Rule::parent ( )
inline
void QgsRuleBasedRendererV2::Rule::removeChild ( Rule rule)

delete child rule

void QgsRuleBasedRendererV2::Rule::removeChildAt ( int  i)

delete child rule

bool QgsRuleBasedRendererV2::Rule::renderFeature ( QgsRuleBasedRendererV2::FeatureToRender featToRender,
QgsRenderContext context,
QgsRuleBasedRendererV2::RenderQueue renderQueue 
)
QString QgsRuleBasedRendererV2::Rule::ruleKey ( ) const
inline

Unique rule identifier (for identification of rule within renderer)

Note
added in 2.6
QgsRuleBasedRendererV2::RuleList QgsRuleBasedRendererV2::Rule::rulesForFeature ( QgsFeature feat)

tell which rules will be used to render the feature

QDomElement QgsRuleBasedRendererV2::Rule::save ( QDomDocument &  doc,
QgsSymbolV2Map symbolMap 
)
int QgsRuleBasedRendererV2::Rule::scaleMaxDenom ( ) const
inline
int QgsRuleBasedRendererV2::Rule::scaleMinDenom ( ) const
inline
void QgsRuleBasedRendererV2::Rule::setCheckState ( bool  state)
inline
Note
added in 2.6
void QgsRuleBasedRendererV2::Rule::setDescription ( QString  description)
inline
void QgsRuleBasedRendererV2::Rule::setFilterExpression ( QString  filterExp)
inline
void QgsRuleBasedRendererV2::Rule::setIsElse ( bool  iselse)
inline
void QgsRuleBasedRendererV2::Rule::setLabel ( QString  label)
inline
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

Note
not available in python bindings
void QgsRuleBasedRendererV2::Rule::setRuleKey ( const QString &  key)
inline

Override the assigned rule key (should be used just internally by rule-based renderer)

Note
added in 2.6
void QgsRuleBasedRendererV2::Rule::setScaleMaxDenom ( int  scaleMaxDenom)
inline
void QgsRuleBasedRendererV2::Rule::setScaleMinDenom ( int  scaleMinDenom)
inline
void QgsRuleBasedRendererV2::Rule::setSymbol ( QgsSymbolV2 sym)

set a new symbol (or NULL). Deletes old symbol.

bool QgsRuleBasedRendererV2::Rule::startRender ( QgsRenderContext context,
const QgsFields fields 
)

prepare the rule for rendering and its children (build active children array)

void QgsRuleBasedRendererV2::Rule::stopRender ( QgsRenderContext context)
QgsSymbolV2* QgsRuleBasedRendererV2::Rule::symbol ( )
inline
QgsSymbolV2List QgsRuleBasedRendererV2::Rule::symbols ( )
QgsSymbolV2List QgsRuleBasedRendererV2::Rule::symbolsForFeature ( QgsFeature feat)

tell which symbols will be used to render the feature

Note
added in 1.9
void QgsRuleBasedRendererV2::Rule::takeChild ( Rule rule)

take child rule out, set parent as null

QgsRuleBasedRendererV2::Rule * QgsRuleBasedRendererV2::Rule::takeChildAt ( int  i)

take child rule out, set parent as null

void QgsRuleBasedRendererV2::Rule::toSld ( QDomDocument &  doc,
QDomElement &  element,
QgsStringMap  props 
)
void QgsRuleBasedRendererV2::Rule::updateElseRules ( )
QSet< QString > QgsRuleBasedRendererV2::Rule::usedAttributes ( )
bool QgsRuleBasedRendererV2::Rule::willRenderFeature ( QgsFeature feat)

only tell whether a feature will be rendered without actually rendering it

Note
added in 1.9

Member Data Documentation

RuleList QgsRuleBasedRendererV2::Rule::mActiveChildren
protected
bool QgsRuleBasedRendererV2::Rule::mCheckState
protected
RuleList QgsRuleBasedRendererV2::Rule::mChildren
protected
QString QgsRuleBasedRendererV2::Rule::mDescription
protected
bool QgsRuleBasedRendererV2::Rule::mElseRule
protected
RuleList QgsRuleBasedRendererV2::Rule::mElseRules
protected
QgsExpression* QgsRuleBasedRendererV2::Rule::mFilter
protected
QString QgsRuleBasedRendererV2::Rule::mFilterExp
protected
QString QgsRuleBasedRendererV2::Rule::mLabel
protected
Rule* QgsRuleBasedRendererV2::Rule::mParent
protected
QString QgsRuleBasedRendererV2::Rule::mRuleKey
protected
int QgsRuleBasedRendererV2::Rule::mScaleMaxDenom
protected
int QgsRuleBasedRendererV2::Rule::mScaleMinDenom
protected
QgsSymbolV2* QgsRuleBasedRendererV2::Rule::mSymbol
protected
QList<int> QgsRuleBasedRendererV2::Rule::mSymbolNormZLevels
protected

The documentation for this class was generated from the following files: