Skip to content

Commit eb7f755

Browse files
authoredApr 20, 2018
Merge pull request #6813 from m-kuhn/constrenderers
Const correctness for feature renderers
2 parents 7d78798 + f2de572 commit eb7f755

33 files changed

+294
-251
lines changed
 

‎python/core/symbology/qgs25drenderer.sip.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ Create a new 2.5D renderer from XML
3737
virtual QgsFeatureRenderer *clone() const /Factory/;
3838

3939

40-
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context );
40+
virtual QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
4141

42-
virtual QgsSymbolList symbols( QgsRenderContext &context );
42+
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;
4343

4444

4545
QColor roofColor() const;

‎python/core/symbology/qgscategorizedsymbolrenderer.sip.in

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ class QgsCategorizedSymbolRenderer : QgsFeatureRenderer
8383

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

86-
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context );
86+
virtual QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
8787

88-
virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context );
88+
virtual QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
8989

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

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

105-
virtual QgsSymbolList symbols( QgsRenderContext &context );
105+
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;
106106

107107

108108
void updateSymbols( QgsSymbol *sym );
@@ -163,7 +163,7 @@ create renderer from XML element
163163

164164
virtual QgsLegendSymbolList legendSymbolItems() const;
165165

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

168168

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

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

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

283283

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

‎python/core/symbology/qgsgraduatedsymbolrenderer.sip.in

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ class QgsGraduatedSymbolRenderer : QgsFeatureRenderer
120120

121121
~QgsGraduatedSymbolRenderer();
122122

123-
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context );
123+
virtual QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
124124

125-
virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context );
125+
virtual QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
126126

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

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

139139
virtual QgsFeatureRenderer::Capabilities capabilities();
140-
virtual QgsSymbolList symbols( QgsRenderContext &context );
140+
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;
141141

142142

143143
QString classAttribute() const;
@@ -292,7 +292,7 @@ create renderer from XML element
292292

293293
virtual QgsLegendSymbolList legendSymbolItems() const;
294294

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

297297

298298
QgsSymbol *sourceSymbol();
@@ -440,9 +440,9 @@ Will return null if the functionality is disabled.
440440

441441

442442

443-
QgsSymbol *symbolForValue( double value );
443+
QgsSymbol *symbolForValue( double value ) const;
444444
%Docstring
445-
attribute index (derived from attribute name in startRender)
445+
Get the symbol which is used to represent ``value``.
446446
%End
447447

448448
QString legendKeyForValue( double value ) const;

‎python/core/symbology/qgsheatmaprenderer.sip.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ class QgsHeatmapRenderer : QgsFeatureRenderer
2929

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

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

3434
virtual void stopRender( QgsRenderContext &context );
3535

36-
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context );
36+
virtual QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
3737

3838
%Docstring
3939

4040
.. note::
4141

4242
symbolForFeature2 in Python bindings
4343
%End
44-
virtual QgsSymbolList symbols( QgsRenderContext &context );
44+
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;
4545

4646
%Docstring
4747

‎python/core/symbology/qgsinvertedpolygonrenderer.sip.in

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Direct copies are forbidden. Use clone() instead.
4646
virtual void startRender( QgsRenderContext &context, const QgsFields &fields );
4747

4848

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

5151
%Docstring
5252
Renders a given feature.
@@ -82,31 +82,31 @@ Proxy that will call this method on the embedded renderer.
8282
Proxy that will call this method on the embedded renderer.
8383
%End
8484

85-
virtual QgsSymbolList symbols( QgsRenderContext &context );
85+
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;
8686

8787
%Docstring
8888
Proxy that will call this method on the embedded renderer.
8989
%End
9090

91-
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context );
91+
virtual QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
9292

9393
%Docstring
9494
Proxy that will call this method on the embedded renderer.
9595
%End
9696

97-
virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feat, QgsRenderContext &context );
97+
virtual QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
9898

9999
%Docstring
100100
Proxy that will call this method on the embedded renderer.
101101
%End
102102

103-
virtual QgsSymbolList symbolsForFeature( QgsFeature &feat, QgsRenderContext &context );
103+
virtual QgsSymbolList symbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
104104

105105
%Docstring
106106
Proxy that will call this method on the embedded renderer.
107107
%End
108108

109-
virtual QgsSymbolList originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context );
109+
virtual QgsSymbolList originalSymbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
110110

111111
%Docstring
112112
Proxy that will call this method on the embedded renderer.
@@ -118,7 +118,7 @@ Proxy that will call this method on the embedded renderer.
118118
Proxy that will call this method on the embedded renderer.
119119
%End
120120

121-
virtual bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context );
121+
virtual bool willRenderFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
122122

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

‎python/core/symbology/qgsnullsymbolrenderer.sip.in

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ and diagrams for the layer. Selected features will also be drawn with a default
2424

2525
QgsNullSymbolRenderer();
2626

27-
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context );
27+
virtual QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
2828

29-
virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context );
29+
virtual QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
3030

3131

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

3434
virtual void stopRender( QgsRenderContext &context );
3535

36-
virtual bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context );
36+
virtual bool willRenderFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
3737

3838

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

4343
virtual QgsFeatureRenderer *clone() const /Factory/;
4444

45-
virtual QgsSymbolList symbols( QgsRenderContext &context );
45+
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;
4646

4747

4848
static QgsFeatureRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) /Factory/;

‎python/core/symbology/qgspointdistancerenderer.sip.in

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,25 @@ Constructor for QgsPointDistanceRenderer.
6565

6666
virtual void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap &props = QgsStringMap() ) const;
6767

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

7070
virtual QSet<QString> usedAttributes( const QgsRenderContext &context ) const;
7171

7272
virtual QgsFeatureRenderer::Capabilities capabilities();
7373

74-
virtual QgsSymbolList symbols( QgsRenderContext &context );
74+
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;
7575

76-
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context );
76+
virtual QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
7777

78-
virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feat, QgsRenderContext &context );
78+
virtual QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
7979

80-
virtual QgsSymbolList symbolsForFeature( QgsFeature &feat, QgsRenderContext &context );
80+
virtual QgsSymbolList symbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
8181

82-
virtual QgsSymbolList originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context );
82+
virtual QgsSymbolList originalSymbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
8383

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

86-
virtual bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context );
86+
virtual bool willRenderFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
8787

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

‎python/core/symbology/qgsrenderer.sip.in

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,28 @@ class QgsFeatureRenderer
4343
#include "qgsrenderer.h"
4444
%End
4545
%ConvertToSubClassCode
46-
if ( sipCpp->type() == "singleSymbol" )
46+
47+
const QString type = sipCpp->type();
48+
49+
if ( type == QStringLiteral( "singleSymbol" ) )
4750
sipType = sipType_QgsSingleSymbolRenderer;
48-
else if ( sipCpp->type() == "categorizedSymbol" )
51+
else if ( type == QStringLiteral( "categorizedSymbol" ) )
4952
sipType = sipType_QgsCategorizedSymbolRenderer;
50-
else if ( sipCpp->type() == "graduatedSymbol" )
53+
else if ( type == QStringLiteral( "graduatedSymbol" ) )
5154
sipType = sipType_QgsGraduatedSymbolRenderer;
52-
else if ( sipCpp->type() == "RuleRenderer" )
55+
else if ( type == QStringLiteral( "RuleRenderer" ) )
5356
sipType = sipType_QgsRuleBasedRenderer;
54-
else if ( sipCpp->type() == "heatmapRenderer" )
57+
else if ( type == QStringLiteral( "heatmapRenderer" ) )
5558
sipType = sipType_QgsHeatmapRenderer;
56-
else if ( sipCpp->type() == "invertedPolygonRenderer" )
59+
else if ( type == QStringLiteral( "invertedPolygonRenderer" ) )
5760
sipType = sipType_QgsInvertedPolygonRenderer;
58-
else if ( sipCpp->type() == "pointCluster" )
61+
else if ( type == QStringLiteral( "pointCluster" ) )
5962
sipType = sipType_QgsPointClusterRenderer;
60-
else if ( sipCpp->type() == "pointDisplacement" )
63+
else if ( type == QStringLiteral( "pointDisplacement" ) )
6164
sipType = sipType_QgsPointDisplacementRenderer;
62-
else if ( sipCpp->type() == "25dRenderer" )
65+
else if ( type == QStringLiteral( "25dRenderer" ) )
6366
sipType = sipType_Qgs25DRenderer;
64-
else if ( sipCpp->type() == "nullSymbol" )
67+
else if ( type == QStringLiteral( "nullSymbol" ) )
6568
sipType = sipType_QgsNullSymbolRenderer;
6669
else
6770
sipType = 0;
@@ -75,7 +78,7 @@ return a new renderer - used by default in vector layers
7578

7679
QString type() const;
7780

78-
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) = 0;
81+
virtual QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const = 0;
7982
%Docstring
8083
To be overridden
8184

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

92-
virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context );
95+
virtual QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
9396
%Docstring
9497
Return symbol for feature. The difference compared to symbolForFeature() is that it returns original
9598
symbol which can be used as an identifier for renderer's rule - the former may return a temporary replacement
@@ -98,7 +101,7 @@ of a symbol for use in rendering.
98101
.. versionadded:: 2.12
99102
%End
100103

101-
virtual QSet< QString > legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context );
104+
virtual QSet< QString > legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
102105
%Docstring
103106
Return legend keys matching a specified feature.
104107

@@ -172,7 +175,7 @@ and generate a proper subclass.
172175
:return: A copy of this renderer
173176
%End
174177

