Skip to content

Commit

Permalink
Consider alpha component of colors in data defined symbology
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Apr 3, 2013
1 parent c04a219 commit 80f7b5a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
12 changes: 5 additions & 7 deletions src/core/symbology-ng/qgsfillsymbollayerv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ void QgsSimpleFillSymbolLayerV2::applyDataDefinedSymbology( QgsSymbolV2RenderCon
{
if ( mColorExpression )
{
brush.setColor( QColor( mColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() ) );
brush.setColor( QgsSymbolLayerV2Utils::decodeColor( mColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() ) );

This comment has been minimized.

Copy link
@jef-n

jef-n Apr 3, 2013

Member

Now the brand new color widget is wrong, isn't it? I had it implemented using decodeColor/encodeColor and found that the expression needed to produce Qt color names - and thinking about it, I found it more appealing.

}
if ( mColorBorderExpression )
{
pen.setColor( QColor( mColorBorderExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() ) );
pen.setColor( QgsSymbolLayerV2Utils::decodeColor( mColorBorderExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() ) );
}
if ( mWidthBorderExpression )
{
Expand Down Expand Up @@ -1147,14 +1147,12 @@ void QgsSVGFillSymbolLayer::applyDataDefinedSettings( const QgsSymbolV2RenderCon
QColor svgFillColor = mSvgFillColor;
if ( mFillColorExpression )
{
QString colorString = mFillColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString();
svgFillColor = QgsSymbolLayerV2Utils::decodeColor( colorString );
svgFillColor = QgsSymbolLayerV2Utils::decodeColor( mFillColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() );
}
QColor svgOutlineColor = mSvgOutlineColor;
if ( mOutlineColorExpression )
{
QString colorString = mOutlineColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString();
svgOutlineColor = QgsSymbolLayerV2Utils::decodeColor( colorString );
svgOutlineColor = QgsSymbolLayerV2Utils::decodeColor( mOutlineColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() );
}
double outlineWidth = mSvgOutlineWidth;
if ( mOutlineWidthExpression )
Expand Down Expand Up @@ -1733,7 +1731,7 @@ void QgsLinePatternFillSymbolLayer::applyDataDefinedSettings( const QgsSymbolV2R
QColor color = mColor;
if ( mColorExpression )
{
color = QColor( mColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() );
color = QgsSymbolLayerV2Utils::decodeColor( mColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() );
}
applyPattern( context, mBrush, lineAngle, distance, lineWidth, color );
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgslinesymbollayerv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ void QgsSimpleLineSymbolLayerV2::applyDataDefinedSymbology( QgsSymbolV2RenderCon
//color
if ( mStrokeColorExpression )
{
pen.setColor( QColor( mStrokeColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() ) );
pen.setColor( QgsSymbolLayerV2Utils::decodeColor( mStrokeColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() ) );
}

//offset
Expand Down
10 changes: 4 additions & 6 deletions src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,11 @@ void QgsSimpleMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV

if ( mColorExpression )
{
mBrush.setColor( QColor( mColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() ) );
mBrush.setColor( QgsSymbolLayerV2Utils::decodeColor( mColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() ) );
}
if ( mColorBorderExpression )
{
mPen.setColor( QColor( mColorBorderExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() ) );
mPen.setColor( QgsSymbolLayerV2Utils::decodeColor( mColorBorderExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() ) );
}

p->setBrush( context.selected() ? mSelBrush : mBrush );
Expand Down Expand Up @@ -1093,15 +1093,13 @@ void QgsSvgMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2Re
QColor fillColor = mFillColor;
if ( mFillExpression )
{
QString colorString = mFillExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString();
fillColor = QgsSymbolLayerV2Utils::decodeColor( colorString );
fillColor = QgsSymbolLayerV2Utils::decodeColor( mFillExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() );
}

QColor outlineColor = mOutlineColor;
if ( mOutlineExpression )
{
QString colorString = mOutlineExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString();
outlineColor = QgsSymbolLayerV2Utils::decodeColor( colorString );
outlineColor = QgsSymbolLayerV2Utils::decodeColor( mOutlineExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() );
}


Expand Down

0 comments on commit 80f7b5a

Please sign in to comment.