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

When drawing a vector layer with rule-based renderer, it goes through the rules and draws features with symbols from rules that match. More...

#include <qgsrulebasedrendererv2.h>

Inheritance diagram for QgsRuleBasedRendererV2:
Inheritance graph
[legend]

Classes

struct  FeatureToRender
 
struct  RenderJob
 
struct  RenderLevel
 
class  Rule
 This class keeps data about a rules for rule-based renderer. More...
 

Public Types

enum  FeatureFlags { FeatIsSelected = 1, FeatDrawMarkers = 2 }
 
typedef QList< RenderLevelRenderQueue
 
typedef QList< Rule * > RuleList
 
- Public Types inherited from QgsFeatureRendererV2
enum  Capabilities {
  SymbolLevels = 1, RotationField = 1 << 1, MoreSymbolsPerFeature = 1 << 2, Filter = 1 << 3,
  ScaleDependent = 1 << 4
}
 

Public Member Functions

 QgsRuleBasedRendererV2 (QgsRuleBasedRendererV2::Rule *root)
 Constructs the renderer from given tree of rules (takes ownership) More...
 
 QgsRuleBasedRendererV2 (QgsSymbolV2 *defaultSymbol)
 Constructor for convenience. Creates a root rule and adds a default rule with symbol (takes ownership) More...
 
 ~QgsRuleBasedRendererV2 ()
 
virtual int capabilities ()
 returns bitwise OR-ed capabilities of the renderer More...
 
virtual void checkLegendSymbolItem (QString key, bool state=true)
 item in symbology was checked More...
 
virtual QgsFeatureRendererV2clone () const
 
virtual QString dump () const
 for debugging More...
 
virtual bool legendSymbolItemChecked (QString key)
 items of symbology items in legend is checked More...
 
virtual QgsLegendSymbolList legendSymbolItems (double scaleDenominator=-1, QString rule="")
 return a list of item text / symbol More...
 
virtual bool legendSymbolItemsCheckable () const
 items of symbology items in legend should be checkable More...
 
virtual QgsLegendSymbolListV2 legendSymbolItemsV2 () const
 Return a list of symbology items for the legend. More...
 
virtual QgsLegendSymbologyList legendSymbologyItems (QSize iconSize)
 return a list of symbology items for the legend More...
 
virtual QgsSymbolV2List originalSymbolsForFeature (QgsFeature &feat)
 Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbols per feature - similar to symbolsForFeature() More...
 
