QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgsmeshdataprovider.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmeshdataprovider.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 QGSMESHDATAPROVIDER_H
19 #define QGSMESHDATAPROVIDER_H
20 
21 #include <QVector>
22 #include <QString>
23 #include <QMap>
24 #include <limits>
25 
26 #include "qgis_core.h"
27 #include "qgspoint.h"
28 #include "qgsdataprovider.h"
29 
30 class QgsRectangle;
31 
42 class CORE_EXPORT QgsMeshDatasetIndex
43 {
44  public:
46  QgsMeshDatasetIndex( int group = -1, int dataset = -1 );
48  int group() const;
50  int dataset() const;
52  bool isValid() const;
54  bool operator == ( const QgsMeshDatasetIndex &other ) const;
56  bool operator != ( const QgsMeshDatasetIndex &other ) const;
57  private:
58  int mGroupIndex = -1;
59  int mDatasetIndex = -1;
60 };
61 
64 
66 typedef QVector<int> QgsMeshFace;
67 
79 class CORE_EXPORT QgsMeshDatasetValue
80 {
81  public:
83  QgsMeshDatasetValue( double x,
84  double y );
85 
87  QgsMeshDatasetValue( double scalar );
88 
90  QgsMeshDatasetValue() = default;
91 
93  ~QgsMeshDatasetValue() = default;
94 
96  void set( double scalar );
97 
99  void setX( double x );
100 
102  void setY( double y ) ;
103 
105  double scalar() const;
106 
108  double x() const;
109 
111  double y() const;
112 
113  bool operator==( const QgsMeshDatasetValue &other ) const;
114 
115  private:
116  double mX = std::numeric_limits<double>::quiet_NaN();
117  double mY = std::numeric_limits<double>::quiet_NaN();
118 };
119 
131 {
132  public:
133 
135  enum DataType
136  {
138  DataOnVertices
139  };
140 
142  QgsMeshDatasetGroupMetadata() = default;
143 
152  QgsMeshDatasetGroupMetadata( const QString &name,
153  bool isScalar,
154  bool isOnVertices,
155  const QMap<QString, QString> &extraOptions );
156 
160  QString name() const;
161 
165  QMap<QString, QString> extraOptions() const;
166 
170  bool isVector() const;
171 
175  bool isScalar() const;
176 
180  DataType dataType() const;
181 
182  private:
183  QString mName;
184  bool mIsScalar = false;
185  bool mIsOnVertices = false;
186  QMap<QString, QString> mExtraOptions;
187 };
188 
199 class CORE_EXPORT QgsMeshDatasetMetadata
200 {
201  public:
203  QgsMeshDatasetMetadata() = default;
204 
211  QgsMeshDatasetMetadata( double time,
212  bool isValid );
213 
217  double time() const;
218 
222  bool isValid() const;
223 
224  private:
225  double mTime = std::numeric_limits<double>::quiet_NaN();
226  bool mIsValid = false;
227 };
228 
246 {
247  public:
249  virtual ~QgsMeshDataSourceInterface() = default;
250 
255  virtual int vertexCount() const = 0;
256 
261  virtual int faceCount() const = 0;
262 
266  virtual QgsMeshVertex vertex( int index ) const = 0;
267 
271  virtual QgsMeshFace face( int index ) const = 0;
272 };
273 
290 {
291  public:
293  virtual ~QgsMeshDatasetSourceInterface() = default;
294 
300  virtual bool addDataset( const QString &uri ) = 0;
301 
305  virtual QStringList extraDatasets() const = 0;
306 
310  virtual int datasetGroupCount( ) const = 0;
311 
315  virtual int datasetCount( int groupIndex ) const = 0;
316 
320  int datasetCount( QgsMeshDatasetIndex index ) const;
321 
325  virtual QgsMeshDatasetGroupMetadata datasetGroupMetadata( int groupIndex ) const = 0;
326 
330  QgsMeshDatasetGroupMetadata datasetGroupMetadata( QgsMeshDatasetIndex index ) const;
331 
335  virtual QgsMeshDatasetMetadata datasetMetadata( QgsMeshDatasetIndex index ) const = 0;
336 
342  virtual QgsMeshDatasetValue datasetValue( QgsMeshDatasetIndex index, int valueIndex ) const = 0;
343 
354  virtual bool isFaceActive( QgsMeshDatasetIndex index, int faceIndex ) const = 0;
355 };
356 
357 
369 {
370  Q_OBJECT
371 
372  public:
374  QgsMeshDataProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options );
375 
380  QgsRectangle extent() const override;
381 
382  signals:
384  void datasetGroupsAdded( int count );
385 };
386 
387 #endif // QGSMESHDATAPROVIDER_H
A rectangle specified with double values.
Definition: qgsrectangle.h:40
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Abstract base class for spatial data provider implementations.
#define SIP_ABSTRACT
Definition: qgis_sip.h:187
DataType
Location of where data is specified for datasets in the dataset group.
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.
Interface for mesh datasets and dataset groups.
QgsMeshDatasetGroupMetadata is a collection of dataset group metadata such as whether the data is vec...
QVector< int > QgsMeshFace
List of vertex indexes.
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
virtual QgsRectangle extent() const =0
Returns the extent of the layer.
QgsMeshDatasetValue represents single dataset value.
QgsMeshDatasetMetadata is a collection of mesh dataset metadata such as whether the data is valid or ...
Interface for mesh data sources.
QgsPoint QgsMeshVertex
xyz coords of vertex