Skip to content

Commit

Permalink
Deprecate default ctor for mesh layer options
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso authored and nyalldawson committed Apr 17, 2019
1 parent f8dfdc4 commit 82f2cb1
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 21 deletions.
38 changes: 35 additions & 3 deletions python/core/auto_generated/mesh/qgsmeshlayer.sip.in
Expand Up @@ -78,16 +78,26 @@ is the MDAL connection string. QGIS must be built with MDAL support to allow thi
struct LayerOptions
{

explicit LayerOptions( const QgsCoordinateTransformContext &transformContext = QgsCoordinateTransformContext() );
explicit LayerOptions( ) /Deprecated/;
%Docstring
Constructor for LayerOptions.

.. deprecated:: Use version with transformContext argument instead
%End


explicit LayerOptions( const QgsCoordinateTransformContext &transformContext );
%Docstring
Constructor for LayerOptions.

.. versionadded:: 3.10
%End

QgsCoordinateTransformContext transformContext;
};

explicit QgsMeshLayer( const QString &path = QString(), const QString &baseName = QString(), const QString &providerLib = "mesh_memory",
const QgsMeshLayer::LayerOptions &options = QgsMeshLayer::LayerOptions() );
explicit QgsMeshLayer( const QString &path = QString(), const QString &baseName = QString(), const QString &providerLib = "mesh_memory",
const QgsMeshLayer::LayerOptions &options = QgsMeshLayer::LayerOptions() ) /Deprecated/;
%Docstring
Constructor - creates a mesh layer

Expand All @@ -100,7 +110,29 @@ data.
:param baseName: The name used to represent the layer in the legend
:param providerLib: The name of the data provider, e.g., "mesh_memory", "mdal"
:param options: general mesh layer options

.. deprecated:: Use version with layer options as a first argument instead
%End

explicit QgsMeshLayer( const QgsMeshLayer::LayerOptions &options, const QString &path = QString(),
const QString &baseName = QString(), const QString &providerLib = "mesh_memory" );
%Docstring
Constructor - creates a mesh layer

The QgsMeshLayer is constructed by instantiating a data provider. The provider
interprets the supplied path (url) of the data source to connect to and access the
data.

:param options: general mesh layer options
:param path: The path or url of the parameter. Typically this encodes
parameters used by the data provider as url query items.
:param baseName: The name used to represent the layer in the legend
:param providerLib: The name of the data provider, e.g., "mesh_memory", "mdal"

.. versionadded:: 3.10
%End


~QgsMeshLayer();


Expand Down
13 changes: 2 additions & 11 deletions python/core/auto_generated/raster/qgsrasterlayer.sip.in
Expand Up @@ -104,21 +104,12 @@ Constructor. Provider is not set.
struct LayerOptions
{

explicit LayerOptions( bool loadDefaultStyle = true ) /Deprecated/;
explicit LayerOptions( bool loadDefaultStyle = true,
const QgsCoordinateTransformContext &transformContext = QgsCoordinateTransformContext() );
%Docstring
Constructor for LayerOptions.

.. deprecated:: Use version with transformContext argument instead
%End

explicit LayerOptions( const QgsCoordinateTransformContext &transformContext, bool loadDefaultStyle = true );
%Docstring
Constructor for LayerOptions.

.. versionadded:: 3.10
%End


bool loadDefaultStyle;

QgsCoordinateTransformContext transformContext;
Expand Down
17 changes: 14 additions & 3 deletions src/core/mesh/qgsmeshlayer.cpp
Expand Up @@ -34,24 +34,35 @@
#include "qgsstyle.h"
#include "qgstriangularmesh.h"



QgsMeshLayer::QgsMeshLayer( const QString &meshLayerPath,
const QString &baseName,
const QString &providerKey,
const LayerOptions & )
const LayerOptions &options )
: QgsMapLayer( QgsMapLayerType::MeshLayer, baseName, meshLayerPath )
, mOptions( options )
{
setProviderType( providerKey );
// if we’re given a provider type, try to create and bind one to this layer
if ( !meshLayerPath.isEmpty() && !providerKey.isEmpty() )
{
QgsDataProvider::ProviderOptions providerOptions;
QgsDataProvider::ProviderOptions providerOptions { options.transformContext };
setDataProvider( providerKey, providerOptions );
}

setLegend( QgsMapLayerLegend::defaultMeshLegend( this ) );
setDefaultRendererSettings();
} // QgsMeshLayer ctor

