QGIS API Documentation  3.4.15-Madeira (e83d02e274)
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsCategorizedSymbolRenderer Class Reference

#include <qgscategorizedsymbolrenderer.h>

Inheritance diagram for QgsCategorizedSymbolRenderer:
Inheritance graph
[legend]

Public Member Functions

 QgsCategorizedSymbolRenderer (const QString &attrName=QString(), const QgsCategoryList &categories=QgsCategoryList())
 Constructor for QgsCategorizedSymbolRenderer. More...
 
void addCategory (const QgsRendererCategory &category)
 Adds a new category to the renderer. More...
 
QgsFeatureRenderer::Capabilities capabilities () override
 Returns details about internals of this renderer. More...
 
const QgsCategoryListcategories () const
 Returns a list of all categories recognized by the renderer. More...
 
int categoryIndexForLabel (const QString &val)
 Returns the index of the category with the specified label (or -1 if the label was not found, or is not unique). More...
 
int categoryIndexForValue (const QVariant &val)
 Returns the index for the category with the specified value (or -1 if not found). More...
 
void checkLegendSymbolItem (const QString &key, bool state=true) override
 item in symbology was checked More...
 
QString classAttribute () const
 Returns the class attribute for the renderer, which is the field name or expression string from the layer which will be matched against the renderer categories. More...
 
QgsCategorizedSymbolRendererclone () const override
 Create a deep copy of this renderer. More...
 
QgsDataDefinedSizeLegenddataDefinedSizeLegend () const
 Returns configuration of appearance of legend when using data-defined size for marker symbols. More...
 
void deleteAllCategories ()
 Deletes all existing categories from the renderer. More...
 
bool deleteCategory (int catIndex)
 Deletes the category with the specified index from the renderer. More...
 
QString dump () const override
 Returns debug information about this renderer. More...
 
QString filter (const QgsFields &fields=QgsFields()) override
 If a renderer does not require all the features this method may be overridden and return an expression used as where clause. More...
 
bool filterNeedsGeometry () const override
 Returns true if this renderer requires the geometry to apply the filter. More...
 
QString legendClassificationAttribute () const override
 If supported by the renderer, return classification attribute for the use in legend. More...
 
QSet< QString > legendKeysForFeature (const QgsFeature &feature, QgsRenderContext &context) const override
 Returns legend keys matching a specified feature. More...
 
bool legendSymbolItemChecked (const QString &key) override
 items of symbology items in legend is checked More...
 
QgsLegendSymbolList legendSymbolItems () const override
 Returns a list of symbology items for the legend. More...
 
bool legendSymbolItemsCheckable () const override
 items of symbology items in legend should be checkable More...
 
int matchToSymbols (QgsStyle *style, QgsSymbol::SymbolType type, QVariantList &unmatchedCategories, QStringList &unmatchedSymbols, bool caseSensitive=true, bool useTolerantMatch=false)
 Replaces category symbols with the symbols from a style that have a matching name and symbol type. More...
 
void moveCategory (int from, int to)
 Moves an existing category at index position from to index position to. More...
 
QgsSymboloriginalSymbolForFeature (const QgsFeature &feature, QgsRenderContext &context) const override
 Returns symbol for feature. More...
 
QDomElement save (QDomDocument &doc, const QgsReadWriteContext &context) override
 store renderer info to XML element More...
 
void setClassAttribute (const QString &attr)
 Sets the class attribute for the renderer, which is the field name or expression string from the layer which will be matched against the renderer categories. More...
 
void setDataDefinedSizeLegend (QgsDataDefinedSizeLegend *settings)
 Configures appearance of legend when renderer is configured to use data-defined size for marker symbols. More...
 
void setLegendSymbolItem (const QString &key, QgsSymbol *symbol) override
 Sets the symbol to be used for a legend symbol item. More...
 
void setSourceColorRamp (QgsColorRamp *ramp)
 Sets the source color ramp. More...
 
void setSourceSymbol (QgsSymbol *sym)
 Sets the source symbol for the renderer, which is the base symbol used for the each categories' symbol before applying the categories' color. More...
 
