Skip to content

Commit

Permalink
interpolated line symbol layer
Browse files Browse the repository at this point in the history
  • Loading branch information
vcloarec authored and wonder-sk committed May 5, 2021
1 parent 02685f1 commit 9a3ad85
Show file tree
Hide file tree
Showing 29 changed files with 2,232 additions and 56 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -951,7 +951,7 @@ if (WITH_CORE AND WITH_BINDINGS AND NOT WITH_QT6)
include(SIPMacros)

set(SIP_INCLUDES ${PYQT_SIP_DIR} ${CMAKE_SOURCE_DIR}/python)
set(SIP_CONCAT_PARTS 11)
set(SIP_CONCAT_PARTS 12)

if (NOT BINDINGS_GLOBAL_INSTALL)
set(Python_SITEARCH ${QGIS_DATA_DIR}/python)
Expand Down
15 changes: 15 additions & 0 deletions python/core/auto_generated/raster/qgscolorrampshader.sip.in
Expand Up @@ -234,6 +234,21 @@ Ownership of ``settings`` is transferred.
.. versionadded:: 3.18
%End


QVariantMap properties() const;
%Docstring
Returns a string map that contains the configuration information for a symbol layer.

.. versionadded:: 3.20
%End

static QgsColorRampShader createFromSymbolLayerProperties( const QVariantMap &properties );
%Docstring
Creates a color ramp sahder from symbol layer properties

.. versionadded:: 3.20
%End

protected:


Expand Down
Expand Up @@ -8,7 +8,7 @@



class QgsGeometryGeneratorSymbolLayer : QgsSymbolLayer
class QgsGeometryGeneratorSymbolLayer : QgsHybridSymbolLayer
{

%TypeHeaderCode
Expand Down Expand Up @@ -90,6 +90,7 @@ care about the geometry of its parents.
%End

virtual void render( QgsSymbolRenderContext &context );

%Docstring
Will render this symbol layer using the context.
In comparison to other symbols there is no geometry passed in, since
Expand Down
Expand Up @@ -9,6 +9,7 @@




class QgsInterpolatedLineColor
{
%Docstring(signature="appended")
Expand Down Expand Up @@ -57,6 +58,13 @@ Sets the single color to define the coloring
QColor color( double magnitude ) const;
%Docstring
Returns the color corresponding to the magnitude
%End

void setColoringMethod( const QgsInterpolatedLineColor::ColoringMethod &coloringMethod );
%Docstring
Sets the coloring method used

.. versionadded:: 3.20
%End

QgsInterpolatedLineColor::ColoringMethod coloringMethod() const;
Expand All @@ -67,6 +75,13 @@ Returns the coloring method used
QgsColorRampShader colorRampShader() const;
%Docstring
Returns the color ramp shader
%End

QColor singleColor() const;
%Docstring
Returns the single color that is used if SingleColor coloring mode is set

.. versionadded:: 3.20
%End

QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
Expand Down Expand Up @@ -195,7 +210,7 @@ Reads configuration from the given DOM element
class QgsInterpolatedLineRenderer
{
%Docstring(signature="appended")
Represents a line with width and color varying depending on values.
Represents a simple line renderer with width and color varying depending on values.

.. versionadded:: 3.14
%End
Expand All @@ -204,29 +219,181 @@ Represents a line with width and color varying depending on values.
#include "qgsinterpolatedlinerenderer.h"
%End
public:

void setInterpolatedWidth( const QgsInterpolatedLineWidth &strokeWidth );
%Docstring
Sets the stroke width used to plot
Sets the stroke width used to render
%End

QgsInterpolatedLineWidth interpolatedLineWidth() const;
%Docstring
Returns the stroke width used to render

.. versionadded:: 3.20
%End

void setWidthUnit( const QgsUnitTypes::RenderUnit &strokeWidthUnit );
%Docstring
Sets the unit of the stroke width
%End

QgsUnitTypes::RenderUnit widthUnit() const;
%Docstring
Returns the unit of the stroke width

.. versionadded:: 3.20
%End

void setInterpolatedColor( const QgsInterpolatedLineColor &strokeColoring );
%Docstring
Sets the stroke color used to plot
Sets the stroke color used to render
%End

QgsInterpolatedLineColor interpolatedColor() const;
%Docstring
Returns the stroke color used to render

.. versionadded:: 3.20
%End

void render( double value1, double value2, QgsPointXY point1, QgsPointXY point2, QgsRenderContext &context ) const;
void render( double value1, double value2, const QgsPointXY &point1, const QgsPointXY &point2, QgsRenderContext &context ) const;
%Docstring
Render a line in the ``context`` between ``point1`` and ``point2``
Renders a line in the ``context`` between ``point1`` and ``point2``
with color and width that vary depending on ``value1`` and ``value2``
%End

void render( double valueColor1, double valueColor2, double valueWidth1, double valueWidth2, const QgsPointXY &point1, const QgsPointXY &point2, QgsRenderContext &context ) const;
%Docstring
Renders a line in the ``context`` between ``point1`` and ``point2``
with color that varies depending on ``valueColor1`` and ``valueColor2`` and and width that varies between ``valueWidth1`` and ``valueWidth2``

.. versionadded:: 3.20
%End

void setSelected( bool selected );
%Docstring
Sets if the rendering must be done as the element is selected

.. versionadded:: 3.20
%End

};

class QgsInterpolatedLineSymbolLayer : QgsHybridSymbolLayer
{
%Docstring(signature="appended")
A symbol layer that represents vector layer line feature as interpolated line
The interpolation is done between two values defined at the extremities

.. versionadded:: 3.20
%End

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

QgsInterpolatedLineSymbolLayer();
%Docstring
Constructor
%End

static QgsSymbolLayer *create( const QVariantMap &properties ) /Factory/;
%Docstring
Creates the symbol layer
%End

virtual QString layerType() const;

virtual void startRender( QgsSymbolRenderContext &context );

virtual void stopRender( QgsSymbolRenderContext &context );

virtual QgsInterpolatedLineSymbolLayer *clone() const /Factory/;

virtual QVariantMap properties() const;

virtual void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size );


virtual void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context );

virtual void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context );

