QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgsmeshmemorydataprovider.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmeshmemorydataprovider.h
3  ---------------------------
4  begin : April 2018
5  copyright : (C) 2018 by Peter Petrik
6  email : zilolv 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 QGSMESHMEMORYDATAPROVIDER_H
19 #define QGSMESHMEMORYDATAPROVIDER_H
20 
21 #define SIP_NO_FILE
22 
24 
25 #include <QString>
26 
27 #include "qgis_core.h"
28 #include "qgis.h"
29 #include "qgsmeshdataprovider.h"
30 #include "qgsrectangle.h"
31 
32 struct QgsMeshMemoryDataset
33 {
34  QVector<QgsMeshDatasetValue> values;
35  double time = -1;
36  bool valid = false;
37 };
38 
39 struct QgsMeshMemoryDatasetGroup
40 {
41  QMap<QString, QString> metadata;
42  QVector<QgsMeshMemoryDataset> datasets;
43  QString name;
44  bool isScalar = true;
45  bool isOnVertices = true;
46 };
47 
53 class QgsMeshMemoryDataProvider: public QgsMeshDataProvider
54 {
55  Q_OBJECT
56 
57  public:
58 
81  QgsMeshMemoryDataProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options );
82 
83  bool isValid() const override;
84  QString name() const override;
85  QString description() const override;
86  QgsCoordinateReferenceSystem crs() const override;
87 
88  int vertexCount() const override;
89  int faceCount() const override;
90  QgsMeshVertex vertex( int index ) const override;
91  QgsMeshFace face( int index ) const override;
92 
93 
123  bool addDataset( const QString &uri ) override;
124  QStringList extraDatasets() const override;
125  int datasetGroupCount() const override;
126  int datasetCount( int groupIndex ) const override;
127 
128  QgsMeshDatasetGroupMetadata datasetGroupMetadata( int groupIndex ) const override;
129  QgsMeshDatasetMetadata datasetMetadata( QgsMeshDatasetIndex index ) const override;
130  QgsMeshDatasetValue datasetValue( QgsMeshDatasetIndex index, int valueIndex ) const override;
131  bool isFaceActive( QgsMeshDatasetIndex index, int faceIndex ) const override;
132 
134  static QString providerKey();
136  static QString providerDescription();
138  static QgsMeshMemoryDataProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options );
139  private:
140  bool splitMeshSections( const QString &uri );
141  bool addMeshVertices( const QString &def );
142  bool addMeshFaces( const QString &def );
143 
144  bool splitDatasetSections( const QString &uri, QgsMeshMemoryDatasetGroup &datasetGroup );
145  bool setDatasetGroupType( const QString &uri, QgsMeshMemoryDatasetGroup &datasetGroup );
146  bool addDatasetGroupMetadata( const QString &def, QgsMeshMemoryDatasetGroup &datasetGroup );
147  bool addDatasetValues( const QString &def, QgsMeshMemoryDataset &dataset, bool isScalar );
148  bool checkDatasetValidity( QgsMeshMemoryDataset &dataset, bool isOnVertices );
149 
150  QVector<QgsMeshVertex> mVertices;
151  QVector<QgsMeshFace> mFaces;
152  QVector<QgsMeshMemoryDatasetGroup> mDatasetGroups;
153 
154  bool mIsValid = false;
155  QStringList mExtraDatasetUris;
156 };
157 
159 
160 #endif // QGSMESHMEMORYDATAPROVIDER_H
const QgsCoordinateReferenceSystem & crs
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
Base class for providing data for QgsMeshLayer.
Setting options for creating vector data providers.
QgsMeshDatasetGroupMetadata is a collection of dataset group metadata such as whether the data is vec...
QVector< int > QgsMeshFace
List of vertex indexes.
This class represents a coordinate reference system (CRS).
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
QgsMeshDatasetValue represents single dataset value.
QgsMeshDatasetMetadata is a collection of mesh dataset metadata such as whether the data is valid or ...