Skip to content
Permalink
Browse files
Fix size scaling ignored for line symbology (fix #11751)
  • Loading branch information
nyalldawson committed Nov 28, 2014
1 parent 9c8b44a commit 05276eac943a82528940d9dc2cdeffeb154e2eef
Showing with 16 additions and 9 deletions.
  1. +15 −9 src/core/symbology-ng/qgslinesymbollayerv2.cpp
  2. +1 −0 src/core/symbology-ng/qgslinesymbollayerv2.h
@@ -302,6 +302,12 @@ void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
return;
}

//size scaling by field
if ( context.renderHints() & QgsSymbolV2::DataDefinedSizeScale )
{
applySizeScale( context, mPen, mSelPen );
}

double offset = mOffset;
applyDataDefinedSymbology( context, mPen, mSelPen, offset );

@@ -458,24 +464,24 @@ QgsSymbolLayerV2* QgsSimpleLineSymbolLayerV2::createFromSld( QDomElement &elemen
return l;
}

void QgsSimpleLineSymbolLayerV2::applySizeScale( QgsSymbolV2RenderContext& context, QPen& pen, QPen& selPen )
{
double scaledWidth = mWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mWidthUnit, mWidthMapUnitScale );
pen.setWidthF( scaledWidth );
selPen.setWidthF( scaledWidth );
}

void QgsSimpleLineSymbolLayerV2::applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QPen& pen, QPen& selPen, double& offset )
{
if ( mDataDefinedProperties.isEmpty() )
return; // shortcut

//data defined properties
double scaledWidth = 0;
QgsExpression* strokeWidthExpression = expression( "width" );
if ( strokeWidthExpression )
{
scaledWidth = strokeWidthExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble()
* QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mWidthUnit, mWidthMapUnitScale );
pen.setWidthF( scaledWidth );
selPen.setWidthF( scaledWidth );
}
else if ( context.renderHints() & QgsSymbolV2::DataDefinedSizeScale )
{
scaledWidth = mWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mWidthUnit, mWidthMapUnitScale );
double scaledWidth = strokeWidthExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble()
* QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mWidthUnit, mWidthMapUnitScale );
pen.setWidthF( scaledWidth );
selPen.setWidthF( scaledWidth );
}
@@ -137,6 +137,7 @@ class CORE_EXPORT QgsSimpleLineSymbolLayerV2 : public QgsLineSymbolLayerV2
private:
//helper functions for data defined symbology
void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QPen& pen, QPen& selPen, double& offset );
void applySizeScale( QgsSymbolV2RenderContext& context, QPen& pen, QPen& selPen );
};

/////////

0 comments on commit 05276ea

Please sign in to comment.