virtual bool renderFeature (QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
 
RulerootRule ()
 
virtual QDomElement save (QDomDocument &doc)
 store renderer info to XML element More...
 
virtual void startRender (QgsRenderContext &context, const QgsFields &fields)
 
virtual void stopRender (QgsRenderContext &context)
 
virtual QgsSymbolV2symbolForFeature (QgsFeature &feature)
 return symbol for current feature. Should not be used individually: there could be more symbols for a feature More...
 
virtual QgsSymbolV2List symbols ()
 for symbol levels More...
 
virtual QgsSymbolV2List symbolsForFeature (QgsFeature &feat)
 return list of symbols used for rendering the feature. More...
 
virtual void toSld (QDomDocument &doc, QDomElement &element) const
 used from subclasses to create SLD Rule elements following SLD v1.1 specs More...
 
virtual QList< QString > usedAttributes ()
 
virtual bool willRenderFeature (QgsFeature &feat)
 return whether the renderer will render a feature or not. More...
 
- Public Member Functions inherited from QgsFeatureRendererV2
virtual ~QgsFeatureRendererV2 ()
 
virtual QString legendClassificationAttribute () const
 If supported by the renderer, return classification attribute for the use in legend. More...
 
virtual QgsSymbolV2originalSymbolForFeature (QgsFeature &feature)
 Return symbol for feature. More...
 
virtual QString rotationField () const
 return rotation field name (or empty string if not set or not supported by renderer) More...
 
virtual void setRotationField (QString fieldName)
 sets rotation field of renderer (if supported by the renderer) More...
 
void setUsingSymbolLevels (bool usingSymbolLevels)
 
void setVertexMarkerAppearance (int type, int size)
 set type and size of editing vertex markers for subsequent rendering More...
 
virtual Q_DECL_DEPRECATED void startRender (QgsRenderContext &context, const QgsVectorLayer *vlayer)
 
QString type () const
 
bool usingSymbolLevels () const
 
virtual QDomElement writeSld (QDomDocument &doc, const QgsVectorLayer &layer) const
 create the SLD UserStyle element following the SLD v1.1 specs More...
 

Static Public Member Functions

static QgsRuleBasedRendererV2convertFromRenderer (const QgsFeatureRendererV2 *renderer)
 creates a QgsRuleBasedRendererV2 from an existing renderer. More...
 
static void convertToDataDefinedSymbology (QgsSymbolV2 *symbol, QString sizeScaleField, QString rotationField)
 helper function to convert the size scale and rotation fields present in some other renderers to data defined symbology More...
 
static QgsFeatureRendererV2create (QDomElement &element)
 
static QgsFeatureRendererV2createFromSld (QDomElement &element, QGis::GeometryType geomType)
 
static void refineRuleCategories (Rule *initialRule, QgsCategorizedSymbolRendererV2 *r)
 take a rule and create a list of new rules based on the categories from categorized symbol renderer More...
 
static void refineRuleRanges (Rule *initialRule, QgsGraduatedSymbolRendererV2 *r)
 take a rule and create a list of new rules based on the ranges from graduated symbol renderer More...
 
static void refineRuleScales (Rule *initialRule, QList< int > scales)
 take a rule and create a list of new rules with intervals of scales given by the passed scale denominators More...
 
- Static Public Member Functions inherited from QgsFeatureRendererV2
static QgsFeatureRendererV2defaultRenderer (QGis::GeometryType geomType)
 return a new renderer - used by default in vector layers More...
 
static QgsFeatureRendererV2load (QDomElement &symbologyElem)
 create a renderer from XML element More...
 
static QgsFeatureRendererV2loadSld (const QDomNode &node, QGis::GeometryType geomType, QString &errorMessage)
 create a new renderer according to the information contained in the UserStyle element of a SLD style document More...
 

Protected Attributes

QList< FeatureToRendermCurrentFeatures
 
RenderQueue mRenderQueue
 
RulemRootRule
 the root node with hierarchical list of rules More...
 
- Protected Attributes inherited from QgsFeatureRendererV2
int mCurrentVertexMarkerSize
 The current size of editing marker. More...
 
int mCurrentVertexMarkerType
 The current type of editing marker. More...
 
QString mType
 
bool mUsingSymbolLevels
 

Additional Inherited Members

- Protected Member Functions inherited from QgsFeatureRendererV2
 QgsFeatureRendererV2 (QString type)
 
void renderFeatureWithSymbol (QgsFeature &feature, QgsSymbolV2 *symbol, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker)
 
void renderVertexMarker (QPointF &pt, QgsRenderContext &context)
 render editing vertex marker at specified point More...
 
void renderVertexMarkerPolygon (QPolygonF &pts, QList< QPolygonF > *rings, QgsRenderContext &context)
 render editing vertex marker for a polygon More...
 
void renderVertexMarkerPolyline (QPolygonF &pts, QgsRenderContext &context)
 render editing vertex marker for a polyline More...
 
void setScaleMethodToSymbol (QgsSymbolV2 *symbol, int scaleMethod)
 
- Static Protected Member Functions inherited from QgsFeatureRendererV2
static const unsigned char * _getLineString (QPolygonF &pts, QgsRenderContext &context, const unsigned char *wkb)
 
static const unsigned char * _getPoint (QPointF &pt, QgsRenderContext &context, const unsigned char *wkb)
 
static const unsigned char * _getPolygon (QPolygonF &pts, QList< QPolygonF > &holes, QgsRenderContext &context, const unsigned char *wkb)
 

Detailed Description

When drawing a vector layer with rule-based renderer, it goes through the rules and draws features with symbols from rules that match.

Definition at line 34 of file qgsrulebasedrendererv2.h.

Member Typedef Documentation

Definition at line 71 of file qgsrulebasedrendererv2.h.

Definition at line 73 of file qgsrulebasedrendererv2.h.

Member Enumeration Documentation

Enumerator
FeatIsSelected 
FeatDrawMarkers 

Definition at line 41 of file qgsrulebasedrendererv2.h.

Constructor & Destructor Documentation

QgsRuleBasedRendererV2::QgsRuleBasedRendererV2 ( QgsRuleBasedRendererV2::Rule root)

Constructs the renderer from given tree of rules (takes ownership)

Definition at line 740 of file qgsrulebasedrendererv2.cpp.

QgsRuleBasedRendererV2::QgsRuleBasedRendererV2 ( QgsSymbolV2 defaultSymbol)

Constructor for convenience. Creates a root rule and adds a default rule with symbol (takes ownership)

Definition at line 745 of file qgsrulebasedrendererv2.cpp.

QgsRuleBasedRendererV2::~QgsRuleBasedRendererV2 ( )

Definition at line 752 of file qgsrulebasedrendererv2.cpp.

Member Function Documentation

virtual int QgsRuleBasedRendererV2::capabilities ( )
inlinevirtual

returns bitwise OR-ed capabilities of the renderer

Reimplemented from QgsFeatureRendererV2.

Definition at line 279 of file qgsrulebasedrendererv2.h.

void QgsRuleBasedRendererV2::checkLegendSymbolItem ( QString  key,
bool  state = true 
)
virtual

item in symbology was checked

Note
added in 2.5

Reimplemented from QgsFeatureRendererV2.

Definition at line 922 of file qgsrulebasedrendererv2.cpp.

QgsFeatureRendererV2 * QgsRuleBasedRendererV2::clone ( ) const
virtual

Implements QgsFeatureRendererV2.

Definition at line 850 of file qgsrulebasedrendererv2.cpp.

QgsRuleBasedRendererV2 * QgsRuleBasedRendererV2::convertFromRenderer ( const QgsFeatureRendererV2 renderer)
static

creates a QgsRuleBasedRendererV2 from an existing renderer.

Note
added in 2.5
Returns
a new renderer if the conversion was possible, otherwise 0.

Definition at line 1074 of file qgsrulebasedrendererv2.cpp.

void QgsRuleBasedRendererV2::convertToDataDefinedSymbology ( QgsSymbolV2 symbol,
QString  sizeScaleField,
QString  rotationField 
)
static

helper function to convert the size scale and rotation fields present in some other renderers to data defined symbology

Definition at line 1195 of file qgsrulebasedrendererv2.cpp.

QgsFeatureRendererV2 * QgsRuleBasedRendererV2::create ( QDomElement &  element)
static

Definition at line 940 of file qgsrulebasedrendererv2.cpp.

QgsFeatureRendererV2 * QgsRuleBasedRendererV2::createFromSld ( QDomElement &  element,
QGis::GeometryType  geomType 
)
static

Definition at line 963 of file qgsrulebasedrendererv2.cpp.

QString QgsRuleBasedRendererV2::dump ( ) const
virtual

for debugging

Reimplemented from QgsFeatureRendererV2.

Definition at line 1052 of file qgsrulebasedrendererv2.cpp.

bool QgsRuleBasedRendererV2::legendSymbolItemChecked ( QString  key)
virtual

items of symbology items in legend is checked

Note
added in 2.5

Reimplemented from QgsFeatureRendererV2.

Definition at line 916 of file qgsrulebasedrendererv2.cpp.

QgsLegendSymbolList QgsRuleBasedRendererV2::legendSymbolItems ( double  scaleDenominator = -1,
QString  rule = "" 
)
virtual

return a list of item text / symbol

Note
not available in python bindings

Reimplemented from QgsFeatureRendererV2.

Definition at line 929 of file qgsrulebasedrendererv2.cpp.

bool QgsRuleBasedRendererV2::legendSymbolItemsCheckable ( ) const
virtual

items of symbology items in legend should be checkable

Note
added in 2.5

Reimplemented from QgsFeatureRendererV2.

Definition at line 911 of file qgsrulebasedrendererv2.cpp.

QgsLegendSymbolListV2 QgsRuleBasedRendererV2::legendSymbolItemsV2 ( ) const
virtual

Return a list of symbology items for the legend.

Better choice than legendSymbolItems(). Default fallback implementation just uses legendSymbolItems() implementation

Note
added in 2.6

Reimplemented from QgsFeatureRendererV2.

Definition at line 934 of file qgsrulebasedrendererv2.cpp.

QgsLegendSymbologyList QgsRuleBasedRendererV2::legendSymbologyItems ( QSize  iconSize)
virtual

return a list of symbology items for the legend

Reimplemented from QgsFeatureRendererV2.

Definition at line 898 of file qgsrulebasedrendererv2.cpp.

QgsSymbolV2List QgsRuleBasedRendererV2::originalSymbolsForFeature ( QgsFeature feat)
virtual

Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbols per feature - similar to symbolsForFeature()

Note
added in 2.6

Reimplemented from QgsFeatureRendererV2.

Definition at line 1069 of file qgsrulebasedrendererv2.cpp.

void QgsRuleBasedRendererV2::refineRuleCategories ( QgsRuleBasedRendererV2::Rule initialRule,
QgsCategorizedSymbolRendererV2 r 
)
static

take a rule and create a list of new rules based on the categories from categorized symbol renderer

Definition at line 997 of file qgsrulebasedrendererv2.cpp.

void QgsRuleBasedRendererV2::refineRuleRanges ( QgsRuleBasedRendererV2::Rule initialRule,
QgsGraduatedSymbolRendererV2 r 
)
static

take a rule and create a list of new rules based on the ranges from graduated symbol renderer

Definition at line 1018 of file qgsrulebasedrendererv2.cpp.

void QgsRuleBasedRendererV2::refineRuleScales ( QgsRuleBasedRendererV2::Rule initialRule,
QList< int >  scales 
)
static

take a rule and create a list of new rules with intervals of scales given by the passed scale denominators

Definition at line 1033 of file qgsrulebasedrendererv2.cpp.

bool QgsRuleBasedRendererV2::renderFeature ( QgsFeature feature,
QgsRenderContext context,
int  layer = -1,
bool  selected = false,
bool  drawVertexMarker = false 
)
virtual

Reimplemented from QgsFeatureRendererV2.

Definition at line 764 of file qgsrulebasedrendererv2.cpp.

Rule* QgsRuleBasedRendererV2::rootRule ( )
inline

Definition at line 283 of file qgsrulebasedrendererv2.h.

QDomElement QgsRuleBasedRendererV2::save ( QDomDocument &  doc)
virtual

store renderer info to XML element

Reimplemented from QgsFeatureRendererV2.

Definition at line 880 of file qgsrulebasedrendererv2.cpp.

void QgsRuleBasedRendererV2::startRender ( QgsRenderContext context,
const QgsFields fields 
)
virtual

Implements QgsFeatureRendererV2.

Definition at line 780 of file qgsrulebasedrendererv2.cpp.

void QgsRuleBasedRendererV2::stopRender ( QgsRenderContext context)
virtual

Implements QgsFeatureRendererV2.

Definition at line 803 of file qgsrulebasedrendererv2.cpp.

QgsSymbolV2 * QgsRuleBasedRendererV2::symbolForFeature ( QgsFeature feature)
virtual

return symbol for current feature. Should not be used individually: there could be more symbols for a feature

Implements QgsFeatureRendererV2.

Definition at line 758 of file qgsrulebasedrendererv2.cpp.

QgsSymbolV2List QgsRuleBasedRendererV2::symbols ( )
virtual

for symbol levels

Implements QgsFeatureRendererV2.

Definition at line 875 of file qgsrulebasedrendererv2.cpp.

QgsSymbolV2List QgsRuleBasedRendererV2::symbolsForFeature ( QgsFeature feat)
virtual

return list of symbols used for rendering the feature.

For renderers that do not support MoreSymbolsPerFeature it is more efficient to use symbolForFeature()

Reimplemented from QgsFeatureRendererV2.

Definition at line 1064 of file qgsrulebasedrendererv2.cpp.

void QgsRuleBasedRendererV2::toSld ( QDomDocument &  doc,
QDomElement &  element 
) const
virtual

used from subclasses to create SLD Rule elements following SLD v1.1 specs

Reimplemented from QgsFeatureRendererV2.

Definition at line 869 of file qgsrulebasedrendererv2.cpp.

QList< QString > QgsRuleBasedRendererV2::usedAttributes ( )
virtual

Implements QgsFeatureRendererV2.

Definition at line 844 of file qgsrulebasedrendererv2.cpp.

bool QgsRuleBasedRendererV2::willRenderFeature ( QgsFeature feat)
virtual

return whether the renderer will render a feature or not.

Must be called between startRender() and stopRender() calls.

Reimplemented from QgsFeatureRendererV2.

Definition at line 1059 of file qgsrulebasedrendererv2.cpp.

Member Data Documentation

QList<FeatureToRender> QgsRuleBasedRendererV2::mCurrentFeatures
protected

Definition at line 308 of file qgsrulebasedrendererv2.h.

RenderQueue QgsRuleBasedRendererV2::mRenderQueue
protected

Definition at line 307 of file qgsrulebasedrendererv2.h.

Rule* QgsRuleBasedRendererV2::mRootRule
protected

the root node with hierarchical list of rules

Definition at line 304 of file qgsrulebasedrendererv2.h.


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