Skip to content

Commit

Permalink
consider data defined svg pattern rotation (fixes #7736)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jul 11, 2013
1 parent 3e83901 commit fd85aee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/core/symbology-ng/qgsfillsymbollayerv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ void QgsImageFillSymbolLayer::renderPolygon( const QPolygonF& points, QList<QPol
return;
}

mNextAngle = mAngle;
applyDataDefinedSettings( context );

p->setPen( QPen( Qt::NoPen ) );
Expand All @@ -315,14 +316,14 @@ void QgsImageFillSymbolLayer::renderPolygon( const QPolygonF& points, QList<QPol
_renderPolygon( p, points, rings );
}

if ( qgsDoubleNear( mAngle, 0.0 ) )
if ( qgsDoubleNear( mNextAngle, 0.0 ) )
{
p->setBrush( mBrush );
}
else
{
QTransform t = mBrush.transform();
t.rotate( mAngle );
t.rotate( mNextAngle );
QBrush rotatedBrush = mBrush;
rotatedBrush.setTransform( t );
p->setBrush( rotatedBrush );
Expand Down Expand Up @@ -766,11 +767,17 @@ void QgsSVGFillSymbolLayer::applyDataDefinedSettings( const QgsSymbolV2RenderCon
QgsExpression* fillColorExpression = expression( "svgFillColor" );
QgsExpression* outlineColorExpression = expression( "svgOutlineColor" );
QgsExpression* outlineWidthExpression = expression( "svgOutlineWidth" );
if ( !widthExpression && !svgFileExpression && !fillColorExpression && !outlineColorExpression && !outlineWidthExpression )
QgsExpression* angleExpression = expression( "angle" );
if ( !widthExpression && !svgFileExpression && !fillColorExpression && !outlineColorExpression && !outlineWidthExpression && !angleExpression )
{
return; //no data defined settings
}

if ( angleExpression )
{
mNextAngle = angleExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble();
}

double width = mPatternWidth;
if ( widthExpression )
{
Expand Down
1 change: 1 addition & 0 deletions src/core/symbology-ng/qgsfillsymbollayerv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class CORE_EXPORT QgsImageFillSymbolLayer: public QgsFillSymbolLayerV2

protected:
QBrush mBrush;
double mNextAngle; // mAngle / data defined angle

/**Outline width*/
double mOutlineWidth;
Expand Down

0 comments on commit fd85aee

Please sign in to comment.