Skip to content

Commit 4d07516

Browse files
mhugentnyalldawson
authored andcommitted
2.18: fix ellipse symbollayer transparency
1 parent 514d036 commit 4d07516

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/core/symbology-ng/qgsellipsesymbollayerv2.cpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,28 @@ void QgsEllipseSymbolLayerV2::renderPoint( QPointF point, QgsSymbolV2RenderConte
242242
context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mColor ) );
243243
QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_FILL_COLOR, context, QVariant(), &ok ).toString();
244244
if ( ok )
245-
mBrush.setColor( QgsSymbolLayerV2Utils::decodeColor( colorString ) );
245+
{
246+
QColor fillColor = QgsSymbolLayerV2Utils::decodeColor( colorString );
247+
if ( context.alpha() < 1.0 )
248+
{
249+
fillColor.setAlpha( fillColor.alphaF() * context.alpha() );
250+
}
251+
mBrush.setColor( fillColor );
252+
}
246253
}
247254
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_COLOR ) )
248255
{
249256
context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mOutlineColor ) );
250257
QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_COLOR, context, QVariant(), &ok ).toString();
251258
if ( ok )
252-
mPen.setColor( QgsSymbolLayerV2Utils::decodeColor( colorString ) );
259+
{
260+
QColor outlineColor = QgsSymbolLayerV2Utils::decodeColor( colorString );
261+
if ( context.alpha() < 1.0 )
262+
{
263+
outlineColor.setAlpha( outlineColor.alphaF() * context.alpha() );
264+
}
265+
mPen.setColor( outlineColor );
266+
}
253267
}
254268
double scaledWidth = mSymbolWidth;
255269
double scaledHeight = mSymbolHeight;
@@ -348,11 +362,21 @@ void QgsEllipseSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
348362
{
349363
preparePath( mSymbolName, context );
350364
}
351-
mPen.setColor( mOutlineColor );
365+
366+
QColor outlineColor = mOutlineColor;
367+
QColor fillColor = mColor;
368+
369+
if ( context.alpha() < 1.0 )
370+
{
371+
outlineColor.setAlphaF( mOutlineColor.alphaF() * context.alpha() );
372+
fillColor.setAlphaF( mColor.alphaF() * context.alpha() );
373+
}
374+
375+
mPen.setColor( outlineColor );
352376
mPen.setStyle( mOutlineStyle );
353377
mPen.setJoinStyle( mPenJoinStyle );
354378
mPen.setWidthF( QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), mOutlineWidth, mOutlineWidthUnit, mOutlineWidthMapUnitScale ) );
355-
mBrush.setColor( mColor );
379+
mBrush.setColor( fillColor );
356380
prepareExpressions( context );
357381
}
358382

0 commit comments

Comments
 (0)