void sortByLabel (Qt::SortOrder order=Qt::AscendingOrder)
 Sorts the existing categories by their label. More...
 
void sortByValue (Qt::SortOrder order=Qt::AscendingOrder)
 Sorts the existing categories by their value. More...
 
QgsColorRampsourceColorRamp ()
 Returns the source color ramp, from which each categories' color is derived. More...
 
QgsSymbolsourceSymbol ()
 Returns the renderer's source symbol, which is the base symbol used for the each categories' symbol before applying the categories' color. More...
 
void startRender (QgsRenderContext &context, const QgsFields &fields) override
 Must be called when a new render cycle is started. More...
 
void stopRender (QgsRenderContext &context) override
 Must be called when a render cycle has finished, to allow the renderer to clean up. More...
 
QgsSymbolsymbolForFeature (const QgsFeature &feature, QgsRenderContext &context) const override
 To be overridden. More...
 
QgsSymbolList symbols (QgsRenderContext &context) const override
 Returns list of symbols used by the renderer. More...
 
void toSld (QDomDocument &doc, QDomElement &element, const QgsStringMap &props=QgsStringMap()) const override
 used from subclasses to create SLD Rule elements following SLD v1.1 specs More...
 
bool updateCategoryLabel (int catIndex, const QString &label)
 Changes the label for the category with the specified index. More...
 
bool updateCategoryRenderState (int catIndex, bool render)
 Changes the render state for the category with the specified index. More...
 
bool updateCategorySymbol (int catIndex, QgsSymbol *symbol)
 Changes the symbol for the category with the specified index. More...
 
bool updateCategoryValue (int catIndex, const QVariant &value)
 Changes the value for the category with the specified index. More...
 
void updateColorRamp (QgsColorRamp *ramp)
 Update the color ramp used and all symbols colors. More...
 
void updateSymbols (QgsSymbol *sym)
 Update all the symbols but leave categories and colors. More...
 
QSet< QString > usedAttributes (const QgsRenderContext &context) const override
 Returns a list of attributes required by this renderer. More...
 
- Public Member Functions inherited from QgsFeatureRenderer
virtual ~QgsFeatureRenderer ()
 
virtual const QgsFeatureRendererembeddedRenderer () const
 Returns the current embedded renderer (subrenderer) for this feature renderer. More...
 
bool forceRasterRender () const
 Returns whether the renderer must render as a raster. More...
 
virtual void modifyRequestExtent (QgsRectangle &extent, QgsRenderContext &context)
 Allows for a renderer to modify the extent of a feature request prior to rendering. More...
 
QgsFeatureRequest::OrderBy orderBy () const
 Gets the order in which features shall be processed by this renderer. More...
 
bool orderByEnabled () const
 Returns whether custom ordering will be applied before features are processed by this renderer. More...
 
virtual QgsSymbolList originalSymbolsForFeature (const QgsFeature &feature, QgsRenderContext &context) const
 Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbols per feature - similar to symbolsForFeature() More...
 
QgsPaintEffectpaintEffect () const
 Returns the current paint effect for the renderer. More...
 
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. More...
 
virtual void setEmbeddedRenderer (QgsFeatureRenderer *subRenderer)
 Sets an embedded renderer (subrenderer) for this feature renderer. More...
 
void setForceRasterRender (bool forceRaster)
 Sets whether the renderer should be rendered to a raster destination. More...
 
void setOrderBy (const QgsFeatureRequest::OrderBy &orderBy)
 Define the order in which features shall be processed by this renderer. More...
 
void setOrderByEnabled (bool enabled)
 Sets whether custom ordering should be applied before features are processed by this renderer. More...
 
void setPaintEffect (QgsPaintEffect *effect)
 Sets the current paint effect for the renderer. More...
 
void setUsingSymbolLevels (bool usingSymbolLevels)
 
void setVertexMarkerAppearance (int type, double size)
 Sets type and size of editing vertex markers for subsequent rendering. More...
 
virtual QgsSymbolList symbolsForFeature (const QgsFeature &feature, QgsRenderContext &context) const
 Returns list of symbols used for rendering the feature. More...
 
