QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
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
22#include "qgsmeshdataprovider.h"
23#include "qgsmeshdataset.h"
24
25#define SIP_NO_FILE
26
27class QgsMeshLayer;
28
40{
41 public:
43 int addDatasetGroup( std::unique_ptr< QgsMeshDatasetGroup > datasetGroup );
44
46 void removeDatasetGroup( int index );
47
49 bool hasTemporalCapabilities() const;
50
52 qint64 datasetRelativeTime( QgsMeshDatasetIndex index ) const;
53
55 QString description( int groupIndex ) const;
56
58 QgsMeshDatasetGroup *datasetGroup( int groupIndex ) const;
59
60 int datasetGroupCount() const override;
61 int datasetCount( int groupIndex ) const override;
62 QgsMeshDatasetGroupMetadata datasetGroupMetadata( int groupIndex ) const override;
64 QgsMeshDatasetValue datasetValue( QgsMeshDatasetIndex index, int valueIndex ) const override;
65 QgsMeshDataBlock datasetValues( QgsMeshDatasetIndex index, int valueIndex, int count ) const override;
66 QgsMesh3DDataBlock dataset3dValues( QgsMeshDatasetIndex index, int faceIndex, int count ) const override;
67 bool isFaceActive( QgsMeshDatasetIndex index, int faceIndex ) const override;
68 QgsMeshDataBlock areFacesActive( QgsMeshDatasetIndex index, int faceIndex, int count ) const override;
69
71 bool addDataset( const QString &uri ) override;
72
74 QStringList extraDatasets() const override;
75
79 const QString &outputFilePath,
80 const QString &outputDriver,
82 const QVector<QgsMeshDataBlock> &datasetValues,
83 const QVector<QgsMeshDataBlock> &datasetActive,
84 const QVector<double> &times
85 ) override;
86
88 bool persistDatasetGroup( const QString &outputFilePath, const QString &outputDriver, QgsMeshDatasetSourceInterface *source, int datasetGroupIndex ) override;
89
91 QDomElement writeXml( int groupIndex, QDomDocument &doc, const QgsReadWriteContext &context );
92
95
96 private:
97 std::vector<std::unique_ptr<QgsMeshDatasetGroup>> mGroups;
98};
99
121class QgsMeshDatasetGroupStore : public QObject
122{
123 Q_OBJECT
124
126 typedef QPair<QgsMeshDatasetSourceInterface *, int> DatasetGroup;
127
128 public:
130 explicit QgsMeshDatasetGroupStore( QgsMeshLayer *layer );
131
133 void setPersistentProvider( QgsMeshDataProvider *provider, const QStringList &extraDatasetUri );
134
136 bool addPersistentDatasets( const QString &path );
137
143 bool addDatasetGroup( std::unique_ptr< QgsMeshDatasetGroup > group );
144
146 bool saveDatasetGroup( QString filePath, int groupIndex, QString driver );
147
150
153
160
162 QList<int> datasetGroupIndexes() const;
163
169 QList<int> enabledDatasetGroupIndexes() const;
170
172 int datasetGroupCount() const;
173
175 int extraDatasetGroupCount() const;
176
178 int datasetCount( int groupIndex ) const;
179
182
185
187 QgsMeshDatasetValue datasetValue( const QgsMeshDatasetIndex &index, int valueIndex ) const;
188
190 QgsMeshDataBlock datasetValues( const QgsMeshDatasetIndex &index, int valueIndex, int count ) const;
191
193 QgsMesh3DDataBlock dataset3dValues( const QgsMeshDatasetIndex &index, int faceIndex, int count ) const;
194
196 QgsMeshDataBlock areFacesActive( const QgsMeshDatasetIndex &index, int faceIndex, int count ) const;
197
199 bool isFaceActive( const QgsMeshDatasetIndex &index, int faceIndex ) const;
200
203
209 QList<QgsMeshDatasetIndex> datasetIndexInTimeInterval( qint64 time1, qint64 time2, int groupIndex ) const;
210
212 qint64 datasetRelativeTime( const QgsMeshDatasetIndex &index ) const;
213
215 bool hasTemporalCapabilities() const;
216
218 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context );
219
221 void readXml( const QDomElement &storeElem, const QgsReadWriteContext &context );
222
229 int globalDatasetGroupIndexInSource( QgsMeshDatasetSourceInterface *source, int nativeGroupIndex ) const;
230
236 int indexFromGroupName( const QString &groupName ) const;
237
243 QString groupName( int groupIndex ) const;
244
250 void removeDatasetGroup( int groupIndex );
251
252 signals:
254 void datasetGroupsAdded( QList<int> indexes );
255
256 private slots:
257 void onPersistentDatasetAdded( int count );
258
259 private:
260 QgsMeshLayer *mLayer = nullptr;
261 QgsMeshDataProvider *mPersistentProvider = nullptr;
262 QgsMeshExtraDatasetStore mExtraDatasets;
263 QMap< int, DatasetGroup> mRegistry;
264 QList<int> mPersistentExtraDatasetGroupIndexes;
265 QMap<QString, int> mGroupNameToGlobalIndex;
266 std::unique_ptr<QgsMeshDatasetGroupTreeItem> mDatasetGroupTreeRootItem;
267
268 void removePersistentProvider();
269
271 void reindexDatasetGroups();
272
273 DatasetGroup datasetGroup( int index ) const;
274
276 int newIndex();
277
278 int registerDatasetGroup( const DatasetGroup &group );
279 void createDatasetGroupTreeItems( const QList<int> &indexes );
280
282 void eraseDatasetGroup( const DatasetGroup &group );
283
285 void eraseExtraDataset( int indexInExtraStore );
286
287 void checkDatasetConsistency( QgsMeshDatasetSourceInterface *source );
288 void removeUnregisteredItemFromTree();
289 void unregisterGroupNotPresentInTree();
290
291 void syncItemToDatasetGroup( int groupIndex );
292};
293
294#endif // QGSMESHDATASETGROUPSTORE_H
A block of 3d stacked mesh data related N faces defined on base mesh frame.
A block of integers/doubles from a mesh dataset.
MatchingTemporalDatasetMethod
Method for selection of temporal mesh dataset from a range time.
Base class for providing data for QgsMeshLayer.
A collection of dataset group metadata such as whether the data is vector or scalar,...
QgsMeshDatasetGroupTreeItem * datasetGroupTreeItem() const
Returns a pointer to the root of the dataset groups tree item.
QgsMeshDatasetMetadata datasetMetadata(const QgsMeshDatasetIndex &index) const
Returns the metadata of the dataset with global index.
void setDatasetGroupTreeItem(const QgsMeshDatasetGroupTreeItem *rootItem)
Sets the root of the dataset groups tree item.
QList< int > enabledDatasetGroupIndexes() const
Returns a list of all group indexes that are enabled.
bool addPersistentDatasets(const QString &path)
Adds persistent datasets from a file with path.
QgsMeshDatasetGroupMetadata datasetGroupMetadata(const QgsMeshDatasetIndex &index) const
Returns the metadata of the dataset group with global index.
bool isFaceActive(const QgsMeshDatasetIndex &index, int faceIndex) const
Returns whether face is active for particular dataset.
QList< int > datasetGroupIndexes() const
Returns a list of all group indexes.
bool hasTemporalCapabilities() const
Returns whether at lea&st one of stored dataset group is temporal.
void resetDatasetGroupTreeItem()
Resets to default state the dataset groups tree item.
QgsMeshDataBlock datasetValues(const QgsMeshDatasetIndex &index, int valueIndex, int count) const
Returns count values of the dataset with global index and from valueIndex.
QgsMeshDatasetIndex datasetIndexAtTime(qint64 time, int groupIndex, QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod method) const
Returns the global dataset index of the dataset int the dataset group with groupIndex,...
bool saveDatasetGroup(QString filePath, int groupIndex, QString driver)
Saves on a file with filePath the dataset groups index with groupIndex with the specified driver.
QList< QgsMeshDatasetIndex > datasetIndexInTimeInterval(qint64 time1, qint64 time2, int groupIndex) const
Returns the global dataset index of the dataset int the dataset group with groupIndex,...
QgsMeshDatasetValue datasetValue(const QgsMeshDatasetIndex &index, int valueIndex) const
Returns the value of the dataset with global index and valueIndex.
void removeDatasetGroup(int groupIndex)
Removes dataset group with global index groupIndex.
bool addDatasetGroup(std::unique_ptr< QgsMeshDatasetGroup > group)
Adds a extra dataset group, take ownership, returns True if the group is effectively added.
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context)
Writes the store's information in a DOM document.
int extraDatasetGroupCount() const
Returns the count of extra dataset groups.
int datasetGroupCount() const
Returns the count of dataset groups.
QgsMeshDatasetGroupStore(QgsMeshLayer *layer)
Constructor.
QgsMeshDataBlock areFacesActive(const QgsMeshDatasetIndex &index, int faceIndex, int count) const
Returns whether faces are active for particular dataset.
QString groupName(int groupIndex) const
Returns the name of the dataset group with global index groupIndex.
void setPersistentProvider(QgsMeshDataProvider *provider, const QStringList &extraDatasetUri)
Sets the persistent mesh data provider with the path of its extra dataset to be loaded by the provide...
qint64 datasetRelativeTime(const QgsMeshDatasetIndex &index) const
Returns the relative time of the dataset from the persistent provider reference time.
int datasetCount(int groupIndex) const
Returns the total count of dataset group in the store.
void readXml(const QDomElement &storeElem, const QgsReadWriteContext &context)
Reads the store's information from a DOM document.
int globalDatasetGroupIndexInSource(QgsMeshDatasetSourceInterface *source, int nativeGroupIndex) const
Returns the global dataset group index of the dataset group with native index nativeGroupIndex in the...
int indexFromGroupName(const QString &groupName) const
Returns the global dataset group index of the dataset with name groupName.
void datasetGroupsAdded(QList< int > indexes)
Emitted after dataset groups are added.
QgsMesh3DDataBlock dataset3dValues(const QgsMeshDatasetIndex &index, int faceIndex, int count) const
Returns count 3D values of the dataset with global index and from valueIndex.
Tree item for display of the mesh dataset groups.
Abstract class that represents a dataset group.
An index that identifies the dataset group (e.g.
Represents mesh dataset metadata, such as whether the data is valid or the associated time.
Interface for mesh datasets and dataset groups.
virtual Q_DECL_DEPRECATED bool persistDatasetGroup(const QString &path, const QgsMeshDatasetGroupMetadata &meta, const QVector< QgsMeshDataBlock > &datasetValues, const QVector< QgsMeshDataBlock > &datasetActive, const QVector< double > &times)
Creates a new dataset group from a data and persists it into a destination path.
Represents a single mesh dataset value.
Stores and accesses extra dataset groups for meshes.
int datasetCount(int groupIndex) const override
Returns number of datasets loaded in the group.
QString description(int groupIndex) const
Returns information related to the dataset group with groupIndex.
void updateTemporalCapabilities()
Updates the temporal capabilities.
QStringList extraDatasets() const override
Not implemented, always returns empty list.
QgsMeshDatasetGroup * datasetGroup(int groupIndex) const
Returns a pointer to the dataset group.
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.
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.
qint64 datasetRelativeTime(QgsMeshDatasetIndex index) const
Returns the relative times of the dataset index with index, returned value in milliseconds.
QgsMeshDataBlock datasetValues(QgsMeshDatasetIndex index, int valueIndex, int count) const override
Returns N vector/scalar values from the index from the dataset.
QgsMeshDataBlock areFacesActive(QgsMeshDatasetIndex index, int faceIndex, int count) const override
Returns whether the faces are active for particular dataset.
int datasetGroupCount() const override
Returns number of datasets groups loaded.
bool hasTemporalCapabilities() const
Returns whether if the dataset groups have temporal capabilities (a least one dataset group with more...
bool isFaceActive(QgsMeshDatasetIndex index, int faceIndex) const override
Returns whether the face is active for particular dataset.
QDomElement writeXml(int groupIndex, QDomDocument &doc, const QgsReadWriteContext &context)
Writes the store's information in a DOM document.
int addDatasetGroup(std::unique_ptr< QgsMeshDatasetGroup > datasetGroup)
Adds a dataset group, returns the index of the added dataset group.
QgsMeshDatasetMetadata datasetMetadata(QgsMeshDatasetIndex index) const override
Returns dataset metadata.
void removeDatasetGroup(int index)
Removes the dataset group with the local index.
QgsMeshDatasetGroupMetadata datasetGroupMetadata(int groupIndex) const override
Returns dataset group metadata.
QgsMeshDatasetValue datasetValue(QgsMeshDatasetIndex index, int valueIndex) const override
Returns vector/scalar value associated with the index from the dataset To read multiple continuous va...
bool addDataset(const QString &uri) override
Not implemented, always returns false.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
A container for the context for various read/write operations on objects.