Skip to content
Permalink
Browse files
[feature][symbology] New "Lineburst" line symbol layer type
This adds a new "Lineburst" symbol layer type, which renders
a gradient along the WIDTH of a line (as opposed to the interpolated
line renderer, which renders a gradient along the LENGTH of
a line). It's like the shapeburst fill symbol type, but for lines!

Sponsored by North Road, thanks to SLYR
  • Loading branch information
nyalldawson committed Oct 28, 2021
1 parent 92aefdc commit 4a4e0061e158132bd77fb2ff744b73c435902ccd
Showing with 1,528 additions and 254 deletions.
  1. +151 −13 python/core/auto_generated/symbology/qgslinesymbollayer.sip.in
  2. +2 −0 python/core/auto_generated/symbology/qgssymbollayer.sip.in
  3. +42 −0 python/gui/auto_generated/symbology/qgssymbollayerwidget.sip.in
  4. +465 −220 src/core/symbology/qgslinesymbollayer.cpp
  5. +141 −21 src/core/symbology/qgslinesymbollayer.h
  6. +2 −0 src/core/symbology/qgssymbollayer.h
  7. +2 −0 src/core/symbology/qgssymbollayerregistry.cpp
  8. +1 −0 src/gui/symbology/qgslayerpropertieswidget.cpp
  9. +180 −0 src/gui/symbology/qgssymbollayerwidget.cpp
  10. +42 −0 src/gui/symbology/qgssymbollayerwidget.h
  11. +267 −0 src/ui/symbollayer/widget_gradientline.ui
  12. +1 −0 tests/src/python/CMakeLists.txt
  13. +232 −0 tests/src/python/test_qgslineburstsymbollayer.py
  14. BIN ...ata/control_images/symbol_lineburst/expected_lineburst_beveljoin/expected_lineburst_beveljoin.png
  15. BIN .../testdata/control_images/symbol_lineburst/expected_lineburst_closed/expected_lineburst_closed.png
  16. BIN ...ata/control_images/symbol_lineburst/expected_lineburst_colorramp/expected_lineburst_colorramp.png
  17. BIN ...estdata/control_images/symbol_lineburst/expected_lineburst_flatcap/expected_lineburst_flatcap.png
  18. BIN ...ata/control_images/symbol_lineburst/expected_lineburst_miterjoin/expected_lineburst_miterjoin.png
  19. BIN .../testdata/control_images/symbol_lineburst/expected_lineburst_offset/expected_lineburst_offset.png
  20. BIN ...ata/control_images/symbol_lineburst/expected_lineburst_squarecap/expected_lineburst_squarecap.png
  21. BIN ...ata/control_images/symbol_lineburst/expected_lineburst_two_color/expected_lineburst_two_color.png
  22. BIN ...rol_images/symbol_rasterline/expected_rasterline_beveljoin/expected_rasterline_beveljoin_mask.png
  23. BIN ...a/control_images/symbol_rasterline/expected_rasterline_closed/expected_rasterline_closed_mask.png
  24. BIN ...control_images/symbol_rasterline/expected_rasterline_flatcap/expected_rasterline_flatcap_mask.png
  25. BIN ...rol_images/symbol_rasterline/expected_rasterline_miterjoin/expected_rasterline_miterjoin_mask.png
  26. BIN ...a/control_images/symbol_rasterline/expected_rasterline_offset/expected_rasterline_offset_mask.png
  27. BIN ...control_images/symbol_rasterline/expected_rasterline_opacity/expected_rasterline_opacity_mask.png
  28. BIN ...a/control_images/symbol_rasterline/expected_rasterline_render/expected_rasterline_render_mask.png
  29. BIN ...rol_images/symbol_rasterline/expected_rasterline_squarecap/expected_rasterline_squarecap_mask.png
@@ -1170,7 +1170,63 @@ Returns the map unit scale for the hash length.
QgsHashedLineSymbolLayer( const QgsHashedLineSymbolLayer &other );
};

class QgsRasterLineSymbolLayer : QgsLineSymbolLayer

class QgsAbstractBrushedLineSymbolLayer : QgsLineSymbolLayer
{
%Docstring(signature="appended")

Base class for line symbol layer types which draws line sections using a QBrush.

.. versionadded:: 3.24
%End

%TypeHeaderCode
#include "qgslinesymbollayer.h"
%End
public:

Qt::PenJoinStyle penJoinStyle() const;
%Docstring
Returns the pen join style used to render the line (e.g. miter, bevel, round, etc).

.. seealso:: :py:func:`setPenJoinStyle`
%End

void setPenJoinStyle( Qt::PenJoinStyle style );
%Docstring
Sets the pen join ``style`` used to render the line (e.g. miter, bevel, round, etc).

.. seealso:: :py:func:`penJoinStyle`
%End

Qt::PenCapStyle penCapStyle() const;
%Docstring
Returns the pen cap style used to render the line (e.g. flat, square, round, etc).

.. seealso:: :py:func:`setPenCapStyle`
%End

void setPenCapStyle( Qt::PenCapStyle style );
%Docstring
Sets the pen cap ``style`` used to render the line (e.g. flat, square, round, etc).

.. seealso:: :py:func:`penCapStyle`
%End

protected:

void renderPolylineUsingBrush( const QPolygonF &points, QgsSymbolRenderContext &context, const QBrush &brush,
double patternThickness, double patternLength );
%Docstring
Renders a polyline of ``points`` using the specified ``brush``.
%End


};