QString type () const
 
bool usingSymbolLevels () const
 
virtual bool willRenderFeature (const QgsFeature &feature, QgsRenderContext &context) const
 Returns whether the renderer will render a feature or not. More...
 
virtual QDomElement writeSld (QDomDocument &doc, const QString &styleName, const QgsStringMap &props=QgsStringMap()) const
 create the SLD UserStyle element following the SLD v1.1 specs with the given name More...
 

Static Public Member Functions

static QgsCategorizedSymbolRendererconvertFromRenderer (const QgsFeatureRenderer *renderer)
 creates a QgsCategorizedSymbolRenderer from an existing renderer. More...
 
static QgsFeatureRenderercreate (QDomElement &element, const QgsReadWriteContext &context)
 Creates a categorized renderer from an XML element. More...
 
- Static Public Member Functions inherited from QgsFeatureRenderer
static QgsFeatureRendererdefaultRenderer (QgsWkbTypes::GeometryType geomType)
 Returns a new renderer - used by default in vector layers. More...
 
static QgsFeatureRendererload (QDomElement &symbologyElem, const QgsReadWriteContext &context)
 create a renderer from XML element More...
 
static QgsFeatureRendererloadSld (const QDomNode &node, QgsWkbTypes::GeometryType geomType, QString &errorMessage)
 Create a new renderer according to the information contained in the UserStyle element of a SLD style document. More...
 

Protected Member Functions

void rebuildHash ()
 
Q_DECL_DEPRECATED QgsSymbolskipRender ()
 
Q_DECL_DEPRECATED QgsSymbolsymbolForValue (const QVariant &value) const
 Returns the matching symbol corresponding to an attribute value. More...
 
QgsSymbolsymbolForValue (const QVariant &value, bool &foundMatchingSymbol) const
 Returns the matching symbol corresponding to an attribute value. More...
 
- Protected Member Functions inherited from QgsFeatureRenderer
 QgsFeatureRenderer (const QString &type)
 
void copyRendererData (QgsFeatureRenderer *destRenderer) const
 Clones generic renderer data to another renderer. More...
 
void renderFeatureWithSymbol (const QgsFeature &feature, QgsSymbol *symbol, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker) SIP_THROW(QgsCsException)
 Render the feature with the symbol using context. More...
 
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...
 

Protected Attributes

QString mAttrName
 
int mAttrNum = -1
 attribute index (derived from attribute name in startRender) More...
 
QgsCategoryList mCategories
 
bool mCounting = false
 
std::unique_ptr< QgsDataDefinedSizeLegendmDataDefinedSizeLegend
 
std::unique_ptr< QgsExpressionmExpression
 
std::unique_ptr< QgsColorRampmSourceColorRamp
 
std::unique_ptr< QgsSymbolmSourceSymbol
 
QHash< QString, QgsSymbol * > mSymbolHash
 hashtable for faster access to symbols More...
 
- Protected Attributes inherited from QgsFeatureRenderer
double mCurrentVertexMarkerSize
 The current size of editing marker. More...
 
int mCurrentVertexMarkerType
 The current type of editing marker. More...
 
bool mForceRaster
 
QgsFeatureRequest::OrderBy mOrderBy
 
bool mOrderByEnabled
 
QgsPaintEffectmPaintEffect = nullptr
 
QString mType
 
bool mUsingSymbolLevels
 

Additional Inherited Members

- Public Types inherited from QgsFeatureRenderer
enum  Capability { SymbolLevels = 1, MoreSymbolsPerFeature = 1 << 2, Filter = 1 << 3, ScaleDependent = 1 << 4 }
 Used to specify details about a renderer. More...
 
- Static Protected Member Functions inherited from QgsFeatureRenderer
static QPointF _getPoint (QgsRenderContext &context, const QgsPoint &point)
 Creates a point in screen coordinates from a wkb string in map coordinates. More...
 
static void convertSymbolRotation (QgsSymbol *symbol, const QString &field)
 
static void convertSymbolSizeScale (QgsSymbol *symbol, QgsSymbol::ScaleMethod method, const QString &field)
 

