Skip to content
Permalink
Browse files
Fix widget for data defined line color in lineburst symbol layer
  • Loading branch information
nyalldawson committed Oct 29, 2021
1 parent 957f898 commit ccf5ff0a29e0dc4f524a85326243dd4114af6c0c
@@ -4662,7 +4662,7 @@ void QgsGeometryGeneratorSymbolLayerWidget::updateSymbolType()
QgsSymbolLayerList layers;
for ( int i = 0; i < subSymbol->symbolLayerCount(); ++i )
{
if ( const QgsLineSymbolLayer *lineLayer = dynamic_cast< const QgsLineSymbolLayer * >( subSymbol->symbolLayer( i ) ) )
if ( dynamic_cast< const QgsLineSymbolLayer * >( subSymbol->symbolLayer( i ) ) )
layers << subSymbol->symbolLayer( i )->clone();
}

@@ -4996,7 +4996,7 @@ void QgsLineburstSymbolLayerWidget::setSymbolLayer( QgsSymbolLayer *layer )
whileBlocking( cboJoinStyle )->setPenJoinStyle( mLayer->penJoinStyle() );
whileBlocking( cboCapStyle )->setPenCapStyle( mLayer->penCapStyle() );

registerDataDefinedButton( mStartColorDDBtn, QgsSymbolLayer::PropertyFillColor );
registerDataDefinedButton( mStartColorDDBtn, QgsSymbolLayer::PropertyStrokeColor );
registerDataDefinedButton( mEndColorDDBtn, QgsSymbolLayer::PropertySecondaryColor );
registerDataDefinedButton( mPenWidthDDBtn, QgsSymbolLayer::PropertyStrokeWidth );
registerDataDefinedButton( mJoinStyleDDBtn, QgsSymbolLayer::PropertyJoinStyle );
@@ -33,7 +33,9 @@
QgsGradientColorRamp,
QgsGradientStop,
QgsLineSymbol,
QgsLineburstSymbolLayer
QgsLineburstSymbolLayer,
QgsSymbolLayer,
QgsProperty
)
from qgis.testing import unittest, start_app

@@ -68,6 +70,23 @@ def testTwoColor(self):
rendered_image = self.renderGeometry(s, g)
self.assertTrue(self.imageCheck('lineburst_two_color', 'lineburst_two_color', rendered_image))

def testDataDefinedColors(self):
s = QgsLineSymbol()
s.deleteSymbolLayer(0)

line = QgsLineburstSymbolLayer()
line.setColor(QColor(255, 0, 0))
line.setColor2(QColor(0, 255, 0))
line.setWidth(8)
line.setDataDefinedProperty(QgsSymbolLayer.PropertyStrokeColor, QgsProperty.fromExpression("'orange'"))
line.setDataDefinedProperty(QgsSymbolLayer.PropertySecondaryColor, QgsProperty.fromExpression("'purple'"))

s.appendSymbolLayer(line.clone())

g = QgsGeometry.fromWkt('LineString(0 0, 10 10, 10 0)')
rendered_image = self.renderGeometry(s, g)
self.assertTrue(self.imageCheck('lineburst_datadefined_color', 'lineburst_datadefined_color', rendered_image))

def testColorRamp(self):
s = QgsLineSymbol()
s.deleteSymbolLayer(0)
Binary file not shown.

0 comments on commit ccf5ff0

Please sign in to comment.