Skip to content

Commit 82f2cb1

Browse files
elpasonyalldawson
authored andcommittedApr 17, 2019
Deprecate default ctor for mesh layer options
1 parent f8dfdc4 commit 82f2cb1

File tree

4 files changed

+89
-21
lines changed

4 files changed

+89
-21
lines changed
 

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

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,26 @@ is the MDAL connection string. QGIS must be built with MDAL support to allow thi
7878
struct LayerOptions
7979
{
8080

81-
explicit LayerOptions( const QgsCoordinateTransformContext &transformContext = QgsCoordinateTransformContext() );
81+
explicit LayerOptions( ) /Deprecated/;
8282
%Docstring
8383
Constructor for LayerOptions.
84+
85+
.. deprecated:: Use version with transformContext argument instead
86+
%End
87+
88+
89+
explicit LayerOptions( const QgsCoordinateTransformContext &transformContext );
90+
%Docstring
91+
Constructor for LayerOptions.
92+
93+
.. versionadded:: 3.10
8494
%End
8595

8696
QgsCoordinateTransformContext transformContext;
8797
};
8898

89-
explicit QgsMeshLayer( const QString &path = QString(), const QString &baseName = QString(), const QString &providerLib = "mesh_memory",
90-
const QgsMeshLayer::LayerOptions &options = QgsMeshLayer::LayerOptions() );
99+
explicit QgsMeshLayer( const QString &path = QString(), const QString &baseName = QString(), const QString &providerLib = "mesh_memory",
100+
const QgsMeshLayer::LayerOptions &options = QgsMeshLayer::LayerOptions() ) /Deprecated/;
91101
%Docstring
92102
Constructor - creates a mesh layer
93103

@@ -100,7 +110,29 @@ data.
100110
:param baseName: The name used to represent the layer in the legend
101111
:param providerLib: The name of the data provider, e.g., "mesh_memory", "mdal"
102112
:param options: general mesh layer options
113+
114+
.. deprecated:: Use version with layer options as a first argument instead
103115
%End
116+
117+
explicit QgsMeshLayer( const QgsMeshLayer::LayerOptions &options, const QString &path = QString(),
118+
const QString &baseName = QString(), const QString &providerLib = "mesh_memory" );
119+
%Docstring
120+
Constructor - creates a mesh layer
121+
122+
The QgsMeshLayer is constructed by instantiating a data provider. The provider
123+
interprets the supplied path (url) of the data source to connect to and access the
124+
data.
125+
126+
:param options: general mesh layer options
127+
:param path: The path or url of the parameter. Typically this encodes
128+
parameters used by the data provider as url query items.
129+
:param baseName: The name used to represent the layer in the legend
130+
:param providerLib: The name of the data provider, e.g., "mesh_memory", "mdal"
131+
132+
.. versionadded:: 3.10
133+
%End
134+
135+
104136
~QgsMeshLayer();
105137

106138

‎python/core/auto_generated/raster/qgsrasterlayer.sip.in

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,12 @@ Constructor. Provider is not set.
104104
struct LayerOptions
105105
{
106106

107-
explicit LayerOptions( bool loadDefaultStyle = true ) /Deprecated/;
107+
explicit LayerOptions( bool loadDefaultStyle = true,
108+
const QgsCoordinateTransformContext &transformContext = QgsCoordinateTransformContext() );
108109
%Docstring
109110
Constructor for LayerOptions.
110-
111-
.. deprecated:: Use version with transformContext argument instead
112-
%End
113-
114-
explicit LayerOptions( const QgsCoordinateTransformContext &transformContext, bool loadDefaultStyle = true );
115-
%Docstring
116-
Constructor for LayerOptions.
117-
118-
.. versionadded:: 3.10
119111
%End
120112

121-
122113
bool loadDefaultStyle;
123114

124115
QgsCoordinateTransformContext transformContext;

‎src/core/mesh/qgsmeshlayer.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,35 @@
3434
#include "qgsstyle.h"
3535
#include "qgstriangularmesh.h"
3636

37+
38+
3739
QgsMeshLayer::QgsMeshLayer( const QString &meshLayerPath,
3840
const QString &baseName,
3941
const QString &providerKey,
40-
const LayerOptions & )
42+
const LayerOptions &options )
4143
: QgsMapLayer( QgsMapLayerType::MeshLayer, baseName, meshLayerPath )
44+
, mOptions( options )
4245
{
4346
setProviderType( providerKey );
4447
// if we’re given a provider type, try to create and bind one to this layer
4548
if ( !meshLayerPath.isEmpty() && !providerKey.isEmpty() )
4649
{
47-
QgsDataProvider::ProviderOptions providerOptions;
50+
QgsDataProvider::ProviderOptions providerOptions { options.transformContext };
4851
setDataProvider( providerKey, providerOptions );
4952
}
5053

5154
setLegend( QgsMapLayerLegend::defaultMeshLegend( this ) );
5255
setDefaultRendererSettings();
5356
} // QgsMeshLayer ctor
5457