Detailed Description

Definition at line 143 of file qgscategorizedsymbolrenderer.h.

Constructor & Destructor Documentation

QgsCategorizedSymbolRenderer::QgsCategorizedSymbolRenderer ( const QString &  attrName = QString(),
const QgsCategoryList categories = QgsCategoryList() 
)

Constructor for QgsCategorizedSymbolRenderer.

The attrName argument specifies the layer's field name, or expression, which the categories will be matched against.

A list of renderer categories can optionally be specified. If no categories are specified in the constructor, they can be added later by calling addCategory().

Definition at line 159 of file qgscategorizedsymbolrenderer.cpp.

Member Function Documentation

void QgsCategorizedSymbolRenderer::addCategory ( const QgsRendererCategory category)

Adds a new category to the renderer.

See also
categories()

Definition at line 321 of file qgscategorizedsymbolrenderer.cpp.

QgsFeatureRenderer::Capabilities QgsCategorizedSymbolRenderer::capabilities ( )
inlineoverridevirtual

Returns details about internals of this renderer.

E.g. if you only want to deal with visible features:

1 if not renderer.capabilities().testFlag(QgsFeatureRenderer.Filter) or renderer.willRenderFeature(feature, context):
2  deal_with_my_feature()
3 else:
4  skip_the_curren_feature()

Reimplemented from QgsFeatureRenderer.

Definition at line 166 of file qgscategorizedsymbolrenderer.h.

const QgsCategoryList& QgsCategorizedSymbolRenderer::categories ( ) const
inline

Returns a list of all categories recognized by the renderer.

Definition at line 181 of file qgscategorizedsymbolrenderer.h.

int QgsCategorizedSymbolRenderer::categoryIndexForLabel ( const QString &  val)

Returns the index of the category with the specified label (or -1 if the label was not found, or is not unique).

Since
QGIS 2.5

Definition at line 273 of file qgscategorizedsymbolrenderer.cpp.

int QgsCategorizedSymbolRenderer::categoryIndexForValue ( const QVariant &  val)

Returns the index for the category with the specified value (or -1 if not found).

Definition at line 263 of file qgscategorizedsymbolrenderer.cpp.

void QgsCategorizedSymbolRenderer::checkLegendSymbolItem ( const QString &  key,
bool  state = true 
)
overridevirtual

item in symbology was checked

Since
QGIS 2.5

Reimplemented from QgsFeatureRenderer.

Definition at line 916 of file qgscategorizedsymbolrenderer.cpp.

QString QgsCategorizedSymbolRenderer::classAttribute ( ) const
inline

Returns the class attribute for the renderer, which is the field name or expression string from the layer which will be matched against the renderer categories.

See also
setClassAttribute()

Definition at line 287 of file qgscategorizedsymbolrenderer.h.

QgsCategorizedSymbolRenderer * QgsCategorizedSymbolRenderer::clone ( ) const
overridevirtual

Create a deep copy of this renderer.

Should be implemented by all subclasses and generate a proper subclass.

Returns
A copy of this renderer

Implements QgsFeatureRenderer.

Definition at line 476 of file qgscategorizedsymbolrenderer.cpp.

QgsCategorizedSymbolRenderer * QgsCategorizedSymbolRenderer::convertFromRenderer ( const QgsFeatureRenderer renderer)
static

creates a QgsCategorizedSymbolRenderer from an existing renderer.

Returns
a new renderer if the conversion was possible, otherwise 0.
Since
QGIS 2.5

Definition at line 924 of file qgscategorizedsymbolrenderer.cpp.

QgsFeatureRenderer * QgsCategorizedSymbolRenderer::create ( QDomElement &  element,
const QgsReadWriteContext context 
)
static

Creates a categorized renderer from an XML element.

Definition at line 587 of file qgscategorizedsymbolrenderer.cpp.

QgsDataDefinedSizeLegend * QgsCategorizedSymbolRenderer::dataDefinedSizeLegend ( ) const

Returns configuration of appearance of legend when using data-defined size for marker symbols.

Will return null if the functionality is disabled.

Since
QGIS 3.0

