Skip to content

Commit

Permalink
Fix size scaling ignored for line symbology (fix #11751)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 28, 2014
1 parent 9c8b44a commit 05276ea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/core/symbology-ng/qgslinesymbollayerv2.cpp
Expand Up @@ -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 );

Expand Down Expand Up @@ -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 );
}
Expand Down
1 change: 1 addition & 0 deletions src/core/symbology-ng/qgslinesymbollayerv2.h
Expand Up @@ -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 );
};

/////////
Expand Down

0 comments on commit 05276ea

Please sign in to comment.