175-
virtual bool renderFeature( QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false );
178+
virtual bool renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false );
176179
%Docstring
177180
Render a feature using this renderer in the given context.
178181
Must be called between startRender() and stopRender() calls.
@@ -218,7 +221,7 @@ E.g. if you only want to deal with visible features:
218221
skip_the_curren_feature()
219222
%End
220223

221-
virtual QgsSymbolList symbols( QgsRenderContext &context );
224+
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;
222225
%Docstring
223226
Returns list of symbols used by the renderer.
224227

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

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

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

338-
virtual QgsSymbolList originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context );
341+
virtual QgsSymbolList originalSymbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
339342
%Docstring
340343
Equivalent of originalSymbolsForFeature() call
341344
extended to support renderers that may use more symbols per feature - similar to symbolsForFeature()
@@ -473,12 +476,18 @@ implementation does not use subrenderers and will always return null.
473476
protected:
474477
QgsFeatureRenderer( const QString &type );
475478

476-
void renderFeatureWithSymbol( QgsFeature &feature,
479+
void renderFeatureWithSymbol( const QgsFeature &feature,
477480
QgsSymbol *symbol,
478481
QgsRenderContext &context,
479482
int layer,
480483
bool selected,
481484
bool drawVertexMarker );
485+
%Docstring
486+
Render the ``feature`` with the ``symbol`` using ``context``.
487+
Use ``layer`` to specify the symbol layer, ``selected`` to
488+
specify if it should be rendered as selected and ``drawVertexMarker``
489+
to specify if vertex markers should be rendered.
490+
%End
482491

483492
void renderVertexMarker( QPointF pt, QgsRenderContext &context );
484493
%Docstring

‎python/core/symbology/qgsrulebasedrenderer.sip.in

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ the rules and draws features with symbols from rules that match.
3131

3232
struct FeatureToRender
3333
{
34-
FeatureToRender( QgsFeature &_f, int _flags );
34+
FeatureToRender( const QgsFeature &_f, int _flags );
3535
QgsFeature feat;
3636
int flags; // selected and/or draw markers
3737
};
@@ -130,7 +130,7 @@ Returns true if this rule or one of its chilren needs the geometry to be applied
130130
.. versionadded:: 2.6
131131
%End
132132

133-
bool isFilterOK( QgsFeature &f, QgsRenderContext *context = 0 ) const;
133+
bool isFilterOK( const QgsFeature &f, QgsRenderContext *context = 0 ) const;
134134
%Docstring
135135
Check if a given feature shall be rendered by this rule
136136

@@ -307,29 +307,29 @@ Render a given feature, will recursively call subclasses and only render if the
307307
the reason for not rendering the feature.
308308
%End
309309

310-
bool willRenderFeature( QgsFeature &feat, QgsRenderContext *context = 0 );
310+
bool willRenderFeature( const QgsFeature &feature, QgsRenderContext *context = 0 );
311311
%Docstring
312312
only tell whether a feature will be rendered without actually rendering it
313313
%End
314314

315-
QgsSymbolList symbolsForFeature( QgsFeature &feat, QgsRenderContext *context = 0 );
315+
QgsSymbolList symbolsForFeature( const QgsFeature &feature, QgsRenderContext *context = 0 );
316316
%Docstring
317317
tell which symbols will be used to render the feature
318318
%End
319319

320-
QSet< QString > legendKeysForFeature( QgsFeature &feat, QgsRenderContext *context = 0 );
320+
QSet< QString > legendKeysForFeature( const QgsFeature &feature, QgsRenderContext *context = 0 );
321321
%Docstring
322322
Returns which legend keys match the feature
323323

324324
.. versionadded:: 2.14
325325
%End
326326

327-
QgsRuleBasedRenderer::RuleList rulesForFeature( QgsFeature &feat, QgsRenderContext *context = 0, bool onlyActive = true );
327+
QgsRuleBasedRenderer::RuleList rulesForFeature( const QgsFeature &feature, QgsRenderContext *context = 0, bool onlyActive = true );
328328
%Docstring
329329
Returns the list of rules used to render the feature in a specific
330330
context.
331331

332-
:param feat: The feature for which rules have to be find
332+
:param feature: The feature for which rules have to be find
333333
:param context: The rendering context
334334
:param onlyActive: True to search for active rules only, false otherwise
335335
%End
@@ -351,7 +351,7 @@ Create a rule from an XML definition
351351
:return: A new rule
352352
%End
353353

354-
QgsRuleBasedRenderer::RuleList &children();
354+
const QgsRuleBasedRenderer::RuleList &children();
355355
%Docstring
356356
Return all children rules of this rule
357357

@@ -447,13 +447,13 @@ Constructor for convenience. Creates a root rule and adds a default rule with sy
447447

448448
~QgsRuleBasedRenderer();
449449

450-
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context );
450+
virtual QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
451451

452452
%Docstring
453453
return symbol for current feature. Should not be used individually: there could be more symbols for a feature
454454
%End
455455

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

458458

459459
virtual void startRender( QgsRenderContext &context, const QgsFields &fields );
@@ -479,7 +479,7 @@ return symbol for current feature. Should not be used individually: there could
479479

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

482-
virtual QgsSymbolList symbols( QgsRenderContext &context );
482+
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;
483483

484484

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

498498
virtual QString dump() const;
499499

500-
virtual bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context );
500+
virtual bool willRenderFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
501501

502-
virtual QgsSymbolList symbolsForFeature( QgsFeature &feat, QgsRenderContext &context );
502+
virtual QgsSymbolList symbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
503503

504-
virtual QgsSymbolList originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context );
504+
virtual QgsSymbolList originalSymbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
505505

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

508508
virtual QgsFeatureRenderer::Capabilities capabilities();
509509

‎python/core/symbology/qgssinglesymbolrenderer.sip.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ class QgsSingleSymbolRenderer : QgsFeatureRenderer
1717

1818
QgsSingleSymbolRenderer( QgsSymbol *symbol /Transfer/ );
1919

20-
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context );
20+
virtual QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
2121

22-
virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context );
22+
virtual QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
2323

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

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

4444
virtual QgsFeatureRenderer::Capabilities capabilities();
45-
virtual QgsSymbolList symbols( QgsRenderContext &context );
45+
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;
4646

4747

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

5454
virtual QgsLegendSymbolList legendSymbolItems() const;
5555

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

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

‎src/core/symbology/qgs25drenderer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,14 @@ QgsFeatureRenderer *Qgs25DRenderer::clone() const
162162
return c;
163163
}
164164

165-
QgsSymbol *Qgs25DRenderer::symbolForFeature( QgsFeature &feature, QgsRenderContext &context )
165+
QgsSymbol *Qgs25DRenderer::symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
166166
{
167167
Q_UNUSED( feature )
168168
Q_UNUSED( context )
169169
return mSymbol.get();
170170
}
171171

