Skip to content

Commit 9296528

Browse files
wonder-skPeterPetrik
authored andcommitted
[FEATURE] Rendering of scalar data on mesh layers
Rudimentary support for rendering of scalar data (e.g. water depth) on mesh map layers.
1 parent 3154102 commit 9296528

12 files changed

Lines changed: 476 additions & 4 deletions

‎python/core/auto_generated/mesh/qgsmeshdataprovider.sip.in‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ class QgsMeshDatasetValue
2323
QgsMeshDatasetValue is a vector or a scalar value on vertex or face of the mesh with
2424
support of nodata values
2525

26+
.. note::
27+
28+
The API is considered EXPERIMENTAL and can be changed without a notice
29+
2630
.. versionadded:: 3.2
2731
%End
2832

@@ -59,6 +63,10 @@ Mesh is a collection of vertices and faces in 2D or 3D space
5963
Base on the underlying data provider/format, whole mesh is either stored in memory or
6064
read on demand
6165

66+
.. note::
67+
68+
The API is considered EXPERIMENTAL and can be changed without a notice
69+
6270
.. versionadded:: 3.2
6371
%End
6472

@@ -105,6 +113,10 @@ Dataset is a collection of vector or scalar values on vertices or faces of the
105113
Base on the underlying data provider/format, whole dataset is either stored in memory or
106114
read on demand
107115

116+
.. note::
117+
118+
The API is considered EXPERIMENTAL and can be changed without a notice
119+
108120
.. versionadded:: 3.2
109121
%End
110122

@@ -158,6 +170,10 @@ Base class for providing data for :py:class:`QgsMeshLayer`
158170

159171
Responsible for reading native mesh data
160172

173+
.. note::
174+
175+
The API is considered EXPERIMENTAL and can be changed without a notice
176+
161177
.. seealso:: :py:class:`QgsMeshSource`
162178

163179
.. versionadded:: 3.2

‎python/core/auto_generated/mesh/qgsmeshlayer.sip.in‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ is the MDAL connection string. QGIS must be built with MDAL support to allow thi
6464
QString uri = "test/land.2dm";
6565
QgsMeshLayer *scratchLayer = new QgsMeshLayer(uri, "My Scratch Layer", "mdal");
6666

67+
.. note::
68+
69+
The API is considered EXPERIMENTAL and can be changed without a notice
70+
71+
6772
.. versionadded:: 3.2
6873
%End
6974

@@ -138,6 +143,8 @@ Toggle rendering of triangular (derived) mesh. Off by default
138143
void setActiveScalarDataset( int index = -1 );
139144
void setActiveVectorDataset( int index = -1 );
140145

146+
int activeScalarDataset() const;
147+
141148
private: // Private methods
142149
QgsMeshLayer( const QgsMeshLayer &rhs );
143150
};

‎src/core/CMakeLists.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ SET(QGIS_CORE_SRCS
453453
mesh/qgsmeshlayerrenderer.cpp
454454
mesh/qgsmeshmemorydataprovider.cpp
455455
mesh/qgstriangularmesh.cpp
456+
mesh/qgsmeshlayerinterpolator.cpp
456457

457458
geometry/qgsabstractgeometry.cpp
458459
geometry/qgsbox3d.cpp
@@ -1075,6 +1076,7 @@ SET(QGIS_CORE_HDRS
10751076

10761077
mesh/qgstriangularmesh.h
10771078
mesh/qgsmeshlayerrenderer.h
1079+
mesh/qgsmeshlayerinterpolator.h
10781080

10791081
scalebar/qgsdoubleboxscalebarrenderer.h
10801082
scalebar/qgsnumericscalebarrenderer.h

‎src/core/mesh/qgsmeshdataprovider.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ void QgsMeshDatasetValue::setX( double x )
9494
{
9595
mIsNodata = true;
9696
}
97+
else
98+
{
99+
mIsNodata = false;
100+
}
97101
}
98102

99103
void QgsMeshDatasetValue::setY( double y )

‎src/core/mesh/qgsmeshdataprovider.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ typedef QMap<QString, QString> QgsMeshDatasetMetadata;
4343
* QgsMeshDatasetValue is a vector or a scalar value on vertex or face of the mesh with
4444
* support of nodata values
4545
*
46+
* \note The API is considered EXPERIMENTAL and can be changed without a notice
47+
*
4648
* \since QGIS 3.2
4749
*/
4850
class CORE_EXPORT QgsMeshDatasetValue
@@ -83,6 +85,8 @@ class CORE_EXPORT QgsMeshDatasetValue
8385
* Base on the underlying data provider/format, whole mesh is either stored in memory or
8486
* read on demand
8587
*
88+
* \note The API is considered EXPERIMENTAL and can be changed without a notice
89+
*
8690
* \since QGIS 3.2
8791
*/
8892
class CORE_EXPORT QgsMeshSource SIP_ABSTRACT
@@ -123,6 +127,8 @@ class CORE_EXPORT QgsMeshSource SIP_ABSTRACT
123127
* Base on the underlying data provider/format, whole dataset is either stored in memory or
124128
* read on demand
125129
*
130+
* \note The API is considered EXPERIMENTAL and can be changed without a notice
131+
*
126132
* \since QGIS 3.2
127133
*/
128134
class CORE_EXPORT QgsMeshDatasetSource SIP_ABSTRACT
@@ -174,6 +180,8 @@ class CORE_EXPORT QgsMeshDatasetSource SIP_ABSTRACT
174180
*
175181
* Responsible for reading native mesh data
176182
*
183+
* \note The API is considered EXPERIMENTAL and can be changed without a notice
184+
*
177185
* \see QgsMeshSource
178186
* \since QGIS 3.2
179187
*/

‎src/core/mesh/qgsmeshlayer.cpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,25 @@ void QgsMeshLayer::toggleTriangularMeshRendering( bool toggle )
129129

130130
void QgsMeshLayer::setActiveScalarDataset( int index )
131131
{
132+
if ( index < 0 )
133+
{
134+
mActiveScalarDataset = -1;
135+
return;
136+
}
137+
132138
Q_ASSERT( dataProvider()->datasetCount() > index );
133139
if ( dataProvider()->datasetHasScalarData( index ) )
134140
mActiveScalarDataset = index;
135141
}
136142

137143
void QgsMeshLayer::setActiveVectorDataset( int index )
138144
{
145+
if ( index < 0 )
146+
{
147+
mActiveVectorDataset = -1;
148+
return;
149+
}
150+
139151
Q_ASSERT( dataProvider()->datasetCount() > index );
140152
if ( !dataProvider()->datasetHasScalarData( index ) )
141153
mActiveVectorDataset = index;

‎src/core/mesh/qgsmeshlayer.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ struct QgsMesh;
8282
* QgsMeshLayer *scratchLayer = new QgsMeshLayer(uri, "My Scratch Layer", "mdal");
8383
* \endcode
8484
*
85+
* \note The API is considered EXPERIMENTAL and can be changed without a notice
86+
*
8587
* \since QGIS 3.2
8688
*/
8789
class CORE_EXPORT QgsMeshLayer : public QgsMapLayer
@@ -145,6 +147,8 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer
145147
void setActiveScalarDataset( int index = -1 );
146148
void setActiveVectorDataset( int index = -1 );
147149

150+
int activeScalarDataset() const { return mActiveScalarDataset; }
151+
148152
private: // Private methods
149153

150154
/**

0 commit comments

Comments
 (0)