Skip to content
Browse files
[feature][symbology] New "Raster Line" symbol layer type
This new symbol layer type renders a raster image following
a line feature's shape.

Options are present for:
- picture path (including data defined path)
- line width
- opacity
- line join/cap styles

Sponsored by North Road, thanks to SLYR
  • Loading branch information
nyalldawson committed Oct 28, 2021
1 parent 3a7d855 commit 066736326104261b53d4afca8c776591ddcb9fcb
Showing with 1,645 additions and 0 deletions.
  1. +123 −0 python/core/auto_generated/symbology/
  2. +2 −0 python/core/auto_generated/symbology/
  3. +42 −0 python/gui/auto_generated/symbology/
  4. +562 −0 src/core/symbology/qgslinesymbollayer.cpp
  5. +111 −0 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. +182 −0 src/gui/symbology/qgssymbollayerwidget.cpp
  10. +46 −0 src/gui/symbology/qgssymbollayerwidget.h
  11. +325 −0 src/ui/symbollayer/widget_rasterline.ui
  12. +1 −0 tests/src/python/CMakeLists.txt
  13. +246 −0 tests/src/python/
  14. BIN .../control_images/symbol_rasterline/expected_rasterline_beveljoin/expected_rasterline_beveljoin.png
  15. BIN ...stdata/control_images/symbol_rasterline/expected_rasterline_closed/expected_rasterline_closed.png
  16. BIN
  17. BIN .../control_images/symbol_rasterline/expected_rasterline_miterjoin/expected_rasterline_miterjoin.png
  18. BIN ...stdata/control_images/symbol_rasterline/expected_rasterline_offset/expected_rasterline_offset.png
  19. BIN
  20. BIN ...stdata/control_images/symbol_rasterline/expected_rasterline_render/expected_rasterline_render.png
  21. BIN .../control_images/symbol_rasterline/expected_rasterline_squarecap/expected_rasterline_squarecap.png
  22. BIN tests/testdata/raster_brush.png
@@ -1170,6 +1170,129 @@ Returns the map unit scale for the hash length.
QgsHashedLineSymbolLayer( const QgsHashedLineSymbolLayer &other );

class QgsRasterLineSymbolLayer : QgsLineSymbolLayer

Line symbol layer type which draws line sections using a raster image file.

.. versionadded:: 3.24

#include "qgslinesymbollayer.h"

QgsRasterLineSymbolLayer( const QString &path = QString() );
Constructor for QgsRasterLineSymbolLayer, with the specified raster image path.
virtual ~QgsRasterLineSymbolLayer();

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

static void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving );
Turns relative paths in properties map to absolute when reading and vice versa when writing.
Used internally when reading/writing symbols.

QString path() const;
Returns the raster image path.

.. seealso:: :py:func:`setPath`

void setPath( const QString &path );
Set the raster image ``path``.

.. seealso:: :py:func:`path`

double opacity() const;
Returns the line opacity.

:return: opacity value between 0 (fully transparent) and 1 (fully opaque)

.. seealso:: :py:func:`setOpacity`

void setOpacity( double opacity );
Set the line opacity.

:param opacity: opacity value between 0 (fully transparent) and 1 (fully opaque)

.. seealso:: :py:func:`opacity`

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 QgsRasterLineSymbolLayer *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;

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

.. seealso:: :py:func:`setPenJoinStyle`

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

.. seealso:: :py:func:`penJoinStyle`

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

.. seealso:: :py:func:`setPenCapStyle`

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

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



@@ -54,6 +54,8 @@ class QgsSymbolLayer
sipType = sipType_QgsArrowSymbolLayer;
else if ( sipCpp->layerType() == "InterpolatedLine" )
sipType = sipType_QgsInterpolatedLineSymbolLayer;
else if ( sipCpp->layerType() == "RasterLine" )
sipType = sipType_QgsRasterLineSymbolLayer;
sipType = sipType_QgsLineSymbolLayer;
@@ -574,6 +574,48 @@ Creates a new QgsRasterFillSymbolLayerWidget.

class QgsRasterLineSymbolLayerWidget : QgsSymbolLayerWidget
Widget for configuring :py:class:`QgsRasterLineSymbolLayer` symbol layers.

.. versionadded:: 3.24

#include "qgssymbollayerwidget.h"

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

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

static QgsSymbolLayerWidget *create( QgsVectorLayer *vl ) /Factory/;
Creates a new QgsRasterLineSymbolLayerWidget.

:param vl: associated vector layer

virtual void setSymbolLayer( QgsSymbolLayer *layer );

virtual QgsSymbolLayer *symbolLayer();



class QgsSVGFillSymbolLayerWidget : QgsSymbolLayerWidget


0 comments on commit 0667363

Please sign in to comment.