172-
QgsSymbolList Qgs25DRenderer::symbols( QgsRenderContext &context )
172+
QgsSymbolList Qgs25DRenderer::symbols( QgsRenderContext &context ) const
173173
{
174174
Q_UNUSED( context );
175175
QgsSymbolList lst;

‎src/core/symbology/qgs25drenderer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ class CORE_EXPORT Qgs25DRenderer : public QgsFeatureRenderer
4545
QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
4646
QgsFeatureRenderer *clone() const override SIP_FACTORY;
4747

48-
QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
49-
QgsSymbolList symbols( QgsRenderContext &context ) override;
48+
QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
49+
QgsSymbolList symbols( QgsRenderContext &context ) const override;
5050

5151
/**
5252
* Get the roof color

‎src/core/symbology/qgscategorizedsymbolrenderer.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,13 @@ QgsSymbol *QgsCategorizedSymbolRenderer::skipRender()
177177
return nullptr;
178178
}
179179

180-
QgsSymbol *QgsCategorizedSymbolRenderer::symbolForValue( const QVariant &value )
180+
QgsSymbol *QgsCategorizedSymbolRenderer::symbolForValue( const QVariant &value ) const
181181
{
182182
bool found = false;
183183
return symbolForValue( value, found );
184184
}
185185

186-
QgsSymbol *QgsCategorizedSymbolRenderer::symbolForValue( const QVariant &value, bool &foundMatchingSymbol )
186+
QgsSymbol *QgsCategorizedSymbolRenderer::symbolForValue( const QVariant &value, bool &foundMatchingSymbol ) const
187187
{
188188
foundMatchingSymbol = false;
189189

@@ -207,12 +207,12 @@ QgsSymbol *QgsCategorizedSymbolRenderer::symbolForValue( const QVariant &value,
207207
return *it;
208208
}
209209

210-
QgsSymbol *QgsCategorizedSymbolRenderer::symbolForFeature( QgsFeature &feature, QgsRenderContext &context )
210+
QgsSymbol *QgsCategorizedSymbolRenderer::symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
211211
{
212212
return originalSymbolForFeature( feature, context );
213213
}
214214

215-
QVariant QgsCategorizedSymbolRenderer::valueForFeature( QgsFeature &feature, QgsRenderContext &context ) const
215+
QVariant QgsCategorizedSymbolRenderer::valueForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
216216
{
217217
QgsAttributes attrs = feature.attributes();
218218
QVariant value;
@@ -230,7 +230,7 @@ QVariant QgsCategorizedSymbolRenderer::valueForFeature( QgsFeature &feature, Qgs
230230
return value;
231231
}
232232

233-
QgsSymbol *QgsCategorizedSymbolRenderer::originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context )
233+
QgsSymbol *QgsCategorizedSymbolRenderer::originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
234234
{
235235
QVariant value = valueForFeature( feature, context );
236236

@@ -547,7 +547,7 @@ QString QgsCategorizedSymbolRenderer::filter( const QgsFields &fields )
547547
}
548548
}
549549

550-
QgsSymbolList QgsCategorizedSymbolRenderer::symbols( QgsRenderContext &context )
550+
QgsSymbolList QgsCategorizedSymbolRenderer::symbols( QgsRenderContext &context ) const
551551
{
552552
Q_UNUSED( context );
553553
QgsSymbolList lst;
@@ -789,7 +789,7 @@ QgsLegendSymbolList QgsCategorizedSymbolRenderer::legendSymbolItems() const
789789
return baseLegendSymbolItems();
790790
}
791791

792-
QSet<QString> QgsCategorizedSymbolRenderer::legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context )
792+
QSet<QString> QgsCategorizedSymbolRenderer::legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
793793
{
794794
QString value = valueForFeature( feature, context ).toString();
795795
int i = 0;

‎src/core/symbology/qgscategorizedsymbolrenderer.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
9696

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

99-
QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
100-
QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
99+
QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
100+
QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
101101
void startRender( QgsRenderContext &context, const QgsFields &fields ) override;
102102
void stopRender( QgsRenderContext &context ) override;
103103
QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
@@ -106,7 +106,7 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
106106
void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap &props = QgsStringMap() ) const override;
107107
QgsFeatureRenderer::Capabilities capabilities() override { return SymbolLevels | Filter; }
108108
QString filter( const QgsFields &fields = QgsFields() ) override;
109-
QgsSymbolList symbols( QgsRenderContext &context ) override;
109+
QgsSymbolList symbols( QgsRenderContext &context ) const override;
110110

111111
/**
112112
* Update all the symbols but leave categories and colors. This method also sets the source
@@ -152,7 +152,7 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
152152

153153
QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) override;
154154
QgsLegendSymbolList legendSymbolItems() const override;
155-
QSet< QString > legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
155+
QSet< QString > legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
156156

157157
/**
158158
* Returns the renderer's source symbol, which is the base symbol used for the each categories' symbol before applying
@@ -252,7 +252,7 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
252252
* Returns the matching symbol corresponding to an attribute \a value.
253253
* \deprecated use variant which takes a second bool argument instead.
254254
*/
255-
Q_DECL_DEPRECATED QgsSymbol *symbolForValue( const QVariant &value ) SIP_DEPRECATED;
255+
Q_DECL_DEPRECATED QgsSymbol *symbolForValue( const QVariant &value ) const SIP_DEPRECATED;
256256

257257
// TODO QGIS 4.0 - rename Python method to symbolForValue
258258

@@ -269,7 +269,7 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
269269
*
270270
* \note available in Python bindings as symbolForValue2
271271
*/
272-
QgsSymbol *symbolForValue( const QVariant &value, bool &foundMatchingSymbol SIP_OUT ) SIP_PYNAME( symbolForValue2 );
272+
QgsSymbol *symbolForValue( const QVariant &value, bool &foundMatchingSymbol SIP_OUT ) const SIP_PYNAME( symbolForValue2 );
273273

274274
private:
275275
#ifdef SIP_RUN
@@ -278,7 +278,7 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
278278
#endif
279279

280280
//! Returns calculated classification value for a feature
281-
QVariant valueForFeature( QgsFeature &feature, QgsRenderContext &context ) const;
281+
QVariant valueForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
282282

283283
//! Returns list of legend symbol items from individual categories
284284
QgsLegendSymbolList baseLegendSymbolItems() const;

‎src/core/symbology/qgsgraduatedsymbolrenderer.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ QgsGraduatedSymbolRenderer::~QgsGraduatedSymbolRenderer()
296296
mRanges.clear(); // should delete all the symbols
297297
}
298298

299-
QgsSymbol *QgsGraduatedSymbolRenderer::symbolForValue( double value )
299+
QgsSymbol *QgsGraduatedSymbolRenderer::symbolForValue( double value ) const
300300
{
301301
Q_FOREACH ( const QgsRendererRange &range, mRanges )
302302
{
@@ -330,12 +330,12 @@ QString QgsGraduatedSymbolRenderer::legendKeyForValue( double value ) const
330330
return QString();
331331
}
332332

333-
QgsSymbol *QgsGraduatedSymbolRenderer::symbolForFeature( QgsFeature &feature, QgsRenderContext &context )
333+
QgsSymbol *QgsGraduatedSymbolRenderer::symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
334334
{
335335
return originalSymbolForFeature( feature, context );
336336
}
337337

338-
QVariant QgsGraduatedSymbolRenderer::valueForFeature( QgsFeature &feature, QgsRenderContext &context ) const
338+
QVariant QgsGraduatedSymbolRenderer::valueForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
339339
{
340340
QgsAttributes attrs = feature.attributes();
341341
QVariant value;
@@ -351,7 +351,7 @@ QVariant QgsGraduatedSymbolRenderer::valueForFeature( QgsFeature &feature, QgsRe
351351
return value;
352352
}
353353

354-
QgsSymbol *QgsGraduatedSymbolRenderer::originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context )
354+
QgsSymbol *QgsGraduatedSymbolRenderer::originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
355355
{
356356
QVariant value = valueForFeature( feature, context );
357357

@@ -513,7 +513,7 @@ void QgsGraduatedSymbolRenderer::toSld( QDomDocument &doc, QDomElement &element,
513513
}
514514
}
515515

516-
QgsSymbolList QgsGraduatedSymbolRenderer::symbols( QgsRenderContext &context )
516+
QgsSymbolList QgsGraduatedSymbolRenderer::symbols( QgsRenderContext &context ) const
517517
{
518518
Q_UNUSED( context );
519519
QgsSymbolList lst;
@@ -1190,7 +1190,7 @@ QgsLegendSymbolList QgsGraduatedSymbolRenderer::legendSymbolItems() const
11901190
return baseLegendSymbolItems();
11911191
}
11921192

1193-
QSet< QString > QgsGraduatedSymbolRenderer::legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context )
1193+
QSet< QString > QgsGraduatedSymbolRenderer::legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
11941194
{
11951195
QVariant value = valueForFeature( feature, context );
11961196

‎src/core/symbology/qgsgraduatedsymbolrenderer.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,16 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer
147147

148148
~QgsGraduatedSymbolRenderer() override;
149149

150-
QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
151-
QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
150+
QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
151+
QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
152152
void startRender( QgsRenderContext &context, const QgsFields &fields ) override;
153153
void stopRender( QgsRenderContext &context ) override;
154154
QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
155155
QString dump() const override;
156156
QgsGraduatedSymbolRenderer *clone() const override SIP_FACTORY;
157157
void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap &props = QgsStringMap() ) const override;
158158
QgsFeatureRenderer::Capabilities capabilities() override { return SymbolLevels | Filter; }
159-
QgsSymbolList symbols( QgsRenderContext &context ) override;
159+
QgsSymbolList symbols( QgsRenderContext &context ) const override;
160160

161161
QString classAttribute() const { return mAttrName; }
162162
void setClassAttribute( const QString &attr ) { mAttrName = attr; }
@@ -276,7 +276,7 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer
276276

277277
QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) override;
278278
QgsLegendSymbolList legendSymbolItems() const override;
279-
QSet< QString > legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
279+
QSet< QString > legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
280280

281281
/**
282282
* Returns the renderer's source symbol, which is the base symbol used for the each classes' symbol before applying
@@ -408,7 +408,10 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer
408408

409409
std::unique_ptr<QgsDataDefinedSizeLegend> mDataDefinedSizeLegend;
410410

411-
QgsSymbol *symbolForValue( double value );
411+
/**
412+
* Get the symbol which is used to represent \a value.
413+
*/
414+
QgsSymbol *symbolForValue( double value ) const;
412415

413416
/**
414417
* Returns the matching legend key for a value.
@@ -423,7 +426,7 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer
423426
/**
424427
* Returns calculated value used for classifying a feature.
425428
*/
426-
QVariant valueForFeature( QgsFeature &feature, QgsRenderContext &context ) const;
429+
QVariant valueForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
427430

428431
//! Returns list of legend symbol items from individual ranges
429432
QgsLegendSymbolList baseLegendSymbolItems() const;

‎src/core/symbology/qgsheatmaprenderer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ QgsMultiPointXY QgsHeatmapRenderer::convertToMultipoint( const QgsGeometry *geom
8787
return multiPoint;
8888
}
8989

