Skip to content

Commit

Permalink
[FEATURE] Rendering of scalar data on mesh layers
Browse files Browse the repository at this point in the history
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 16, 2018
1 parent 3154102 commit 9296528
Show file tree
Hide file tree
Showing 12 changed files with 476 additions and 4 deletions.
16 changes: 16 additions & 0 deletions python/core/auto_generated/mesh/qgsmeshdataprovider.sip.in
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions python/core/auto_generated/mesh/qgsmeshlayer.sip.in
Expand Up @@ -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

Expand Down Expand Up @@ -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 );
};
Expand Down
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -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
Expand Down Expand Up @@ -1075,6 +1076,7 @@ SET(QGIS_CORE_HDRS

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

scalebar/qgsdoubleboxscalebarrenderer.h
scalebar/qgsnumericscalebarrenderer.h
Expand Down
4 changes: 4 additions & 0 deletions src/core/mesh/qgsmeshdataprovider.cpp
Expand Up @@ -94,6 +94,10 @@ void QgsMeshDatasetValue::setX( double x )
{
mIsNodata = true;
}
else
{
mIsNodata = false;
}
}

void QgsMeshDatasetValue::setY( double y )
Expand Down
8 changes: 8 additions & 0 deletions src/core/mesh/qgsmeshdataprovider.h
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
*/
Expand Down
12 changes: 12 additions & 0 deletions src/core/mesh/qgsmeshlayer.cpp
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/core/mesh/qgsmeshlayer.h
Expand Up @@ -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
Expand Down Expand Up @@ -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

/**
Expand Down

0 comments on commit 9296528

Please sign in to comment.