Skip to content

Commit d633f59

Browse files
committed
Allow coloring of svg markers when used with graduated/categorised renderers (fix #11658)
(cherry-picked from a721752)
1 parent 14d47ab commit d633f59

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

‎src/core/symbology-ng/qgsmarkersymbollayerv2.cpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ QgsSvgMarkerSymbolLayerV2::QgsSvgMarkerSymbolLayerV2( QString name, double size,
10531053
mScaleMethod = scaleMethod;
10541054
mOutlineWidth = 1.0;
10551055
mOutlineWidthUnit = QgsSymbolV2::MM;
1056-
mFillColor = QColor( Qt::black );
1056+
mColor = QColor( Qt::black );
10571057
mOutlineColor = QColor( Qt::black );
10581058
}
10591059

@@ -1337,7 +1337,7 @@ void QgsSvgMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2Re
13371337
outlineWidth = outlineWidthExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble();
13381338
}
13391339

1340-
QColor fillColor = mFillColor;
1340+
QColor fillColor = mColor;
13411341
QgsExpression* fillExpression = expression( "fill" );
13421342
if ( fillExpression )
13431343
{
@@ -1428,7 +1428,7 @@ QgsStringMap QgsSvgMarkerSymbolLayerV2::properties() const
14281428
map["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit );
14291429
map["offset_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOffsetMapUnitScale );
14301430
map["scale_method"] = QgsSymbolLayerV2Utils::encodeScaleMethod( mScaleMethod );
1431-
map["color"] = mFillColor.name();
1431+
map["color"] = mColor.name();
14321432
map["outline_color"] = mOutlineColor.name();
14331433
map["outline_width"] = QString::number( mOutlineWidth );
14341434
map["outline_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOutlineWidthUnit );
@@ -1443,7 +1443,7 @@ QgsStringMap QgsSvgMarkerSymbolLayerV2::properties() const
14431443
QgsSymbolLayerV2* QgsSvgMarkerSymbolLayerV2::clone() const
14441444
{
14451445
QgsSvgMarkerSymbolLayerV2* m = new QgsSvgMarkerSymbolLayerV2( mPath, mSize, mAngle );
1446-
m->setFillColor( mFillColor );
1446+
m->setFillColor( mColor );
14471447
m->setOutlineColor( mOutlineColor );
14481448
m->setOutlineWidth( mOutlineWidth );
14491449
m->setOutlineWidthUnit( mOutlineWidthUnit );
@@ -1496,7 +1496,7 @@ void QgsSvgMarkerSymbolLayerV2::writeSldMarker( QDomDocument &doc, QDomElement &
14961496
QDomElement graphicElem = doc.createElement( "se:Graphic" );
14971497
element.appendChild( graphicElem );
14981498

1499-
QgsSymbolLayerV2Utils::externalGraphicToSld( doc, graphicElem, mPath, "image/svg+xml", mFillColor, mSize );
1499+
QgsSymbolLayerV2Utils::externalGraphicToSld( doc, graphicElem, mPath, "image/svg+xml", mColor, mSize );
15001500

15011501
// <Rotation>
15021502
QString angleFunc;
@@ -1634,7 +1634,7 @@ bool QgsSvgMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScale
16341634
outlineWidth = outlineWidthExpression->evaluate( *f ).toDouble();
16351635
}
16361636

1637-
QColor fillColor = mFillColor;
1637+
QColor fillColor = mColor;
16381638
QgsExpression *fillExpression = expression( "fill" );
16391639
if ( fillExpression )
16401640
{

‎src/core/symbology-ng/qgsmarkersymbollayerv2.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ class CORE_EXPORT QgsSvgMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
179179
QString path() const { return mPath; }
180180
void setPath( QString path );
181181

182-
QColor fillColor() const override { return mFillColor; }
183-
void setFillColor( const QColor& c ) override { mFillColor = c; }
182+
QColor fillColor() const override { return color(); }
183+
void setFillColor( const QColor& color ) override { setColor( color ); }
184184

185185
QColor outlineColor() const override { return mOutlineColor; }
186186
void setOutlineColor( const QColor& c ) override { mOutlineColor = c; }
@@ -207,7 +207,6 @@ class CORE_EXPORT QgsSvgMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
207207

208208
//param(fill), param(outline), param(outline-width) are going
209209
//to be replaced in memory
210-
QColor mFillColor;
211210
QColor mOutlineColor;
212211
double mOutlineWidth;
213212
QgsSymbolV2::OutputUnit mOutlineWidthUnit;

0 commit comments

Comments
 (0)