90-
bool QgsHeatmapRenderer::renderFeature( QgsFeature &feature, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
90+
bool QgsHeatmapRenderer::renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
9191
{
9292
Q_UNUSED( layer );
9393
Q_UNUSED( selected );
@@ -349,13 +349,13 @@ QDomElement QgsHeatmapRenderer::save( QDomDocument &doc, const QgsReadWriteConte
349349
return rendererElem;
350350
}
351351

352-
QgsSymbol *QgsHeatmapRenderer::symbolForFeature( QgsFeature &feature, QgsRenderContext & )
352+
QgsSymbol *QgsHeatmapRenderer::symbolForFeature( const QgsFeature &feature, QgsRenderContext & ) const
353353
{
354354
Q_UNUSED( feature );
355355
return nullptr;
356356
}
357357

358-
QgsSymbolList QgsHeatmapRenderer::symbols( QgsRenderContext & )
358+
QgsSymbolList QgsHeatmapRenderer::symbols( QgsRenderContext & ) const
359359
{
360360
return QgsSymbolList();
361361
}

‎src/core/symbology/qgsheatmaprenderer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ class CORE_EXPORT QgsHeatmapRenderer : public QgsFeatureRenderer
4545
//reimplemented methods
4646
QgsHeatmapRenderer *clone() const override SIP_FACTORY;
4747
void startRender( QgsRenderContext &context, const QgsFields &fields ) override;
48-
bool renderFeature( QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) override;
48+
bool renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) override;
4949
void stopRender( QgsRenderContext &context ) override;
5050
//! \note symbolForFeature2 in Python bindings
51-
QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
51+
QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
5252
//! \note symbol2 in Python bindings
53-
QgsSymbolList symbols( QgsRenderContext &context ) override;
53+
QgsSymbolList symbols( QgsRenderContext &context ) const override;
5454
QString dump() const override;
5555
QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
5656
//! Creates a new heatmap renderer instance from XML

‎src/core/symbology/qgsinvertedpolygonrenderer.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void QgsInvertedPolygonRenderer::startRender( QgsRenderContext &context, const Q
151151
mExtentPolygon.append( exteriorRing );
152152
}
153153

154-
bool QgsInvertedPolygonRenderer::renderFeature( QgsFeature &feature, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
154+
bool QgsInvertedPolygonRenderer::renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
155155
{
156156
if ( !context.painter() )
157157
{
@@ -417,7 +417,7 @@ QDomElement QgsInvertedPolygonRenderer::save( QDomDocument &doc, const QgsReadWr
417417
return rendererElem;
418418
}
419419

420-
QgsSymbol *QgsInvertedPolygonRenderer::symbolForFeature( QgsFeature &feature, QgsRenderContext &context )
420+
QgsSymbol *QgsInvertedPolygonRenderer::symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
421421
{
422422
if ( !mSubRenderer )
423423
{
@@ -426,14 +426,14 @@ QgsSymbol *QgsInvertedPolygonRenderer::symbolForFeature( QgsFeature &feature, Qg
426426
return mSubRenderer->symbolForFeature( feature, context );
427427
}
428428

429-
QgsSymbol *QgsInvertedPolygonRenderer::originalSymbolForFeature( QgsFeature &feat, QgsRenderContext &context )
429+
QgsSymbol *QgsInvertedPolygonRenderer::originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
430430
{
431431
if ( !mSubRenderer )
432432
return nullptr;
433-
return mSubRenderer->originalSymbolForFeature( feat, context );
433+
return mSubRenderer->originalSymbolForFeature( feature, context );
434434
}
435435

436-
QgsSymbolList QgsInvertedPolygonRenderer::symbolsForFeature( QgsFeature &feature, QgsRenderContext &context )
436+
QgsSymbolList QgsInvertedPolygonRenderer::symbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
437437
{
438438
if ( !mSubRenderer )
439439
{
@@ -442,14 +442,14 @@ QgsSymbolList QgsInvertedPolygonRenderer::symbolsForFeature( QgsFeature &feature
442442
return mSubRenderer->symbolsForFeature( feature, context );
443443
}
444444

445-
QgsSymbolList QgsInvertedPolygonRenderer::originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context )
445+
QgsSymbolList QgsInvertedPolygonRenderer::originalSymbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
446446
{
447447
if ( !mSubRenderer )
448448
return QgsSymbolList();
449-
return mSubRenderer->originalSymbolsForFeature( feat, context );
449+
return mSubRenderer->originalSymbolsForFeature( feature, context );
450450
}
451451

452-
QgsSymbolList QgsInvertedPolygonRenderer::symbols( QgsRenderContext &context )
452+
QgsSymbolList QgsInvertedPolygonRenderer::symbols( QgsRenderContext &context ) const
453453
{
454454
if ( !mSubRenderer )
455455
{
@@ -485,13 +485,13 @@ QgsLegendSymbolList QgsInvertedPolygonRenderer::legendSymbolItems() const
485485
return mSubRenderer->legendSymbolItems();
486486
}
487487

488-
bool QgsInvertedPolygonRenderer::willRenderFeature( QgsFeature &feat, QgsRenderContext &context )
488+
bool QgsInvertedPolygonRenderer::willRenderFeature( const QgsFeature &feature, QgsRenderContext &context ) const
489489
{
490490
if ( !mSubRenderer )
491491
{
492492
return false;
493493
}
494-
return mSubRenderer->willRenderFeature( feat, context );
494+
return mSubRenderer->willRenderFeature( feature, context );
495495
}
496496

497497
QgsInvertedPolygonRenderer *QgsInvertedPolygonRenderer::convertFromRenderer( const QgsFeatureRenderer *renderer )

‎src/core/symbology/qgsinvertedpolygonrenderer.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class CORE_EXPORT QgsInvertedPolygonRenderer : public QgsFeatureRenderer
6767
* \param drawVertexMarker whether this feature has vertex markers (in edit mode usually)
6868
* \returns true if the rendering was OK
6969
*/
70-
bool renderFeature( QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) override;
70+
bool renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) override;
7171

7272
/**
7373
* The actual rendering will take place here.
@@ -85,27 +85,27 @@ class CORE_EXPORT QgsInvertedPolygonRenderer : public QgsFeatureRenderer
8585
/**
8686
* Proxy that will call this method on the embedded renderer.
8787
*/
88-
QgsSymbolList symbols( QgsRenderContext &context ) override;
88+
QgsSymbolList symbols( QgsRenderContext &context ) const override;
8989

9090
/**
9191
* Proxy that will call this method on the embedded renderer.
9292
*/
93-
QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
93+
QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
9494

9595
/**
9696
* Proxy that will call this method on the embedded renderer.
9797
*/
98-
QgsSymbol *originalSymbolForFeature( QgsFeature &feat, QgsRenderContext &context ) override;
98+
QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
9999

100100
/**
101101
* Proxy that will call this method on the embedded renderer.
102102
*/
103-
QgsSymbolList symbolsForFeature( QgsFeature &feat, QgsRenderContext &context ) override;
103+
QgsSymbolList symbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
104104

105105
/**
106106
* Proxy that will call this method on the embedded renderer.
107107
*/
108-
QgsSymbolList originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context ) override;
108+
QgsSymbolList originalSymbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
109109

110110
/**
111111
* Proxy that will call this method on the embedded renderer.
@@ -115,7 +115,7 @@ class CORE_EXPORT QgsInvertedPolygonRenderer : public QgsFeatureRenderer
115115
/**
116116
* Proxy that will call this method on the embedded renderer.
117117
*/
118-
bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context ) override;
118+
bool willRenderFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
119119

120120
//! Creates a renderer out of an XML, for loading
121121
static QgsFeatureRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
@@ -186,7 +186,7 @@ class CORE_EXPORT QgsInvertedPolygonRenderer : public QgsFeatureRenderer
186186
bool selected;
187187
bool drawMarkers;
188188
int layer;
189-
FeatureDecoration( QgsFeature &a_feature, bool a_selected, bool a_drawMarkers, int a_layer )
189+
FeatureDecoration( const QgsFeature &a_feature, bool a_selected, bool a_drawMarkers, int a_layer )
190190
: feature( a_feature )
191191
, selected( a_selected )
192192
, drawMarkers( a_drawMarkers )

‎src/core/symbology/qgsnullsymbolrenderer.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ QgsNullSymbolRenderer::QgsNullSymbolRenderer()
2525
{
2626
}
2727

28-
QgsSymbol *QgsNullSymbolRenderer::symbolForFeature( QgsFeature &, QgsRenderContext & )
28+
QgsSymbol *QgsNullSymbolRenderer::symbolForFeature( const QgsFeature &, QgsRenderContext & ) const
2929
{
3030
return nullptr;
3131
}
3232

33-
QgsSymbol *QgsNullSymbolRenderer::originalSymbolForFeature( QgsFeature &, QgsRenderContext & )
33+
QgsSymbol *QgsNullSymbolRenderer::originalSymbolForFeature( const QgsFeature &, QgsRenderContext & ) const
3434
{
3535
return nullptr;
3636
}
3737

38-
bool QgsNullSymbolRenderer::renderFeature( QgsFeature &feature, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
38+
bool QgsNullSymbolRenderer::renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
3939
{
4040
//render selected features or features being edited only
4141
if ( !selected && !drawVertexMarker )
@@ -70,7 +70,7 @@ void QgsNullSymbolRenderer::stopRender( QgsRenderContext &context )
7070
}
7171
}
7272

73-
bool QgsNullSymbolRenderer::willRenderFeature( QgsFeature &, QgsRenderContext & )
73+
bool QgsNullSymbolRenderer::willRenderFeature( const QgsFeature &, QgsRenderContext & ) const
7474
{
7575
//return true for every feature - so they are still selectable
7676
return true;
@@ -92,7 +92,7 @@ QgsFeatureRenderer *QgsNullSymbolRenderer::clone() const
9292
return r;
9393
}
9494

95-
QgsSymbolList QgsNullSymbolRenderer::symbols( QgsRenderContext & )
95+
QgsSymbolList QgsNullSymbolRenderer::symbols( QgsRenderContext & ) const
9696
{
9797
return QgsSymbolList();
9898
}

‎src/core/symbology/qgsnullsymbolrenderer.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ class CORE_EXPORT QgsNullSymbolRenderer : public QgsFeatureRenderer
3434

3535
QgsNullSymbolRenderer();
3636

37-
QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
38-
QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
37+
QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
38+
QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
3939

40-
bool renderFeature( QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) override;
40+
bool renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) override;
4141
void stopRender( QgsRenderContext &context ) override;
42-
bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context ) override;
42+
bool willRenderFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
4343

4444
QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
4545
QString dump() const override;
4646
QgsFeatureRenderer *clone() const override SIP_FACTORY;
47-
QgsSymbolList symbols( QgsRenderContext &context ) override;
47+
QgsSymbolList symbols( QgsRenderContext &context ) const override;
4848

4949
/**
5050
* Creates a null renderer from XML element.

‎src/core/symbology/qgspointdistancerenderer.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void QgsPointDistanceRenderer::toSld( QDomDocument &doc, QDomElement &element, c
4545
}
4646

4747

48-
bool QgsPointDistanceRenderer::renderFeature( QgsFeature &feature, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
48+
bool QgsPointDistanceRenderer::renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
4949
{
5050
Q_UNUSED( drawVertexMarker );
5151
Q_UNUSED( context );
@@ -227,7 +227,7 @@ QgsFeatureRenderer::Capabilities QgsPointDistanceRenderer::capabilities()
227227
return mRenderer->capabilities();
228228
}
229229

230-
QgsSymbolList QgsPointDistanceRenderer::symbols( QgsRenderContext &context )
230+
QgsSymbolList QgsPointDistanceRenderer::symbols( QgsRenderContext &context ) const
231231
{
232232
if ( !mRenderer )
233233
{
@@ -236,7 +236,7 @@ QgsSymbolList QgsPointDistanceRenderer::symbols( QgsRenderContext &context )
236236
return mRenderer->symbols( context );
237237
}
238238

239-
QgsSymbol *QgsPointDistanceRenderer::symbolForFeature( QgsFeature &feature, QgsRenderContext &context )
239+
QgsSymbol *QgsPointDistanceRenderer::symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
240240
{
241241
if ( !mRenderer )
242242
{
@@ -245,14 +245,14 @@ QgsSymbol *QgsPointDistanceRenderer::symbolForFeature( QgsFeature &feature, QgsR
245245
return mRenderer->symbolForFeature( feature, context );
246246
}
247247

248-
QgsSymbol *QgsPointDistanceRenderer::originalSymbolForFeature( QgsFeature &feat, QgsRenderContext &context )
248+
QgsSymbol *QgsPointDistanceRenderer::originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
249249
{
250250
if ( !mRenderer )
251251
return nullptr;
252-
return mRenderer->originalSymbolForFeature( feat, context );
252+
return mRenderer->originalSymbolForFeature( feature, context );
253253
}
254254

255-
QgsSymbolList QgsPointDistanceRenderer::symbolsForFeature( QgsFeature &feature, QgsRenderContext &context )
255+
QgsSymbolList QgsPointDistanceRenderer::symbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
256256
{
257257
if ( !mRenderer )
258258
{
@@ -261,27 +261,27 @@ QgsSymbolList QgsPointDistanceRenderer::symbolsForFeature( QgsFeature &feature,
261261
return mRenderer->symbolsForFeature( feature, context );
262262
}
263263

264-
QgsSymbolList QgsPointDistanceRenderer::originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context )
264+
QgsSymbolList QgsPointDistanceRenderer::originalSymbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
265265
{
266266
if ( !mRenderer )
267267
return QgsSymbolList();
268-
return mRenderer->originalSymbolsForFeature( feat, context );
268+
return mRenderer->originalSymbolsForFeature( feature, context );
269269
}
270270

271-
QSet< QString > QgsPointDistanceRenderer::legendKeysForFeature( QgsFeature &feat, QgsRenderContext &context )
271+
QSet< QString > QgsPointDistanceRenderer::legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
272272
{
273273
if ( !mRenderer )
274274
return QSet< QString >() << QString();
275-
return mRenderer->legendKeysForFeature( feat, context );
275+
return mRenderer->legendKeysForFeature( feature, context );
276276
}
277277

278-
bool QgsPointDistanceRenderer::willRenderFeature( QgsFeature &feat, QgsRenderContext &context )
278+
bool QgsPointDistanceRenderer::willRenderFeature( const QgsFeature &feature, QgsRenderContext &context ) const
279279
{
280280
if ( !mRenderer )
281281
{
282282
return false;
283283
}
284-
return mRenderer->willRenderFeature( feat, context );
284+
return mRenderer->willRenderFeature( feature, context );
285285
}
286286

287287

@@ -467,7 +467,7 @@ QgsExpressionContextScope *QgsPointDistanceRenderer::createGroupScope( const Clu
467467
return clusterScope;
468468
}
469469

470-
QgsMarkerSymbol *QgsPointDistanceRenderer::firstSymbolForFeature( QgsFeature &feature, QgsRenderContext &context )
470+
QgsMarkerSymbol *QgsPointDistanceRenderer::firstSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context )
471471
{
472472
if ( !mRenderer )
473473
{

‎src/core/symbology/qgspointdistancerenderer.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,16 @@ class CORE_EXPORT QgsPointDistanceRenderer: public QgsFeatureRenderer
8484
QgsPointDistanceRenderer( const QString &rendererName, const QString &labelAttributeName = QString() );
8585

8686
void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap &props = QgsStringMap() ) const override;
87-
bool renderFeature( QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) override;
87+
bool renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) override;
8888
QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
8989
QgsFeatureRenderer::Capabilities capabilities() override;
90-
QgsSymbolList symbols( QgsRenderContext &context ) override;
91-
QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
92-
QgsSymbol *originalSymbolForFeature( QgsFeature &feat, QgsRenderContext &context ) override;
93-
QgsSymbolList symbolsForFeature( QgsFeature &feat, QgsRenderContext &context ) override;
94-
QgsSymbolList originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context ) override;
95-
QSet< QString > legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
96-
bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context ) override;
90+
QgsSymbolList symbols( QgsRenderContext &context ) const override;
91+
QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
92+
QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
93+
QgsSymbolList symbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
94+
QgsSymbolList originalSymbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
95+
QSet< QString > legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
96+
bool willRenderFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
9797
void startRender( QgsRenderContext &context, const QgsFields &fields ) override;
9898
void stopRender( QgsRenderContext &context ) override;
9999
QgsLegendSymbolList legendSymbolItems() const override;
@@ -302,7 +302,7 @@ class CORE_EXPORT QgsPointDistanceRenderer: public QgsFeatureRenderer
302302
* \param feature source feature
303303
* \param context target render context
304304
*/
305-
QgsMarkerSymbol *firstSymbolForFeature( QgsFeature &feature, QgsRenderContext &context );
305+
QgsMarkerSymbol *firstSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context );
306306

307307
/**
308308
* Creates an expression context scope for a clustered group, with variables reflecting the group's properties.

‎src/core/symbology/qgsrenderer.cpp

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ QgsFeatureRenderer *QgsFeatureRenderer::defaultRenderer( QgsWkbTypes::GeometryTy
7777
return new QgsSingleSymbolRenderer( QgsSymbol::defaultSymbol( geomType ) );
7878
}
7979

80-
QgsSymbol *QgsFeatureRenderer::originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context )
80+
QgsSymbol *QgsFeatureRenderer::originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
8181
{
8282
return symbolForFeature( feature, context );
8383
}
8484

85-
QSet< QString > QgsFeatureRenderer::legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context )
85+
QSet< QString > QgsFeatureRenderer::legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
8686
{
8787
Q_UNUSED( feature );
8888
Q_UNUSED( context );
@@ -115,7 +115,7 @@ bool QgsFeatureRenderer::filterNeedsGeometry() const
115115
return false;
116116
}
117117

118-
bool QgsFeatureRenderer::renderFeature( QgsFeature &feature, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
118+
bool QgsFeatureRenderer::renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
119119
{
120120
#ifdef QGISDEBUG
121121
Q_ASSERT_X( mThread == QThread::currentThread(), "QgsFeatureRenderer::renderFeature", "renderFeature called in a different thread - use a cloned renderer instead" );
@@ -129,7 +129,7 @@ bool QgsFeatureRenderer::renderFeature( QgsFeature &feature, QgsRenderContext &c
129129
return true;
130130
}
131131

132-
void QgsFeatureRenderer::renderFeatureWithSymbol( QgsFeature &feature, QgsSymbol *symbol, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
132+
void QgsFeatureRenderer::renderFeatureWithSymbol( const QgsFeature &feature, QgsSymbol *symbol, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
133133
{
134134
symbol->renderFeature( feature, context, layer, selected, drawVertexMarker, mCurrentVertexMarkerType, mCurrentVertexMarkerSize );
135135
}
@@ -139,6 +139,12 @@ QString QgsFeatureRenderer::dump() const
139139
return QStringLiteral( "UNKNOWN RENDERER\n" );
140140
}
141141

142+
QgsSymbolList QgsFeatureRenderer::symbols( QgsRenderContext &context ) const
143+
{
144+
Q_UNUSED( context );
145+
return QgsSymbolList();
146+
}
147+
142148
QgsFeatureRenderer *QgsFeatureRenderer::load( QDomElement &element, const QgsReadWriteContext &context )
143149
{
144150
// <renderer-v2 type=""> ... </renderer-v2>
@@ -332,9 +338,9 @@ void QgsFeatureRenderer::setVertexMarkerAppearance( int type, int size )
332338
mCurrentVertexMarkerSize = size;
333339
}
334340

335-
bool QgsFeatureRenderer::willRenderFeature( QgsFeature &feat, QgsRenderContext &context )
341+
bool QgsFeatureRenderer::willRenderFeature( const QgsFeature &feature, QgsRenderContext &context ) const
336342
{
337-
return nullptr != symbolForFeature( feat, context );
343+
return nullptr != symbolForFeature( feature, context );
338344
}
339345

340346
void QgsFeatureRenderer::renderVertexMarker( QPointF pt, QgsRenderContext &context )
@@ -365,18 +371,24 @@ void QgsFeatureRenderer::renderVertexMarkerPolygon( QPolygonF &pts, QList<QPolyg
365371
}
366372
}
367373

368-
QgsSymbolList QgsFeatureRenderer::symbolsForFeature( QgsFeature &feat, QgsRenderContext &context )
374+
QgsSymbolList QgsFeatureRenderer::symbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
369375
{
370376
QgsSymbolList lst;
371-
QgsSymbol *s = symbolForFeature( feat, context );
377+
QgsSymbol *s = symbolForFeature( feature, context );
372378
if ( s ) lst.append( s );
373379
return lst;
374380
}
375381

376-
QgsSymbolList QgsFeatureRenderer::originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context )
382+
void QgsFeatureRenderer::modifyRequestExtent( QgsRectangle &extent, QgsRenderContext &context )
383+
{
384+
Q_UNUSED( extent );
385+
Q_UNUSED( context );
386+
}
387+
388+
QgsSymbolList QgsFeatureRenderer::originalSymbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
377389
{
378390
QgsSymbolList lst;
379-
QgsSymbol *s = originalSymbolForFeature( feat, context );
391+
QgsSymbol *s = originalSymbolForFeature( feature, context );
380392
if ( s ) lst.append( s );
381393
return lst;
382394
}
@@ -412,6 +424,16 @@ void QgsFeatureRenderer::setOrderByEnabled( bool enabled )
412424
mOrderByEnabled = enabled;
413425
}
414426

427+
void QgsFeatureRenderer::setEmbeddedRenderer( QgsFeatureRenderer *subRenderer )
428+
{
429+
delete subRenderer;
430+
}
431+
432+
const QgsFeatureRenderer *QgsFeatureRenderer::embeddedRenderer() const
433+
{
434+
return nullptr;
435+
}
436+
415437
void QgsFeatureRenderer::convertSymbolSizeScale( QgsSymbol *symbol, QgsSymbol::ScaleMethod method, const QString &field )
416438
{
417439
if ( symbol->type() == QgsSymbol::Marker )

‎src/core/symbology/qgsrenderer.h

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -92,25 +92,28 @@ class CORE_EXPORT QgsFeatureRenderer
9292

9393
#ifdef SIP_RUN
9494
SIP_CONVERT_TO_SUBCLASS_CODE
95-
if ( sipCpp->type() == "singleSymbol" )
95+
96+
const QString type = sipCpp->type();
97+
98+
if ( type == QStringLiteral( "singleSymbol" ) )
9699
sipType = sipType_QgsSingleSymbolRenderer;
97-
else if ( sipCpp->type() == "categorizedSymbol" )
100+
else if ( type == QStringLiteral( "categorizedSymbol" ) )
98101
sipType = sipType_QgsCategorizedSymbolRenderer;
99-
else if ( sipCpp->type() == "graduatedSymbol" )
102+
else if ( type == QStringLiteral( "graduatedSymbol" ) )
100103
sipType = sipType_QgsGraduatedSymbolRenderer;
101-
else if ( sipCpp->type() == "RuleRenderer" )
104+
else if ( type == QStringLiteral( "RuleRenderer" ) )
102105
sipType = sipType_QgsRuleBasedRenderer;
103-
else if ( sipCpp->type() == "heatmapRenderer" )
106+
else if ( type == QStringLiteral( "heatmapRenderer" ) )
104107
sipType = sipType_QgsHeatmapRenderer;
105-
else if ( sipCpp->type() == "invertedPolygonRenderer" )
108+
else if ( type == QStringLiteral( "invertedPolygonRenderer" ) )
106109
sipType = sipType_QgsInvertedPolygonRenderer;
107-
else if ( sipCpp->type() == "pointCluster" )
110+
else if ( type == QStringLiteral( "pointCluster" ) )
108111
sipType = sipType_QgsPointClusterRenderer;
109-
else if ( sipCpp->type() == "pointDisplacement" )
112+
else if ( type == QStringLiteral( "pointDisplacement" ) )
110113
sipType = sipType_QgsPointDisplacementRenderer;
111-
else if ( sipCpp->type() == "25dRenderer" )
114+
else if ( type == QStringLiteral( "25dRenderer" ) )
112115
sipType = sipType_Qgs25DRenderer;
113-
else if ( sipCpp->type() == "nullSymbol" )
116+
else if ( type == QStringLiteral( "nullSymbol" ) )
114117
sipType = sipType_QgsNullSymbolRenderer;
115118
else
116119
sipType = 0;
@@ -134,21 +137,21 @@ class CORE_EXPORT QgsFeatureRenderer
134137
* \returns returns pointer to symbol or 0 if symbol was not found
135138
* \since QGIS 2.12
136139
*/
137-
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) = 0;
140+
virtual QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const = 0;
138141

139142
/**
140143
* Return symbol for feature. The difference compared to symbolForFeature() is that it returns original
141144
* symbol which can be used as an identifier for renderer's rule - the former may return a temporary replacement
142145
* of a symbol for use in rendering.
143146
* \since QGIS 2.12
144147
*/
145-
virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context );
148+
virtual QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
146149

