Skip to content

Commit

Permalink
[FEATURE][MESH] 1D mesh width/color varying (#35926)
Browse files Browse the repository at this point in the history
Introduce a renderer for 1D mesh edges that can vary width over the line. The line can also have different color based on the actual dataset value on the line's point.

Co-authored-by: Peter Petrik <zilolv@gmail.com>
  • Loading branch information
vcloarec and PeterPetrik committed Apr 24, 2020
1 parent 2cdd2ee commit f8fae3c
Show file tree
Hide file tree
Showing 29 changed files with 1,876 additions and 371 deletions.
3 changes: 1 addition & 2 deletions python/3d/auto_generated/qgslayoutitem3dmap.sip.in
Expand Up @@ -9,15 +9,14 @@




// this is needed for the "convert to subclass" code below to compile
%ModuleHeaderCode
#include "qgslayoutitem3dmap.h"
%End



class QgsLayoutItem3DMap : QgsLayoutItem
class QgsLayoutItem3DMap : QgsLayoutItem, QgsTemporalRangeObject
{
%Docstring

Expand Down
52 changes: 25 additions & 27 deletions python/core/auto_generated/mesh/qgsmeshrenderersettings.sip.in
Expand Up @@ -152,41 +152,41 @@ Sets data interpolation method
.. versionadded:: 3.12
%End

QDomElement writeXml( QDomDocument &doc ) const;
QgsInterpolatedLineWidth edgeStrokeWidth() const;
%Docstring
Writes configuration to a new DOM element
%End
void readXml( const QDomElement &elem );
%Docstring
Reads configuration from the given DOM element
Returns the stroke width used to render edges scalar dataset

.. versionadded:: 3.14
%End

double edgeWidth() const;
void setEdgeStrokeWidth( const QgsInterpolatedLineWidth &strokeWidth );
%Docstring
Returns width of the edge
Sets the stroke width used to render edges scalar dataset

.. versionadded:: 3.14
%End

void setEdgeWidth( double edgeWidth );
QgsUnitTypes::RenderUnit edgeStrokeWidthUnit() const;
%Docstring
Sets width of the edge
Returns the stroke width unit used to render edges scalar dataset

.. versionadded:: 3.14
%End

QgsUnitTypes::RenderUnit edgeWidthUnit() const;
void setEdgeStrokeWidthUnit( const QgsUnitTypes::RenderUnit &edgeStrokeWidthUnit );
%Docstring
Returns length units of the width of the edge
Sets the stroke width unit used to render edges scalar dataset

.. versionadded:: 3.14
%End

void setEdgeWidthUnit( const QgsUnitTypes::RenderUnit &edgeWidthUnit );
QDomElement writeXml( QDomDocument &doc ) const;
%Docstring
Sets length units of the width of the edge

.. versionadded:: 3.14
Writes configuration to a new DOM element
%End
void readXml( const QDomElement &elem );
%Docstring
Reads configuration from the given DOM element
%End

};
Expand Down Expand Up @@ -449,15 +449,6 @@ Represents a renderer settings for vector datasets
Traces
};

enum ColoringMethod
{
//! Render the vector with a single color
SingleColor,
//! Render the vector with a color ramp
ColorRamp
};


double lineWidth() const;
%Docstring
Returns line width of the arrow (in millimeters)
Expand Down Expand Up @@ -545,14 +536,14 @@ Sets the displaying method used to render vector datasets
.. versionadded:: 3.12
%End

ColoringMethod coloringMethod() const;
QgsInterpolatedLineColor::ColoringMethod coloringMethod() const;
%Docstring
Returns the coloring method used to render vector datasets

.. versionadded:: 3.14
%End

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

Expand All @@ -570,6 +561,13 @@ Sets the color ramp shader used to render vector datasets
%Docstring
Returns the color ramp shader used to render vector datasets

.. versionadded:: 3.14
%End

QgsInterpolatedLineColor vectorStrokeColoring() const;
%Docstring
Returns the stroke coloring used to render vector datasets

.. versionadded:: 3.14
%End

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




class QgsInterpolatedLineColor
{
%Docstring

Class defining color to render mesh datasets. The color can vary depending on the dataset value.

.. versionadded:: 3.14
%End

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

enum ColoringMethod
{
//! Render with a single color
SingleColor,
//! Render with a color ramp
ColorRamp
};

QgsInterpolatedLineColor();
%Docstring
Default constructor
%End
QgsInterpolatedLineColor( const QgsColorRampShader &colorRampShader );
%Docstring
Constructor with variable color depending on magnitude
%End
QgsInterpolatedLineColor( const QColor &color );
%Docstring
Constructor with fixed color
%End

void setColor( const QgsColorRampShader &colorRampShader );
%Docstring
Sets the color ramp to define the coloring
%End

void setColor( const QColor &color );
%Docstring
Sets the single color to define the coloring
%End

QColor color( double magnitude ) const;
%Docstring
Returns the color corresponding to the magnitude
%End

QgsInterpolatedLineColor::ColoringMethod coloringMethod() const;
%Docstring
Returns the coloring method used
%End

QgsColorRampShader colorRampShader() const;
%Docstring
Returns the color ramp shader
%End

QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
%Docstring
Writes configuration to a new DOM element
%End
void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
%Docstring
Reads configuration from the given DOM element
%End

void graduatedColors( double value1, double value2, QList<double> &breakValues, QList<QColor> &breakColors, QList<QLinearGradient> &gradients ) const;
%Docstring
Returns the break values, graduated colors and the associated gradients between two values
- If the color is fixed or only one color for the interval (value1, value2), returns only one color in ``breakColors``
and void lists for ``breakValues``, ``gradients``
- If the color ramp is classified with 'exact', returns void ``gradients``
- If the color ramp is classified with 'discrete', return ``gradients`` with uniform colors
- if nothing to render (out of range), return all lists void
%End

};

