Skip to content
Permalink
Browse files

Deprecate default ctor for mesh layer options

  • Loading branch information
elpaso authored and nyalldawson committed Apr 17, 2019
1 parent f8dfdc4 commit 82f2cb18b28599e8adffbd8e05c2d3efbf9b8f4c
@@ -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

@@ -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();


@@ -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;
@@ -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 )
@@ -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;
}
@@ -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;
};

/**
@@ -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.
@@ -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.
You can’t perform that action at this time.