147150
/**
148151
* Return legend keys matching a specified feature.
149152
* \since QGIS 2.14
150153
*/
151-
virtual QSet< QString > legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context );
154+
virtual QSet< QString > legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
152155

153156
/**
154157
* Must be called when a new render cycle is started. A call to startRender() must always
@@ -225,7 +228,7 @@ class CORE_EXPORT QgsFeatureRenderer
225228
* \see startRender()
226229
* \see stopRender()
227230
*/
228-
virtual bool renderFeature( QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false );
231+
virtual bool renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false );
229232

230233
//! Returns debug information about this renderer
231234
virtual QString dump() const;
@@ -263,7 +266,7 @@ class CORE_EXPORT QgsFeatureRenderer
263266
* \param context render context
264267
* \since QGIS 2.12
265268
*/
266-
virtual QgsSymbolList symbols( QgsRenderContext &context ) { Q_UNUSED( context ); return QgsSymbolList(); }
269+
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;
267270

268271
bool usingSymbolLevels() const { return mUsingSymbolLevels; }
269272
void setUsingSymbolLevels( bool usingSymbolLevels ) { mUsingSymbolLevels = usingSymbolLevels; }
@@ -347,22 +350,22 @@ class CORE_EXPORT QgsFeatureRenderer
347350
* Default implementation uses symbolForFeature().
348351
* \since QGIS 2.12
349352
*/
350-
virtual bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context );
353+
virtual bool willRenderFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
351354

