QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsmeshdatasetgroupstore.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmeshdatasetgroupstore.h
3  ---------------------
4  begin : June 2020
5  copyright : (C) 2020 by Vincent Cloarec
6  email : vcloarec at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSMESHDATASETGROUPSTORE_H
19 #define QGSMESHDATASETGROUPSTORE_H
20 
21 #define SIP_NO_FILE
22 
23 #include "qgsmeshdataprovider.h"
24 #include "qgsmeshdataset.h"
25 
26 class QgsMeshLayer;
27 
37 {
38  public:
39 
42 
44  void removeDatasetGroup( int index );
45 
47  bool hasTemporalCapabilities() const;
48 
51 
53  QString description( int groupIndex ) const;
54 
56  QgsMeshDatasetGroup *datasetGroup( int groupIndex ) const;
57 
58  int datasetGroupCount() const override;
59  int datasetCount( int groupIndex ) const override;
60  QgsMeshDatasetGroupMetadata datasetGroupMetadata( int groupIndex ) const override;
62  QgsMeshDatasetValue datasetValue( QgsMeshDatasetIndex index, int valueIndex ) const override;
63  QgsMeshDataBlock datasetValues( QgsMeshDatasetIndex index, int valueIndex, int count ) const override;
64  QgsMesh3dDataBlock dataset3dValues( QgsMeshDatasetIndex index, int faceIndex, int count ) const override;
65  bool isFaceActive( QgsMeshDatasetIndex index, int faceIndex ) const override;
66  QgsMeshDataBlock areFacesActive( QgsMeshDatasetIndex index, int faceIndex, int count ) const override;
67 
69  bool addDataset( const QString &uri ) override;
70 
72  QStringList extraDatasets() const override;
73 
75  bool persistDatasetGroup( const QString &outputFilePath,
76  const QString &outputDriver,
77  const QgsMeshDatasetGroupMetadata &meta,
78  const QVector<QgsMeshDataBlock> &datasetValues,
79  const QVector<QgsMeshDataBlock> &datasetActive,
80  const QVector<double> &times ) override;
81 
83  bool persistDatasetGroup( const QString &outputFilePath,
84  const QString &outputDriver,
86  int datasetGroupIndex ) override;
87 
89  QDomElement writeXml( int groupIndex, QDomDocument &doc, const QgsReadWriteContext &context );
90 
93 
94  private:
95  std::vector<std::unique_ptr<QgsMeshDatasetGroup>> mGroups;
96 };
97 
119 class QgsMeshDatasetGroupStore: public QObject
120 {
121  Q_OBJECT
122 
124  typedef QPair<QgsMeshDatasetSourceInterface *, int> DatasetGroup;
125 
126  public:
129 
131  void setPersistentProvider( QgsMeshDataProvider *provider );
132 
134  bool addPersistentDatasets( const QString &path );
135 
142  bool addDatasetGroup( QgsMeshDatasetGroup *group );
143 
145  bool saveDatasetGroup( QString filePath, int groupIndex, QString driver );
146 
149 
152 
155 
157  QList<int> datasetGroupIndexes() const;
158 
160  int datasetGroupCount() const;
161 
163  int extraDatasetGroupCount() const;
164 
166  int datasetCount( int groupIndex ) const;
167 
170 
173 
175  QgsMeshDatasetValue datasetValue( const QgsMeshDatasetIndex &index, int valueIndex ) const;
176 
178  QgsMeshDataBlock datasetValues( const QgsMeshDatasetIndex &index, int valueIndex, int count ) const;
179 
181  QgsMesh3dDataBlock dataset3dValues( const QgsMeshDatasetIndex &index, int faceIndex, int count ) const;
182 
184  QgsMeshDataBlock areFacesActive( const QgsMeshDatasetIndex &index, int faceIndex, int count ) const;
185 
187  bool isFaceActive( const QgsMeshDatasetIndex &index, int faceIndex ) const;
188 
191  int groupIndex,
193 
195  qint64 datasetRelativeTime( const QgsMeshDatasetIndex &index ) const;
196 
198  bool hasTemporalCapabilities() const;
199 
201  QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context );
202 
204  void readXml( const QDomElement &storeElem, const QgsReadWriteContext &context );
205 
206  signals:
208  void datasetGroupsAdded( QList<int> indexes );
209 
210  private slots:
211  void onPersistentDatasetAdded( int count );
212 
213  private:
214  QgsMeshLayer *mLayer = nullptr;
215  QgsMeshDataProvider *mPersistentProvider = nullptr;
216  std::unique_ptr<QgsMeshExtraDatasetStore> mExtraDatasets;
217  QMap < int, DatasetGroup> mRegistery;
218  std::unique_ptr<QgsMeshDatasetGroupTreeItem> mDatasetGroupTreeRootItem;
219 
220  void removePersistentProvider();
221 
222  DatasetGroup datasetGroup( int index ) const;
223  int newIndex();
224 
225  int registerDatasetGroup( const DatasetGroup &group );
226  int nativeIndexToGroupIndex( QgsMeshDatasetSourceInterface *source, int providerIndex );
227  void createDatasetGroupTreeItems( const QList<int> &indexes );
228 
230  void eraseDatasetGroup( const DatasetGroup &group );
231 
233  void eraseExtraDataset( int indexInExtraStore );
234 
235  void checkDatasetConsistency( QgsMeshDatasetSourceInterface *source );
236  void removeUnregisteredItemFromTree();
237  void unregisterGroupNotPresentInTree();
238 
239  void syncItemToDatasetGroup( int groupIndex );
240 };
241 
242 #endif // QGSMESHDATASETGROUPSTORE_H
QgsMeshExtraDatasetStore::persistDatasetGroup
bool persistDatasetGroup(const QString &outputFilePath, const QString &outputDriver, const QgsMeshDatasetGroupMetadata &meta, const QVector< QgsMeshDataBlock > &datasetValues, const QVector< QgsMeshDataBlock > &datasetActive, const QVector< double > &times) override
Not implemented, always returns true.
Definition: qgsmeshdatasetgroupstore.cpp:721
QgsMeshDatasetGroupStore::setDatasetGroupTreeItem
void setDatasetGroupTreeItem(QgsMeshDatasetGroupTreeItem *rootItem)
Sets the root of the dataset groups tree item, doesn't take onwnershib but clone the root item.
Definition: qgsmeshdatasetgroupstore.cpp:121
QgsMeshDatasetGroupStore::writeXml
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context)
Writes the store's information in a DOM document.
Definition: qgsmeshdatasetgroupstore.cpp:240
QgsMeshDatasetGroupStore::datasetValue
QgsMeshDatasetValue datasetValue(const QgsMeshDatasetIndex &index, int valueIndex) const
Returns the value of the dataset with global index and valueIndex.
Definition: qgsmeshdatasetgroupstore.cpp:158
QgsMeshDatasetGroupStore::dataset3dValues
QgsMesh3dDataBlock dataset3dValues(const QgsMeshDatasetIndex &index, int faceIndex, int count) const
Returns count 3D values of the dataset with global index and from valueIndex.
Definition: qgsmeshdatasetgroupstore.cpp:176
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:35
QgsMeshExtraDatasetStore::description
QString description(int groupIndex) const
Returns information related to the dataset group with groupIndex.
Definition: qgsmeshdatasetgroupstore.cpp:596
QgsMeshExtraDatasetStore::extraDatasets
QStringList extraDatasets() const override
Not implemented, always returns empty list.
Definition: qgsmeshdatasetgroupstore.cpp:618
QgsMeshDatasetGroupStore::addDatasetGroup
bool addDatasetGroup(QgsMeshDatasetGroup *group)
Adds a extra dataset group, take ownership.
Definition: qgsmeshdatasetgroupstore.cpp:71
QgsMeshDatasetGroupStore::datasetGroupMetadata
QgsMeshDatasetGroupMetadata datasetGroupMetadata(const QgsMeshDatasetIndex &index) const
Returns the metadata of the dataset group with global index.
Definition: qgsmeshdatasetgroupstore.cpp:131
QgsMeshDatasetValue
QgsMeshDatasetValue represents single dataset value.
Definition: qgsmeshdataset.h:78
QgsMeshDatasetGroupStore::areFacesActive
QgsMeshDataBlock areFacesActive(const QgsMeshDatasetIndex &index, int faceIndex, int count) const
Returns whether faces are active for particular dataset.
Definition: qgsmeshdatasetgroupstore.cpp:185
QgsMeshExtraDatasetStore::datasetValues
QgsMeshDataBlock datasetValues(QgsMeshDatasetIndex index, int valueIndex, int count) const override
Returns N vector/scalar values from the index from the dataset.
Definition: qgsmeshdatasetgroupstore.cpp:671
QgsMeshDatasetGroupTreeItem
Tree item for display of the mesh dataset groups.
Definition: qgsmeshdataset.h:785
QgsMeshDatasetGroupStore::datasetGroupCount
int datasetGroupCount() const
Returns the count of dataset groups.
Definition: qgsmeshdatasetgroupstore.cpp:30
QgsMeshDatasetMetadata
QgsMeshDatasetMetadata is a collection of mesh dataset metadata such as whether the data is valid or ...
Definition: qgsmeshdataset.h:476
QgsMesh3dDataBlock
QgsMesh3dDataBlock is a block of 3d stacked mesh data related N faces defined on base mesh frame.
Definition: qgsmeshdataset.h:245
QgsMeshExtraDatasetStore::writeXml
QDomElement writeXml(int groupIndex, QDomDocument &doc, const QgsReadWriteContext &context)
Writes the store's information in a DOM document.
Definition: qgsmeshdatasetgroupstore.cpp:749
QgsMeshDatasetGroupStore
Class used to register and access all the dataset groups related to a mesh layer.
Definition: qgsmeshdatasetgroupstore.h:120
QgsMeshExtraDatasetStore::datasetGroup
QgsMeshDatasetGroup * datasetGroup(int groupIndex) const
Returns a pointer to the dataset group.
Definition: qgsmeshdatasetgroupstore.cpp:604
QgsMeshExtraDatasetStore::addDataset
bool addDataset(const QString &uri) override
Not implemented, always returns false.
Definition: qgsmeshdatasetgroupstore.cpp:612
QgsMeshExtraDatasetStore::isFaceActive
bool isFaceActive(QgsMeshDatasetIndex index, int faceIndex) const override
Returns whether the face is active for particular dataset.
Definition: qgsmeshdatasetgroupstore.cpp:694
QgsMeshExtraDatasetStore::areFacesActive
QgsMeshDataBlock areFacesActive(QgsMeshDatasetIndex index, int faceIndex, int count) const override
Returns whether the faces are active for particular dataset.
Definition: qgsmeshdatasetgroupstore.cpp:708
QgsMeshDatasetGroupStore::extraDatasetGroupCount
int extraDatasetGroupCount() const
Returns the count of extra dataset groups.
Definition: qgsmeshdatasetgroupstore.cpp:35
QgsMeshExtraDatasetStore::datasetCount
int datasetCount(int groupIndex) const override
Returns number of datasets loaded in the group.
Definition: qgsmeshdatasetgroupstore.cpp:628
QgsMeshDatasetIndex
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
Definition: qgsmeshdataset.h:47
QgsMeshDatasetGroupStore::datasetGroupTreeItem
QgsMeshDatasetGroupTreeItem * datasetGroupTreeItem() const
Returns a pointer to the root of the dataset groups tree item.
Definition: qgsmeshdatasetgroupstore.cpp:116
QgsMeshDatasetGroupStore::datasetGroupIndexes
QList< int > datasetGroupIndexes() const
Returns a list of all group indexes.
Definition: qgsmeshdatasetgroupstore.cpp:25
QgsMeshLayer
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Definition: qgsmeshlayer.h:95
QgsMeshDatasetGroupStore::resetDatasetGroupTreeItem
void resetDatasetGroupTreeItem()
Resets to default state the dataset groups tree item.
Definition: qgsmeshdatasetgroupstore.cpp:107
QgsMeshDataProvider
Base class for providing data for QgsMeshLayer.
Definition: qgsmeshdataprovider.h:398
QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod
MatchingTemporalDatasetMethod
Method for selection of temporal mesh dataset from a range time.
Definition: qgsmeshdataprovidertemporalcapabilities.h:42
QgsMeshExtraDatasetStore::datasetRelativeTime
quint64 datasetRelativeTime(QgsMeshDatasetIndex index)
Returns the relative times of the dataset index with index, returned value in milliseconds.
Definition: qgsmeshdatasetgroupstore.cpp:591
QgsMeshExtraDatasetStore::datasetGroupCount
int datasetGroupCount() const override
Returns number of datasets groups loaded.
Definition: qgsmeshdatasetgroupstore.cpp:623
QgsMeshDatasetGroupStore::datasetMetadata
QgsMeshDatasetMetadata datasetMetadata(const QgsMeshDatasetIndex &index) const
Returns the metadata of the dataset with global index.
Definition: qgsmeshdatasetgroupstore.cpp:149
QgsMeshDatasetSourceInterface
Interface for mesh datasets and dataset groups.
Definition: qgsmeshdataprovider.h:189
QgsMeshDatasetGroup
Abstract class that represents a dataset group.
Definition: qgsmeshdataset.h:576
QgsMeshExtraDatasetStore::datasetGroupMetadata
QgsMeshDatasetGroupMetadata datasetGroupMetadata(int groupIndex) const override
Returns dataset group metadata.
Definition: qgsmeshdatasetgroupstore.cpp:636
QgsMeshExtraDatasetStore::hasTemporalCapabilities
bool hasTemporalCapabilities() const
Returns whether if the dataset groups have temporal capabilities (a least one dataset group with more...
Definition: qgsmeshdatasetgroupstore.cpp:586
QgsMeshDatasetGroupStore::datasetCount
int datasetCount(int groupIndex) const
Returns the total count of dataset group in the store.
Definition: qgsmeshdatasetgroupstore.cpp:140
QgsMeshDatasetGroupStore::hasTemporalCapabilities
bool hasTemporalCapabilities() const
Returns whether at lea&st one of stored dataset group is temporal.
Definition: qgsmeshdatasetgroupstore.cpp:234
QgsMeshDatasetGroupMetadata
QgsMeshDatasetGroupMetadata is a collection of dataset group metadata such as whether the data is vec...
Definition: qgsmeshdataset.h:350
QgsMeshDatasetGroupStore::isFaceActive
bool isFaceActive(const QgsMeshDatasetIndex &index, int faceIndex) const
Returns whether face is active for particular dataset.
Definition: qgsmeshdatasetgroupstore.cpp:194
QgsMeshExtraDatasetStore::datasetValue
QgsMeshDatasetValue datasetValue(QgsMeshDatasetIndex index, int valueIndex) const override
Returns vector/scalar value associated with the index from the dataset To read multiple continuous va...
Definition: qgsmeshdatasetgroupstore.cpp:657
QgsMeshExtraDatasetStore
Class that can be used to store and access extra dataset group, like memory dataset (temporary) Deriv...
Definition: qgsmeshdatasetgroupstore.h:37
QgsMeshDatasetGroupStore::QgsMeshDatasetGroupStore
QgsMeshDatasetGroupStore(QgsMeshLayer *layer)
Constructor.
Definition: qgsmeshdatasetgroupstore.cpp:40
qgsmeshdataset.h
QgsMeshExtraDatasetStore::datasetMetadata
QgsMeshDatasetMetadata datasetMetadata(QgsMeshDatasetIndex index) const override
Returns dataset metadata.
Definition: qgsmeshdatasetgroupstore.cpp:644
QgsMeshDatasetGroupStore::datasetGroupsAdded
void datasetGroupsAdded(QList< int > indexes)
Emitted after dataset groups are added.
QgsMeshDataBlock
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e....
Definition: qgsmeshdataset.h:136
QgsMeshDatasetGroupStore::readXml
void readXml(const QDomElement &storeElem, const QgsReadWriteContext &context)
Reads the store's information from a DOM document.
Definition: qgsmeshdatasetgroupstore.cpp:277
QgsMeshExtraDatasetStore::addDatasetGroup
int addDatasetGroup(QgsMeshDatasetGroup *datasetGroup)
Adds a dataset group, returns the index of the added dataset group.
Definition: qgsmeshdatasetgroupstore.cpp:562
QgsMeshDatasetGroupStore::saveDatasetGroup
bool saveDatasetGroup(QString filePath, int groupIndex, QString driver)
Saves on a file with filePath the dataset groups index with groupIndex with the specified driver.
Definition: qgsmeshdatasetgroupstore.cpp:327
QgsMeshDatasetGroupStore::setPersistentProvider
void setPersistentProvider(QgsMeshDataProvider *provider)
Sets the persistent mesh data provider.
Definition: qgsmeshdatasetgroupstore.cpp:46
QgsMeshDatasetGroupStore::addPersistentDatasets
bool addPersistentDatasets(const QString &path)
Adds persistent datasets from a file with path.
Definition: qgsmeshdatasetgroupstore.cpp:64
QgsMeshDatasetGroupStore::datasetValues
QgsMeshDataBlock datasetValues(const QgsMeshDatasetIndex &index, int valueIndex, int count) const
Returns count values of the dataset with global index and from valueIndex.
Definition: qgsmeshdatasetgroupstore.cpp:167
QgsMeshDatasetGroupStore::datasetIndexAtTime
QgsMeshDatasetIndex datasetIndexAtTime(qint64 time, int groupIndex, QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod method) const
Returns the global dataset index of the dataset int the dataset group with groupIndex,...
Definition: qgsmeshdatasetgroupstore.cpp:203
qgsmeshdataprovider.h
QgsMeshExtraDatasetStore::removeDatasetGroup
void removeDatasetGroup(int index)
Removes the dataset group with the local index.
Definition: qgsmeshdatasetgroupstore.cpp:577
QgsMeshDatasetGroupStore::datasetRelativeTime
qint64 datasetRelativeTime(const QgsMeshDatasetIndex &index) const
Returns the relative time of the dataset from the persistent provider reference time.
Definition: qgsmeshdatasetgroupstore.cpp:217
QgsMeshExtraDatasetStore::updateTemporalCapabilities
void updateTemporalCapabilities()
Updates the temporal capabilities.
Definition: qgsmeshdatasetgroupstore.cpp:757
QgsMeshExtraDatasetStore::dataset3dValues
QgsMesh3dDataBlock dataset3dValues(QgsMeshDatasetIndex index, int faceIndex, int count) const override
Returns N vector/scalar values from the face index from the dataset for 3d stacked meshes.
Definition: qgsmeshdatasetgroupstore.cpp:685