Skip to content

Commit

Permalink
[MESH][FEATURE] use only specified dataset group (#36334)
Browse files Browse the repository at this point in the history
[MESH][FEATURE] Allow to select only specific subset of dataset groups in mesh layer tree 

This could be done in the mesh layer properties dialog in the source tab.
A new tree view displays all the available dataset groups from the data provider. The dataset groups can be checked/unckecked and renamed.
This widget provides also buttons to load extra dataset group from files, to expand/collpase the tree, to check/unchek all items and to reset to default from the provider (for now, only the original name).
Then only the checked dataset group will be displayed in the active dataset widget in renderer settings.
  • Loading branch information
vcloarec committed May 14, 2020
1 parent 1135941 commit 838faf8
Show file tree
Hide file tree
Showing 22 changed files with 1,732 additions and 352 deletions.
1 change: 1 addition & 0 deletions images/images.qrc
Expand Up @@ -400,6 +400,7 @@
<file>themes/default/mActionSelectRadius.svg</file>
<file>themes/default/mActionSelectRectangle.svg</file>
<file>themes/default/mActionSelectAllTree.svg</file>
<file>themes/default/mActionDeselectAllTree.svg</file>
<file>themes/default/mActionSetProjection.svg</file>
<file>themes/default/mActionSetToCanvasExtent.svg</file>
<file>themes/default/mActionSetToCanvasScale.svg</file>
Expand Down
126 changes: 126 additions & 0 deletions images/themes/default/mActionDeselectAllTree.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
180 changes: 180 additions & 0 deletions python/core/auto_generated/mesh/qgsmeshdataset.sip.in
Expand Up @@ -549,6 +549,186 @@ Returns maximum number of vertical levels for 3d stacked meshes

};


class QgsMeshDatasetGroupTreeItem
{
%Docstring

Tree item for display of the mesh dataset groups.
Dataset group is set of datasets with the same name,
but different control variable (e.g. time)

Support for multiple levels, because groups can have
subgroups, for example

Groups:
Depth
Minimum
Maximum
Velocity
Wind speed
Minimum
Maximum

.. versionadded:: 3.14
%End

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

QgsMeshDatasetGroupTreeItem();
%Docstring
Constructor for an empty dataset group tree item
%End

QgsMeshDatasetGroupTreeItem( const QString &defaultName,
bool isVector,
int index );
%Docstring
Constructor

:param defaultName: the name that will be used to display the item if iot not overrides (:py:func:`setName`)
:param isVector: whether the dataset group is a vector dataset group
:param index: index of the dataset group
%End

QgsMeshDatasetGroupTreeItem( const QDomElement &itemElement, const QgsReadWriteContext &context );
%Docstring
Constructor from a DOM element, contruct also the children

:param itemElement: the DOM element
:param context: writing context (e.g. for conversion between relative and absolute paths)
%End

~QgsMeshDatasetGroupTreeItem();

QgsMeshDatasetGroupTreeItem *clone() const /Factory/;
%Docstring
Clones the item

:return: the cloned item
%End

void appendChild( QgsMeshDatasetGroupTreeItem *item /Transfer/ );
%Docstring
Appends a item child

:param item: the item to append

.. note::

takes ownership of item
%End

QgsMeshDatasetGroupTreeItem *child( int row ) const;
%Docstring
Returns a child

:param row: the position of the child

:return: the item at the positon ``row``
%End

QgsMeshDatasetGroupTreeItem *childFromDatasetGroupIndex( int index );
%Docstring
Returns the child with dataset group ``index``
Searches as depper as needed on the child hierarchy

:param index: the index of the dataset group index

:return: the item with index as dataset group index, None if no item is found
%End

int childCount() const;
%Docstring
Returns the count of children

:return: the children's count
%End

int totalChildCount() const;
%Docstring
Returns the total count of children, that is included deeper children

:return:
%End

QgsMeshDatasetGroupTreeItem *parentItem() const;
%Docstring
Returns the parent item, None if it is root item

:return: the parent item
%End

int row() const;
%Docstring
Returns the position of the item in the parent

:return: tow position of the item
%End

QString name() const;
%Docstring
Returns the name of the item
This mame is the default name if the name has not been overrided (:py:func:`setName`)

:return: the name to display
%End

void setName( const QString &name );
%Docstring
Overrides the default name with the name to display.
The default name is still stored in the item
but will not be displayed anymore except if the empty string is setted.

:param name: to display
%End

bool isVector() const;
%Docstring

:return: whether the dataset group is vector
%End

int datasetGroupIndex() const;
%Docstring

:return: the dataset group index
%End

bool isEnabled() const;
%Docstring

:return: whether the item is enabled, that is if it is displayed in view
%End

void setIsEnabled( bool isEnabled );
%Docstring
Sets whether the item is enabled, that is if it is displayed in view

:param isEnabled: whether the item is enabled
%End

QString defaultName() const;
%Docstring

:return: the default name
%End

QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context );
%Docstring
Write the item and its children in a DOM document

:param doc: the DOM document
:param context: writing context (e.g. for conversion between relative and absolute paths)

:return: the dom element where the item is written
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
Expand Down
42 changes: 42 additions & 0 deletions python/core/auto_generated/mesh/qgsmeshlayer.sip.in
Expand Up @@ -150,6 +150,18 @@ QgsMeshLayer cannot be copied.
Returns the provider type for this layer
%End

bool addDatasets( const QString &path, const QDateTime &defaultReferenceTime = QDateTime() );
%Docstring
Add datasets to the mesh from file with ``path``. Use the the time ``defaultReferenceTime`` as reference time is not provided in the file

:param path: the path to the atasets file
:param defaultReferenceTime: reference time used if not provided in the file

:return: whether the dataset is added

.. versionadded:: 3.14
%End




Expand Down Expand Up @@ -345,6 +357,36 @@ The returned position is in map coordinates.
:return: the position of the snapped point on the closest element, empty QgsPointXY if no element of type ``elementType``


.. versionadded:: 3.14
%End

QgsMeshDatasetGroupTreeItem *datasetGroupTreeRootItem() const;
%Docstring
Returns the root items of the dataset group tree item

:return: the root item

.. versionadded:: 3.14
%End

void setDatasetGroupTreeRootItem( QgsMeshDatasetGroupTreeItem *rootItem );
%Docstring
Sets the root items of the dataset group tree item.
Changes active dataset groups if those one are not enabled anymore :
- new active scalar dataset group is the first root item enabled child
- new active vector dataset group is none

Doesn't take ownership of the pointed item, the root item is cloned.

:param rootItem: the new root item

.. versionadded:: 3.14
%End

void resetDatasetGroupTreeItem();
%Docstring
Reset the dataset group tree item to default from provider

.. versionadded:: 3.14
%End

Expand Down
1 change: 1 addition & 0 deletions src/app/CMakeLists.txt
Expand Up @@ -212,6 +212,7 @@ SET(QGIS_APP_SRCS

mesh/qgsmeshlayerproperties.cpp
mesh/qgsrenderermeshpropertieswidget.cpp
mesh/qgsmeshdatasetgrouptreewidget.cpp
mesh/qgsmeshrenderer3daveragingwidget.cpp
mesh/qgsmeshrenderermeshsettingswidget.cpp
mesh/qgsmeshrendererscalarsettingswidget.cpp
Expand Down

0 comments on commit 838faf8

Please sign in to comment.