Branch data Line data Source code
1 : : /***************************************************************************
2 : : qgsmaplayer.h - description
3 : : -------------------
4 : : begin : Fri Jun 28 2002
5 : : copyright : (C) 2002 by Gary E.Sherman
6 : : email : sherman at mrcc.com
7 : : ***************************************************************************/
8 : :
9 : : /***************************************************************************
10 : : * *
11 : : * This program is free software; you can redistribute it and/or modify *
12 : : * it under the terms of the GNU General Public License as published by *
13 : : * the Free Software Foundation; either version 2 of the License, or *
14 : : * (at your option) any later version. *
15 : : * *
16 : : ***************************************************************************/
17 : :
18 : : #ifndef QGSMAPLAYER_H
19 : : #define QGSMAPLAYER_H
20 : :
21 : : #include "qgis_core.h"
22 : : #include <QDateTime>
23 : : #include <QDomNode>
24 : : #include <QImage>
25 : : #include <QObject>
26 : : #include <QPainter>
27 : : #include <QUndoStack>
28 : : #include <QVariant>
29 : : #include <QIcon>
30 : :
31 : : #include "qgis_sip.h"
32 : : #include "qgserror.h"
33 : : #include "qgsobjectcustomproperties.h"
34 : : #include "qgsrectangle.h"
35 : : #include "qgscoordinatereferencesystem.h"
36 : : #include "qgsrendercontext.h"
37 : : #include "qgsmaplayerdependency.h"
38 : : #include "qgslayermetadata.h"
39 : : #include "qgsmaplayerstyle.h"
40 : : #include "qgsreadwritecontext.h"
41 : : #include "qgsdataprovider.h"
42 : :
43 : : class QgsAbstract3DRenderer;
44 : : class QgsDataProvider;
45 : : class QgsMapLayerLegend;
46 : : class QgsMapLayerRenderer;
47 : : class QgsMapLayerStyleManager;
48 : : class QgsProject;
49 : : class QgsStyleEntityVisitorInterface;
50 : : class QgsMapLayerTemporalProperties;
51 : : class QgsMapLayerElevationProperties;
52 : :
53 : : class QDomDocument;
54 : : class QKeyEvent;
55 : : class QPainter;
56 : :
57 : : /*
58 : : * Constants used to describe copy-paste MIME types
59 : : */
60 : : #define QGSCLIPBOARD_MAPLAYER_MIME "application/qgis.maplayer"
61 : :
62 : :
63 : : /**
64 : : * \ingroup core
65 : : * \brief Types of layers that can be added to a map
66 : : * \since QGIS 3.8
67 : : */
68 : : enum class QgsMapLayerType SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsMapLayer, LayerType ) : int
69 : : {
70 : : VectorLayer,
71 : : RasterLayer,
72 : : PluginLayer,
73 : : MeshLayer, //!< Added in 3.2
74 : : VectorTileLayer, //!< Added in 3.14
75 : : AnnotationLayer, //!< Contains freeform, georeferenced annotations. Added in QGIS 3.16
76 : : PointCloudLayer, //!< Added in 3.18
77 : : };
78 : :
79 : : /**
80 : : * \ingroup core
81 : : * \brief Base class for all map layer types.
82 : : * This is the base class for all map layer types (vector, raster).
83 : : */
84 : : class CORE_EXPORT QgsMapLayer : public QObject
85 : : {
86 : 141 : Q_OBJECT
87 : :
88 : : Q_PROPERTY( QString name READ name WRITE setName NOTIFY nameChanged )
89 : : Q_PROPERTY( int autoRefreshInterval READ autoRefreshInterval WRITE setAutoRefreshInterval NOTIFY autoRefreshIntervalChanged )
90 : : Q_PROPERTY( QgsLayerMetadata metadata READ metadata WRITE setMetadata NOTIFY metadataChanged )
91 : : Q_PROPERTY( QgsCoordinateReferenceSystem crs READ crs WRITE setCrs NOTIFY crsChanged )
92 : : Q_PROPERTY( QgsMapLayerType type READ type CONSTANT )
93 : : Q_PROPERTY( bool isValid READ isValid NOTIFY isValidChanged )
94 : : Q_PROPERTY( double opacity READ opacity WRITE setOpacity NOTIFY opacityChanged )
95 : :
96 : : #ifdef SIP_RUN
97 : : SIP_CONVERT_TO_SUBCLASS_CODE
98 : : QgsMapLayer * layer = qobject_cast<QgsMapLayer *>( sipCpp );
99 : :
100 : : sipType = 0;
101 : :
102 : : if ( layer )
103 : : {
104 : : switch ( layer->type() )
105 : : {
106 : : case QgsMapLayerType::VectorLayer:
107 : : sipType = sipType_QgsVectorLayer;
108 : : break;
109 : : case QgsMapLayerType::RasterLayer:
110 : : sipType = sipType_QgsRasterLayer;
111 : : break;
112 : : case QgsMapLayerType::PluginLayer:
113 : : sipType = sipType_QgsPluginLayer;
114 : : break;
115 : : case QgsMapLayerType::MeshLayer:
116 : : sipType = sipType_QgsMeshLayer;
117 : : break;
118 : : case QgsMapLayerType::VectorTileLayer:
119 : : sipType = sipType_QgsVectorTileLayer;
120 : : break;
121 : : case QgsMapLayerType::AnnotationLayer:
122 : : sipType = sipType_QgsAnnotationLayer;
123 : : break;
124 : : case QgsMapLayerType::PointCloudLayer:
125 : : sipType = sipType_QgsPointCloudLayer;
126 : : break;
127 : : default:
128 : : sipType = nullptr;
129 : : break;
130 : : }
131 : : }
132 : : SIP_END
133 : : #endif
134 : :
135 : : public:
136 : :
137 : : /**
138 : : * Maplayer has a style and a metadata property
139 : : * \since QGIS 3.0
140 : : */
141 : : enum PropertyType
142 : : {
143 : : Style = 0,
144 : : Metadata,
145 : : };
146 : :
147 : : /**
148 : : * Flags for the map layer
149 : : * \note Flags are options specified by the user used for the UI but are not preventing any API call.
150 : : * \since QGIS 3.4
151 : : */
152 : : enum LayerFlag
153 : : {
154 : : Identifiable = 1 << 0, //!< If the layer is identifiable using the identify map tool and as a WMS layer.
155 : : Removable = 1 << 1, //!< If the layer can be removed from the project. The layer will not be removable from the legend menu entry but can still be removed with an API call.
156 : : Searchable = 1 << 2, //!< Only for vector-layer, determines if the layer is used in the 'search all layers' locator.
157 : : Private = 1 << 3, //!< Determines if the layer is meant to be exposed to the GUI, i.e. visible in the layer legend tree.
158 : : };
159 : 0 : Q_ENUM( LayerFlag )
160 : : Q_DECLARE_FLAGS( LayerFlags, LayerFlag )
161 : : Q_FLAG( LayerFlags )
162 : :
163 : : /**
164 : : * Categories of style to distinguish appropriate sections for import/export
165 : : * \since QGIS 3.4
166 : : */
167 : : enum StyleCategory
168 : : {
169 : : LayerConfiguration = 1 << 0, //!< General configuration: identifiable, removable, searchable, display expression, read-only
170 : : Symbology = 1 << 1, //!< Symbology
171 : : Symbology3D = 1 << 2, //!< 3D symbology
172 : : Labeling = 1 << 3, //!< Labeling
173 : : Fields = 1 << 4, //!< Aliases, widgets, WMS/WFS, expressions, constraints, virtual fields
174 : : Forms = 1 << 5, //!< Feature form
175 : : Actions = 1 << 6, //!< Actions
176 : : MapTips = 1 << 7, //!< Map tips
177 : : Diagrams = 1 << 8, //!< Diagrams
178 : : AttributeTable = 1 << 9, //!< Attribute table settings: choice and order of columns, conditional styling
179 : : Rendering = 1 << 10, //!< Rendering: scale visibility, simplify method, opacity
180 : : CustomProperties = 1 << 11, //!< Custom properties (by plugins for instance)
181 : : GeometryOptions = 1 << 12, //!< Geometry validation configuration
182 : : Relations = 1 << 13, //!< Relations
183 : : Temporal = 1 << 14, //!< Temporal properties (since QGIS 3.14)
184 : : Legend = 1 << 15, //!< Legend settings (since QGIS 3.16)
185 : : Elevation = 1 << 16, //!< Elevation settings (since QGIS 3.18)
186 : : AllStyleCategories = LayerConfiguration | Symbology | Symbology3D | Labeling | Fields | Forms | Actions |
187 : : MapTips | Diagrams | AttributeTable | Rendering | CustomProperties | GeometryOptions | Relations | Temporal | Legend | Elevation,
188 : : };
189 : 0 : Q_ENUM( StyleCategory )
190 : : Q_DECLARE_FLAGS( StyleCategories, StyleCategory )
191 : 0 : Q_FLAG( StyleCategories )
192 : :
193 : : /**
194 : : * Constructor for QgsMapLayer
195 : : * \param type layer type
196 : : * \param name display name for the layer
197 : : * \param source datasource of layer
198 : : */
199 : : QgsMapLayer( QgsMapLayerType type = QgsMapLayerType::VectorLayer, const QString &name = QString(), const QString &source = QString() );
200 : :
201 : : ~QgsMapLayer() override;
202 : :
203 : : //! QgsMapLayer cannot be copied
204 : : QgsMapLayer( QgsMapLayer const & ) = delete;
205 : : //! QgsMapLayer cannot be copied
206 : : QgsMapLayer &operator=( QgsMapLayer const & ) = delete;
207 : :
208 : : /**
209 : : * Returns a new instance equivalent to this one except for the id which
210 : : * is still unique.
211 : : * \returns a new layer instance
212 : : * \since QGIS 3.0
213 : : */
214 : : virtual QgsMapLayer *clone() const = 0;
215 : :
216 : : /**
217 : : * Returns the type of the layer.
218 : : */
219 : : QgsMapLayerType type() const;
220 : :
221 : : /**
222 : : * Returns the flags for this layer.
223 : : * \note Flags are options specified by the user used for the UI but are not preventing any API call.
224 : : * For instance, even if the Removable flag is not set, the layer can still be removed with the API
225 : : * but the action will not be listed in the legend menu.
226 : : * \since QGIS 3.4
227 : : */
228 : : QgsMapLayer::LayerFlags flags() const;
229 : :
230 : : /**
231 : : * Returns the flags for this layer.
232 : : * \note Flags are options specified by the user used for the UI but are not preventing any API call.
233 : : * For instance, even if the Removable flag is not set, the layer can still be removed with the API
234 : : * but the action will not be listed in the legend menu.
235 : : * \since QGIS 3.4
236 : : */
237 : : void setFlags( QgsMapLayer::LayerFlags flags );
238 : :
239 : : /**
240 : : * Returns the extension of a Property.
241 : : * \returns The extension
242 : : * \since QGIS 3.0
243 : : */
244 : : static QString extensionPropertyType( PropertyType type );
245 : :
246 : : //! Returns the layer's unique ID, which is used to access this layer from QgsProject.
247 : : QString id() const;
248 : :
249 : : /**
250 : : * Set the display \a name of the layer.
251 : : * \see name()
252 : : * \since QGIS 2.16
253 : : */
254 : : void setName( const QString &name );
255 : :
256 : : /**
257 : : * Returns the display name of the layer.
258 : : * \see setName()
259 : : */
260 : : QString name() const;
261 : :
262 : : /**
263 : : * Returns the layer's data provider, it may be NULLPTR.
264 : : */
265 : : Q_INVOKABLE virtual QgsDataProvider *dataProvider();
266 : :
267 : : /**
268 : : * Returns the layer's data provider in a const-correct manner, it may be NULLPTR.
269 : : * \note not available in Python bindings
270 : : */
271 : : virtual const QgsDataProvider *dataProvider() const SIP_SKIP;
272 : :
273 : : /**
274 : : * Sets the short name of the layer
275 : : * used by QGIS Server to identify the layer.
276 : : * \returns the layer short name
277 : : * \see shortName()
278 : : */
279 : 0 : void setShortName( const QString &shortName ) { mShortName = shortName; }
280 : :
281 : : /**
282 : : * Returns the short name of the layer
283 : : * used by QGIS Server to identify the layer.
284 : : * \see setShortName()
285 : : */
286 : : QString shortName() const;
287 : :
288 : : /**
289 : : * Sets the title of the layer
290 : : * used by QGIS Server in GetCapabilities request.
291 : : * \see title()
292 : : */
293 : 0 : void setTitle( const QString &title ) { mTitle = title; }
294 : :
295 : : /**
296 : : * Returns the title of the layer
297 : : * used by QGIS Server in GetCapabilities request.
298 : : * \returns the layer title
299 : : * \see setTitle()
300 : : */
301 : 0 : QString title() const { return mTitle; }
302 : :
303 : : /**
304 : : * Sets the abstract of the layer
305 : : * used by QGIS Server in GetCapabilities request.
306 : : * \returns the layer abstract
307 : : * \see abstract()
308 : : */
309 : 0 : void setAbstract( const QString &abstract ) { mAbstract = abstract; }
310 : :
311 : : /**
312 : : * Returns the abstract of the layer
313 : : * used by QGIS Server in GetCapabilities request.
314 : : * \returns the layer abstract
315 : : * \see setAbstract()
316 : : */
317 : 0 : QString abstract() const { return mAbstract; }
318 : :
319 : : /**
320 : : * Sets the keyword list of the layer
321 : : * used by QGIS Server in GetCapabilities request.
322 : : * \returns the layer keyword list
323 : : * \see keywordList()
324 : : */
325 : 0 : void setKeywordList( const QString &keywords ) { mKeywordList = keywords; }
326 : :
327 : : /**
328 : : * Returns the keyword list of the layer
329 : : * used by QGIS Server in GetCapabilities request.
330 : : * \returns the layer keyword list
331 : : * \see setKeywordList()
332 : : */
333 : 0 : QString keywordList() const { return mKeywordList; }
334 : :
335 : : /* Layer dataUrl information */
336 : :
337 : : /**
338 : : * Sets the DataUrl of the layer
339 : : * used by QGIS Server in GetCapabilities request.
340 : : * DataUrl is a a link to the underlying data represented by a particular layer.
341 : : * \returns the layer DataUrl
342 : : * \see dataUrl()
343 : : */
344 : 0 : void setDataUrl( const QString &dataUrl ) { mDataUrl = dataUrl; }
345 : :
346 : : /**
347 : : * Returns the DataUrl of the layer
348 : : * used by QGIS Server in GetCapabilities request.
349 : : * DataUrl is a a link to the underlying data represented by a particular layer.
350 : : * \returns the layer DataUrl
351 : : * \see setDataUrl()
352 : : */
353 : 0 : QString dataUrl() const { return mDataUrl; }
354 : :
355 : : /**
356 : : * Sets the DataUrl format of the layer
357 : : * used by QGIS Server in GetCapabilities request.
358 : : * DataUrl is a a link to the underlying data represented by a particular layer.
359 : : * \returns the layer DataUrl format
360 : : * \see dataUrlFormat()
361 : : */
362 : 0 : void setDataUrlFormat( const QString &dataUrlFormat ) { mDataUrlFormat = dataUrlFormat; }
363 : :
364 : : /**
365 : : * Returns the DataUrl format of the layer
366 : : * used by QGIS Server in GetCapabilities request.
367 : : * DataUrl is a a link to the underlying data represented by a particular layer.
368 : : * \returns the layer DataUrl format
369 : : * \see setDataUrlFormat()
370 : : */
371 : 0 : QString dataUrlFormat() const { return mDataUrlFormat; }
372 : :
373 : : /* Layer attribution information */
374 : :
375 : : /**
376 : : * Sets the attribution of the layer
377 : : * used by QGIS Server in GetCapabilities request.
378 : : * Attribution indicates the provider of a layer or collection of layers.
379 : : * \returns the layer attribution
380 : : * \see attribution()
381 : : */
382 : 0 : void setAttribution( const QString &attrib ) { mAttribution = attrib; }
383 : :
384 : : /**
385 : : * Returns the attribution of the layer
386 : : * used by QGIS Server in GetCapabilities request.
387 : : * Attribution indicates the provider of a layer or collection of layers.
388 : : * \returns the layer attribution
389 : : * \see setAttribution()
390 : : */
391 : 0 : QString attribution() const { return mAttribution; }
392 : :
393 : : /**
394 : : * Sets the attribution URL of the layer
395 : : * used by QGIS Server in GetCapabilities request.
396 : : * Attribution indicates the provider of a layer or collection of layers.
397 : : * \returns the layer attribution URL
398 : : * \see attributionUrl()
399 : : */
400 : 0 : void setAttributionUrl( const QString &attribUrl ) { mAttributionUrl = attribUrl; }
401 : :
402 : : /**
403 : : * Returns the attribution URL of the layer
404 : : * used by QGIS Server in GetCapabilities request.
405 : : * Attribution indicates the provider of a layer or collection of layers.
406 : : * \returns the layer attribution URL
407 : : * \see setAttributionUrl()
408 : : */
409 : 0 : QString attributionUrl() const { return mAttributionUrl; }
410 : :
411 : : /* Layer metadataUrl information */
412 : :
413 : : /**
414 : : * Sets the metadata URL of the layer
415 : : * used by QGIS Server in GetCapabilities request.
416 : : * MetadataUrl is a a link to the detailed, standardized metadata about the data.
417 : : * \returns the layer metadata URL
418 : : * \see metadataUrl()
419 : : */
420 : 0 : void setMetadataUrl( const QString &metaUrl ) { mMetadataUrl = metaUrl; }
421 : :
422 : : /**
423 : : * Returns the metadata URL of the layer
424 : : * used by QGIS Server in GetCapabilities request.
425 : : * MetadataUrl is a a link to the detailed, standardized metadata about the data.
426 : : * \returns the layer metadata URL
427 : : * \see setMetadataUrl()
428 : : */
429 : 0 : QString metadataUrl() const { return mMetadataUrl; }
430 : :
431 : : /**
432 : : * Set the metadata type of the layer
433 : : * used by QGIS Server in GetCapabilities request
434 : : * MetadataUrlType indicates the standard to which the metadata complies.
435 : : * \returns the layer metadata type
436 : : * \see metadataUrlType()
437 : : */
438 : 0 : void setMetadataUrlType( const QString &metaUrlType ) { mMetadataUrlType = metaUrlType; }
439 : :
440 : : /**
441 : : * Returns the metadata type of the layer
442 : : * used by QGIS Server in GetCapabilities request.
443 : : * MetadataUrlType indicates the standard to which the metadata complies.
444 : : * \returns the layer metadata type
445 : : * \see setMetadataUrlType()
446 : : */
447 : 0 : QString metadataUrlType() const { return mMetadataUrlType; }
448 : :
449 : : /**
450 : : * Sets the metadata format of the layer
451 : : * used by QGIS Server in GetCapabilities request.
452 : : * MetadataUrlType indicates how the metadata is structured.
453 : : * \returns the layer metadata format
454 : : * \see metadataUrlFormat()
455 : : */
456 : 0 : void setMetadataUrlFormat( const QString &metaUrlFormat ) { mMetadataUrlFormat = metaUrlFormat; }
457 : :
458 : : /**
459 : : * Returns the metadata format of the layer
460 : : * used by QGIS Server in GetCapabilities request.
461 : : * MetadataUrlType indicates how the metadata is structured.
462 : : * \returns the layer metadata format
463 : : * \see setMetadataUrlFormat()
464 : : */
465 : 0 : QString metadataUrlFormat() const { return mMetadataUrlFormat; }
466 : :
467 : : /**
468 : : * Set the blending mode used for rendering a layer.
469 : : * \param blendMode new blending mode
470 : : * \see blendMode()
471 : : */
472 : : void setBlendMode( QPainter::CompositionMode blendMode );
473 : :
474 : : /**
475 : : * Returns the current blending mode for a layer.
476 : : * \see setBlendMode()
477 : : */
478 : : QPainter::CompositionMode blendMode() const;
479 : :
480 : : /**
481 : : * Sets the \a opacity for the layer, where \a opacity is a value between 0 (totally transparent)
482 : : * and 1.0 (fully opaque).
483 : : * \see opacity()
484 : : * \see opacityChanged()
485 : : * \note Prior to QGIS 3.18, this method was available for vector layers only
486 : : * \since QGIS 3.18
487 : : */
488 : : virtual void setOpacity( double opacity );
489 : :
490 : : /**
491 : : * Returns the opacity for the layer, where opacity is a value between 0 (totally transparent)
492 : : * and 1.0 (fully opaque).
493 : : * \see setOpacity()
494 : : * \see opacityChanged()
495 : : * \note Prior to QGIS 3.18, this method was available for vector layers only
496 : : * \since QGIS 3.18
497 : : */
498 : : virtual double opacity() const;
499 : :
500 : : //! Returns if this layer is read only.
501 : 0 : bool readOnly() const { return isReadOnly(); }
502 : :
503 : : /**
504 : : * Synchronises with changes in the datasource
505 : : */
506 : : Q_INVOKABLE virtual void reload() {}
507 : :
508 : : /**
509 : : * Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context
510 : : * \since QGIS 2.4
511 : : */
512 : : virtual QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) = 0 SIP_FACTORY;
513 : :
514 : : //! Returns the extent of the layer.
515 : : virtual QgsRectangle extent() const;
516 : :
517 : : /**
518 : : * Returns the WGS84 extent (EPSG:4326) of the layer according to
519 : : * ReadFlag::FlagTrustLayerMetadata. If that flag is activated, then the
520 : : * WGS84 extent read in the qgs project is returned. Otherwise, the actual
521 : : * WGS84 extent is returned.
522 : : * \param forceRecalculate True to return the current WGS84 extent whatever the read flags
523 : : * \since QGIS 3.20
524 : : */
525 : : QgsRectangle wgs84Extent( bool forceRecalculate = false ) const;
526 : :
527 : : /**
528 : : * Returns the status of the layer. An invalid layer is one which has a bad datasource
529 : : * or other problem. Child classes set this flag when initialized.
530 : : * \returns TRUE if the layer is valid and can be accessed
531 : : */
532 : : bool isValid() const;
533 : :
534 : : /**
535 : : * Gets a version of the internal layer definition that has sensitive
536 : : * bits removed (for example, the password). This function should
537 : : * be used when displaying the source name for general viewing.
538 : : * \see source()
539 : : */
540 : : QString publicSource() const;
541 : :
542 : : /**
543 : : * Returns the source for the layer. This source may contain usernames, passwords
544 : : * and other sensitive information.
545 : : * \see publicSource()
546 : : */
547 : : QString source() const;
548 : :
549 : : /**
550 : : * Returns the sublayers of this layer.
551 : : * (Useful for providers that manage their own layers, such as WMS).
552 : : */
553 : : virtual QStringList subLayers() const;
554 : :
555 : : /**
556 : : * Reorders the *previously selected* sublayers of this layer from bottom to top.
557 : : * (Useful for providers that manage their own layers, such as WMS).
558 : : */
559 : : virtual void setLayerOrder( const QStringList &layers );
560 : :
561 : : /**
562 : : * Set the visibility of the given sublayer name.
563 : : * \param name sublayer name
564 : : * \param visible sublayer visibility
565 : : */
566 : : virtual void setSubLayerVisibility( const QString &name, bool visible );
567 : :
568 : : //! Returns TRUE if the layer can be edited.
569 : : virtual bool isEditable() const;
570 : :
571 : : /**
572 : : * Returns TRUE if the layer is considered a spatial layer, ie it has some form of geometry associated with it.
573 : : * \since QGIS 2.16
574 : : */
575 : : virtual bool isSpatial() const;
576 : :
577 : : /**
578 : : * Returns TRUE if the layer is considered a temporary layer.
579 : : *
580 : : * These include memory-only layers such as those created by the "memory" data provider, layers
581 : : * stored inside a local temporary folder (such as the "/tmp" folder on Linux)
582 : : * or layer with temporary data (as temporary mesh layer dataset)
583 : : *
584 : : * \since QGIS 3.10.1
585 : : */
586 : : virtual bool isTemporary() const;
587 : :
588 : : /**
589 : : * Flags which control project read behavior.
590 : : * \since QGIS 3.10
591 : : */
592 : : enum ReadFlag
593 : : {
594 : : FlagDontResolveLayers = 1 << 0, //!< Don't resolve layer paths or create data providers for layers.
595 : : FlagTrustLayerMetadata = 1 << 1, //!< Trust layer metadata. Improves layer load time by skipping expensive checks like primary key unicity, geometry type and srid and by using estimated metadata on layer load. Since QGIS 3.16
596 : : };
597 : : Q_DECLARE_FLAGS( ReadFlags, ReadFlag )
598 : :
599 : : /**
600 : : * Sets state from DOM document
601 : : * \param layerElement The DOM element corresponding to ``maplayer'' tag
602 : : * \param context writing context (e.g. for conversion between relative and absolute paths)
603 : : * \param flags optional argument which can be used to control layer reading behavior.
604 : : * \note
605 : : *
606 : : * The DOM node corresponds to a DOM document project file XML element read
607 : : * by QgsProject.
608 : : *
609 : : * This, in turn, calls readXml() (and then readSymbology()), which is overridable
610 : : * by sub-classes so that they can read their own specific state from the given DOM node.
611 : : *
612 : : * Invoked by QgsProject::read().
613 : : *
614 : : * \returns TRUE if successful
615 : : */
616 : : bool readLayerXml( const QDomElement &layerElement, QgsReadWriteContext &context, QgsMapLayer::ReadFlags flags = QgsMapLayer::ReadFlags() );
617 : :
618 : : /**
619 : : * Stores state in DOM node
620 : : * \param layerElement is a DOM element corresponding to ``maplayer'' tag
621 : : * \param document is a the DOM document being written
622 : : * \param context reading context (e.g. for conversion between relative and absolute paths)
623 : : * \note
624 : : *
625 : : * The DOM node corresponds to a DOM document project file XML element to be
626 : : * written by QgsProject.
627 : : *
628 : : * This, in turn, calls writeXml() (and then writeSymbology), which is over-rideable
629 : : * by sub-classes so that they can write their own specific state to the given DOM node.
630 : : *
631 : : * Invoked by QgsProject::write().
632 : : *
633 : : * \returns TRUE if successful
634 : : */
635 : : bool writeLayerXml( QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context ) const;
636 : :
637 : : /**
638 : : * Resolve references to other layers (kept as layer IDs after reading XML) into layer objects.
639 : : * \since QGIS 3.0
640 : : */
641 : : virtual void resolveReferences( QgsProject *project );
642 : :
643 : : /**
644 : : * Returns list of all keys within custom properties. Properties are stored in a map and saved in project file.
645 : : * \see customProperty()
646 : : * \since QGIS 3.0
647 : : */
648 : : Q_INVOKABLE QStringList customPropertyKeys() const;
649 : :
650 : : /**
651 : : * Set a custom property for layer. Properties are stored in a map and saved in project file.
652 : : * \see customProperty()
653 : : * \see removeCustomProperty()
654 : : */
655 : : Q_INVOKABLE void setCustomProperty( const QString &key, const QVariant &value );
656 : :
657 : : /**
658 : : * Read a custom property from layer. Properties are stored in a map and saved in project file.
659 : : * \see setCustomProperty()
660 : : */
661 : : Q_INVOKABLE QVariant customProperty( const QString &value, const QVariant &defaultValue = QVariant() ) const;
662 : :
663 : : /**
664 : : * Set custom properties for layer. Current properties are dropped.
665 : : * \since QGIS 3.0
666 : : */
667 : : void setCustomProperties( const QgsObjectCustomProperties &properties );
668 : :
669 : : /**
670 : : * Read all custom properties from layer. Properties are stored in a map and saved in project file.
671 : : * \see setCustomProperties
672 : : * \since QGIS 3.14
673 : : */
674 : : const QgsObjectCustomProperties &customProperties() const;
675 : :
676 : : /**
677 : : * Remove a custom property from layer. Properties are stored in a map and saved in project file.
678 : : * \see setCustomProperty()
679 : : */
680 : : void removeCustomProperty( const QString &key );
681 : :
682 : : /**
683 : : * Gets current status error. This error describes some principal problem
684 : : * for which layer cannot work and thus is not valid. It is not last error
685 : : * after accessing data by draw() etc.
686 : : */
687 : : virtual QgsError error() const;
688 : :
689 : : /**
690 : : * Returns the layer's spatial reference system.
691 : : * \since QGIS 1.4
692 : : */
693 : : QgsCoordinateReferenceSystem crs() const;
694 : :
695 : : //! Sets layer's spatial reference system
696 : : void setCrs( const QgsCoordinateReferenceSystem &srs, bool emitSignal = true );
697 : :
698 : : /**
699 : : * Returns the layer data provider coordinate transform context
700 : : * or a default transform context if the layer does not have a valid data provider.
701 : : * \since QGIS 3.8
702 : : */
703 : : QgsCoordinateTransformContext transformContext( ) const;
704 : :
705 : :
706 : : /**
707 : : * A convenience function to capitalize and format a layer \a name.
708 : : *
709 : : * \since QGIS 3.0
710 : : */
711 : : static QString formatLayerName( const QString &name );
712 : :
713 : : /**
714 : : * Retrieve the metadata URI for this layer
715 : : * (either as a .qmd file on disk or as a
716 : : * record in the users style table in their personal qgis.db)
717 : : * \returns a QString with the metadata file name
718 : : * \since QGIS 3.0
719 : : */
720 : : virtual QString metadataUri() const;
721 : :
722 : : /**
723 : : * Export the current metadata of this layer as named metadata in a QDomDocument
724 : : * \param doc the target QDomDocument
725 : : * \param errorMsg this QString will be initialized on error
726 : : * \since QGIS 3.0
727 : : */
728 : : void exportNamedMetadata( QDomDocument &doc, QString &errorMsg ) const;
729 : :
730 : : /**
731 : : * Save the current metadata of this layer as the default metadata
732 : : * (either as a .qmd file on disk or as a
733 : : * record in the users style table in their personal qgis.db)
734 : : * \param resultFlag a reference to a flag that will be set to FALSE if
735 : : * we did not manage to save the default metadata.
736 : : * \returns a QString with any status messages
737 : : * \since QGIS 3.0
738 : : */
739 : : virtual QString saveDefaultMetadata( bool &resultFlag SIP_OUT );
740 : :
741 : : /**
742 : : * Save the current metadata of this layer as a named metadata
743 : : * (either as a .qmd file on disk or as a
744 : : * record in the users style table in their personal qgis.db)
745 : : * \param uri the file name or other URI for the
746 : : * metadata file. First an attempt will be made to see if this
747 : : * is a file and save to that, if that fails the qgis.db metadata
748 : : * table will be used to create a metadata entry who's
749 : : * key matches the URI.
750 : : * \param resultFlag a reference to a flag that will be set to FALSE if
751 : : * we did not manage to save the default metadata.
752 : : * \returns a QString with any status messages
753 : : * \since QGIS 3.0
754 : : */
755 : : QString saveNamedMetadata( const QString &uri, bool &resultFlag );
756 : :
757 : : /**
758 : : * Retrieve a named metadata for this layer if one
759 : : * exists (either as a .qmd file on disk or as a
760 : : * record in the users style table in their personal qgis.db)
761 : : * \param uri - the file name or other URI for the
762 : : * metadata file. First an attempt will be made to see if this
763 : : * is a file and load that, if that fails the qgis.db metadata
764 : : * table will be consulted to see if there is a metadata who's
765 : : * key matches the URI.
766 : : * \param resultFlag a reference to a flag that will be set to FALSE if
767 : : * we did not manage to load the default metadata.
768 : : * \returns a QString with any status messages
769 : : * \since QGIS 3.0
770 : : */
771 : : virtual QString loadNamedMetadata( const QString &uri, bool &resultFlag SIP_OUT );
772 : :
773 : : /**
774 : : * Retrieve the default metadata for this layer if one
775 : : * exists (either as a .qmd file on disk or as a
776 : : * record in the users metadata table in their personal qgis.db)
777 : : * \param resultFlag a reference to a flag that will be set to FALSE if
778 : : * we did not manage to load the default metadata.
779 : : * \returns a QString with any status messages
780 : : * \since QGIS 3.0
781 : : */
782 : : virtual QString loadDefaultMetadata( bool &resultFlag );
783 : :
784 : : /**
785 : : * Retrieve a named metadata for this layer from a sqlite database.
786 : : * \param db path to sqlite database
787 : : * \param uri uri for table
788 : : * \param qmd will be set to QMD xml metadata content from database
789 : : * \returns TRUE if style was successfully loaded
790 : : * \since QGIS 3.0
791 : : */
792 : : bool loadNamedMetadataFromDatabase( const QString &db, const QString &uri, QString &qmd );
793 : :
794 : : /**
795 : : * Import the metadata of this layer from a QDomDocument
796 : : * \param document source QDomDocument
797 : : * \param errorMessage this QString will be initialized on error
798 : : * \returns TRUE on success
799 : : * \since QGIS 3.0
800 : : */
801 : : bool importNamedMetadata( QDomDocument &document, QString &errorMessage );
802 : :
803 : : /**
804 : : * Retrieve the style URI for this layer
805 : : * (either as a .qml file on disk or as a
806 : : * record in the users style table in their personal qgis.db)
807 : : * \returns a QString with the style file name
808 : : * \see also loadNamedStyle() and saveNamedStyle();
809 : : */
810 : : virtual QString styleURI() const;
811 : :
812 : : /**
813 : : * Retrieve the default style for this layer if one
814 : : * exists (either as a .qml file on disk or as a
815 : : * record in the users style table in their personal qgis.db)
816 : : * \param resultFlag a reference to a flag that will be set to FALSE if
817 : : * we did not manage to load the default style.
818 : : * \returns a QString with any status messages
819 : : * \see also loadNamedStyle();
820 : : */
821 : : virtual QString loadDefaultStyle( bool &resultFlag SIP_OUT );
822 : :
823 : : /**
824 : : * Retrieve a named style for this layer if one
825 : : * exists (either as a .qml file on disk or as a
826 : : * record in the users style table in their personal qgis.db)
827 : : * \param uri - the file name or other URI for the
828 : : * style file. First an attempt will be made to see if this
829 : : * is a file and load that, if that fails the qgis.db styles
830 : : * table will be consulted to see if there is a style who's
831 : : * key matches the URI.
832 : : * \param resultFlag a reference to a flag that will be set to FALSE if
833 : : * we did not manage to load the default style.
834 : : * \param categories the style categories to be loaded.
835 : : * \returns a QString with any status messages
836 : : * \see also loadDefaultStyle ();
837 : : */
838 : : virtual QString loadNamedStyle( const QString &uri, bool &resultFlag SIP_OUT, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
839 : :
840 : : /**
841 : : * Retrieve a named style for this layer from a sqlite database.
842 : : * \param db path to sqlite database
843 : : * \param uri uri for table
844 : : * \param qml will be set to QML style content from database
845 : : * \returns TRUE if style was successfully loaded
846 : : */
847 : : virtual bool loadNamedStyleFromDatabase( const QString &db, const QString &uri, QString &qml SIP_OUT );
848 : :
849 : : /**
850 : : * Import the properties of this layer from a QDomDocument
851 : : * \param doc source QDomDocument
852 : : * \param errorMsg this QString will be initialized on error
853 : : * during the execution of readSymbology
854 : : * \param categories the style categories to import
855 : : * \returns TRUE on success
856 : : * \since QGIS 2.8
857 : : */
858 : : virtual bool importNamedStyle( QDomDocument &doc, QString &errorMsg SIP_OUT,
859 : : QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
860 : :
861 : : /**
862 : : * Export the properties of this layer as named style in a QDomDocument
863 : : * \param doc the target QDomDocument
864 : : * \param errorMsg this QString will be initialized on error
865 : : * \param context read write context
866 : : * \param categories the style categories to export
867 : : * during the execution of writeSymbology
868 : : */
869 : : virtual void exportNamedStyle( QDomDocument &doc, QString &errorMsg SIP_OUT, const QgsReadWriteContext &context = QgsReadWriteContext(),
870 : : QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const;
871 : :
872 : :
873 : : /**
874 : : * Export the properties of this layer as SLD style in a QDomDocument
875 : : * \param doc the target QDomDocument
876 : : * \param errorMsg this QString will be initialized on error
877 : : * during the execution of writeSymbology
878 : : */
879 : : virtual void exportSldStyle( QDomDocument &doc, QString &errorMsg ) const;
880 : :
881 : : /**
882 : : * Save the properties of this layer as the default style
883 : : * (either as a .qml file on disk or as a
884 : : * record in the users style table in their personal qgis.db)
885 : : * \param resultFlag a reference to a flag that will be set to FALSE if
886 : : * we did not manage to save the default style.
887 : : * \returns a QString with any status messages
888 : : * \see loadNamedStyle() and \see saveNamedStyle()
889 : : */
890 : : virtual QString saveDefaultStyle( bool &resultFlag SIP_OUT );
891 : :
892 : : /**
893 : : * Save the properties of this layer as a named style
894 : : * (either as a .qml file on disk or as a
895 : : * record in the users style table in their personal qgis.db)
896 : : * \param uri the file name or other URI for the
897 : : * style file. First an attempt will be made to see if this
898 : : * is a file and save to that, if that fails the qgis.db styles
899 : : * table will be used to create a style entry who's
900 : : * key matches the URI.
901 : : * \param resultFlag a reference to a flag that will be set to FALSE if
902 : : * we did not manage to save the default style.
903 : : * \param categories the style categories to be saved.
904 : : * \returns a QString with any status messages
905 : : * \see saveDefaultStyle()
906 : : */
907 : : virtual QString saveNamedStyle( const QString &uri, bool &resultFlag SIP_OUT, StyleCategories categories = AllStyleCategories );
908 : :
909 : : /**
910 : : * Saves the properties of this layer to an SLD format file.
911 : : * \param uri uri of destination for exported SLD file.
912 : : * \param resultFlag a reference to a flag that will be set to FALSE if
913 : : * the SLD file could not be generated
914 : : * \returns a string with any status or error messages
915 : : * \see loadSldStyle()
916 : : */
917 : : virtual QString saveSldStyle( const QString &uri, bool &resultFlag ) const;
918 : :
919 : : /**
920 : : * Attempts to style the layer using the formatting from an SLD type file.
921 : : * \param uri uri of source SLD file
922 : : * \param resultFlag a reference to a flag that will be set to FALSE if
923 : : * the SLD file could not be loaded
924 : : * \returns a string with any status or error messages
925 : : * \see saveSldStyle()
926 : : */
927 : : virtual QString loadSldStyle( const QString &uri, bool &resultFlag );
928 : :
929 : : virtual bool readSld( const QDomNode &node, QString &errorMessage )
930 : : { Q_UNUSED( node ) errorMessage = QStringLiteral( "Layer type %1 not supported" ).arg( static_cast<int>( type() ) ); return false; }
931 : :
932 : :
933 : :
934 : : /**
935 : : * Read the symbology for the current layer from the DOM node supplied.
936 : : * \param node node that will contain the symbology definition for this layer.
937 : : * \param errorMessage reference to string that will be updated with any error messages
938 : : * \param context reading context (used for transform from relative to absolute paths)
939 : : * \param categories the style categories to be read
940 : : * \returns TRUE in case of success.
941 : : */
942 : : virtual bool readSymbology( const QDomNode &node, QString &errorMessage,
943 : : QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) = 0;
944 : :
945 : : /**
946 : : * Read the style for the current layer from the DOM node supplied.
947 : : * \param node node that will contain the style definition for this layer.
948 : : * \param errorMessage reference to string that will be updated with any error messages
949 : : * \param context reading context (used for transform from relative to absolute paths)
950 : : * \param categories the style categories to be read
951 : : * \returns TRUE in case of success.
952 : : * \note To be implemented in subclasses. Default implementation does nothing and returns FALSE.
953 : : * \since QGIS 2.16
954 : : */
955 : : virtual bool readStyle( const QDomNode &node, QString &errorMessage,
956 : : QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories );
957 : :
958 : : /**
959 : : * Write the style for the layer into the docment provided.
960 : : * \param node the node that will have the style element added to it.
961 : : * \param doc the document that will have the QDomNode added.
962 : : * \param errorMessage reference to string that will be updated with any error messages
963 : : * \param context writing context (used for transform from absolute to relative paths)
964 : : * \param categories the style categories to be written
965 : : * \note There is a confusion of terms with the GUI. This method actually writes what is called a style in the application.
966 : : * \returns TRUE in case of success.
967 : : */
968 : : virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
969 : : StyleCategories categories = AllStyleCategories ) const = 0;
970 : :
971 : : /**
972 : : * Write just the symbology information for the layer into the document
973 : : * \param node the node that will have the style element added to it.
974 : : * \param doc the document that will have the QDomNode added.
975 : : * \param errorMessage reference to string that will be updated with any error messages
976 : : * \param context writing context (used for transform from absolute to relative paths)
977 : : * \param categories the style categories to be written
978 : : * \returns TRUE in case of success.
979 : : * \note To be implemented in subclasses. Default implementation does nothing and returns FALSE.
980 : : * \note There is a confusion of terms with the GUI. This method actually writes what is known as the symbology in the application.
981 : : * \since QGIS 2.16
982 : : */
983 : : virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
984 : : StyleCategories categories = AllStyleCategories ) const;
985 : :
986 : :
987 : : /**
988 : : * Updates the data source of the layer. The layer's renderer and legend will be preserved only
989 : : * if the geometry type of the new data source matches the current geometry type of the layer.
990 : : *
991 : : * Subclasses should override this method: default implementation does nothing.
992 : : *
993 : : * \param dataSource new layer data source
994 : : * \param baseName base name of the layer
995 : : * \param provider provider string
996 : : * \param options provider options
997 : : * \param loadDefaultStyleFlag set to TRUE to reset the layer's style to the default for the
998 : : * data source
999 : : * \see dataSourceChanged()
1000 : : * \since QGIS 3.6
1001 : : */
1002 : : virtual void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false );
1003 : :
1004 : : /**
1005 : : * Returns the provider type (provider key) for this layer
1006 : : */
1007 : : QString providerType() const;
1008 : :
1009 : : //! Returns pointer to layer's undo stack
1010 : : QUndoStack *undoStack();
1011 : :
1012 : : /**
1013 : : * Returns pointer to layer's style undo stack
1014 : : * \since QGIS 2.16
1015 : : */
1016 : : QUndoStack *undoStackStyles();
1017 : :
1018 : : /**
1019 : : * Sets the URL for the layer's legend.
1020 : : */
1021 : 0 : void setLegendUrl( const QString &legendUrl ) { mLegendUrl = legendUrl; }
1022 : :
1023 : : /**
1024 : : * Returns the URL for the layer's legend.
1025 : : */
1026 : 0 : QString legendUrl() const { return mLegendUrl; }
1027 : :
1028 : : /**
1029 : : * Sets the format for a URL based layer legend.
1030 : : */
1031 : 0 : void setLegendUrlFormat( const QString &legendUrlFormat ) { mLegendUrlFormat = legendUrlFormat; }
1032 : :
1033 : : /**
1034 : : * Returns the format for a URL based layer legend.
1035 : : */
1036 : 0 : QString legendUrlFormat() const { return mLegendUrlFormat; }
1037 : :
1038 : : /**
1039 : : * Assign a legend controller to the map layer. The object will be responsible for providing legend items.
1040 : : * \param legend Takes ownership of the object. Can be NULLPTR.
1041 : : * \since QGIS 2.6
1042 : : */
1043 : : void setLegend( QgsMapLayerLegend *legend SIP_TRANSFER );
1044 : :
1045 : : /**
1046 : : * Can be NULLPTR.
1047 : : * \since QGIS 2.6
1048 : : */
1049 : : QgsMapLayerLegend *legend() const;
1050 : :
1051 : : /**
1052 : : * Gets access to the layer's style manager. Style manager allows switching between multiple styles.
1053 : : * \since QGIS 2.8
1054 : : */
1055 : : QgsMapLayerStyleManager *styleManager() const;
1056 : :
1057 : : /**
1058 : : * Sets 3D renderer for the layer. Takes ownership of the renderer.
1059 : : * \since QGIS 3.0
1060 : : */
1061 : : void setRenderer3D( QgsAbstract3DRenderer *renderer SIP_TRANSFER );
1062 : :
1063 : : /**
1064 : : * Returns 3D renderer associated with the layer. May be NULLPTR.
1065 : : * \since QGIS 3.0
1066 : : */
1067 : : QgsAbstract3DRenderer *renderer3D() const;
1068 : :
1069 : : /**
1070 : : * Tests whether the layer should be visible at the specified \a scale.
1071 : : * The \a scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
1072 : : * \returns TRUE if the layer is visible at the given scale.
1073 : : * \see minimumScale()
1074 : : * \see maximumScale()
1075 : : * \see hasScaleBasedVisibility()
1076 : : * \since QGIS 2.16
1077 : : */
1078 : : bool isInScaleRange( double scale ) const;
1079 : :
1080 : : /**
1081 : : * Returns the minimum map scale (i.e. most "zoomed out" scale) at which the layer will be visible.
1082 : : * The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
1083 : : * A scale of 0 indicates no minimum scale visibility.
1084 : : * \note Scale based visibility is only used if setScaleBasedVisibility() is set to TRUE.
1085 : : * \see setMinimumScale()
1086 : : * \see maximumScale()
1087 : : * \see hasScaleBasedVisibility()
1088 : : * \see isInScaleRange()
1089 : : */
1090 : : double minimumScale() const;
1091 : :
1092 : : /**
1093 : : * Returns the maximum map scale (i.e. most "zoomed in" scale) at which the layer will be visible.
1094 : : * The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
1095 : : * A scale of 0 indicates no maximum scale visibility.
1096 : : * \note Scale based visibility is only used if setScaleBasedVisibility() is set to TRUE.
1097 : : * \see setMaximumScale()
1098 : : * \see minimumScale()
1099 : : * \see hasScaleBasedVisibility()
1100 : : * \see isInScaleRange()
1101 : : */
1102 : : double maximumScale() const;
1103 : :
1104 : : /**
1105 : : * Returns whether scale based visibility is enabled for the layer.
1106 : : * \returns TRUE if scale based visibility is enabled
1107 : : * \see minimumScale()
1108 : : * \see maximumScale()
1109 : : * \see setScaleBasedVisibility()
1110 : : * \see isInScaleRange()
1111 : : */
1112 : : bool hasScaleBasedVisibility() const;
1113 : :
1114 : : /**
1115 : : * Returns TRUE if auto refresh is enabled for the layer.
1116 : : * \see autoRefreshInterval()
1117 : : * \see setAutoRefreshEnabled()
1118 : : * \since QGIS 3.0
1119 : : */
1120 : : bool hasAutoRefreshEnabled() const;
1121 : :
1122 : : /**
1123 : : * Returns the auto refresh interval (in milliseconds). Note that
1124 : : * auto refresh is only active when hasAutoRefreshEnabled() is TRUE.
1125 : : * \see hasAutoRefreshEnabled()
1126 : : * \see setAutoRefreshInterval()
1127 : : * \since QGIS 3.0
1128 : : */
1129 : : int autoRefreshInterval() const;
1130 : :
1131 : : /**
1132 : : * Sets the auto refresh interval (in milliseconds) for the layer. This
1133 : : * will cause the layer to be automatically redrawn on a matching interval.
1134 : : * Note that auto refresh must be enabled by calling setAutoRefreshEnabled().
1135 : : *
1136 : : * Note that auto refresh triggers deferred repaints of the layer. Any map
1137 : : * canvas must be refreshed separately in order to view the refreshed layer.
1138 : : * \see autoRefreshInterval()
1139 : : * \see setAutoRefreshEnabled()
1140 : : * \since QGIS 3.0
1141 : : */
1142 : : void setAutoRefreshInterval( int interval );
1143 : :
1144 : : /**
1145 : : * Sets whether auto refresh is enabled for the layer.
1146 : : * \see hasAutoRefreshEnabled()
1147 : : * \see setAutoRefreshInterval()
1148 : : * \since QGIS 3.0
1149 : : */
1150 : : void setAutoRefreshEnabled( bool enabled );
1151 : :
1152 : : /**
1153 : : * Returns a reference to the layer's metadata store.
1154 : : * \see setMetadata()
1155 : : * \see metadataChanged()
1156 : : * \since QGIS 3.0
1157 : : */
1158 : : virtual const QgsLayerMetadata &metadata() const;
1159 : :
1160 : : /**
1161 : : * Sets the layer's \a metadata store.
1162 : : * \see metadata()
1163 : : * \see metadataChanged()
1164 : : * \since QGIS 3.0
1165 : : */
1166 : : virtual void setMetadata( const QgsLayerMetadata &metadata );
1167 : :
1168 : : /**
1169 : : * Obtain a formatted HTML string containing assorted metadata for this layer.
1170 : : * \since QGIS 3.0
1171 : : */
1172 : : virtual QString htmlMetadata() const;
1173 : :
1174 : : //! Time stamp of data source in the moment when data/metadata were loaded by provider
1175 : : virtual QDateTime timestamp() const;
1176 : :
1177 : : /**
1178 : : * Gets the list of dependencies. This includes data dependencies set by the user (\see setDataDependencies)
1179 : : * as well as dependencies given by the provider
1180 : : *
1181 : : * \returns a set of QgsMapLayerDependency
1182 : : * \since QGIS 3.0
1183 : : */
1184 : : virtual QSet<QgsMapLayerDependency> dependencies() const;
1185 : :
1186 : : /**
1187 : : * Returns the message that should be notified by the provider to triggerRepaint
1188 : : *
1189 : : * \since QGIS 3.0
1190 : : */
1191 : 0 : QString refreshOnNotifyMessage() const { return mRefreshOnNofifyMessage; }
1192 : :
1193 : : /**
1194 : : * Returns TRUE if the refresh on provider nofification is enabled
1195 : : *
1196 : : * \since QGIS 3.0
1197 : : */
1198 : 0 : bool isRefreshOnNotifyEnabled() const { return mIsRefreshOnNofifyEnabled; }
1199 : :
1200 : : /**
1201 : : * Returns the XML properties of the original layer as they were when the layer
1202 : : * was first read from the project file. In case of new layers this is normally empty.
1203 : : *
1204 : : * The storage format for the XML is qlr
1205 : : *
1206 : : * \since QGIS 3.6
1207 : : */
1208 : : QString originalXmlProperties() const;
1209 : :
1210 : : /**
1211 : : * Sets the original XML properties for the layer to \a originalXmlProperties
1212 : : *
1213 : : * The storage format for the XML is qlr
1214 : : *
1215 : : * \since QGIS 3.6
1216 : : */
1217 : : void setOriginalXmlProperties( const QString &originalXmlProperties );
1218 : :
1219 : : /**
1220 : : * Generates an unique identifier for this layer, the generate ID is prefixed by \a layerName
1221 : : * \since QGIS 3.8
1222 : : */
1223 : : static QString generateId( const QString &layerName );
1224 : :
1225 : : /**
1226 : : * Accepts the specified symbology \a visitor, causing it to visit all symbols associated
1227 : : * with the layer.
1228 : : *
1229 : : * Returns TRUE if the visitor should continue visiting other objects, or FALSE if visiting
1230 : : * should be canceled.
1231 : : *
1232 : : * \since QGIS 3.10
1233 : : */
1234 : : virtual bool accept( QgsStyleEntityVisitorInterface *visitor ) const;
1235 : :
1236 : : /**
1237 : : * Returns the layer's temporal properties. This may be NULLPTR, depending on the layer type.
1238 : : *
1239 : : * \since QGIS 3.14
1240 : : */
1241 : : virtual QgsMapLayerTemporalProperties *temporalProperties() { return nullptr; }
1242 : :
1243 : : /**
1244 : : * Returns the layer's elevation properties. This may be NULLPTR, depending on the layer type.
1245 : : *
1246 : : * \since QGIS 3.18
1247 : : */
1248 : : virtual QgsMapLayerElevationProperties *elevationProperties() { return nullptr; }
1249 : :
1250 : : public slots:
1251 : :
1252 : : /**
1253 : : * Sets the minimum map \a scale (i.e. most "zoomed out" scale) at which the layer will be visible.
1254 : : * The \a scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
1255 : : * A \a scale of 0 indicates no minimum scale visibility.
1256 : : * \note Scale based visibility is only used if setScaleBasedVisibility() is set to TRUE.
1257 : : * \see minimumScale()
1258 : : * \see setMaximumScale()
1259 : : * \see setScaleBasedVisibility()
1260 : : */
1261 : : void setMinimumScale( double scale );
1262 : :
1263 : : /**
1264 : : * Sets the maximum map \a scale (i.e. most "zoomed in" scale) at which the layer will be visible.
1265 : : * The \a scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
1266 : : * A \a scale of 0 indicates no maximum scale visibility.
1267 : : * \note Scale based visibility is only used if setScaleBasedVisibility() is set to TRUE.
1268 : : * \see maximumScale()
1269 : : * \see setMinimumScale()
1270 : : * \see setScaleBasedVisibility()
1271 : : */
1272 : : void setMaximumScale( double scale );
1273 : :
1274 : : /**
1275 : : * Sets whether scale based visibility is enabled for the layer.
1276 : : * \param enabled set to TRUE to enable scale based visibility
1277 : : * \see setMinimumScale
1278 : : * \see setMaximumScale
1279 : : * \see hasScaleBasedVisibility
1280 : : */
1281 : : void setScaleBasedVisibility( bool enabled );
1282 : :
1283 : : /**
1284 : : * Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
1285 : : * Will emit a repaintRequested() signal.
1286 : : * If \a deferredUpdate is TRUE then the layer will only be repainted when the canvas is next
1287 : : * re-rendered, and will not trigger any canvas redraws itself.
1288 : : *
1289 : : * \note in 2.6 function moved from vector/raster subclasses to QgsMapLayer
1290 : : */
1291 : : void triggerRepaint( bool deferredUpdate = false );
1292 : :
1293 : : /**
1294 : : * Will advise any 3D maps that this layer requires to be updated in the scene.
1295 : : * Will emit a request3DUpdate() signal.
1296 : : *
1297 : : * \since QGIS 3.18
1298 : : */
1299 : : void trigger3DUpdate();
1300 : :
1301 : : /**
1302 : : * Triggers an emission of the styleChanged() signal.
1303 : : * \since QGIS 2.16
1304 : : */
1305 : : void emitStyleChanged();
1306 : :
1307 : : /**
1308 : : * Sets the list of dependencies.
1309 : : * \see dependencies()
1310 : : *
1311 : : * \param layers set of QgsMapLayerDependency. Only user-defined dependencies will be added
1312 : : * \returns FALSE if a dependency cycle has been detected
1313 : : * \since QGIS 3.0
1314 : : */
1315 : : virtual bool setDependencies( const QSet<QgsMapLayerDependency> &layers );
1316 : :
1317 : : /**
1318 : : * Set whether provider notification is connected to triggerRepaint
1319 : : *
1320 : : * \since QGIS 3.0
1321 : : */
1322 : : void setRefreshOnNotifyEnabled( bool enabled );
1323 : :
1324 : : /**
1325 : : * Set the notification message that triggers repaint
1326 : : * If refresh on notification is enabled, the notification will triggerRepaint only
1327 : : * if the notification message is equal to \param message
1328 : : *
1329 : : * \since QGIS 3.0
1330 : : */
1331 : 0 : void setRefreshOnNofifyMessage( const QString &message ) { mRefreshOnNofifyMessage = message; }
1332 : :
1333 : : /**
1334 : : * Sets the coordinate transform context to \a transformContext
1335 : : *
1336 : : * \since QGIS 3.8
1337 : : */
1338 : : virtual void setTransformContext( const QgsCoordinateTransformContext &transformContext ) = 0;
1339 : :
1340 : : #ifdef SIP_RUN
1341 : : SIP_PYOBJECT __repr__();
1342 : : % MethodCode
1343 : : QString str = QStringLiteral( "<QgsMapLayer: '%1' (%2)>" ).arg( sipCpp->name(), sipCpp->dataProvider() ? sipCpp->dataProvider()->name() : QStringLiteral( "Invalid" ) );
1344 : : sipRes = PyUnicode_FromString( str.toUtf8().constData() );
1345 : : % End
1346 : : #endif
1347 : :
1348 : : /**
1349 : : * Returns the parent project if this map layer is added to a project.
1350 : : * Otherwise returns NULLPTR
1351 : : *
1352 : : * \since QGIS 3.18
1353 : : */
1354 : : QgsProject *project() const;
1355 : :
1356 : : signals:
1357 : :
1358 : : /**
1359 : : * Emitted when all layers are loaded and references can be resolved,
1360 : : * just before the references of this layer are resolved.
1361 : : *
1362 : : * \since QGIS 3.10
1363 : : */
1364 : : void beforeResolveReferences( QgsProject *project );
1365 : :
1366 : : //! Emit a signal with status (e.g. to be caught by QgisApp and display a msg on status bar)
1367 : : void statusChanged( const QString &status );
1368 : :
1369 : : /**
1370 : : * Emitted when the name has been changed
1371 : : *
1372 : : * \since QGIS 2.16
1373 : : */
1374 : : void nameChanged();
1375 : :
1376 : : //! Emit a signal that layer's CRS has been reset
1377 : : void crsChanged();
1378 : :
1379 : : /**
1380 : : * By emitting this signal the layer tells that either appearance or content have been changed
1381 : : * and any view showing the rendered layer should refresh itself.
1382 : : * If \a deferredUpdate is TRUE then the layer will only be repainted when the canvas is next
1383 : : * re-rendered, and will not trigger any canvas redraws itself.
1384 : : */
1385 : : void repaintRequested( bool deferredUpdate = false );
1386 : :
1387 : : //! This is used to send a request that any mapcanvas using this layer update its extents
1388 : : void recalculateExtents() const;
1389 : :
1390 : : //! Data of layer changed
1391 : : void dataChanged();
1392 : :
1393 : : //! Signal emitted when the blend mode is changed, through QgsMapLayer::setBlendMode()
1394 : : void blendModeChanged( QPainter::CompositionMode blendMode );
1395 : :
1396 : : /**
1397 : : * Emitted when the layer's opacity is changed, where \a opacity is a value between 0 (transparent)
1398 : : * and 1 (opaque).
1399 : : * \see setOpacity()
1400 : : * \see opacity()
1401 : : * \note Prior to QGIS 3.18, this signal was available for vector layers only
1402 : : * \since QGIS 3.18
1403 : : */
1404 : : void opacityChanged( double opacity );
1405 : :
1406 : : /**
1407 : : * Signal emitted when renderer is changed.
1408 : : * \see styleChanged()
1409 : : */
1410 : : void rendererChanged();
1411 : :
1412 : : /**
1413 : : * Signal emitted whenever a change affects the layer's style. Ie this may be triggered
1414 : : * by renderer changes, label style changes, or other style changes such as blend
1415 : : * mode or layer opacity changes.
1416 : : * \see rendererChanged()
1417 : : * \since QGIS 2.16
1418 : : */
1419 : : void styleChanged();
1420 : :
1421 : : /**
1422 : : * Signal emitted when legend of the layer has changed
1423 : : * \since QGIS 2.6
1424 : : */
1425 : : void legendChanged();
1426 : :
1427 : : /**
1428 : : * Signal emitted when 3D renderer associated with the layer has changed.
1429 : : * \since QGIS 3.0
1430 : : */
1431 : : void renderer3DChanged();
1432 : :
1433 : : /**
1434 : : * Signal emitted when a layer requires an update in any 3D maps.
1435 : : *
1436 : : * \since QGIS 3.18
1437 : : */
1438 : : void request3DUpdate();
1439 : :
1440 : : /**
1441 : : * Emitted whenever the configuration is changed. The project listens to this signal
1442 : : * to be marked as dirty.
1443 : : */
1444 : : void configChanged();
1445 : :
1446 : : /**
1447 : : * Emitted when dependencies are changed.
1448 : : */
1449 : : void dependenciesChanged();
1450 : :
1451 : : /**
1452 : : * Emitted in the destructor when the layer is about to be deleted,
1453 : : * but it is still in a perfectly valid state: the last chance for
1454 : : * other pieces of code for some cleanup if they use the layer.
1455 : : * \since QGIS 3.0
1456 : : */
1457 : : void willBeDeleted();
1458 : :
1459 : : /**
1460 : : * Emitted when the auto refresh interval changes.
1461 : : * \see setAutoRefreshInterval()
1462 : : * \since QGIS 3.0
1463 : : */
1464 : : void autoRefreshIntervalChanged( int interval );
1465 : :
1466 : : /**
1467 : : * Emitted when the layer's metadata is changed.
1468 : : * \see setMetadata()
1469 : : * \see metadata()
1470 : : * \since QGIS 3.0
1471 : : */
1472 : : void metadataChanged();
1473 : :
1474 : : /**
1475 : : * Emitted when layer's flags have been modified.
1476 : : * \see setFlags()
1477 : : * \see flags()
1478 : : * \since QGIS 3.4
1479 : : */
1480 : : void flagsChanged();
1481 : :
1482 : : /**
1483 : : * Emitted whenever the layer's data source has been changed.
1484 : : *
1485 : : * \see setDataSource()
1486 : : *
1487 : : * \since QGIS 3.5
1488 : : */
1489 : : void dataSourceChanged();
1490 : :
1491 : : /**
1492 : : * Emitted when a style has been loaded
1493 : : * \param categories style categories
1494 : : * \since QGIS 3.12
1495 : : */
1496 : : void styleLoaded( QgsMapLayer::StyleCategories categories );
1497 : :
1498 : : /**
1499 : : * Emitted when the validity of this layer changed.
1500 : : *
1501 : : * \since QGIS 3.16
1502 : : */
1503 : : void isValidChanged();
1504 : :
1505 : : /**
1506 : : * Emitted when a custom property of the layer has been changed or removed.
1507 : : *
1508 : : * \since QGIS 3.18
1509 : : */
1510 : : void customPropertyChanged( const QString &key );
1511 : :
1512 : : private slots:
1513 : :
1514 : : void onNotified( const QString &message );
1515 : :
1516 : : protected:
1517 : :
1518 : : /**
1519 : : * Copies attributes like name, short name, ... into another layer.
1520 : : * \param layer The copy recipient
1521 : : * \since QGIS 3.0
1522 : : */
1523 : : void clone( QgsMapLayer *layer ) const;
1524 : :
1525 : : //! Sets the extent
1526 : : virtual void setExtent( const QgsRectangle &rect );
1527 : :
1528 : : //! Sets whether layer is valid or not
1529 : : void setValid( bool valid );
1530 : :
1531 : : /**
1532 : : * Called by readLayerXML(), used by children to read state specific to them from
1533 : : * project files.
1534 : : */
1535 : : virtual bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context );
1536 : :
1537 : : /**
1538 : : * Called by writeLayerXML(), used by children to write state specific to them to
1539 : : * project files.
1540 : : */
1541 : : virtual bool writeXml( QDomNode &layer_node, QDomDocument &document, const QgsReadWriteContext &context ) const;
1542 : :
1543 : : /**
1544 : : * Called by writeLayerXML(), used by derived classes to encode provider's specific data
1545 : : * source to project files. Typically resolving absolute or relative paths, usernames and
1546 : : * passwords or drivers prefixes ("HDF5:")
1547 : : *
1548 : : * \param source data source to encode, typically QgsMapLayer::source()
1549 : : * \param context writing context (e.g. for conversion between relative and absolute paths)
1550 : : * \return encoded source, typically to be written in the DOM element "datasource"
1551 : : *
1552 : : * \since QGIS 3.2
1553 : : */
1554 : : virtual QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const;
1555 : :
1556 : : /**
1557 : : * Called by readLayerXML(), used by derived classes to decode provider's specific data
1558 : : * source from project files. Typically resolving absolute or relative paths, usernames and
1559 : : * passwords or drivers prefixes ("HDF5:")
1560 : : *
1561 : : * \param source data source to decode, typically read from layer's DOM element "datasource"
1562 : : * \param dataProvider string identification of data provider (e.g. "ogr"), typically read from layer's DOM element
1563 : : * \param context reading context (e.g. for conversion between relative and absolute paths)
1564 : : * \return decoded source, typically to be used as the layer's datasource
1565 : : *
1566 : : * \since QGIS 3.2
1567 : : */
1568 : : virtual QString decodedSource( const QString &source, const QString &dataProvider, const QgsReadWriteContext &context ) const;
1569 : :
1570 : : /**
1571 : : * Read custom properties from project file.
1572 : : * \param layerNode note to read from
1573 : : * \param keyStartsWith reads only properties starting with the specified string (or all if the string is empty)
1574 : : */
1575 : : void readCustomProperties( const QDomNode &layerNode, const QString &keyStartsWith = QString() );
1576 : :
1577 : : //! Write custom properties to project file.
1578 : : void writeCustomProperties( QDomNode &layerNode, QDomDocument &doc ) const;
1579 : :
1580 : : //! Read style manager's configuration (if any). To be called by subclasses.
1581 : : void readStyleManager( const QDomNode &layerNode );
1582 : : //! Write style manager's configuration (if exists). To be called by subclasses.
1583 : : void writeStyleManager( QDomNode &layerNode, QDomDocument &doc ) const;
1584 : :
1585 : : /**
1586 : : * Write style data common to all layer types
1587 : : * \since QGIS 3.0
1588 : : */
1589 : : void writeCommonStyle( QDomElement &layerElement, QDomDocument &document,
1590 : : const QgsReadWriteContext &context,
1591 : : StyleCategories categories = AllStyleCategories ) const;
1592 : :
1593 : : /**
1594 : : * Read style data common to all layer types
1595 : : * \since QGIS 3.0
1596 : : */
1597 : : void readCommonStyle( const QDomElement &layerElement, const QgsReadWriteContext &context,
1598 : : StyleCategories categories = AllStyleCategories );
1599 : :
1600 : : //! Sets the \a providerType (provider key)
1601 : : void setProviderType( const QString &providerType );
1602 : :
1603 : : #ifndef SIP_RUN
1604 : : #if 0
1605 : : //! Debugging member - invoked when a connect() is made to this object
1606 : : void connectNotify( const char *signal ) override;
1607 : : #endif
1608 : : #endif
1609 : :
1610 : : //! Add error message
1611 : 0 : void appendError( const QgsErrorMessage &error ) { mError.append( error );}
1612 : : //! Sets error message
1613 : 0 : void setError( const QgsError &error ) { mError = error;}
1614 : :
1615 : : /**
1616 : : * Invalidates the WGS84 extent. If FlagTrustLayerMetadata is enabled,
1617 : : * the extent is not invalidated because we want to trust metadata whatever
1618 : : * happens.
1619 : : * \since QGIS 3.20
1620 : : */
1621 : : void invalidateWgs84Extent();
1622 : :
1623 : : //! Indicates if the layer is valid and can be drawn
1624 : : bool mValid = false;
1625 : :
1626 : : //! Data source description string, varies by layer type
1627 : : QString mDataSource;
1628 : :
1629 : : //! Name of the layer - used for display
1630 : : QString mLayerName;
1631 : :
1632 : : QString mShortName;
1633 : : QString mTitle;
1634 : :
1635 : : //! Description of the layer
1636 : : QString mAbstract;
1637 : : QString mKeywordList;
1638 : :
1639 : : //! DataUrl of the layer
1640 : : QString mDataUrl;
1641 : : QString mDataUrlFormat;
1642 : :
1643 : : //! Attribution of the layer
1644 : : QString mAttribution;
1645 : : QString mAttributionUrl;
1646 : :
1647 : : //! MetadataUrl of the layer
1648 : : QString mMetadataUrl;
1649 : : QString mMetadataUrlType;
1650 : : QString mMetadataUrlFormat;
1651 : :
1652 : : //! WMS legend
1653 : : QString mLegendUrl;
1654 : : QString mLegendUrlFormat;
1655 : :
1656 : : //! \brief Error
1657 : : QgsError mError;
1658 : :
1659 : : //! List of layers that may modify this layer on modification
1660 : : QSet<QgsMapLayerDependency> mDependencies;
1661 : :
1662 : : /**
1663 : : * Checks whether a new set of dependencies will introduce a cycle
1664 : : * this method is now deprecated and always return FALSE, because circular dependencies are now correctly managed.
1665 : : * \deprecated since QGIS 3.10
1666 : : */
1667 : : Q_DECL_DEPRECATED bool hasDependencyCycle( const QSet<QgsMapLayerDependency> & ) const {return false;}
1668 : :
1669 : : bool mIsRefreshOnNofifyEnabled = false;
1670 : : QString mRefreshOnNofifyMessage;
1671 : :
1672 : : //! Data provider key (name of the data provider)
1673 : : QString mProviderKey;
1674 : :
1675 : : //TODO QGIS 4 - move to readXml as a new argument (breaks API)
1676 : :
1677 : : //! Read flags. It's up to the subclass to respect these when restoring state from XML
1678 : : QgsMapLayer::ReadFlags mReadFlags = QgsMapLayer::ReadFlags();
1679 : :
1680 : : /**
1681 : : * TRUE if the layer's CRS should be validated and invalid CRSes are not permitted.
1682 : : *
1683 : : * \since QGIS 3.10
1684 : : */
1685 : : bool mShouldValidateCrs = true;
1686 : :
1687 : : /**
1688 : : * Layer opacity.
1689 : : *
1690 : : * \since QGIS 3.18
1691 : : */
1692 : : double mLayerOpacity = 1.0;
1693 : :
1694 : : private:
1695 : :
1696 : : virtual QString baseURI( PropertyType type ) const;
1697 : : QString saveNamedProperty( const QString &uri, QgsMapLayer::PropertyType type,
1698 : : bool &resultFlag, StyleCategories categories = AllStyleCategories );
1699 : : QString loadNamedProperty( const QString &uri, QgsMapLayer::PropertyType type,
1700 : : bool &resultFlag, StyleCategories categories = AllStyleCategories );
1701 : : bool loadNamedPropertyFromDatabase( const QString &db, const QString &uri, QString &xml, QgsMapLayer::PropertyType type );
1702 : :
1703 : : // const method because extents are mutable
1704 : : void updateExtent( const QgsRectangle &extent ) const;
1705 : :
1706 : : /**
1707 : : * This method returns TRUE by default but can be overwritten to specify
1708 : : * that a certain layer is writable.
1709 : : */
1710 : : virtual bool isReadOnly() const;
1711 : :
1712 : : /**
1713 : : * Layer's spatial reference system.
1714 : : * private to make sure setCrs must be used and crsChanged() is emitted.
1715 : : */
1716 : : QgsCoordinateReferenceSystem mCRS;
1717 : :
1718 : : //! Unique ID of this layer - used to refer to this layer in map layer registry
1719 : : QString mID;
1720 : :
1721 : : //! Type of the layer (e.g., vector, raster)
1722 : : QgsMapLayerType mLayerType;
1723 : :
1724 : : LayerFlags mFlags = LayerFlags( Identifiable | Removable | Searchable );
1725 : :
1726 : : //! Blend mode for the layer
1727 : : QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
1728 : :
1729 : : //! Tag for embedding additional information
1730 : : QString mTag;
1731 : :
1732 : : //set some generous defaults for scale based visibility
1733 : :
1734 : : //! Minimum scale denominator at which this layer should be displayed
1735 : : double mMinScale = 0;
1736 : : //! Maximum scale denominator at which this layer should be displayed
1737 : : double mMaxScale = 100000000;
1738 : : //! A flag that tells us whether to use the above vars to restrict layer visibility
1739 : : bool mScaleBasedVisibility = false;
1740 : :
1741 : : //! Collection of undoable operations for this layer.
1742 : : QUndoStack *mUndoStack = nullptr;
1743 : :
1744 : : QUndoStack *mUndoStackStyles = nullptr;
1745 : :
1746 : : //! Layer's persistent storage of additional properties (may be used by plugins)
1747 : : QgsObjectCustomProperties mCustomProperties;
1748 : :
1749 : : //! Controller of legend items of this layer
1750 : : QgsMapLayerLegend *mLegend = nullptr;
1751 : :
1752 : : //! Manager of multiple styles available for a layer (may be NULLPTR)
1753 : : QgsMapLayerStyleManager *mStyleManager = nullptr;
1754 : :
1755 : : //! Timer for triggering automatic refreshes of the layer
1756 : : QTimer *mRefreshTimer = nullptr;
1757 : :
1758 : : QgsLayerMetadata mMetadata;
1759 : :
1760 : : //! Renderer for 3D views
1761 : : QgsAbstract3DRenderer *m3DRenderer = nullptr;
1762 : :
1763 : : //! Extent of the layer
1764 : : mutable QgsRectangle mExtent;
1765 : :
1766 : : //! Extent of the layer in EPSG:4326
1767 : : mutable QgsRectangle mWgs84Extent;
1768 : :
1769 : : /**
1770 : : * Stores the original XML properties of the layer when loaded from the project
1771 : : *
1772 : : * This information can be used to pass through the bad layers or to reset changes on a good layer
1773 : : */
1774 : : QString mOriginalXmlProperties;
1775 : :
1776 : : //! To avoid firing multiple time repaintRequested signal on circular layer circular dependencies
1777 : : bool mRepaintRequestedFired = false;
1778 : :
1779 : : friend class QgsVectorLayer;
1780 : : };
1781 : :
1782 : 0 : Q_DECLARE_METATYPE( QgsMapLayer * )
1783 : : Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayer::LayerFlags )
1784 : : Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayer::StyleCategories )
1785 : : Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayer::ReadFlags )
1786 : :
1787 : :
1788 : : #ifndef SIP_RUN
1789 : :
1790 : : /**
1791 : : * Weak pointer for QgsMapLayer
1792 : : * \note not available in Python bindings
1793 : : * \since QGIS 3.0
1794 : : */
1795 : : typedef QPointer< QgsMapLayer > QgsWeakMapLayerPointer;
1796 : :
1797 : : /**
1798 : : * A list of weak pointers to QgsMapLayers.
1799 : : * \note not available in Python bindings
1800 : : * \since QGIS 3.0
1801 : : */
1802 : : typedef QList< QgsWeakMapLayerPointer > QgsWeakMapLayerPointerList;
1803 : : #endif
1804 : :
1805 : : #endif
|