Skip to content

Commit

Permalink
Const correctness for renderers
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Apr 18, 2018
1 parent 0e0e133 commit 3775cdb
Show file tree
Hide file tree
Showing 30 changed files with 196 additions and 168 deletions.
4 changes: 2 additions & 2 deletions python/core/symbology/qgs25drenderer.sip.in
Expand Up @@ -37,9 +37,9 @@ Create a new 2.5D renderer from XML
virtual QgsFeatureRenderer *clone() const /Factory/;


virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context );
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) const;

virtual QgsSymbolList symbols( QgsRenderContext &context );
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;


QColor roofColor() const;
Expand Down
12 changes: 6 additions & 6 deletions python/core/symbology/qgscategorizedsymbolrenderer.sip.in
Expand Up @@ -83,9 +83,9 @@ class QgsCategorizedSymbolRenderer : QgsFeatureRenderer

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

virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context );
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) const;

virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context );
virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context ) const;

virtual void startRender( QgsRenderContext &context, const QgsFields &fields );

Expand All @@ -102,7 +102,7 @@ class QgsCategorizedSymbolRenderer : QgsFeatureRenderer
virtual QgsFeatureRenderer::Capabilities capabilities();
virtual QString filter( const QgsFields &fields = QgsFields() );

virtual QgsSymbolList symbols( QgsRenderContext &context );
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;


void updateSymbols( QgsSymbol *sym );
Expand Down Expand Up @@ -163,7 +163,7 @@ create renderer from XML element

virtual QgsLegendSymbolList legendSymbolItems() const;

virtual QSet< QString > legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context );
virtual QSet< QString > legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context ) const;


QgsSymbol *sourceSymbol();
Expand Down Expand Up @@ -273,15 +273,15 @@ hashtable for faster access to symbols
.. deprecated:: No longer used, will be removed in QGIS 4.0
%End

QgsSymbol *symbolForValue( const QVariant &value ) /Deprecated/;
QgsSymbol *symbolForValue( const QVariant &value ) const /Deprecated/;
%Docstring
Returns the matching symbol corresponding to an attribute ``value``.

.. deprecated:: use variant which takes a second bool argument instead.
%End


QgsSymbol *symbolForValue( const QVariant &value, bool &foundMatchingSymbol /Out/ ) /PyName=symbolForValue2/;
QgsSymbol *symbolForValue( const QVariant &value, bool &foundMatchingSymbol /Out/ ) const /PyName=symbolForValue2/;
%Docstring
Returns the matching symbol corresponding to an attribute ``value``.

Expand Down
10 changes: 5 additions & 5 deletions python/core/symbology/qgsgraduatedsymbolrenderer.sip.in
Expand Up @@ -120,9 +120,9 @@ class QgsGraduatedSymbolRenderer : QgsFeatureRenderer

~QgsGraduatedSymbolRenderer();

virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context );
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) const;

virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context );
virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context ) const;

virtual void startRender( QgsRenderContext &context, const QgsFields &fields );

Expand All @@ -137,7 +137,7 @@ class QgsGraduatedSymbolRenderer : QgsFeatureRenderer
virtual void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap &props = QgsStringMap() ) const;

virtual QgsFeatureRenderer::Capabilities capabilities();
virtual QgsSymbolList symbols( QgsRenderContext &context );
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;


QString classAttribute() const;
Expand Down Expand Up @@ -292,7 +292,7 @@ create renderer from XML element

virtual QgsLegendSymbolList legendSymbolItems() const;

virtual QSet< QString > legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context );
virtual QSet< QString > legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context ) const;


QgsSymbol *sourceSymbol();
Expand Down Expand Up @@ -440,7 +440,7 @@ Will return null if the functionality is disabled.



QgsSymbol *symbolForValue( double value );
QgsSymbol *symbolForValue( double value ) const;
%Docstring
attribute index (derived from attribute name in startRender)
%End
Expand Down
4 changes: 2 additions & 2 deletions python/core/symbology/qgsheatmaprenderer.sip.in
Expand Up @@ -33,15 +33,15 @@ class QgsHeatmapRenderer : QgsFeatureRenderer

virtual void stopRender( QgsRenderContext &context );

virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context );
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) const;

%Docstring

.. note::

symbolForFeature2 in Python bindings
%End
virtual QgsSymbolList symbols( QgsRenderContext &context );
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;

%Docstring

Expand Down
12 changes: 6 additions & 6 deletions python/core/symbology/qgsinvertedpolygonrenderer.sip.in
Expand Up @@ -82,31 +82,31 @@ Proxy that will call this method on the embedded renderer.
Proxy that will call this method on the embedded renderer.
%End

virtual QgsSymbolList symbols( QgsRenderContext &context );
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;

%Docstring
Proxy that will call this method on the embedded renderer.
%End

virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context );
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) const;

