@@ -302,6 +302,12 @@ void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
302
302
return ;
303
303
}
304
304
305
+ // size scaling by field
306
+ if ( context.renderHints () & QgsSymbolV2::DataDefinedSizeScale )
307
+ {
308
+ applySizeScale ( context, mPen , mSelPen );
309
+ }
310
+
305
311
double offset = mOffset ;
306
312
applyDataDefinedSymbology ( context, mPen , mSelPen , offset );
307
313
@@ -458,24 +464,24 @@ QgsSymbolLayerV2* QgsSimpleLineSymbolLayerV2::createFromSld( QDomElement &elemen
458
464
return l;
459
465
}
460
466
467
+ void QgsSimpleLineSymbolLayerV2::applySizeScale ( QgsSymbolV2RenderContext& context, QPen& pen, QPen& selPen )
468
+ {
469
+ double scaledWidth = mWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor ( context.renderContext (), mWidthUnit , mWidthMapUnitScale );
470
+ pen.setWidthF ( scaledWidth );
471
+ selPen.setWidthF ( scaledWidth );
472
+ }
473
+
461
474
void QgsSimpleLineSymbolLayerV2::applyDataDefinedSymbology ( QgsSymbolV2RenderContext& context, QPen& pen, QPen& selPen, double & offset )
462
475
{
463
476
if ( mDataDefinedProperties .isEmpty () )
464
477
return ; // shortcut
465
478
466
479
// data defined properties
467
- double scaledWidth = 0 ;
468
480
QgsExpression* strokeWidthExpression = expression ( " width" );
469
481
if ( strokeWidthExpression )
470
482
{
471
- scaledWidth = strokeWidthExpression->evaluate ( const_cast <QgsFeature*>( context.feature () ) ).toDouble ()
472
- * QgsSymbolLayerV2Utils::lineWidthScaleFactor ( context.renderContext (), mWidthUnit , mWidthMapUnitScale );
473
- pen.setWidthF ( scaledWidth );
474
- selPen.setWidthF ( scaledWidth );
475
- }
476
- else if ( context.renderHints () & QgsSymbolV2::DataDefinedSizeScale )
477
- {
478
- scaledWidth = mWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor ( context.renderContext (), mWidthUnit , mWidthMapUnitScale );
483
+ double scaledWidth = strokeWidthExpression->evaluate ( const_cast <QgsFeature*>( context.feature () ) ).toDouble ()
484
+ * QgsSymbolLayerV2Utils::lineWidthScaleFactor ( context.renderContext (), mWidthUnit , mWidthMapUnitScale );
479
485
pen.setWidthF ( scaledWidth );
480
486
selPen.setWidthF ( scaledWidth );
481
487
}
0 commit comments