Skip to content
Permalink
Browse files

Fix vector field symbol does not use subsymbol color (fix #15130)

(cherry-picked from e6034e9)
  • Loading branch information
nyalldawson committed Jul 1, 2016
1 parent 92fc4eb commit 8bd4558fec426dfe5d6fe6d36b9c91d67678b507
@@ -34,6 +34,9 @@ class QgsVectorFieldSymbolLayer : QgsMarkerSymbolLayerV2
bool setSubSymbol( QgsSymbolV2* symbol /Transfer/ );
QgsSymbolV2* subSymbol();

void setColor( const QColor& color );
virtual QColor color() const;

void renderPoint( QPointF point, QgsSymbolV2RenderContext& context );
void startRender( QgsSymbolV2RenderContext& context );
void stopRender( QgsSymbolV2RenderContext& context );
@@ -319,4 +319,17 @@ void QgsVectorFieldSymbolLayer::convertPolarToCartesian( double length, double a
y = length * cos( angle );
}

void QgsVectorFieldSymbolLayer::setColor( const QColor& color )
{
if ( mLineSymbol )
mLineSymbol->setColor( color );

mColor = color;
}

QColor QgsVectorFieldSymbolLayer::color() const
{
return mLineSymbol ? mLineSymbol->color() : mColor;
}


@@ -54,6 +54,9 @@ class CORE_EXPORT QgsVectorFieldSymbolLayer: public QgsMarkerSymbolLayerV2
bool setSubSymbol( QgsSymbolV2* symbol ) override;
QgsSymbolV2* subSymbol() override { return mLineSymbol; }

void setColor( const QColor& color ) override;
virtual QColor color() const override;

void renderPoint( QPointF point, QgsSymbolV2RenderContext& context ) override;
void startRender( QgsSymbolV2RenderContext& context ) override;
void stopRender( QgsSymbolV2RenderContext& context ) override;
@@ -730,5 +730,19 @@ def testQgsSvgMarkerSymbolLayerV2(self):
mMessage = 'Expected "%s" got "%s"' % (mExpectedValue, mValue)
assert mExpectedValue == mValue, mMessage

def testQgsVectorFieldSymbolLayer(self):
"""
Test QgsVectorFieldSymbolLayer
"""
# test colors, need to make sure colors are passed/retrieved from subsymbol
mSymbolLayer = QgsVectorFieldSymbolLayer.create()

mSymbolLayer.setColor(QColor(150, 50, 100))
self.assertEqual(mSymbolLayer.color(), QColor(150, 50, 100))
self.assertEqual(mSymbolLayer.subSymbol().color(), QColor(150, 50, 100))
mSymbolLayer.subSymbol().setColor(QColor(250, 150, 200))
self.assertEqual(mSymbolLayer.subSymbol().color(), QColor(250, 150, 200))
self.assertEqual(mSymbolLayer.color(), QColor(250, 150, 200))

if __name__ == '__main__':
unittest.main()

0 comments on commit 8bd4558

Please sign in to comment.
You can’t perform that action at this time.