58+
QgsMeshLayer::QgsMeshLayer( const QString &meshLayerPath,
59+
const QString &baseName,
60+
const QString &providerKey,
61+
const LayerOptions &options )
62+
: QgsMeshLayer( options, meshLayerPath, baseName, providerKey )
63+
{
64+
}
65+
5566
void QgsMeshLayer::setDefaultRendererSettings()
5667
{
5768
if ( mDataProvider && mDataProvider->datasetGroupCount() > 0 )
@@ -85,7 +96,7 @@ const QgsMeshDataProvider *QgsMeshLayer::dataProvider() const
8596

8697
QgsMeshLayer *QgsMeshLayer::clone() const
8798
{
88-
QgsMeshLayer *layer = new QgsMeshLayer( source(), name(), mProviderKey );
99+
QgsMeshLayer *layer = new QgsMeshLayer( mOptions, source(), name(), mProviderKey );
89100
QgsMapLayer::clone( layer );
90101
return layer;
91102
}

‎src/core/mesh/qgsmeshlayer.h

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,23 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer
100100

101101
/**
102102
* Constructor for LayerOptions.
103+
* \deprecated Use version with transformContext argument instead
104+
*
103105
*/
104-
explicit LayerOptions( const QgsCoordinateTransformContext &transformContext = QgsCoordinateTransformContext() )
106+
Q_DECL_DEPRECATED explicit LayerOptions( ) SIP_DEPRECATED
107+
: transformContext( QgsCoordinateTransformContext() )
108+
{}
109+
110+
111+
/**
112+
* Constructor for LayerOptions.
113+
* \since QGIS 3.10
114+
*/
115+
explicit LayerOptions( const QgsCoordinateTransformContext &transformContext )
105116
: transformContext( transformContext )
106117
{}
107118

108-
QgsCoordinateTransformContext transformContext = QgsCoordinateTransformContext();
119+
QgsCoordinateTransformContext transformContext;
109120
};
110121

111122
/**
@@ -120,9 +131,29 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer
120131
* \param baseName The name used to represent the layer in the legend
121132
* \param providerLib The name of the data provider, e.g., "mesh_memory", "mdal"
122133
* \param options general mesh layer options
134+
* \deprecated Use version with layer options as a first argument instead
135+
*/
136+
Q_DECL_DEPRECATED explicit QgsMeshLayer( const QString &path = QString(), const QString &baseName = QString(), const QString &providerLib = "mesh_memory",
137+
const QgsMeshLayer::LayerOptions &options = QgsMeshLayer::LayerOptions() ) SIP_DEPRECATED;
138+
139+
/**
140+
* Constructor - creates a mesh layer
141+
*
142+
* The QgsMeshLayer is constructed by instantiating a data provider. The provider
143+
* interprets the supplied path (url) of the data source to connect to and access the
144+
* data.
145+
*
146+
* \param options general mesh layer options
147+
* \param path The path or url of the parameter. Typically this encodes
148+
* parameters used by the data provider as url query items.
149+
* \param baseName The name used to represent the layer in the legend
150+
* \param providerLib The name of the data provider, e.g., "mesh_memory", "mdal"
151+
* \since QGIS 3.10
123152
*/
124-
explicit QgsMeshLayer( const QString &path = QString(), const QString &baseName = QString(), const QString &providerLib = "mesh_memory",
125-
const QgsMeshLayer::LayerOptions &options = QgsMeshLayer::LayerOptions() );
153+
explicit QgsMeshLayer( const QgsMeshLayer::LayerOptions &options, const QString &path = QString(),
154+
const QString &baseName = QString(), const QString &providerLib = "mesh_memory" );
155+
156+
126157
~QgsMeshLayer() override;
127158

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

304335
//! Time format configuration
305336
QgsMeshTimeSettings mTimeSettings;
337+
338+
//! Layer options
339+
QgsMeshLayer::LayerOptions mOptions;
306340
};
307341

308342
#endif //QGSMESHLAYER_H

0 commit comments

Comments
 (0)
Please sign in to comment.