Skip to content

Commit

Permalink
Fix vector field symbol does not use subsymbol color (fix #15130)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 26, 2016
1 parent 302f8d4 commit e6034e9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/core/symbology-ng/qgsvectorfieldsymbollayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
13 changes: 13 additions & 0 deletions src/core/symbology-ng/qgsvectorfieldsymbollayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


3 changes: 3 additions & 0 deletions src/core/symbology-ng/qgsvectorfieldsymbollayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions tests/src/python/test_qgssymbollayerv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,5 +804,19 @@ def testQgsFilledMarkerSymbolLayer(self):
self.assertEqual(mSymbolLayer.subSymbol().color(), QColor(250, 150, 200))
self.assertEqual(mSymbolLayer.color(), QColor(250, 150, 200))

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 e6034e9

Please sign in to comment.