Skip to content
Permalink
Browse files

[FEATURE] Rendering of scalar data on mesh layers

Rudimentary support for rendering of scalar data (e.g. water depth)
on mesh map layers.
  • Loading branch information
wonder-sk authored and PeterPetrik committed May 10, 2018
1 parent 3154102 commit 92965288228f06dd4a30e23a51697b19eb69d7e6
@@ -23,6 +23,10 @@ class QgsMeshDatasetValue
QgsMeshDatasetValue is a vector or a scalar value on vertex or face of the mesh with
support of nodata values

.. note::

The API is considered EXPERIMENTAL and can be changed without a notice

.. versionadded:: 3.2
%End

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

.. note::

The API is considered EXPERIMENTAL and can be changed without a notice

.. versionadded:: 3.2
%End

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

.. note::

The API is considered EXPERIMENTAL and can be changed without a notice

.. versionadded:: 3.2
%End

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

Responsible for reading native mesh data

.. note::

The API is considered EXPERIMENTAL and can be changed without a notice

.. seealso:: :py:class:`QgsMeshSource`

.. versionadded:: 3.2
@@ -64,6 +64,11 @@ is the MDAL connection string. QGIS must be built with MDAL support to allow thi
QString uri = "test/land.2dm";
QgsMeshLayer *scratchLayer = new QgsMeshLayer(uri, "My Scratch Layer", "mdal");

.. note::

The API is considered EXPERIMENTAL and can be changed without a notice


.. versionadded:: 3.2
%End

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

int activeScalarDataset() const;

private: // Private methods
QgsMeshLayer( const QgsMeshLayer &rhs );
};
@@ -453,6 +453,7 @@ SET(QGIS_CORE_SRCS
mesh/qgsmeshlayerrenderer.cpp
mesh/qgsmeshmemorydataprovider.cpp
mesh/qgstriangularmesh.cpp
mesh/qgsmeshlayerinterpolator.cpp

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

mesh/qgstriangularmesh.h
mesh/qgsmeshlayerrenderer.h
mesh/qgsmeshlayerinterpolator.h

scalebar/qgsdoubleboxscalebarrenderer.h
scalebar/qgsnumericscalebarrenderer.h
@@ -94,6 +94,10 @@ void QgsMeshDatasetValue::setX( double x )
{
mIsNodata = true;
}
else
{
mIsNodata = false;
}
}

void QgsMeshDatasetValue::setY( double y )
@@ -43,6 +43,8 @@ typedef QMap<QString, QString> QgsMeshDatasetMetadata;
* QgsMeshDatasetValue is a vector or a scalar value on vertex or face of the mesh with
* support of nodata values
*
* \note The API is considered EXPERIMENTAL and can be changed without a notice
*
* \since QGIS 3.2
*/
class CORE_EXPORT QgsMeshDatasetValue
@@ -83,6 +85,8 @@ class CORE_EXPORT QgsMeshDatasetValue
* Base on the underlying data provider/format, whole mesh is either stored in memory or
* read on demand
*
* \note The API is considered EXPERIMENTAL and can be changed without a notice
*
* \since QGIS 3.2
*/
class CORE_EXPORT QgsMeshSource SIP_ABSTRACT
@@ -123,6 +127,8 @@ class CORE_EXPORT QgsMeshSource SIP_ABSTRACT
* Base on the underlying data provider/format, whole dataset is either stored in memory or
* read on demand
*
* \note The API is considered EXPERIMENTAL and can be changed without a notice
*
* \since QGIS 3.2
*/
class CORE_EXPORT QgsMeshDatasetSource SIP_ABSTRACT
@@ -174,6 +180,8 @@ class CORE_EXPORT QgsMeshDatasetSource SIP_ABSTRACT
*
* Responsible for reading native mesh data
*
* \note The API is considered EXPERIMENTAL and can be changed without a notice
*
* \see QgsMeshSource
* \since QGIS 3.2
*/
@@ -129,13 +129,25 @@ void QgsMeshLayer::toggleTriangularMeshRendering( bool toggle )

void QgsMeshLayer::setActiveScalarDataset( int index )
{
if ( index < 0 )
{
mActiveScalarDataset = -1;
return;
}

Q_ASSERT( dataProvider()->datasetCount() > index );
if ( dataProvider()->datasetHasScalarData( index ) )
mActiveScalarDataset = index;
}

void QgsMeshLayer::setActiveVectorDataset( int index )
{
if ( index < 0 )
{
mActiveVectorDataset = -1;
return;
}

Q_ASSERT( dataProvider()->datasetCount() > index );
if ( !dataProvider()->datasetHasScalarData( index ) )
mActiveVectorDataset = index;
@@ -82,6 +82,8 @@ struct QgsMesh;
* QgsMeshLayer *scratchLayer = new QgsMeshLayer(uri, "My Scratch Layer", "mdal");
* \endcode
*
* \note The API is considered EXPERIMENTAL and can be changed without a notice
*
* \since QGIS 3.2
*/
class CORE_EXPORT QgsMeshLayer : public QgsMapLayer
@@ -145,6 +147,8 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer
void setActiveScalarDataset( int index = -1 );
void setActiveVectorDataset( int index = -1 );

int activeScalarDataset() const { return mActiveScalarDataset; }

private: // Private methods

/**

0 comments on commit 9296528

Please sign in to comment.
You can’t perform that action at this time.