Skip to content
Permalink
Browse files

[MESH][FEATURE] use only specified dataset group (#36334)

[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 838faf8a3f95742ca2a46693e0bdfe3710f48bf5
@@ -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>
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
id="svg24"
version="1.1"
width="24"
viewBox="0 0 6.3499999 6.3500002"
height="24">
<metadata
id="metadata30">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs28" />
<path
id="path2"
overflow="visible"
fill-rule="evenodd"
fill="#888a85"
d="m .21387155.81343653v.41939607h5.87154485v-.41939607z" />
<path
id="path4"
overflow="visible"
fill-rule="evenodd"
fill="#b2b2b2"
d="m .63347422 1.2328326v4.6133566h.41939608v-4.6133566z" />
<path
id="path6"
overflow="visible"
fill-rule="evenodd"
fill="#b2b2b2"
d="m1.0526637 1.9591893v.4193961h.8389984v-.4193961z" />
<path
id="path8"
overflow="visible"
fill-rule="evenodd"
fill="#b2b2b2"
d="m1.0379072 4.9783355v.4193958h.838792v-.4193958z" />
<path
id="path10"
stroke-width=".19291691"
stroke="#afcc00"
fill-rule="evenodd"
fill="#fce94f"
d="m3.3727126 4.7698011h2.4481208v.83646154h-2.4481208z" />
<path
id="path12"
overflow="visible"
fill-rule="evenodd"
fill="#b2b2b2"
d="m1.0130849 3.4805437v.4193961h.8389983v-.4193961z" />
<path
id="path14"
stroke-width=".1929169"
stroke="#afcc00"
fill-rule="evenodd"
fill="#fce94f"
d="m3.3727129 3.272011h2.4481208v.83646154h-2.4481208z" />
<path
fill="#fce94f"
fill-rule="evenodd"
stroke="#afcc00"
stroke-width=".1929169"
id="path16"
d="m3.3727124 1.7506566h2.4481208v.83646154h-2.4481208z" />
<path
id="path18"
stroke-width=".22048612"
stroke="#415a75"
fill="none"
d="m2.0725693 4.8947917l.4409723.6614584.6614583-1.1024306" />
<path
id="path20"
stroke-width=".22048612"
stroke="#415a75"
fill="none"
d="m2.0725693 3.4616319l.4409722.6614585.6614584-1.1024306" />
<path
id="path22"
stroke-width=".22048612"
stroke="#415a75"
fill="none"
d="m2.0725693 2.0284723l.4409723.6614583.6614583-1.1024306" />
<rect
ry="0"
style="stroke-width:0.25568426;fill:none"
y="1.5940872"
x="1.9596746"
height="1.2170833"
width="1.2176619"
id="rect32" />
<g
id="g12"
transform="matrix(0.26458334,0,0,0.26458334,0.00237445,0.00237444)">
<path
d="m 14.357,13.5 h 8.285 c 0.474,0 0.857,0.384 0.857,0.857 v 8.285 c 0,0.474 -0.384,0.857 -0.857,0.857 h -8.285 c -0.474,0 -0.857,-0.384 -0.857,-0.857 v -8.285 c 0,-0.473 0.384,-0.857 0.857,-0.857 z"
id="path4-2"
style="opacity:0.9;fill:#cc0000;stroke:#cc0000;stroke-linecap:square;stroke-linejoin:round" />
<path
d="m 13.5,18.5 h 10 v -3.334 c 0,-1.666 0,-1.666 -2.5,-1.666 -0.582,0 -5.061,0 -5.834,0 -1.666,0 -1.666,0 -1.666,1.666 0,0.834 0,1.668 0,3.334 z"
id="path6-9"
style="opacity:0.5;fill:#fcffff" />
<path
d="m 16.373,20.65 4.254,-4.301"
id="path8-1"
style="fill:none;stroke:#eeeeec;stroke-width:1.5;stroke-linecap:round" />
<circle
cx="18.5"
cy="18.5"
r="4.15625"
id="circle10"
style="fill:none;stroke:#eeeeec;stroke-width:1.6875;stroke-linecap:round" />
</g>
</svg>
@@ -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 *
* *
@@ -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




@@ -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

@@ -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

0 comments on commit 838faf8

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