@@ -153,7 +153,6 @@ QgsCategorizedSymbolRenderer::QgsCategorizedSymbolRenderer( const QString& attrN
153
153
: QgsFeatureRenderer( " categorizedSymbol" )
154
154
, mAttrName( attrName )
155
155
, mInvertedColorRamp( false )
156
- , mScaleMethod( DEFAULT_SCALE_METHOD )
157
156
, mAttrNum( -1 )
158
157
, mCounting( false )
159
158
{
@@ -216,38 +215,9 @@ QgsSymbol* QgsCategorizedSymbolRenderer::symbolForValue( const QVariant& value )
216
215
217
216
QgsSymbol* QgsCategorizedSymbolRenderer::symbolForFeature ( QgsFeature& feature, QgsRenderContext &context )
218
217
{
219
- QgsSymbol* symbol = originalSymbolForFeature ( feature, context );
220
- if ( !symbol )
221
- return nullptr ;
222
-
223
- if ( !mRotation .data () && !mSizeScale .data () )
224
- return symbol; // no data-defined rotation/scaling - just return the symbol
225
-
226
- // find out rotation, size scale
227
- const double rotation = mRotation .data () ? mRotation ->evaluate ( &context.expressionContext () ).toDouble () : 0 ;
228
- const double sizeScale = mSizeScale .data () ? mSizeScale ->evaluate ( &context.expressionContext () ).toDouble () : 1 .;
229
-
230
- // take a temporary symbol (or create it if doesn't exist)
231
- QgsSymbol* tempSymbol = mTempSymbols [symbol];
232
-
233
- // modify the temporary symbol and return it
234
- if ( tempSymbol->type () == QgsSymbol::Marker )
235
- {
236
- QgsMarkerSymbol* markerSymbol = static_cast <QgsMarkerSymbol*>( tempSymbol );
237
- if ( mRotation .data () ) markerSymbol->setAngle ( rotation );
238
- markerSymbol->setSize ( sizeScale * static_cast <QgsMarkerSymbol*>( symbol )->size () );
239
- markerSymbol->setScaleMethod ( mScaleMethod );
240
- }
241
- else if ( tempSymbol->type () == QgsSymbol::Line )
242
- {
243
- QgsLineSymbol* lineSymbol = static_cast <QgsLineSymbol*>( tempSymbol );
244
- lineSymbol->setWidth ( sizeScale * static_cast <QgsLineSymbol*>( symbol )->width () );
245
- }
246
-
247
- return tempSymbol;
218
+ return originalSymbolForFeature ( feature, context );
248
219
}
249
220
250
-
251
221
QVariant QgsCategorizedSymbolRenderer::valueForFeature ( QgsFeature& feature, QgsRenderContext &context ) const
252
222
{
253
223
QgsAttributes attrs = feature.attributes ();
@@ -435,15 +405,6 @@ void QgsCategorizedSymbolRenderer::startRender( QgsRenderContext& context, const
435
405
Q_FOREACH ( const QgsRendererCategory& cat, mCategories )
436
406
{
437
407
cat.symbol ()->startRender ( context, fields );
438
-
439
- if ( mRotation .data () || mSizeScale .data () )
440
- {
441
- QgsSymbol* tempSymbol = cat.symbol ()->clone ();
442
- tempSymbol->setRenderHints (( mRotation .data () ? QgsSymbol::DataDefinedRotation : 0 ) |
443
- ( mSizeScale .data () ? QgsSymbol::DataDefinedSizeScale : 0 ) );
444
- tempSymbol->startRender ( context, fields );
445
- mTempSymbols [ cat.symbol ()] = tempSymbol;
446
- }
447
408
}
448
409
return ;
449
410
}
@@ -454,15 +415,6 @@ void QgsCategorizedSymbolRenderer::stopRender( QgsRenderContext& context )
454
415
{
455
416
cat.symbol ()->stopRender ( context );
456
417
}
457
-
458
- // cleanup mTempSymbols
459
- QHash<QgsSymbol*, QgsSymbol*>::const_iterator it2 = mTempSymbols .constBegin ();
460
- for ( ; it2 != mTempSymbols .constEnd (); ++it2 )
461
- {
462
- it2.value ()->stopRender ( context );
463
- delete it2.value ();
464
- }
465
- mTempSymbols .clear ();
466
418
mExpression .reset ();
467
419
}
468
420
@@ -480,9 +432,6 @@ QList<QString> QgsCategorizedSymbolRenderer::usedAttributes()
480
432
if ( !testExpr.hasParserError () )
481
433
attributes.unite ( testExpr.referencedColumns ().toSet () );
482
434
483
- if ( mRotation .data () ) attributes.unite ( mRotation ->referencedColumns ().toSet () );
484
- if ( mSizeScale .data () ) attributes.unite ( mSizeScale ->referencedColumns ().toSet () );
485
-
486
435
QgsCategoryList::const_iterator catIt = mCategories .constBegin ();
487
436
for ( ; catIt != mCategories .constEnd (); ++catIt )
488
437
{
@@ -514,7 +463,6 @@ QgsCategorizedSymbolRenderer* QgsCategorizedSymbolRenderer::clone() const
514
463
r->setInvertedColorRamp ( mInvertedColorRamp );
515
464
}
516
465
r->setUsingSymbolLevels ( usingSymbolLevels () );
517
- r->setSizeScaleField ( sizeScaleField () );
518
466
519
467
copyRendererData ( r );
520
468
return r;
@@ -523,10 +471,6 @@ QgsCategorizedSymbolRenderer* QgsCategorizedSymbolRenderer::clone() const
523
471
void QgsCategorizedSymbolRenderer::toSld ( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const
524
472
{
525
473
props[ " attribute" ] = mAttrName ;
526
- if ( mRotation .data () )
527
- props[ " angle" ] = mRotation ->expression ();
528
- if ( mSizeScale .data () )
529
- props[ " scale" ] = mSizeScale ->expression ();
530
474
531
475
// create a Rule for each range
532
476
for ( QgsCategoryList::const_iterator it = mCategories .constBegin (); it != mCategories .constEnd (); ++it )
@@ -770,14 +714,9 @@ QDomElement QgsCategorizedSymbolRenderer::save( QDomDocument& doc )
770
714
}
771
715
772
716
QDomElement rotationElem = doc.createElement ( " rotation" );
773
- if ( mRotation .data () )
774
- rotationElem.setAttribute ( " field" , QgsSymbolLayerUtils::fieldOrExpressionFromExpression ( mRotation .data () ) );
775
717
rendererElem.appendChild ( rotationElem );
776
718
777
719
QDomElement sizeScaleElem = doc.createElement ( " sizescale" );
778
- if ( mSizeScale .data () )
779
- sizeScaleElem.setAttribute ( " field" , QgsSymbolLayerUtils::fieldOrExpressionFromExpression ( mSizeScale .data () ) );
780
- sizeScaleElem.setAttribute ( " scalemethod" , QgsSymbolLayerUtils::encodeScaleMethod ( mScaleMethod ) );
781
720
rendererElem.appendChild ( sizeScaleElem );
782
721
783
722
if ( mPaintEffect && !QgsPaintEffectRegistry::isDefaultStack ( mPaintEffect ) )
@@ -936,16 +875,6 @@ void QgsCategorizedSymbolRenderer::updateColorRamp( QgsColorRamp* ramp, bool inv
936
875
}
937
876
}
938
877
939
- void QgsCategorizedSymbolRenderer::setSizeScaleField ( const QString& fieldOrExpression )
940
- {
941
- mSizeScale .reset ( QgsSymbolLayerUtils::fieldOrExpressionToExpression ( fieldOrExpression ) );
942
- }
943
-
944
- QString QgsCategorizedSymbolRenderer::sizeScaleField () const
945
- {
946
- return mSizeScale .data () ? QgsSymbolLayerUtils::fieldOrExpressionFromExpression ( mSizeScale .data () ) : QString ();
947
- }
948
-
949
878
void QgsCategorizedSymbolRenderer::updateSymbols ( QgsSymbol * sym )
950
879
{
951
880
int i = 0 ;
@@ -959,16 +888,6 @@ void QgsCategorizedSymbolRenderer::updateSymbols( QgsSymbol * sym )
959
888
setSourceSymbol ( sym->clone () );
960
889
}
961
890
962
- void QgsCategorizedSymbolRenderer::setScaleMethod ( QgsSymbol::ScaleMethod scaleMethod )
963
- {
964
- mScaleMethod = scaleMethod;
965
- QgsCategoryList::const_iterator catIt = mCategories .constBegin ();
966
- for ( ; catIt != mCategories .constEnd (); ++catIt )
967
- {
968
- setScaleMethodToSymbol ( catIt->symbol (), scaleMethod );
969
- }
970
- }
971
-
972
891
bool QgsCategorizedSymbolRenderer::legendSymbolItemsCheckable () const
973
892
{
974
893
return true ;
0 commit comments