%Docstring
Proxy that will call this method on the embedded renderer.
%End

virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feat, QgsRenderContext &context );
virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feat, QgsRenderContext &context ) const;

%Docstring
Proxy that will call this method on the embedded renderer.
%End

virtual QgsSymbolList symbolsForFeature( QgsFeature &feat, QgsRenderContext &context );
virtual QgsSymbolList symbolsForFeature( QgsFeature &feat, QgsRenderContext &context ) const;

%Docstring
Proxy that will call this method on the embedded renderer.
%End

virtual QgsSymbolList originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context );
virtual QgsSymbolList originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context ) const;

%Docstring
Proxy that will call this method on the embedded renderer.
Expand All @@ -118,7 +118,7 @@ Proxy that will call this method on the embedded renderer.
Proxy that will call this method on the embedded renderer.
%End

virtual bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context );
virtual bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context ) const;

%Docstring
Proxy that will call this method on the embedded renderer.
Expand Down
8 changes: 4 additions & 4 deletions python/core/symbology/qgsnullsymbolrenderer.sip.in
Expand Up @@ -24,16 +24,16 @@ and diagrams for the layer. Selected features will also be drawn with a default

QgsNullSymbolRenderer();

virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context );
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) const;

virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context );
virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context ) const;


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

virtual void stopRender( QgsRenderContext &context );

virtual bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context );
virtual bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context ) const;


virtual QSet<QString> usedAttributes( const QgsRenderContext &context ) const;
Expand All @@ -42,7 +42,7 @@ and diagrams for the layer. Selected features will also be drawn with a default

virtual QgsFeatureRenderer *clone() const /Factory/;

virtual QgsSymbolList symbols( QgsRenderContext &context );
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;


static QgsFeatureRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) /Factory/;
Expand Down
14 changes: 7 additions & 7 deletions python/core/symbology/qgspointdistancerenderer.sip.in
Expand Up @@ -71,19 +71,19 @@ Constructor for QgsPointDistanceRenderer.

virtual QgsFeatureRenderer::Capabilities capabilities();

virtual QgsSymbolList symbols( QgsRenderContext &context );
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;

virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context );
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) const;

virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feat, QgsRenderContext &context );
virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feat, QgsRenderContext &context ) const;

virtual QgsSymbolList symbolsForFeature( QgsFeature &feat, QgsRenderContext &context );
virtual QgsSymbolList symbolsForFeature( QgsFeature &feat, QgsRenderContext &context ) const;

virtual QgsSymbolList originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context );
virtual QgsSymbolList originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context ) const;

virtual QSet< QString > legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context );
virtual QSet< QString > legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context ) const;

virtual bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context );
virtual bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context ) const;

virtual void startRender( QgsRenderContext &context, const QgsFields &fields );

Expand Down
37 changes: 20 additions & 17 deletions python/core/symbology/qgsrenderer.sip.in
Expand Up @@ -43,25 +43,28 @@ class QgsFeatureRenderer
#include "qgsrenderer.h"
%End
%ConvertToSubClassCode
if ( sipCpp->type() == "singleSymbol" )

const QString type = sipCpp->type();

if ( type == QStringLiteral( "singleSymbol" ) )
sipType = sipType_QgsSingleSymbolRenderer;
else if ( sipCpp->type() == "categorizedSymbol" )
else if ( type == QStringLiteral( "categorizedSymbol" ) )
sipType = sipType_QgsCategorizedSymbolRenderer;
else if ( sipCpp->type() == "graduatedSymbol" )
else if ( type == QStringLiteral( "graduatedSymbol" ) )
sipType = sipType_QgsGraduatedSymbolRenderer;
else if ( sipCpp->type() == "RuleRenderer" )
else if ( type == QStringLiteral( "RuleRenderer" ) )
sipType = sipType_QgsRuleBasedRenderer;
else if ( sipCpp->type() == "heatmapRenderer" )
else if ( type == QStringLiteral( "heatmapRenderer" ) )
sipType = sipType_QgsHeatmapRenderer;
else if ( sipCpp->type() == "invertedPolygonRenderer" )
else if ( type == QStringLiteral( "invertedPolygonRenderer" ) )
sipType = sipType_QgsInvertedPolygonRenderer;
else if ( sipCpp->type() == "pointCluster" )
else if ( type == QStringLiteral( "pointCluster" ) )
sipType = sipType_QgsPointClusterRenderer;
else if ( sipCpp->type() == "pointDisplacement" )
else if ( type == QStringLiteral( "pointDisplacement" ) )
sipType = sipType_QgsPointDisplacementRenderer;
else if ( sipCpp->type() == "25dRenderer" )
else if ( type == QStringLiteral( "25dRenderer" ) )
sipType = sipType_Qgs25DRenderer;
else if ( sipCpp->type() == "nullSymbol" )
else if ( type == QStringLiteral( "nullSymbol" ) )
sipType = sipType_QgsNullSymbolRenderer;
else
sipType = 0;
Expand All @@ -75,7 +78,7 @@ return a new renderer - used by default in vector layers