QgsMeshLayer::QgsMeshLayer( const QString &meshLayerPath,
const QString &baseName,
const QString &providerKey,
const LayerOptions &options )
: QgsMeshLayer( options, meshLayerPath, baseName, providerKey )
{
}

void QgsMeshLayer::setDefaultRendererSettings()
{
if ( mDataProvider && mDataProvider->datasetGroupCount() > 0 )
Expand Down Expand Up @@ -85,7 +96,7 @@ const QgsMeshDataProvider *QgsMeshLayer::dataProvider() const

QgsMeshLayer *QgsMeshLayer::clone() const
{
QgsMeshLayer *layer = new QgsMeshLayer( source(), name(), mProviderKey );
QgsMeshLayer *layer = new QgsMeshLayer( mOptions, source(), name(), mProviderKey );
QgsMapLayer::clone( layer );
return layer;
}
Expand Down
42 changes: 38 additions & 4 deletions src/core/mesh/qgsmeshlayer.h
Expand Up @@ -100,12 +100,23 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer

/**
* Constructor for LayerOptions.
* \deprecated Use version with transformContext argument instead
*
*/
explicit LayerOptions( const QgsCoordinateTransformContext &transformContext = QgsCoordinateTransformContext() )
Q_DECL_DEPRECATED explicit LayerOptions( ) SIP_DEPRECATED
: transformContext( QgsCoordinateTransformContext() )
{}


/**
* Constructor for LayerOptions.
* \since QGIS 3.10
*/
explicit LayerOptions( const QgsCoordinateTransformContext &transformContext )
: transformContext( transformContext )
{}

QgsCoordinateTransformContext transformContext = QgsCoordinateTransformContext();
QgsCoordinateTransformContext transformContext;
};

/**
Expand All @@ -120,9 +131,29 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer
* \param baseName The name used to represent the layer in the legend
* \param providerLib The name of the data provider, e.g., "mesh_memory", "mdal"
* \param options general mesh layer options
* \deprecated Use version with layer options as a first argument instead
*/
Q_DECL_DEPRECATED explicit QgsMeshLayer( const QString &path = QString(), const QString &baseName = QString(), const QString &providerLib = "mesh_memory",
const QgsMeshLayer::LayerOptions &options = QgsMeshLayer::LayerOptions() ) SIP_DEPRECATED;

/**
* Constructor - creates a mesh layer
*
* The QgsMeshLayer is constructed by instantiating a data provider. The provider
* interprets the supplied path (url) of the data source to connect to and access the
* data.
*
* \param options general mesh layer options
* \param path The path or url of the parameter. Typically this encodes
* parameters used by the data provider as url query items.
* \param baseName The name used to represent the layer in the legend
* \param providerLib The name of the data provider, e.g., "mesh_memory", "mdal"
* \since QGIS 3.10
*/
explicit QgsMeshLayer( const QString &path = QString(), const QString &baseName = QString(), const QString &providerLib = "mesh_memory",
const QgsMeshLayer::LayerOptions &options = QgsMeshLayer::LayerOptions() );
explicit QgsMeshLayer( const QgsMeshLayer::LayerOptions &options, const QString &path = QString(),
const QString &baseName = QString(), const QString &providerLib = "mesh_memory" );


~QgsMeshLayer() override;

//! QgsMeshLayer cannot be copied.
Expand Down Expand Up @@ -303,6 +334,9 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer

//! Time format configuration
QgsMeshTimeSettings mTimeSettings;

//! Layer options
QgsMeshLayer::LayerOptions mOptions;
};

#endif //QGSMESHLAYER_H

0 comments on commit 82f2cb1

Please sign in to comment.