Skip to content
Permalink
Browse files

Mesh export processes, first part : infrastructure and export vertices (

#39664)

[processing] Infrastructure for QgsMeshLayer to add processing algorithms, dataset group paramater and dataset time parameter to allow the user to easily choose a dataset.
  • Loading branch information
vcloarec committed Nov 3, 2020
1 parent a1fcc7d commit 1fbba79a0fc94e6474c4fedb4da03d8018c66a99
Showing with 2,723 additions and 19 deletions.
  1. +1 −1 python/core/auto_generated/mesh/qgsmeshlayer.sip.in
  2. +18 −0 python/core/auto_generated/processing/qgsprocessingcontext.sip.in
  3. +180 −0 python/core/auto_generated/processing/qgsprocessingparametermeshdataset.sip.in
  4. +5 −0 python/core/auto_generated/processing/qgsprocessingparameters.sip.in
  5. +1 −0 python/core/core_auto.sip
  6. +3 −0 python/plugins/processing/tools/dataobjects.py
  7. +1 −0 src/analysis/CMakeLists.txt
  8. +291 −0 src/analysis/processing/qgsalgorithmexportmeshvertices.cpp
  9. +62 −0 src/analysis/processing/qgsalgorithmexportmeshvertices.h
  10. +2 −0 src/analysis/processing/qgsnativealgorithms.cpp
  11. +2 −0 src/core/CMakeLists.txt
  12. +0 −1 src/core/mesh/qgsmeshdataprovidertemporalcapabilities.cpp
  13. +1 −1 src/core/mesh/qgsmeshlayer.h
  14. +29 −8 src/core/mesh/qgsmeshlayerutils.cpp
  15. +33 −2 src/core/mesh/qgsmeshlayerutils.h
  16. +1 −1 src/core/mesh/qgsmeshtimesettings.h
  17. +10 −0 src/core/processing/qgsprocessingcontext.cpp
  18. +18 −0 src/core/processing/qgsprocessingcontext.h
  19. +293 −0 src/core/processing/qgsprocessingparametermeshdataset.cpp
  20. +258 −0 src/core/processing/qgsprocessingparametermeshdataset.h
  21. +5 −0 src/core/processing/qgsprocessingparameters.h
  22. +3 −0 src/core/processing/qgsprocessingregistry.cpp
  23. +12 −0 src/core/processing/qgsprocessingutils.cpp
  24. +2 −0 src/gui/CMakeLists.txt
  25. +3 −0 src/gui/processing/qgsprocessingguiregistry.cpp
  26. +686 −0 src/gui/processing/qgsprocessingmeshdatasetwidget.cpp
  27. +183 −0 src/gui/processing/qgsprocessingmeshdatasetwidget.h
  28. +0 −1 src/gui/processing/qgsprocessingwidgetwrapperimpl.h
  29. +72 −0 src/ui/processing/qgsprocessingmeshdatasettimewidget.ui
  30. +1 −3 src/ui/qgstemporalcontrollerwidgetbase.ui
  31. +140 −0 tests/src/analysis/testqgsprocessing.cpp
  32. +97 −0 tests/src/analysis/testqgsprocessingalgs.cpp
  33. +1 −1 tests/src/app/testqgsmaptoolidentifyaction.cpp
  34. +309 −0 tests/src/gui/testprocessinggui.cpp
@@ -257,7 +257,7 @@ Returns the extra dataset groups count handle by the layer

QList<int> datasetGroupsIndexes() const;
%Docstring
Returns the list of indexes of dataset groups count handled by the layer
Returns the list of indexes of dataset groups handled by the layer

.. note::

@@ -173,6 +173,24 @@ If not explicitly set, the unit will default to the :py:func:`~QgsProcessingCont
.. seealso:: :py:func:`setDistanceUnit`

.. versionadded:: 3.16
%End

QgsDateTimeRange currentTimeRange() const;
%Docstring
Returns the current time range to use for temporal operations.

.. seealso:: :py:func:`setCurrentTimeRange`

.. versionadded:: 3.18
%End

void setCurrentTimeRange( const QgsDateTimeRange &currentTimeRange );
%Docstring
Sets the ``current`` time range to use for temporal operations.

.. seealso:: :py:func:`currentTimeRange`

.. versionadded:: 3.18
%End

QgsMapLayerStore *temporaryLayerStore();
@@ -0,0 +1,180 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/processing/qgsprocessingparametermeshdataset.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/



class QgsProcessingParameterMeshDatasetGroups : QgsProcessingParameterDefinition
{
%Docstring
A parameter for processing algorithms that need a list of mesh dataset groups
A valid value for this parameter is a list (QVariantList) of dataset groups index in the mesh layer scope
Dataset group index can be evaluated with the method :py:func:`~valueAsDatasetGroup`

.. note::

This parameter is dependent on a mesh layer parameter (see QgsProcessingParameterMeshLayer)

.. versionadded:: 3.18
%End

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

QgsProcessingParameterMeshDatasetGroups( const QString &name,
const QString &description = QString(),
const QString &meshLayerParameterName = QString(),
QgsMeshDatasetGroupMetadata::DataType dataType = QgsMeshDatasetGroupMetadata::DataOnVertices,
bool optional = false );
%Docstring
Constructor

:param name: name of the parameter
:param description: description of the parameter
:param meshLayerParameterName: name of the associated mesh layer parameter
:param dataType: data type supported by the parameter
:param optional: whether the parameter is optional
%End

virtual QgsProcessingParameterDefinition *clone() const /Factory/;

virtual QString type() const;

virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;

virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;

virtual QString asPythonString( QgsProcessing::PythonOutputType outputType = QgsProcessing::PythonQgsProcessingAlgorithmSubclass ) const;

virtual QStringList dependsOnOtherParameters() const;


static QString typeName();
%Docstring
Returns the type name for the parameter class.
%End

QString meshLayerParameterName() const;
%Docstring
Returns the name of the mesh layer parameter
%End

QgsMeshDatasetGroupMetadata::DataType dataType() const;
%Docstring
Returns the data type supported by the parameter
%End

static QList<int> valueAsDatasetGroup( const QVariant &value );
%Docstring
Returns the ``value`` as a list if dataset group indexes
%End

};


class QgsProcessingParameterMeshDatasetTime : QgsProcessingParameterDefinition
{
%Docstring
A parameter for processing algorithms that need a list of mesh dataset index from time parameter
A valid value for this parameter is a map (QVariantMap) with in this form:

- "type" : the type of time settings "current-context-time", "defined-date-time", "dataset-time-step" or "none" if all the dataset groups are static
- "value" : nothing if type is "static" or "current-context-time", QDateTime if "defined-date-time" or, for "dataset_time_step", list of two int representing the dataset index that is the reference for the time step

.. note::

This parameter is dependent on a mesh layer parameter (:py:class:`QgsProcessingParameterMeshLayer`)
and on mesh datast group parameter (:py:class:`QgsProcessingParameterMeshDatasetGroups`)

.. versionadded:: 3.18
%End

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

QgsProcessingParameterMeshDatasetTime(
const QString &name,
const QString &description = QString(),
const QString &meshLayerParameterName = QString(),
const QString &datasetGroupParameterName = QString() );
%Docstring
Constructor

:param name: name of the parameter
:param description: description of the parameter
:param meshLayerParameterName: name of the associated mesh layer parameter (:py:class:`QgsProcessingParameterMeshLayer`)
:param datasetGroupParameterName: name of the associated dataset group parameter (:py:class:`QgsProcessingParameterMeshDatasetGroups`)
%End

virtual QgsProcessingParameterDefinition *clone() const /Factory/;

virtual QString type() const;

virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;

virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;

virtual QString asPythonString( QgsProcessing::PythonOutputType outputType = QgsProcessing::PythonQgsProcessingAlgorithmSubclass ) const;

virtual QStringList dependsOnOtherParameters() const;


static QString typeName();
%Docstring
Returns the type name for the parameter class.
%End

QString meshLayerParameterName() const;
%Docstring
Returns the name of the mesh layer parameter
%End

QString datasetGroupParameterName() const;
%Docstring
Returns the name of the dataset groups parameter
%End

static QString valueAsTimeType( const QVariant &value );
%Docstring
Returns the ``dataset`` value time type as a string :
current-context-time : the time is store in the processing context (e.g. current canvas time), in this case the value does not contain any time value
defined-date-time : absolute time of type QDateTime
dataset-time-step : a time step of existing dataset, in this case the time takes the form of a QMeshDatasetIndex with value to the corresponding dataset index
static : dataset groups are all static, in this case the value does not contain any time value
%End

static QgsMeshDatasetIndex timeValueAsDatasetIndex( const QVariant &value );
%Docstring
Returns the ``value`` as a QgsMeshDatasetIndex if the value has "dataset-time-step" type.
If the value has the wrong type return an invalid dataset index

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

static QDateTime timeValueAsDefinedDateTime( const QVariant &value );
%Docstring
Returns the ``value`` as a QDateTime if the value has "defined-date-time" type.
If the value has the wrong type return an invalid QDatetime

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

};



/************************************************************************
* This file has been generated automatically from *
* *
* src/core/processing/qgsprocessingparametermeshdataset.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -230,6 +230,7 @@ their acceptable ranges, defaults, etc.
#include "qgsprocessingparameterfieldmap.h"
#include "qgsprocessingparametertininputlayers.h"
#include "qgsprocessingparametervectortilewriterlayers.h"
#include "qgsprocessingparametermeshdataset.h"
%End
%ConvertToSubClassCode
if ( sipCpp->type() == QgsProcessingParameterBoolean::typeName() )
@@ -314,6 +315,10 @@ their acceptable ranges, defaults, etc.
sipType = sipType_QgsProcessingParameterVectorTileWriterLayers;
else if ( sipCpp->type() == QgsProcessingParameterDxfLayers::typeName() )
sipType = sipType_QgsProcessingParameterDxfLayers;
else if ( sipCpp->type() == QgsProcessingParameterMeshDatasetGroups::typeName() )
sipType = sipType_QgsProcessingParameterMeshDatasetGroups;
else if ( sipCpp->type() == QgsProcessingParameterMeshDatasetTime::typeName() )
sipType = sipType_QgsProcessingParameterMeshDatasetTime;
else
sipType = nullptr;
%End
@@ -477,6 +477,7 @@
%Include auto_generated/processing/qgsprocessingparameteraggregate.sip
%Include auto_generated/processing/qgsprocessingparameterdxflayers.sip
%Include auto_generated/processing/qgsprocessingparameterfieldmap.sip
%Include auto_generated/processing/qgsprocessingparametermeshdataset.sip
%Include auto_generated/processing/qgsprocessingparameters.sip
%Include auto_generated/processing/qgsprocessingparametertininputlayers.sip
%Include auto_generated/processing/qgsprocessingparametertype.sip
@@ -76,6 +76,9 @@ def createContext(feedback=None):

context.setExpressionContext(createExpressionContext())

if iface and iface.mapCanvas() and iface.mapCanvas().mapSettings().isTemporal():
context.setCurrentTimeRange(iface.mapCanvas().mapSettings().temporalRange())

return context


@@ -61,6 +61,7 @@ SET(QGIS_ANALYSIS_SRCS
processing/qgsalgorithmexecutespatialitequeryregistered.cpp
processing/qgsalgorithmexplode.cpp
processing/qgsalgorithmexplodehstore.cpp
processing/qgsalgorithmexportmeshvertices.cpp
processing/qgsalgorithmextendlines.cpp
processing/qgsalgorithmextentfromlayer.cpp
processing/qgsalgorithmextenttolayer.cpp

0 comments on commit 1fbba79

Please sign in to comment.
You can’t perform that action at this time.