352355
/**
353356
* Returns list of symbols used for rendering the feature.
354357
* For renderers that do not support MoreSymbolsPerFeature it is more efficient
355358
* to use symbolForFeature()
356359
* \since QGIS 2.12
357360
*/
358-
virtual QgsSymbolList symbolsForFeature( QgsFeature &feat, QgsRenderContext &context );
361+
virtual QgsSymbolList symbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
359362

360363
/**
361364
* Equivalent of originalSymbolsForFeature() call
362365
* extended to support renderers that may use more symbols per feature - similar to symbolsForFeature()
363366
* \since QGIS 2.12
364367
*/
365-
virtual QgsSymbolList originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context );
368+
virtual QgsSymbolList originalSymbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
366369

367370
/**
368371
* Allows for a renderer to modify the extent of a feature request prior to rendering
@@ -371,7 +374,7 @@ class CORE_EXPORT QgsFeatureRenderer
371374
* \param context render context
372375
* \since QGIS 2.7
373376
*/
374-
virtual void modifyRequestExtent( QgsRectangle &extent, QgsRenderContext &context ) { Q_UNUSED( extent ); Q_UNUSED( context ); }
377+
virtual void modifyRequestExtent( QgsRectangle &extent, QgsRenderContext &context );
375378

376379
/**
377380
* Returns the current paint effect for the renderer.
@@ -446,20 +449,26 @@ class CORE_EXPORT QgsFeatureRenderer
446449
* \see embeddedRenderer()
447450
* \since QGIS 2.16
448451
*/
449-
virtual void setEmbeddedRenderer( QgsFeatureRenderer *subRenderer SIP_TRANSFER ) { delete subRenderer; }
452+
virtual void setEmbeddedRenderer( QgsFeatureRenderer *subRenderer SIP_TRANSFER );
450453

451454
/**
452455
* Returns the current embedded renderer (subrenderer) for this feature renderer. The base class
453456
* implementation does not use subrenderers and will always return null.
454457
* \see setEmbeddedRenderer()
455458
* \since QGIS 2.16
456459
*/
457-
virtual const QgsFeatureRenderer *embeddedRenderer() const { return nullptr; }
460+
virtual const QgsFeatureRenderer *embeddedRenderer() const;
458461

459462
protected:
460463
QgsFeatureRenderer( const QString &type );
461464

