Skip to content
Permalink
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/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. +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/test_qgsrasterlinesymbollayer.py
  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 ...data/control_images/symbol_rasterline/expected_rasterline_flatcap/expected_rasterline_flatcap.png
  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 ...data/control_images/symbol_rasterline/expected_rasterline_opacity/expected_rasterline_opacity.png
  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
{
%Docstring(signature="appended")

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

.. versionadded:: 3.24
%End

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

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

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

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

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

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

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

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

double opacity() const;
%Docstring
Returns the line opacity.

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

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

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

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

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

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;
%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:

};



/************************************************************************
@@ -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;
else
sipType = sipType_QgsLineSymbolLayer;
break;
@@ -574,6 +574,48 @@ Creates a new QgsRasterFillSymbolLayerWidget.




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

.. versionadded:: 3.24
%End

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

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

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

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

:param vl: associated vector layer
%End

virtual void setSymbolLayer( QgsSymbolLayer *layer );

virtual QgsSymbolLayer *symbolLayer();


protected:


};




class QgsSVGFillSymbolLayerWidget : QgsSymbolLayerWidget
{

Loading

0 comments on commit 0667363

Please sign in to comment.