Definition at line 969 of file qgscategorizedsymbolrenderer.cpp.

void QgsCategorizedSymbolRenderer::deleteAllCategories ( )

Deletes all existing categories from the renderer.

See also
deleteCategory()

Definition at line 341 of file qgscategorizedsymbolrenderer.cpp.

bool QgsCategorizedSymbolRenderer::deleteCategory ( int  catIndex)

Deletes the category with the specified index from the renderer.

See also
deleteAllCategories()

Definition at line 332 of file qgscategorizedsymbolrenderer.cpp.

QString QgsCategorizedSymbolRenderer::dump ( ) const
overridevirtual

Returns debug information about this renderer.

Reimplemented from QgsFeatureRenderer.

Definition at line 468 of file qgscategorizedsymbolrenderer.cpp.

QString QgsCategorizedSymbolRenderer::filter ( const QgsFields fields = QgsFields())
overridevirtual

If a renderer does not require all the features this method may be overridden and return an expression used as where clause.

This will be called once after startRender() and before the first call to renderFeature(). By default this returns a null string and all features will be requested. You do not need to specify the extent in here, this is taken care of separately and will be combined with a filter returned from this method.

Returns
An expression used as where clause

Reimplemented from QgsFeatureRenderer.

Definition at line 504 of file qgscategorizedsymbolrenderer.cpp.

bool QgsCategorizedSymbolRenderer::filterNeedsGeometry ( ) const
overridevirtual

Returns true if this renderer requires the geometry to apply the filter.

Reimplemented from QgsFeatureRenderer.

Definition at line 455 of file qgscategorizedsymbolrenderer.cpp.

QString QgsCategorizedSymbolRenderer::legendClassificationAttribute ( ) const
inlineoverridevirtual

If supported by the renderer, return classification attribute for the use in legend.

Since
QGIS 2.6

Reimplemented from QgsFeatureRenderer.

Definition at line 350 of file qgscategorizedsymbolrenderer.h.

QSet< QString > QgsCategorizedSymbolRenderer::legendKeysForFeature ( const QgsFeature feature,
QgsRenderContext context 
) const
overridevirtual

Returns legend keys matching a specified feature.

Since
QGIS 2.14

Reimplemented from QgsFeatureRenderer.

Definition at line 817 of file qgscategorizedsymbolrenderer.cpp.

bool QgsCategorizedSymbolRenderer::legendSymbolItemChecked ( const QString &  key)
overridevirtual

items of symbology items in legend is checked

Since
QGIS 2.5

Reimplemented from QgsFeatureRenderer.

Definition at line 896 of file qgscategorizedsymbolrenderer.cpp.

QgsLegendSymbolList QgsCategorizedSymbolRenderer::legendSymbolItems ( ) const
overridevirtual

Returns a list of symbology items for the legend.

Since
QGIS 2.6

Reimplemented from QgsFeatureRenderer.

Definition at line 777 of file qgscategorizedsymbolrenderer.cpp.

bool QgsCategorizedSymbolRenderer::legendSymbolItemsCheckable ( ) const
overridevirtual

items of symbology items in legend should be checkable

Since
QGIS 2.5

Reimplemented from QgsFeatureRenderer.

Definition at line 891 of file qgscategorizedsymbolrenderer.cpp.

int QgsCategorizedSymbolRenderer::matchToSymbols ( QgsStyle style,
QgsSymbol::SymbolType  type,
QVariantList &  unmatchedCategories,
QStringList &  unmatchedSymbols,
bool  caseSensitive = true,
bool  useTolerantMatch = false 
)

Replaces category symbols with the symbols from a style that have a matching name and symbol type.

The unmatchedCategories list will be filled with all existing categories which could not be matched to a symbol in style.

The unmatchedSymbols list will be filled with all symbol names from style which were not matched to an existing category.

If caseSensitive is false, then a case-insensitive match will be performed. If useTolerantMatch is true, then non-alphanumeric characters in style and category names will be ignored during the match.

Returns the count of symbols matched.

Since
QGIS 3.4

Definition at line 974 of file qgscategorizedsymbolrenderer.cpp.