QString type() const;

virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) = 0;
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) const = 0;
%Docstring
To be overridden

Expand All @@ -89,7 +92,7 @@ Must be called between startRender() and stopRender() calls.
.. versionadded:: 2.12
%End

virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context );
virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context ) const;
%Docstring
Return 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
Expand All @@ -98,7 +101,7 @@ of a symbol for use in rendering.
.. versionadded:: 2.12
%End

virtual QSet< QString > legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context );
virtual QSet< QString > legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context ) const;
%Docstring
Return legend keys matching a specified feature.

Expand Down Expand Up @@ -218,7 +221,7 @@ E.g. if you only want to deal with visible features:
skip_the_curren_feature()
%End

virtual QgsSymbolList symbols( QgsRenderContext &context );
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;
%Docstring
Returns list of symbols used by the renderer.

Expand Down Expand Up @@ -317,7 +320,7 @@ If supported by the renderer, return classification attribute for the use in leg
set type and size of editing vertex markers for subsequent rendering
%End

virtual bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context );
virtual bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context ) const;
%Docstring
Returns whether the renderer will render a feature or not.
Must be called between startRender() and stopRender() calls.
Expand All @@ -326,7 +329,7 @@ Default implementation uses symbolForFeature().
.. versionadded:: 2.12
%End

virtual QgsSymbolList symbolsForFeature( QgsFeature &feat, QgsRenderContext &context );
virtual QgsSymbolList symbolsForFeature( QgsFeature &feat, QgsRenderContext &context ) const;
%Docstring
Returns list of symbols used for rendering the feature.
For renderers that do not support MoreSymbolsPerFeature it is more efficient
Expand All @@ -335,7 +338,7 @@ to use symbolForFeature()
.. versionadded:: 2.12
%End

virtual QgsSymbolList originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context );
virtual QgsSymbolList originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context ) const;
%Docstring
Equivalent of originalSymbolsForFeature() call
extended to support renderers that may use more symbols per feature - similar to symbolsForFeature()
Expand Down
12 changes: 6 additions & 6 deletions python/core/symbology/qgsrulebasedrenderer.sip.in
Expand Up @@ -447,7 +447,7 @@ Constructor for convenience. Creates a root rule and adds a default rule with sy

~QgsRuleBasedRenderer();

virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context );
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) const;

%Docstring
return symbol for current feature. Should not be used individually: there could be more symbols for a feature
Expand Down Expand Up @@ -479,7 +479,7 @@ return symbol for current feature. Should not be used individually: there could

static QgsFeatureRenderer *createFromSld( QDomElement &element, QgsWkbTypes::GeometryType geomType ) /Factory/;

virtual QgsSymbolList symbols( QgsRenderContext &context );
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;


virtual QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context );
Expand All @@ -497,13 +497,13 @@ return symbol for current feature. Should not be used individually: there could

virtual QString dump() const;

virtual bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context );
virtual bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context ) const;

virtual QgsSymbolList symbolsForFeature( QgsFeature &feat, QgsRenderContext &context );
virtual QgsSymbolList symbolsForFeature( QgsFeature &feat, QgsRenderContext &context ) const;

virtual QgsSymbolList originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context );
virtual QgsSymbolList originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context ) const;

virtual QSet<QString> legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context );
virtual QSet<QString> legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context ) const;

virtual QgsFeatureRenderer::Capabilities capabilities();

Expand Down
8 changes: 4 additions & 4 deletions python/core/symbology/qgssinglesymbolrenderer.sip.in
Expand Up @@ -17,9 +17,9 @@ class QgsSingleSymbolRenderer : QgsFeatureRenderer

QgsSingleSymbolRenderer( QgsSymbol *symbol /Transfer/ );

virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context );
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) const;

virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context );
virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context ) const;

virtual void startRender( QgsRenderContext &context, const QgsFields &fields );

Expand All @@ -42,7 +42,7 @@ class QgsSingleSymbolRenderer : QgsFeatureRenderer
static QgsFeatureRenderer *createFromSld( QDomElement &element, QgsWkbTypes::GeometryType geomType );

virtual QgsFeatureRenderer::Capabilities capabilities();
virtual QgsSymbolList symbols( QgsRenderContext &context );
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;


static QgsFeatureRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) /Factory/;
Expand All @@ -53,7 +53,7 @@ create renderer from XML element

virtual QgsLegendSymbolList legendSymbolItems() const;

virtual QSet< QString > legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context );
virtual QSet< QString > legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context ) const;

virtual void setLegendSymbolItem( const QString &key, QgsSymbol *symbol /Transfer/ );

Expand Down

0 comments on commit 3775cdb

Please sign in to comment.