class QgsRasterLineSymbolLayer : QgsAbstractBrushedLineSymbolLayer
{
%Docstring(signature="appended")

@@ -1260,34 +1316,116 @@ Set the line opacity.
virtual double estimateMaxBleed( const QgsRenderContext &context ) const;


Qt::PenJoinStyle penJoinStyle() const;
protected:

};


class QgsLineburstSymbolLayer : QgsAbstractBrushedLineSymbolLayer
{
%Docstring(signature="appended")

Line symbol layer type which draws a gradient pattern perpendicularly along a line.

See :py:class:`QgsInterpolatedLineSymbolLayer` for a line symbol layer which draws gradients along the length
of a line.

.. versionadded:: 3.24
%End

%TypeHeaderCode
#include "qgslinesymbollayer.h"
%End
public:

QgsLineburstSymbolLayer( const QColor &color = DEFAULT_SIMPLELINE_COLOR,
const QColor &color2 = Qt::white );
%Docstring
Returns the pen join style used to render the line (e.g. miter, bevel, round, etc).
Constructor for QgsLineburstSymbolLayer, with the specified start and end gradient colors.
%End
~QgsLineburstSymbolLayer();

.. seealso:: :py:func:`setPenJoinStyle`
static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) /Factory/;
%Docstring
Creates a new QgsLineburstSymbolLayer, using the settings
serialized in the ``properties`` map (corresponding to the output from
:py:func:`QgsLineburstSymbolLayer.properties()` ).
%End

void setPenJoinStyle( Qt::PenJoinStyle style );
virtual QString layerType() const;

virtual void startRender( QgsSymbolRenderContext &context );

virtual void stopRender( QgsSymbolRenderContext &context );

virtual void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context );

virtual QVariantMap properties() const;

virtual QgsLineburstSymbolLayer *clone() const /Factory/;

virtual void setOutputUnit( QgsUnitTypes::RenderUnit unit );

virtual QgsUnitTypes::RenderUnit outputUnit() const;

virtual bool usesMapUnits() const;

virtual void setMapUnitScale( const QgsMapUnitScale &scale );

virtual QgsMapUnitScale mapUnitScale() const;

virtual double estimateMaxBleed( const QgsRenderContext &context ) const;


Qgis::GradientColorSource gradientColorType() const;
%Docstring
Sets the pen join ``style`` used to render the line (e.g. miter, bevel, round, etc).
Returns the gradient color mode, which controls how gradient color stops are created.

.. seealso:: :py:func:`penJoinStyle`
.. seealso:: :py:func:`setGradientColorType`
%End

Qt::PenCapStyle penCapStyle() const;
void setGradientColorType( Qgis::GradientColorSource gradientColorType );
%Docstring
Returns the pen cap style used to render the line (e.g. flat, square, round, etc).
Sets the gradient color mode, which controls how gradient color stops are created.

.. seealso:: :py:func:`setPenCapStyle`
.. seealso:: :py:func:`gradientColorType`
%End

void setPenCapStyle( Qt::PenCapStyle style );
QgsColorRamp *colorRamp();
%Docstring
Sets the pen cap ``style`` used to render the line (e.g. flat, square, round, etc).
Returns the color ramp used for the gradient line. This is only
used if the gradient color type is set to ColorRamp.

.. seealso:: :py:func:`penCapStyle`
.. seealso:: :py:func:`setColorRamp`

.. seealso:: :py:func:`gradientColorType`
%End

void setColorRamp( QgsColorRamp *ramp /Transfer/ );
%Docstring
Sets the color ramp used for the gradient line. This is only
used if the gradient color type is set to ColorRamp.

:param ramp: color ramp. Ownership is transferred.

.. seealso:: :py:func:`colorRamp`

.. seealso:: :py:func:`setGradientColorType`
%End

QColor color2() const;
%Docstring
Returns the color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor.

.. seealso:: :py:func:`setColor2`
%End

void setColor2( const QColor &color2 );
%Docstring
Sets the color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor.

.. seealso:: :py:func:`color2`
%End

protected:

@@ -56,6 +56,8 @@ class QgsSymbolLayer
sipType = sipType_QgsInterpolatedLineSymbolLayer;
else if ( sipCpp->layerType() == "RasterLine" )
sipType = sipType_QgsRasterLineSymbolLayer;
else if ( sipCpp->layerType() == "Lineburst" )
sipType = sipType_QgsLineburstSymbolLayer;
else
sipType = sipType_QgsLineSymbolLayer;
break;
@@ -616,6 +616,48 @@ Creates a new QgsRasterLineSymbolLayerWidget.




class QgsLineburstSymbolLayerWidget : QgsSymbolLayerWidget
{
%Docstring(signature="appended")
Widget for configuring :py:class:`QgsLineburstSymbolLayer` symbol layers.

.. versionadded:: 3.24
%End

%TypeHeaderCode
#include "qgssymbollayerwidget.h"
%End
public:

QgsLineburstSymbolLayerWidget( QgsVectorLayer *vl, QWidget *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsLineburstSymbolLayerWidget.

:param vl: associated vector layer
:param parent: parent widget
%End

static QgsSymbolLayerWidget *create( QgsVectorLayer *vl ) /Factory/;
%Docstring
Creates a new QgsLineburstSymbolLayerWidget.

:param vl: associated vector layer
%End

virtual void setSymbolLayer( QgsSymbolLayer *layer );

virtual QgsSymbolLayer *symbolLayer();


protected:


};




class QgsSVGFillSymbolLayerWidget : QgsSymbolLayerWidget
{

Loading

0 comments on commit 4a4e006

Please sign in to comment.