void QgsCategorizedSymbolRenderer::moveCategory ( int  from,
int  to 
)

Moves an existing category at index position from to index position to.

Definition at line 346 of file qgscategorizedsymbolrenderer.cpp.

QgsSymbol * QgsCategorizedSymbolRenderer::originalSymbolForFeature ( const QgsFeature feature,
QgsRenderContext context 
) const
overridevirtual

Returns symbol for feature.

The difference compared to symbolForFeature() is that it returns original symbol which can be used as an identifier for renderer's rule - the former may return a temporary replacement of a symbol for use in rendering.

Since
QGIS 2.12

Reimplemented from QgsFeatureRenderer.

Definition at line 245 of file qgscategorizedsymbolrenderer.cpp.

void QgsCategorizedSymbolRenderer::rebuildHash ( )
protected

Definition at line 176 of file qgscategorizedsymbolrenderer.cpp.

QDomElement QgsCategorizedSymbolRenderer::save ( QDomDocument &  doc,
const QgsReadWriteContext context 
)
overridevirtual

store renderer info to XML element

Reimplemented from QgsFeatureRenderer.

Definition at line 684 of file qgscategorizedsymbolrenderer.cpp.

void QgsCategorizedSymbolRenderer::setClassAttribute ( const QString &  attr)
inline

Sets the class attribute for the renderer, which is the field name or expression string from the layer which will be matched against the renderer categories.

See also
classAttribute()

Definition at line 296 of file qgscategorizedsymbolrenderer.h.

void QgsCategorizedSymbolRenderer::setDataDefinedSizeLegend ( QgsDataDefinedSizeLegend settings)

Configures appearance of legend when renderer is configured to use data-defined size for marker symbols.

This allows configuring for which values (symbol sizes) should be shown in the legend, whether to display different symbol sizes collapsed in one legend node or separated across multiple legend nodes etc.

When renderer does not use data-defined size or does not use marker symbols, these settings will be ignored. Takes ownership of the passed settings objects. Null pointer is a valid input that disables data-defined size legend.

Since
QGIS 3.0

Definition at line 964 of file qgscategorizedsymbolrenderer.cpp.

void QgsCategorizedSymbolRenderer::setLegendSymbolItem ( const QString &  key,
QgsSymbol symbol 
)
overridevirtual

Sets the symbol to be used for a legend symbol item.

Parameters
keyrule key for legend symbol
symbolnew symbol for legend item. Ownership is transferred to renderer.
Since
QGIS 2.14

Reimplemented from QgsFeatureRenderer.

Definition at line 906 of file qgscategorizedsymbolrenderer.cpp.

void QgsCategorizedSymbolRenderer::setSourceColorRamp ( QgsColorRamp ramp)

Sets the source color ramp.

Parameters
rampcolor ramp. Ownership is transferred to the renderer
See also
sourceColorRamp()
setSourceSymbol()

Definition at line 851 of file qgscategorizedsymbolrenderer.cpp.

void QgsCategorizedSymbolRenderer::setSourceSymbol ( QgsSymbol sym)

Sets the source symbol for the renderer, which is the base symbol used for the each categories' symbol before applying the categories' color.

Parameters
symsource symbol, ownership is transferred to the renderer
See also
sourceSymbol()
setSourceColorRamp()

Definition at line 841 of file qgscategorizedsymbolrenderer.cpp.

QgsSymbol * QgsCategorizedSymbolRenderer::skipRender ( )
protected
Deprecated:
No longer used, will be removed in QGIS 4.0

Definition at line 187 of file qgscategorizedsymbolrenderer.cpp.

void QgsCategorizedSymbolRenderer::sortByLabel ( Qt::SortOrder  order = Qt::AscendingOrder)

Sorts the existing categories by their label.

See also
sortByValue()

Definition at line 383 of file qgscategorizedsymbolrenderer.cpp.

void QgsCategorizedSymbolRenderer::sortByValue ( Qt::SortOrder  order = Qt::AscendingOrder)

Sorts the existing categories by their value.

See also
sortByLabel()

Definition at line 361 of file qgscategorizedsymbolrenderer.cpp.