virtual void render( QgsSymbolRenderContext &context );

virtual bool isCompatibleWithSymbol( QgsSymbol *symbol ) const;

virtual QSet<QString> usedAttributes( const QgsRenderContext &context ) const;

virtual bool canCauseArtifactsBetweenAdjacentTiles() const;


void setExpressionsStringForWidth( QString start, QString end );
%Docstring
Sets the expressions (as string) that define the extremety values af the line feature for width
%End

QString startValueExpressionForWidth() const;
%Docstring
Returns the epression related to the start extremity value for width
%End

QString endValueExpressionForWidth() const;
%Docstring
Returns the expression related to the end extremity value for width
%End

void setWidthUnit( const QgsUnitTypes::RenderUnit &strokeWidthUnit );
%Docstring
Sets the width unit
%End

QgsUnitTypes::RenderUnit widthUnit() const;
%Docstring
Returns the width unit
%End

void setInterpolatedWidth( const QgsInterpolatedLineWidth &interpolatedLineWidth );
%Docstring
Sets the interpolated width used to render the width of lines, ``see`` :py:class:`QgsInterpolatedLineWidth`
%End

QgsInterpolatedLineWidth interpolatedWidth() const;
%Docstring
Returns the interpolated width used to render the width of lines, see ``:py:class:`QgsInterpolatedLineWidth```
%End

void setExpressionsStringForColor( QString start, QString end );
%Docstring
Sets the expressions (as string) that define the extremety values af the line feature for color
%End

QString startValueExpressionForColor() const;
%Docstring
Returns the epression related to the start extremity value for width for color
%End

QString endValueExpressionForColor() const;
%Docstring
Returns the expression related to the end extremity value for width for color
%End

void setInterpolatedColor( const QgsInterpolatedLineColor &interpolatedLineColor );
%Docstring
Sets the interpolated color used to render the colors of lines, ``see`` :py:class:`QgsInterpolatedLineColor`
%End

QgsInterpolatedLineColor interpolatedColor() const;
%Docstring
Returns the interpolated color used to render the colors of lines, see ``:py:class:`QgsInterpolatedLineColor```
%End

private:
QgsInterpolatedLineSymbolLayer( const QgsInterpolatedLineSymbolLayer &copy );
};


/************************************************************************
* This file has been generated automatically from *
* *
Expand Down
32 changes: 32 additions & 0 deletions python/core/auto_generated/symbology/qgssymbollayer.sip.in
Expand Up @@ -80,6 +80,8 @@ class QgsSymbolLayer
case QgsSymbol::Hybrid:
sipType = sipType_QgsGeometryGeneratorSymbolLayer;
break;
sipType = sipType_QgsInterpolatedLineSymbolLayer;
break;
}
%End
public:
Expand Down Expand Up @@ -1215,6 +1217,36 @@ Default method to render polygon
QgsFillSymbolLayer( const QgsFillSymbolLayer &other );
};

class QgsHybridSymbolLayer : QgsSymbolLayer
{
%Docstring(signature="appended")
:py:class:`QgsHybridSymbolLayer`

.. versionadded:: 3.20
%End

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


virtual void render( QgsSymbolRenderContext &context ) = 0;
%Docstring
Will render this symbol layer using the context.
In comparison to other symbols there is no geometry passed in

:param context: The rendering context which will be used to render
%End

protected:
QgsHybridSymbolLayer( bool locked = false );
%Docstring
Constructor
%End

};




Expand Down
@@ -0,0 +1,17 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/symbology/qgsinterpolatedlinesymbollayerwidget.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/



/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/symbology/qgsinterpolatedlinesymbollayerwidget.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
1 change: 1 addition & 0 deletions python/gui/gui_auto.sip
Expand Up @@ -395,6 +395,7 @@
%Include auto_generated/symbology/qgsgraduatedhistogramwidget.sip
%Include auto_generated/symbology/qgsgraduatedsymbolrendererwidget.sip
%Include auto_generated/symbology/qgsheatmaprendererwidget.sip
%Include auto_generated/symbology/qgsinterpolatedlinesymbollayerwidget.sip
%Include auto_generated/symbology/qgsinvertedpolygonrendererwidget.sip
%Include auto_generated/symbology/qgslayerpropertieswidget.sip
%Include auto_generated/symbology/qgsmergedfeaturerendererwidget.sip
Expand Down

0 comments on commit 9a3ad85

Please sign in to comment.