class QgsInterpolatedLineWidth
{
%Docstring

Represents a width than can vary depending on values

.. versionadded:: 3.14
%End

%TypeHeaderCode
#include "qgsinterpolatedlinerenderer.h"
%End
public:
double minimumValue() const;
%Docstring
Returns the minimum value used to defined the variable width
%End
void setMinimumValue( double minimumValue );
%Docstring
Sets the minimum value used to defined the variable width
%End

double maximumValue() const;
%Docstring
Returns the maximum value used to defined the variable width
%End
void setMaximumValue( double maximumValue );
%Docstring
Sets the maximum value used to defined the variable width
%End

double minimumWidth() const;
%Docstring
Returns the minimum width used to defined the variable width
%End
void setMinimumWidth( double minimumWidth );
%Docstring
Sets the minimum width used to defined the variable width
%End

double maximumWidth() const;
%Docstring
Returns the maximum width used to defined the variable width
%End
void setMaximumWidth( double maximumWidth );
%Docstring
Sets the maximum width used to defined the variable width
%End

bool ignoreOutOfRange() const;
%Docstring
Returns whether the variable width ignores out of range value
%End
void setIgnoreOutOfRange( bool ignoreOutOfRange );
%Docstring
Sets whether the variable width ignores out of range value
%End

bool isVariableWidth() const;
%Docstring
Returns whether the width is variable
%End
void setIsVariableWidth( bool isVariableWidth );
%Docstring
Returns whether the width is variable
%End

double fixedStrokeWidth() const;
%Docstring
Returns the fixed width
%End
void setFixedStrokeWidth( double fixedWidth );
%Docstring
Sets the fixed width
%End

double strokeWidth( double value ) const;
%Docstring
Returns the variable width depending on value, if not varying returns the fixed width
%End

QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
%Docstring
Writes configuration to a new DOM element
%End
void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
%Docstring
Reads configuration from the given DOM element
%End

};

class QgsInterpolatedLineRenderer
{
%Docstring
Represents a line with width and color varying depending on values.

.. versionadded:: 3.14
%End

%TypeHeaderCode
#include "qgsinterpolatedlinerenderer.h"
%End
public:
void setInterpolatedWidth( const QgsInterpolatedLineWidth &strokeWidth );
%Docstring
Sets the stroke width used to plot
%End

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

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

void setOpacity( double opacity );
%Docstring
Sets the opacity used to plot
%End

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

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/symbology/qgsinterpolatedlinerenderer.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
5 changes: 3 additions & 2 deletions python/core/core_auto.sip
Expand Up @@ -410,15 +410,15 @@
%Include auto_generated/locator/qgslocatormodelbridge.sip
%Include auto_generated/mesh/qgsmesh3daveraging.sip
%Include auto_generated/mesh/qgsmeshdataprovider.sip
%Include auto_generated/mesh/qgsmeshdataprovidertemporalcapabilities.sip
%Include auto_generated/mesh/qgsmeshdataset.sip
%Include auto_generated/mesh/qgsmeshlayer.sip
%Include auto_generated/mesh/qgsmeshlayerinterpolator.sip
%Include auto_generated/mesh/qgsmeshlayertemporalproperties.sip
%Include auto_generated/mesh/qgsmeshrenderersettings.sip
%Include auto_generated/mesh/qgsmeshspatialindex.sip
%Include auto_generated/mesh/qgsmeshtimesettings.sip
%Include auto_generated/mesh/qgsmeshtracerenderer.sip
%Include auto_generated/mesh/qgsmeshlayertemporalproperties.sip
%Include auto_generated/mesh/qgsmeshdataprovidertemporalcapabilities.sip
%Include auto_generated/metadata/qgsabstractmetadatabase.sip
%Include auto_generated/metadata/qgslayermetadata.sip
%Include auto_generated/metadata/qgslayermetadataformatter.sip
Expand Down Expand Up @@ -518,6 +518,7 @@
%Include auto_generated/symbology/qgsgeometrygeneratorsymbollayer.sip
%Include auto_generated/symbology/qgsgraduatedsymbolrenderer.sip
%Include auto_generated/symbology/qgsheatmaprenderer.sip
%Include auto_generated/symbology/qgsinterpolatedlinerenderer.sip
%Include auto_generated/symbology/qgsinvertedpolygonrenderer.sip
%Include auto_generated/symbology/qgslegendsymbolitem.sip
%Include auto_generated/symbology/qgslinesymbollayer.sip
Expand Down
1 change: 1 addition & 0 deletions src/app/CMakeLists.txt
Expand Up @@ -220,6 +220,7 @@ SET(QGIS_APP_SRCS
mesh/qgsmeshdatasetgrouptreeview.cpp
mesh/qgsmeshcalculatordialog.cpp
mesh/qgsmeshstaticdatasetwidget.cpp
mesh/qgsmeshvariablestrokewidthwidget.cpp
)

IF (WITH_3D)
Expand Down
2 changes: 1 addition & 1 deletion src/app/mesh/qgsmeshdatasetgrouptreeview.h
Expand Up @@ -200,7 +200,7 @@ class APP_EXPORT QgsMeshDatasetGroupTreeView : public QTreeView
QgsMeshLayer *mMeshLayer = nullptr; // not owned
};

class QgsMeshDatasetGroupListModel: public QAbstractListModel
class APP_EXPORT QgsMeshDatasetGroupListModel: public QAbstractListModel
{
public:
explicit QgsMeshDatasetGroupListModel( QObject *parent ): QAbstractListModel( parent )
Expand Down

0 comments on commit f8fae3c

Please sign in to comment.