QgsColorRamp * QgsCategorizedSymbolRenderer::sourceColorRamp ( )

Returns the source color ramp, from which each categories' color is derived.

See also
setSourceColorRamp()
sourceSymbol()

Definition at line 846 of file qgscategorizedsymbolrenderer.cpp.

QgsSymbol * QgsCategorizedSymbolRenderer::sourceSymbol ( )

Returns the renderer's source symbol, which is the base symbol used for the each categories' symbol before applying the categories' color.

See also
setSourceSymbol()
sourceColorRamp()

Definition at line 837 of file qgscategorizedsymbolrenderer.cpp.

void QgsCategorizedSymbolRenderer::startRender ( QgsRenderContext context,
const QgsFields fields 
)
overridevirtual

Must be called when a new render cycle is started.

A call to startRender() must always be followed by a corresponding call to stopRender() after all features have been rendered.

Parameters
contextAdditional information passed to the renderer about the job which will be rendered
fieldsThe fields available for rendering
See also
stopRender()
Warning
This method is not thread safe. Before calling startRender() in a non-main thread, the renderer should instead be cloned and startRender()/stopRender() called on the clone.

Reimplemented from QgsFeatureRenderer.

Definition at line 395 of file qgscategorizedsymbolrenderer.cpp.

void QgsCategorizedSymbolRenderer::stopRender ( QgsRenderContext context)
overridevirtual

Must be called when a render cycle has finished, to allow the renderer to clean up.

Calls to stopRender() must always be preceded by a call to startRender().

Warning
This method is not thread safe. Before calling startRender() in a non-main thread, the renderer should instead be cloned and startRender()/stopRender() called on the clone.
See also
startRender()

Reimplemented from QgsFeatureRenderer.

Definition at line 418 of file qgscategorizedsymbolrenderer.cpp.

QgsSymbol * QgsCategorizedSymbolRenderer::symbolForFeature ( const QgsFeature feature,
QgsRenderContext context 
) const
overridevirtual

To be overridden.

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

Parameters
featurefeature
contextrender context
Returns
returns pointer to symbol or 0 if symbol was not found
Since
QGIS 2.12

Implements QgsFeatureRenderer.

Definition at line 222 of file qgscategorizedsymbolrenderer.cpp.

QgsSymbol * QgsCategorizedSymbolRenderer::symbolForValue ( const QVariant &  value) const
protected

Returns the matching symbol corresponding to an attribute value.

Deprecated:
use variant which takes a second bool argument instead.

Definition at line 192 of file qgscategorizedsymbolrenderer.cpp.

QgsSymbol * QgsCategorizedSymbolRenderer::symbolForValue ( const QVariant &  value,
bool &  foundMatchingSymbol 
) const
protected

Returns the matching symbol corresponding to an attribute value.

Will return nullptr if no matching symbol was found for value, or if the category corresponding to value is currently disabled (see QgsRendererCategory::renderState()).

If foundMatchingSymbol is specified then it will be set to true if a matching category was found. This can be used to differentiate between a nullptr returned as a result of no matching category vs a nullptr as a result of disabled categories.

Note
available in Python bindings as symbolForValue2

Definition at line 198 of file qgscategorizedsymbolrenderer.cpp.

QgsSymbolList QgsCategorizedSymbolRenderer::symbols ( QgsRenderContext context) const
overridevirtual

Returns list of symbols used by the renderer.

Parameters
contextrender context
Since
QGIS 2.12

Reimplemented from QgsFeatureRenderer.

Definition at line 575 of file qgscategorizedsymbolrenderer.cpp.

void QgsCategorizedSymbolRenderer::toSld ( QDomDocument &  doc,
QDomElement &  element,
const QgsStringMap props = QgsStringMap() 
) const
overridevirtual

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

Reimplemented from QgsFeatureRenderer.

Definition at line 492 of file qgscategorizedsymbolrenderer.cpp.

bool QgsCategorizedSymbolRenderer::updateCategoryLabel ( int  catIndex,
const QString &  label 
)

Changes the label for the category with the specified index.

A category's label is used to represent the category within legends and the layer tree.