462-
void renderFeatureWithSymbol( QgsFeature &feature,
465+
/**
466+
* Render the \a feature with the \a symbol using \a context.
467+
* Use \a layer to specify the symbol layer, \a selected to
468+
* specify if it should be rendered as selected and \a drawVertexMarker
469+
* to specify if vertex markers should be rendered.
470+
*/
471+
void renderFeatureWithSymbol( const QgsFeature &feature,
463472
QgsSymbol *symbol,
464473
QgsRenderContext &context,
465474
int layer,

‎src/core/symbology/qgsrulebasedrenderer.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ QgsLegendSymbolList QgsRuleBasedRenderer::Rule::legendSymbolItems( int currentLe
246246
}
247247

248248

249-
bool QgsRuleBasedRenderer::Rule::isFilterOK( QgsFeature &f, QgsRenderContext *context ) const
249+
bool QgsRuleBasedRenderer::Rule::isFilterOK( const QgsFeature &f, QgsRenderContext *context ) const
250250
{
251251
if ( ! mFilter || mElseRule )
252252
return true;
@@ -537,9 +537,9 @@ QgsRuleBasedRenderer::Rule::RenderResult QgsRuleBasedRenderer::Rule::renderFeatu
537537
return Filtered;
538538
}
539539

540-
bool QgsRuleBasedRenderer::Rule::willRenderFeature( QgsFeature &feat, QgsRenderContext *context )
540+
bool QgsRuleBasedRenderer::Rule::willRenderFeature( const QgsFeature &feature, QgsRenderContext *context )
541541
{
542-
if ( !isFilterOK( feat, context ) )
542+
if ( !isFilterOK( feature, context ) )
543543
return false;
544544

545545
if ( mSymbol )
@@ -551,7 +551,7 @@ bool QgsRuleBasedRenderer::Rule::willRenderFeature( QgsFeature &feat, QgsRenderC
551551
{
552552
if ( rule->children().isEmpty() )
553553
{
554-
RuleList lst = rulesForFeature( feat, context, false );
554+
RuleList lst = rulesForFeature( feature, context, false );
555555
lst.removeOne( rule );
556556

557557
if ( lst.empty() )
@@ -561,36 +561,36 @@ bool QgsRuleBasedRenderer::Rule::willRenderFeature( QgsFeature &feat, QgsRenderC
561561
}
562562
else
563563
{
564-
return rule->willRenderFeature( feat, context );
564+
return rule->willRenderFeature( feature, context );
565565
}
566566
}
567-
else if ( rule->willRenderFeature( feat, context ) )
567+
else if ( rule->willRenderFeature( feature, context ) )
568568
{
569569
return true;
570570
}
571571
}
572572
return false;
573573
}
574574

575-
QgsSymbolList QgsRuleBasedRenderer::Rule::symbolsForFeature( QgsFeature &feat, QgsRenderContext *context )
575+
QgsSymbolList QgsRuleBasedRenderer::Rule::symbolsForFeature( const QgsFeature &feature, QgsRenderContext *context )
576576
{
577577
QgsSymbolList lst;
578-
if ( !isFilterOK( feat, context ) )
578+
if ( !isFilterOK( feature, context ) )
579579
return lst;
580580
if ( mSymbol )
581581
lst.append( mSymbol.get() );
582582

583583
Q_FOREACH ( Rule *rule, mActiveChildren )
584584
{
585-
lst += rule->symbolsForFeature( feat, context );
585+
lst += rule->symbolsForFeature( feature, context );
586586
}
587587
return lst;
588588
}
589589

590-
QSet<QString> QgsRuleBasedRenderer::Rule::legendKeysForFeature( QgsFeature &feat, QgsRenderContext *context )
590+
QSet<QString> QgsRuleBasedRenderer::Rule::legendKeysForFeature( const QgsFeature &feature, QgsRenderContext *context )
591591
{
592592
QSet< QString> lst;
593-
if ( !isFilterOK( feat, context ) )
593+
if ( !isFilterOK( feature, context ) )
594594
return lst;
595595
lst.insert( mRuleKey );
596596

@@ -599,31 +599,31 @@ QSet<QString> QgsRuleBasedRenderer::Rule::legendKeysForFeature( QgsFeature &feat
599599
bool validKey = false;
600600
if ( rule->isElse() )
601601
{
602-
RuleList lst = rulesForFeature( feat, context, false );
602+
RuleList lst = rulesForFeature( feature, context, false );
603603
lst.removeOne( rule );
604604

605605
if ( lst.empty() )
606606
{
607607
validKey = true;
608608
}
609609
}
610-
else if ( !rule->isElse( ) && rule->willRenderFeature( feat, context ) )
610+
else if ( !rule->isElse( ) && rule->willRenderFeature( feature, context ) )
611611
{
612612
validKey = true;
613613
}
614614

615615
if ( validKey )
616616
{
617-
lst.unite( rule->legendKeysForFeature( feat, context ) );
617+
lst.unite( rule->legendKeysForFeature( feature, context ) );
618618
}
619619
}
620620
return lst;
621621
}
622622

623-
QgsRuleBasedRenderer::RuleList QgsRuleBasedRenderer::Rule::rulesForFeature( QgsFeature &feat, QgsRenderContext *context, bool onlyActive )
623+
QgsRuleBasedRenderer::RuleList QgsRuleBasedRenderer::Rule::rulesForFeature( const QgsFeature &feature, QgsRenderContext *context, bool onlyActive )
624624
{
625625
RuleList lst;
626-
if ( !isFilterOK( feat, context ) )
626+
if ( !isFilterOK( feature, context ) )
627627
return lst;
628628

629629
if ( mSymbol )
@@ -635,7 +635,7 @@ QgsRuleBasedRenderer::RuleList QgsRuleBasedRenderer::Rule::rulesForFeature( QgsF
635635

636636
Q_FOREACH ( Rule *rule, listChildren )
637637
{
638-
lst += rule->rulesForFeature( feat, context, onlyActive );
638+
lst += rule->rulesForFeature( feature, context, onlyActive );
639639
}
640640
return lst;
641641
}
@@ -838,13 +838,13 @@ QgsRuleBasedRenderer::~QgsRuleBasedRenderer()
838838
}
839839

840840

841-
QgsSymbol *QgsRuleBasedRenderer::symbolForFeature( QgsFeature &, QgsRenderContext & )
841+
QgsSymbol *QgsRuleBasedRenderer::symbolForFeature( const QgsFeature &, QgsRenderContext & ) const
842842
{
843843
// not used at all
844844
return nullptr;
845845
}
846846

847-
bool QgsRuleBasedRenderer::renderFeature( QgsFeature &feature,
847+
bool QgsRuleBasedRenderer::renderFeature( const QgsFeature &feature,
848848
QgsRenderContext &context,
849849
int layer,
850850
bool selected,
@@ -970,7 +970,7 @@ void QgsRuleBasedRenderer::toSld( QDomDocument &doc, QDomElement &element, const
970970
}
971971

972972
// TODO: ideally this function should be removed in favor of legendSymbol(ogy)Items
973-
QgsSymbolList QgsRuleBasedRenderer::symbols( QgsRenderContext &context )
973+
QgsSymbolList QgsRuleBasedRenderer::symbols( QgsRenderContext &context ) const
974974
{
975975
return mRootRule->symbols( context );
976976
}
@@ -1182,22 +1182,22 @@ QString QgsRuleBasedRenderer::dump() const
11821182
return msg;
11831183
}
11841184

1185-
bool QgsRuleBasedRenderer::willRenderFeature( QgsFeature &feat, QgsRenderContext &context )
1185+
bool QgsRuleBasedRenderer::willRenderFeature( const QgsFeature &feature, QgsRenderContext &context ) const
11861186
{
1187-
return mRootRule->willRenderFeature( feat, &context );
1187+
return mRootRule->willRenderFeature( feature, &context );
11881188
}
11891189

1190-
QgsSymbolList QgsRuleBasedRenderer::symbolsForFeature( QgsFeature &feat, QgsRenderContext &context )
1190+
QgsSymbolList QgsRuleBasedRenderer::symbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
11911191
{
1192-
return mRootRule->symbolsForFeature( feat, &context );
1192+
return mRootRule->symbolsForFeature( feature, &context );
11931193
}
11941194

1195-
QgsSymbolList QgsRuleBasedRenderer::originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context )
1195+
QgsSymbolList QgsRuleBasedRenderer::originalSymbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
11961196
{
1197-
return mRootRule->symbolsForFeature( feat, &context );
1197+
return mRootRule->symbolsForFeature( feature, &context );
11981198
}
11991199

1200-
QSet< QString > QgsRuleBasedRenderer::legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context )
1200+
QSet< QString > QgsRuleBasedRenderer::legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
12011201
{
12021202
return mRootRule->legendKeysForFeature( feature, &context );
12031203
}

‎src/core/symbology/qgsrulebasedrenderer.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class CORE_EXPORT QgsRuleBasedRenderer : public QgsFeatureRenderer
5151
*/
5252
struct FeatureToRender
5353
{
54-
FeatureToRender( QgsFeature &_f, int _flags )
54+
FeatureToRender( const QgsFeature &_f, int _flags )
5555
: feat( _f )
5656
, flags( _flags )
5757
{}
@@ -180,7 +180,7 @@ class CORE_EXPORT QgsRuleBasedRenderer : public QgsFeatureRenderer
180180
* \param context The context in which the rendering happens
181181
* \returns True if the feature shall be rendered
182182
*/
183-
bool isFilterOK( QgsFeature &f, QgsRenderContext *context = nullptr ) const;
183+
bool isFilterOK( const QgsFeature &f, QgsRenderContext *context = nullptr ) const;
184184

185185
/**
186186
* Check if this rule applies for a given \a scale.
@@ -331,26 +331,26 @@ class CORE_EXPORT QgsRuleBasedRenderer : public QgsFeatureRenderer
331331
QgsRuleBasedRenderer::Rule::RenderResult renderFeature( QgsRuleBasedRenderer::FeatureToRender &featToRender, QgsRenderContext &context, QgsRuleBasedRenderer::RenderQueue &renderQueue );
332332

333333
//! only tell whether a feature will be rendered without actually rendering it
334-
bool willRenderFeature( QgsFeature &feat, QgsRenderContext *context = nullptr );
334+
bool willRenderFeature( const QgsFeature &feature, QgsRenderContext *context = nullptr );
335335

336336
//! tell which symbols will be used to render the feature
337-
QgsSymbolList symbolsForFeature( QgsFeature &feat, QgsRenderContext *context = nullptr );
337+
QgsSymbolList symbolsForFeature( const QgsFeature &feature, QgsRenderContext *context = nullptr );
338338

339339
/**
340340
* Returns which legend keys match the feature
341341
* \since QGIS 2.14
342342
*/
343-
QSet< QString > legendKeysForFeature( QgsFeature &feat, QgsRenderContext *context = nullptr );
343+
QSet< QString > legendKeysForFeature( const QgsFeature &feature, QgsRenderContext *context = nullptr );
344344

345345
/**
346346
* Returns the list of rules used to render the feature in a specific
347347
* context.
348348
*
349-
* \param feat The feature for which rules have to be find
349+
* \param feature The feature for which rules have to be find
350350
* \param context The rendering context
351351
* \param onlyActive True to search for active rules only, false otherwise
352352
*/
353-
QgsRuleBasedRenderer::RuleList rulesForFeature( QgsFeature &feat, QgsRenderContext *context = nullptr, bool onlyActive = true );
353+
QgsRuleBasedRenderer::RuleList rulesForFeature( const QgsFeature &feature, QgsRenderContext *context = nullptr, bool onlyActive = true );
354354

355355
/**
356356
* Stop a rendering process. Used to clean up the internal state of this rule
@@ -374,7 +374,7 @@ class CORE_EXPORT QgsRuleBasedRenderer : public QgsFeatureRenderer
374374
*
375375
* \returns A list of rules
376376
*/
377-
QgsRuleBasedRenderer::RuleList &children() { return mChildren; }
377+
const QgsRuleBasedRenderer::RuleList &children() { return mChildren; }
378378

379379
/**
380380
* Returns all children, grand-children, grand-grand-children, grand-gra... you get it
@@ -474,9 +474,9 @@ class CORE_EXPORT QgsRuleBasedRenderer : public QgsFeatureRenderer
474474
~QgsRuleBasedRenderer() override;
475475

476476
//! return symbol for current feature. Should not be used individually: there could be more symbols for a feature
477-
QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
477+
QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
478478

479-
bool renderFeature( QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) override;
479+
bool renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) override;
480480

481481
void startRender( QgsRenderContext &context, const QgsFields &fields ) override;
482482

@@ -494,7 +494,7 @@ class CORE_EXPORT QgsRuleBasedRenderer : public QgsFeatureRenderer
494494

495495
static QgsFeatureRenderer *createFromSld( QDomElement &element, QgsWkbTypes::GeometryType geomType ) SIP_FACTORY;
496496

497-
QgsSymbolList symbols( QgsRenderContext &context ) override;
497+
QgsSymbolList symbols( QgsRenderContext &context ) const override;
498498

499499
QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) override;
500500
bool legendSymbolItemsCheckable() const override;
@@ -504,10 +504,10 @@ class CORE_EXPORT QgsRuleBasedRenderer : public QgsFeatureRenderer
504504
void setLegendSymbolItem( const QString &key, QgsSymbol *symbol SIP_TRANSFER ) override;
505505
QgsLegendSymbolList legendSymbolItems() const override;
506506
QString dump() const override;
507-
bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context ) override;
508-
QgsSymbolList symbolsForFeature( QgsFeature &feat, QgsRenderContext &context ) override;
509-
QgsSymbolList originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context ) override;
510-
QSet<QString> legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
507+
bool willRenderFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
508+
QgsSymbolList symbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
509+
QgsSymbolList originalSymbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
510+
QSet<QString> legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
511511
QgsFeatureRenderer::Capabilities capabilities() override { return MoreSymbolsPerFeature | Filter | ScaleDependent; }
512512

513513
/////

‎src/core/symbology/qgssinglesymbolrenderer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ QgsSingleSymbolRenderer::QgsSingleSymbolRenderer( QgsSymbol *symbol )
4040
Q_ASSERT( symbol );
4141
}
4242

43-
QgsSymbol *QgsSingleSymbolRenderer::symbolForFeature( QgsFeature &, QgsRenderContext & )
43+
QgsSymbol *QgsSingleSymbolRenderer::symbolForFeature( const QgsFeature &, QgsRenderContext & ) const
4444
{
4545
return mSymbol.get();
4646
}
4747

48-
QgsSymbol *QgsSingleSymbolRenderer::originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context )
48+
QgsSymbol *QgsSingleSymbolRenderer::originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
4949
{
5050
Q_UNUSED( context );
5151
Q_UNUSED( feature );
@@ -121,7 +121,7 @@ void QgsSingleSymbolRenderer::toSld( QDomDocument &doc, QDomElement &element, co
121121
if ( mSymbol ) mSymbol->toSld( doc, ruleElem, newProps );
122122
}
123123

124-
QgsSymbolList QgsSingleSymbolRenderer::symbols( QgsRenderContext &context )
124+
QgsSymbolList QgsSingleSymbolRenderer::symbols( QgsRenderContext &context ) const
125125
{
126126
Q_UNUSED( context );
127127
QgsSymbolList lst;
@@ -316,7 +316,7 @@ QgsLegendSymbolList QgsSingleSymbolRenderer::legendSymbolItems() const
316316
return lst;
317317
}
318318

319-
QSet< QString > QgsSingleSymbolRenderer::legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context )
319+
QSet< QString > QgsSingleSymbolRenderer::legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
320320
{
321321
Q_UNUSED( feature );
322322
Q_UNUSED( context );

‎src/core/symbology/qgssinglesymbolrenderer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class CORE_EXPORT QgsSingleSymbolRenderer : public QgsFeatureRenderer
3232

3333
QgsSingleSymbolRenderer( QgsSymbol *symbol SIP_TRANSFER );
3434

35-
QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
36-
QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
35+
QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
36+
QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
3737
void startRender( QgsRenderContext &context, const QgsFields &fields ) override;
3838
void stopRender( QgsRenderContext &context ) override;
3939
QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
@@ -49,13 +49,13 @@ class CORE_EXPORT QgsSingleSymbolRenderer : public QgsFeatureRenderer
4949
static QgsFeatureRenderer *createFromSld( QDomElement &element, QgsWkbTypes::GeometryType geomType );
5050

5151
QgsFeatureRenderer::Capabilities capabilities() override { return SymbolLevels; }
52-
QgsSymbolList symbols( QgsRenderContext &context ) override;
52+
QgsSymbolList symbols( QgsRenderContext &context ) const override;
5353

5454
//! create renderer from XML element
5555
static QgsFeatureRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
5656
QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) override;
5757
QgsLegendSymbolList legendSymbolItems() const override;
58-
QSet< QString > legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
58+
QSet< QString > legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
5959
void setLegendSymbolItem( const QString &key, QgsSymbol *symbol SIP_TRANSFER ) override;
6060

6161
/**

‎src/gui/symbology/qgsrulebasedrendererwidget.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,10 @@ QList<QgsSymbol *> QgsRuleBasedRendererWidget::selectedSymbols()
342342
{
343343
QModelIndex parent = range.parent();
344344
QgsRuleBasedRenderer::Rule *parentRule = mModel->ruleForIndex( parent );
345-
QgsRuleBasedRenderer::RuleList &children = parentRule->children();
345+
const QgsRuleBasedRenderer::RuleList &children = parentRule->children();
346346
for ( int row = range.top(); row <= range.bottom(); row++ )
347347
{
348-
symbolList.append( children[row]->symbol() );
348+
symbolList.append( children.at( row )->symbol() );
349349
}
350350
}
351351

@@ -360,10 +360,10 @@ QgsRuleBasedRenderer::RuleList QgsRuleBasedRendererWidget::selectedRules()
360360
{
361361
QModelIndex parent = range.parent();
362362
QgsRuleBasedRenderer::Rule *parentRule = mModel->ruleForIndex( parent );
363-
QgsRuleBasedRenderer::RuleList &children = parentRule->children();
363+
const QgsRuleBasedRenderer::RuleList &children = parentRule->children();
364364
for ( int row = range.top(); row <= range.bottom(); row++ )
365365
{
366-
rl.append( children[row]->clone() );
366+
rl.append( children.at( row )->clone() );
367367
}
368368
}
369369
return rl;

‎src/plugins/grass/qgsgrasseditrenderer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void QgsGrassEditRenderer::setMarkerRenderer( QgsFeatureRenderer *renderer )
118118
mMarkerRenderer = renderer;
119119
}
120120

121-
QgsSymbol *QgsGrassEditRenderer::symbolForFeature( QgsFeature &feature, QgsRenderContext &context )
121+
QgsSymbol *QgsGrassEditRenderer::symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
122122
{
123123
int symbolCode = feature.attribute( QStringLiteral( "topo_symbol" ) ).toInt();
124124
QgsDebugMsgLevel( QString( "fid = %1 symbolCode = %2" ).arg( feature.id() ).arg( symbolCode ), 3 );
@@ -190,7 +190,7 @@ QgsFeatureRenderer *QgsGrassEditRenderer::clone() const
190190
return r;
191191
}
192192

193-
QgsSymbolList QgsGrassEditRenderer::symbols( QgsRenderContext &context )
193+
QgsSymbolList QgsGrassEditRenderer::symbols( QgsRenderContext &context ) const
194194
{
195195
return mLineRenderer->symbols( context );
196196
}

‎src/plugins/grass/qgsgrasseditrenderer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class QgsGrassEditRenderer : public QgsFeatureRenderer
3232

3333
~QgsGrassEditRenderer() override;
3434

35-
QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
35+
QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
3636

3737
void startRender( QgsRenderContext &context, const QgsFields &fields ) override;
3838

@@ -42,7 +42,7 @@ class QgsGrassEditRenderer : public QgsFeatureRenderer
4242

4343
QgsFeatureRenderer *clone() const override;
4444

45-
QgsSymbolList symbols( QgsRenderContext &context ) override;
45+
QgsSymbolList symbols( QgsRenderContext &context ) const override;
4646

4747
QString dump() const override;
4848

0 commit comments

Comments
 (0)
Please sign in to comment.