See also
updateCategoryValue()
updateCategoryLabel()
updateCategoryRenderState()

Definition at line 305 of file qgscategorizedsymbolrenderer.cpp.

bool QgsCategorizedSymbolRenderer::updateCategoryRenderState ( int  catIndex,
bool  render 
)

Changes the render state for the category with the specified index.

The render state indicates whether or not the category will be rendered, and is reflected in whether the category is checked with the project's layer tree.

See also
updateCategoryValue()
updateCategorySymbol()
updateCategoryLabel()
Since
QGIS 2.5

Definition at line 313 of file qgscategorizedsymbolrenderer.cpp.

bool QgsCategorizedSymbolRenderer::updateCategorySymbol ( int  catIndex,
QgsSymbol symbol 
)

Changes the symbol for the category with the specified index.

Ownership of symbol is transferred to the renderer.

See also
updateCategoryValue()
updateCategoryLabel()
updateCategoryRenderState()

Definition at line 297 of file qgscategorizedsymbolrenderer.cpp.

bool QgsCategorizedSymbolRenderer::updateCategoryValue ( int  catIndex,
const QVariant &  value 
)

Changes the value for the category with the specified index.

See also
updateCategorySymbol()
updateCategoryLabel()
updateCategoryRenderState()

Definition at line 289 of file qgscategorizedsymbolrenderer.cpp.

void QgsCategorizedSymbolRenderer::updateColorRamp ( QgsColorRamp ramp)

Update the color ramp used and all symbols colors.

Parameters
rampcolor ramp. Ownership is transferred to the renderer
Since
QGIS 2.5

Definition at line 856 of file qgscategorizedsymbolrenderer.cpp.

void QgsCategorizedSymbolRenderer::updateSymbols ( QgsSymbol sym)

Update all the symbols but leave categories and colors.

This method also sets the source symbol for the renderer.

Parameters
symsource symbol to use for categories. Ownership is not transferred.
See also
setSourceSymbol()

Definition at line 878 of file qgscategorizedsymbolrenderer.cpp.

QSet< QString > QgsCategorizedSymbolRenderer::usedAttributes ( const QgsRenderContext context) const
overridevirtual

Returns a list of attributes required by this renderer.

Attributes not listed in here may not have been requested from the provider at rendering time.

Returns
A set of attributes

Implements QgsFeatureRenderer.

Definition at line 429 of file qgscategorizedsymbolrenderer.cpp.

Member Data Documentation

QString QgsCategorizedSymbolRenderer::mAttrName
protected

Definition at line 399 of file qgscategorizedsymbolrenderer.h.

int QgsCategorizedSymbolRenderer::mAttrNum = -1
protected

attribute index (derived from attribute name in startRender)

Definition at line 408 of file qgscategorizedsymbolrenderer.h.

QgsCategoryList QgsCategorizedSymbolRenderer::mCategories
protected

Definition at line 400 of file qgscategorizedsymbolrenderer.h.

bool QgsCategorizedSymbolRenderer::mCounting = false
protected

Definition at line 412 of file qgscategorizedsymbolrenderer.h.

std::unique_ptr<QgsDataDefinedSizeLegend> QgsCategorizedSymbolRenderer::mDataDefinedSizeLegend
protected

Definition at line 405 of file qgscategorizedsymbolrenderer.h.

std::unique_ptr<QgsExpression> QgsCategorizedSymbolRenderer::mExpression
protected

Definition at line 403 of file qgscategorizedsymbolrenderer.h.

std::unique_ptr<QgsColorRamp> QgsCategorizedSymbolRenderer::mSourceColorRamp
protected

Definition at line 402 of file qgscategorizedsymbolrenderer.h.

std::unique_ptr<QgsSymbol> QgsCategorizedSymbolRenderer::mSourceSymbol
protected

Definition at line 401 of file qgscategorizedsymbolrenderer.h.

QHash<QString, QgsSymbol *> QgsCategorizedSymbolRenderer::mSymbolHash
protected

hashtable for faster access to symbols

Definition at line 411 of file qgscategorizedsymbolrenderer.h.


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