QGIS API Documentation  3.19.0-Master (e8efe81642)
qgsmaplayer.h
Go to the documentation of this file.
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"
34 #include "qgsrectangle.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 #include "qgis.h"
43 
45 class QgsDataProvider;
46 class QgsMapLayerLegend;
49 class QgsProject;
53 
54 class QDomDocument;
55 class QKeyEvent;
56 class QPainter;
57 
58 /*
59  * Constants used to describe copy-paste MIME types
60  */
61 #define QGSCLIPBOARD_MAPLAYER_MIME "application/qgis.maplayer"
62 
63 
69 class CORE_EXPORT QgsMapLayer : public QObject
70 {
71  Q_OBJECT
72 
73  Q_PROPERTY( QString name READ name WRITE setName NOTIFY nameChanged )
74  Q_PROPERTY( int autoRefreshInterval READ autoRefreshInterval WRITE setAutoRefreshInterval NOTIFY autoRefreshIntervalChanged )
75  Q_PROPERTY( QgsLayerMetadata metadata READ metadata WRITE setMetadata NOTIFY metadataChanged )
76  Q_PROPERTY( QgsCoordinateReferenceSystem crs READ crs WRITE setCrs NOTIFY crsChanged )
77  Q_PROPERTY( QgsMapLayerType type READ type CONSTANT )
78  Q_PROPERTY( bool isValid READ isValid NOTIFY isValidChanged )
79  Q_PROPERTY( double opacity READ opacity WRITE setOpacity NOTIFY opacityChanged )
80 
81 #ifdef SIP_RUN
83  QgsMapLayer *layer = qobject_cast<QgsMapLayer *>( sipCpp );
84 
85  sipType = 0;
86 
87  if ( layer )
88  {
89  switch ( layer->type() )
90  {
92  sipType = sipType_QgsVectorLayer;
93  break;
95  sipType = sipType_QgsRasterLayer;
96  break;
98  sipType = sipType_QgsPluginLayer;
99  break;
101  sipType = sipType_QgsMeshLayer;
102  break;
104  sipType = sipType_QgsVectorTileLayer;
105  break;
107  sipType = sipType_QgsAnnotationLayer;
108  break;
110  sipType = sipType_QgsPointCloudLayer;
111  break;
112  default:
113  sipType = nullptr;
114  break;
115  }
116  }
117  SIP_END
118 #endif
119 
120  public:
121 
127  {
128  Style = 0,
130  };
131 
138  {
139  Identifiable = 1 << 0,
140  Removable = 1 << 1,
141  Searchable = 1 << 2,
142  Private = 1 << 3,
143  };
144  Q_ENUM( LayerFlag )
145  Q_DECLARE_FLAGS( LayerFlags, LayerFlag )
146  Q_FLAG( LayerFlags )
147 
148 
153  {
154  LayerConfiguration = 1 << 0,
155  Symbology = 1 << 1,
156  Symbology3D = 1 << 2,
157  Labeling = 1 << 3,
158  Fields = 1 << 4,
159  Forms = 1 << 5,
160  Actions = 1 << 6,
161  MapTips = 1 << 7,
162  Diagrams = 1 << 8,
163  AttributeTable = 1 << 9,
164  Rendering = 1 << 10,
165  CustomProperties = 1 << 11,
166  GeometryOptions = 1 << 12,
167  Relations = 1 << 13,
168  Temporal = 1 << 14,
169  Legend = 1 << 15,
170  Elevation = 1 << 16,
171  Notes = 1 << 17,
172  AllStyleCategories = LayerConfiguration | Symbology | Symbology3D | Labeling | Fields | Forms | Actions |
173  MapTips | Diagrams | AttributeTable | Rendering | CustomProperties | GeometryOptions | Relations | Temporal | Legend | Elevation | Notes,
174  };
175  Q_ENUM( StyleCategory )
176  Q_DECLARE_FLAGS( StyleCategories, StyleCategory )
177  Q_FLAG( StyleCategories )
178 
179 
185  QgsMapLayer( QgsMapLayerType type = QgsMapLayerType::VectorLayer, const QString &name = QString(), const QString &source = QString() );
186 
187  ~QgsMapLayer() override;
188 
190  QgsMapLayer( QgsMapLayer const & ) = delete;
192  QgsMapLayer &operator=( QgsMapLayer const & ) = delete;
193 
200  virtual QgsMapLayer *clone() const = 0;
201 
205  QgsMapLayerType type() const;
206 
214  QgsMapLayer::LayerFlags flags() const;
215 
223  void setFlags( QgsMapLayer::LayerFlags flags );
224 
230  static QString extensionPropertyType( PropertyType type );
231 
233  QString id() const;
234 
240  void setName( const QString &name );
241 
246  QString name() const;
247 
251  Q_INVOKABLE virtual QgsDataProvider *dataProvider();
252 
257  virtual const QgsDataProvider *dataProvider() const SIP_SKIP;
258 
265  void setShortName( const QString &shortName ) { mShortName = shortName; }
266 
272  QString shortName() const;
273 
279  void setTitle( const QString &title ) { mTitle = title; }
280 
287  QString title() const { return mTitle; }
288 
295  void setAbstract( const QString &abstract ) { mAbstract = abstract; }
296 
303  QString abstract() const { return mAbstract; }
304 
311  void setKeywordList( const QString &keywords ) { mKeywordList = keywords; }
312 
319  QString keywordList() const { return mKeywordList; }
320 
321  /* Layer dataUrl information */
322 
330  void setDataUrl( const QString &dataUrl ) { mDataUrl = dataUrl; }
331 
339  QString dataUrl() const { return mDataUrl; }
340 
348  void setDataUrlFormat( const QString &dataUrlFormat ) { mDataUrlFormat = dataUrlFormat; }
349 
357  QString dataUrlFormat() const { return mDataUrlFormat; }
358 
359  /* Layer attribution information */
360 
368  void setAttribution( const QString &attrib ) { mAttribution = attrib; }
369 
377  QString attribution() const { return mAttribution; }
378 
386  void setAttributionUrl( const QString &attribUrl ) { mAttributionUrl = attribUrl; }
387 
395  QString attributionUrl() const { return mAttributionUrl; }
396 
397  /* Layer metadataUrl information */
398 
406  void setMetadataUrl( const QString &metaUrl ) { mMetadataUrl = metaUrl; }
407 
415  QString metadataUrl() const { return mMetadataUrl; }
416 
424  void setMetadataUrlType( const QString &metaUrlType ) { mMetadataUrlType = metaUrlType; }
425 
433  QString metadataUrlType() const { return mMetadataUrlType; }
434 
442  void setMetadataUrlFormat( const QString &metaUrlFormat ) { mMetadataUrlFormat = metaUrlFormat; }
443 
451  QString metadataUrlFormat() const { return mMetadataUrlFormat; }
452 
458  void setBlendMode( QPainter::CompositionMode blendMode );
459 
464  QPainter::CompositionMode blendMode() const;
465 
474  virtual void setOpacity( double opacity );
475 
484  virtual double opacity() const;
485 
487  bool readOnly() const { return isReadOnly(); }
488 
492  Q_INVOKABLE virtual void reload() {}
493 
499 
501  virtual QgsRectangle extent() const;
502 
511  QgsRectangle wgs84Extent( bool forceRecalculate = false ) const;
512 
518  bool isValid() const;
519 
526  QString publicSource() const;
527 
533  QString source() const;
534 
539  virtual QStringList subLayers() const;
540 
545  virtual void setLayerOrder( const QStringList &layers );
546 
552  virtual void setSubLayerVisibility( const QString &name, bool visible );
553 
555  virtual bool isEditable() const;
556 
561  virtual bool isSpatial() const;
562 
572  virtual bool isTemporary() const;
573 
578  enum ReadFlag
579  {
580  FlagDontResolveLayers = 1 << 0,
581  FlagTrustLayerMetadata = 1 << 1,
582  FlagReadExtentFromXml = 1 << 2,
583  };
584  Q_DECLARE_FLAGS( ReadFlags, ReadFlag )
585 
586 
603  bool readLayerXml( const QDomElement &layerElement, QgsReadWriteContext &context, QgsMapLayer::ReadFlags flags = QgsMapLayer::ReadFlags() );
604 
622  bool writeLayerXml( QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context ) const;
623 
628  virtual void resolveReferences( QgsProject *project );
629 
635  Q_INVOKABLE QStringList customPropertyKeys() const;
636 
642  Q_INVOKABLE void setCustomProperty( const QString &key, const QVariant &value );
643 
648  Q_INVOKABLE QVariant customProperty( const QString &value, const QVariant &defaultValue = QVariant() ) const;
649 
654  void setCustomProperties( const QgsObjectCustomProperties &properties );
655 
661  const QgsObjectCustomProperties &customProperties() const;
662 
667  void removeCustomProperty( const QString &key );
668 
674  virtual QgsError error() const;
675 
681 
683  void setCrs( const QgsCoordinateReferenceSystem &srs, bool emitSignal = true );
684 
690  QgsCoordinateTransformContext transformContext( ) const;
691 
692 
698  static QString formatLayerName( const QString &name );
699 
707  virtual QString metadataUri() const;
708 
715  void exportNamedMetadata( QDomDocument &doc, QString &errorMsg ) const;
716 
726  virtual QString saveDefaultMetadata( bool &resultFlag SIP_OUT );
727 
742  QString saveNamedMetadata( const QString &uri, bool &resultFlag );
743 
758  virtual QString loadNamedMetadata( const QString &uri, bool &resultFlag SIP_OUT );
759 
769  virtual QString loadDefaultMetadata( bool &resultFlag );
770 
779  bool loadNamedMetadataFromDatabase( const QString &db, const QString &uri, QString &qmd );
780 
788  bool importNamedMetadata( QDomDocument &document, QString &errorMessage );
789 
797  virtual QString styleURI() const;
798 
808  virtual QString loadDefaultStyle( bool &resultFlag SIP_OUT );
809 
825  virtual QString loadNamedStyle( const QString &uri, bool &resultFlag SIP_OUT, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
826 
834  virtual bool loadNamedStyleFromDatabase( const QString &db, const QString &uri, QString &qml SIP_OUT );
835 
845  virtual bool importNamedStyle( QDomDocument &doc, QString &errorMsg SIP_OUT,
846  QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
847 
856  virtual void exportNamedStyle( QDomDocument &doc, QString &errorMsg SIP_OUT, const QgsReadWriteContext &context = QgsReadWriteContext(),
857  QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const;
858 
859 
866  virtual void exportSldStyle( QDomDocument &doc, QString &errorMsg ) const;
867 
877  virtual QString saveDefaultStyle( bool &resultFlag SIP_OUT );
878 
894  virtual QString saveNamedStyle( const QString &uri, bool &resultFlag SIP_OUT, StyleCategories categories = AllStyleCategories );
895 
904  virtual QString saveSldStyle( const QString &uri, bool &resultFlag ) const;
905 
914  virtual QString loadSldStyle( const QString &uri, bool &resultFlag );
915 
916  virtual bool readSld( const QDomNode &node, QString &errorMessage )
917  { Q_UNUSED( node ) errorMessage = QStringLiteral( "Layer type %1 not supported" ).arg( static_cast<int>( type() ) ); return false; }
918 
919 
920 
929  virtual bool readSymbology( const QDomNode &node, QString &errorMessage,
930  QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) = 0;
931 
942  virtual bool readStyle( const QDomNode &node, QString &errorMessage,
943  QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories );
944 
955  virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
956  StyleCategories categories = AllStyleCategories ) const = 0;
957 
970  virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
971  StyleCategories categories = AllStyleCategories ) const;
972 
973 
988  void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag = false );
989 
1003  void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false );
1004 
1019  void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags );
1020 
1024  QString providerType() const;
1025 
1027  QUndoStack *undoStack();
1028 
1033  QUndoStack *undoStackStyles();
1034 
1038  void setLegendUrl( const QString &legendUrl ) { mLegendUrl = legendUrl; }
1039 
1043  QString legendUrl() const { return mLegendUrl; }
1044 
1048  void setLegendUrlFormat( const QString &legendUrlFormat ) { mLegendUrlFormat = legendUrlFormat; }
1049 
1053  QString legendUrlFormat() const { return mLegendUrlFormat; }
1054 
1060  void setLegend( QgsMapLayerLegend *legend SIP_TRANSFER );
1061 
1066  QgsMapLayerLegend *legend() const;
1067 
1072  QgsMapLayerStyleManager *styleManager() const;
1073 
1078  void setRenderer3D( QgsAbstract3DRenderer *renderer SIP_TRANSFER );
1079 
1084  QgsAbstract3DRenderer *renderer3D() const;
1085 
1095  bool isInScaleRange( double scale ) const;
1096 
1107  double minimumScale() const;
1108 
1119  double maximumScale() const;
1120 
1129  bool hasScaleBasedVisibility() const;
1130 
1137  bool hasAutoRefreshEnabled() const;
1138 
1146  int autoRefreshInterval() const;
1147 
1159  void setAutoRefreshInterval( int interval );
1160 
1167  void setAutoRefreshEnabled( bool enabled );
1168 
1175  virtual const QgsLayerMetadata &metadata() const;
1176 
1183  virtual void setMetadata( const QgsLayerMetadata &metadata );
1184 
1189  virtual QString htmlMetadata() const;
1190 
1192  virtual QDateTime timestamp() const;
1193 
1201  virtual QSet<QgsMapLayerDependency> dependencies() const;
1202 
1208  QString refreshOnNotifyMessage() const { return mRefreshOnNofifyMessage; }
1209 
1215  bool isRefreshOnNotifyEnabled() const { return mIsRefreshOnNofifyEnabled; }
1216 
1225  QString originalXmlProperties() const;
1226 
1234  void setOriginalXmlProperties( const QString &originalXmlProperties );
1235 
1240  static QString generateId( const QString &layerName );
1241 
1251  virtual bool accept( QgsStyleEntityVisitorInterface *visitor ) const;
1252 
1258  virtual QgsMapLayerTemporalProperties *temporalProperties() { return nullptr; }
1259 
1266 
1267  public slots:
1268 
1278  void setMinimumScale( double scale );
1279 
1289  void setMaximumScale( double scale );
1290 
1298  void setScaleBasedVisibility( bool enabled );
1299 
1308  void triggerRepaint( bool deferredUpdate = false );
1309 
1316  void trigger3DUpdate();
1317 
1322  void emitStyleChanged();
1323 
1332  virtual bool setDependencies( const QSet<QgsMapLayerDependency> &layers );
1333 
1339  void setRefreshOnNotifyEnabled( bool enabled );
1340 
1348  void setRefreshOnNofifyMessage( const QString &message ) { mRefreshOnNofifyMessage = message; }
1349 
1355  virtual void setTransformContext( const QgsCoordinateTransformContext &transformContext ) = 0;
1356 
1357 #ifdef SIP_RUN
1358  SIP_PYOBJECT __repr__();
1359  % MethodCode
1360  QString str = QStringLiteral( "<QgsMapLayer: '%1' (%2)>" ).arg( sipCpp->name(), sipCpp->dataProvider() ? sipCpp->dataProvider()->name() : QStringLiteral( "Invalid" ) );
1361  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
1362  % End
1363 #endif
1364 
1371  QgsProject *project() const;
1372 
1373  signals:
1374 
1382 
1384  void statusChanged( const QString &status );
1385 
1391  void nameChanged();
1392 
1394  void crsChanged();
1395 
1402  void repaintRequested( bool deferredUpdate = false );
1403 
1405  void recalculateExtents() const;
1406 
1408  void dataChanged();
1409 
1411  void blendModeChanged( QPainter::CompositionMode blendMode );
1412 
1421  void opacityChanged( double opacity );
1422 
1428 
1441 
1447 
1453 
1460 
1466 
1471 
1479 
1485  void autoRefreshIntervalChanged( int interval );
1486 
1494 
1502 
1511 
1517  void styleLoaded( QgsMapLayer::StyleCategories categories );
1518 
1525 
1531  void customPropertyChanged( const QString &key );
1532 
1533  private slots:
1534 
1535  void onNotified( const QString &message );
1536 
1552  virtual void setDataSourcePrivate( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags );
1553 
1554  protected:
1555 
1561  void clone( QgsMapLayer *layer ) const;
1562 
1564  virtual void setExtent( const QgsRectangle &rect );
1565 
1567  void setValid( bool valid );
1568 
1573  virtual bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context );
1574 
1579  virtual bool writeXml( QDomNode &layer_node, QDomDocument &document, const QgsReadWriteContext &context ) const;
1580 
1592  virtual QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const;
1593 
1606  virtual QString decodedSource( const QString &source, const QString &dataProvider, const QgsReadWriteContext &context ) const;
1607 
1613  void readCustomProperties( const QDomNode &layerNode, const QString &keyStartsWith = QString() );
1614 
1616  void writeCustomProperties( QDomNode &layerNode, QDomDocument &doc ) const;
1617 
1619  void readStyleManager( const QDomNode &layerNode );
1621  void writeStyleManager( QDomNode &layerNode, QDomDocument &doc ) const;
1622 
1627  void writeCommonStyle( QDomElement &layerElement, QDomDocument &document,
1628  const QgsReadWriteContext &context,
1629  StyleCategories categories = AllStyleCategories ) const;
1630 
1635  void readCommonStyle( const QDomElement &layerElement, const QgsReadWriteContext &context,
1636  StyleCategories categories = AllStyleCategories );
1637 
1639  void setProviderType( const QString &providerType );
1640 
1641 #ifndef SIP_RUN
1642 #if 0
1644  void connectNotify( const char *signal ) override;
1645 #endif
1646 #endif
1647 
1649  void appendError( const QgsErrorMessage &error ) { mError.append( error );}
1651  void setError( const QgsError &error ) { mError = error;}
1652 
1659  void invalidateWgs84Extent();
1660 
1662  bool mValid = false;
1663 
1665  QString mDataSource;
1666 
1668  QString mLayerName;
1669 
1670  QString mShortName;
1671  QString mTitle;
1672 
1674  QString mAbstract;
1675  QString mKeywordList;
1676 
1678  QString mDataUrl;
1680 
1682  QString mAttribution;
1684 
1686  QString mMetadataUrl;
1689 
1691  QString mLegendUrl;
1693 
1696 
1698  QSet<QgsMapLayerDependency> mDependencies;
1699 
1705  Q_DECL_DEPRECATED bool hasDependencyCycle( const QSet<QgsMapLayerDependency> & ) const {return false;}
1706 
1707  bool mIsRefreshOnNofifyEnabled = false;
1709 
1711  QString mProviderKey;
1712 
1713  //TODO QGIS 4 - move to readXml as a new argument (breaks API)
1714 
1716  QgsMapLayer::ReadFlags mReadFlags = QgsMapLayer::ReadFlags();
1717 
1723  bool mShouldValidateCrs = true;
1724 
1730  double mLayerOpacity = 1.0;
1731 
1737  int mBlockStyleChangedSignal = 0;
1738 
1739 #ifndef SIP_RUN
1740 
1749  QString crsHtmlMetadata() const;
1750 #endif
1751 
1752  private:
1753 
1754  virtual QString baseURI( PropertyType type ) const;
1755  QString saveNamedProperty( const QString &uri, QgsMapLayer::PropertyType type,
1756  bool &resultFlag, StyleCategories categories = AllStyleCategories );
1757  QString loadNamedProperty( const QString &uri, QgsMapLayer::PropertyType type,
1758  bool &resultFlag, StyleCategories categories = AllStyleCategories );
1759  bool loadNamedPropertyFromDatabase( const QString &db, const QString &uri, QString &xml, QgsMapLayer::PropertyType type );
1760 
1761  // const method because extents are mutable
1762  void updateExtent( const QgsRectangle &extent ) const;
1763 
1768  virtual bool isReadOnly() const;
1769 
1775 
1777  QString mID;
1778 
1780  QgsMapLayerType mLayerType;
1781 
1782  LayerFlags mFlags = LayerFlags( Identifiable | Removable | Searchable );
1783 
1785  QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
1786 
1788  QString mTag;
1789 
1790  //set some generous defaults for scale based visibility
1791 
1793  double mMinScale = 0;
1795  double mMaxScale = 100000000;
1797  bool mScaleBasedVisibility = false;
1798 
1800  QUndoStack *mUndoStack = nullptr;
1801 
1802  QUndoStack *mUndoStackStyles = nullptr;
1803 
1805  QgsObjectCustomProperties mCustomProperties;
1806 
1808  QgsMapLayerLegend *mLegend = nullptr;
1809 
1811  QgsMapLayerStyleManager *mStyleManager = nullptr;
1812 
1814  QTimer *mRefreshTimer = nullptr;
1815 
1816  QgsLayerMetadata mMetadata;
1817 
1819  QgsAbstract3DRenderer *m3DRenderer = nullptr;
1820 
1822  mutable QgsRectangle mExtent;
1823 
1825  mutable QgsRectangle mWgs84Extent;
1826 
1832  QString mOriginalXmlProperties;
1833 
1835  bool mRepaintRequestedFired = false;
1836 
1837  friend class QgsVectorLayer;
1838 };
1839 
1841 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayer::LayerFlags )
1842 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayer::StyleCategories )
1843 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayer::ReadFlags )
1844 
1845 
1846 #ifndef SIP_RUN
1847 
1853 typedef QPointer< QgsMapLayer > QgsWeakMapLayerPointer;
1854 
1860 typedef QList< QgsWeakMapLayerPointer > QgsWeakMapLayerPointerList;
1861 #endif
1862 
1863 #endif
Base class for all renderers that may to participate in 3D view.
This class represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Abstract base class for spatial data provider implementations.
QgsErrorMessage represents single error message.
Definition: qgserror.h:33
QgsError is container for error messages (report).
Definition: qgserror.h:81
A structured metadata store for a map layer.
Base class for storage of map layer elevation properties.
The QgsMapLayerLegend class is abstract interface for implementations of legends for one map layer.
Base class for utility classes that encapsulate information necessary for rendering of map layers.
Management of styles for use with one map layer.
Base class for storage of map layer temporal properties.
Base class for all map layer types.
Definition: qgsmaplayer.h:70
QString mKeywordList
Definition: qgsmaplayer.h:1675
virtual bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const =0
Write the style for the layer into the docment provided.
QString legendUrlFormat() const
Returns the format for a URL based layer legend.
Definition: qgsmaplayer.h:1053
void dependenciesChanged()
Emitted when dependencies are changed.
void setError(const QgsError &error)
Sets error message.
Definition: qgsmaplayer.h:1651
void legendChanged()
Signal emitted when legend of the layer has changed.
void setAbstract(const QString &abstract)
Sets the abstract of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:295
void recalculateExtents() const
This is used to send a request that any mapcanvas using this layer update its extents.
void metadataChanged()
Emitted when the layer's metadata is changed.
void setLegendUrl(const QString &legendUrl)
Sets the URL for the layer's legend.
Definition: qgsmaplayer.h:1038
void request3DUpdate()
Signal emitted when a layer requires an update in any 3D maps.
QgsError mError
Error.
Definition: qgsmaplayer.h:1695
void configChanged()
Emitted whenever the configuration is changed.
void autoRefreshIntervalChanged(int interval)
Emitted when the auto refresh interval changes.
Q_DECL_DEPRECATED bool hasDependencyCycle(const QSet< QgsMapLayerDependency > &) const
Checks whether a new set of dependencies will introduce a cycle this method is now deprecated and alw...
Definition: qgsmaplayer.h:1705
void isValidChanged()
Emitted when the validity of this layer changed.
QString attribution() const
Returns the attribution of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:377
QString mRefreshOnNofifyMessage
Definition: qgsmaplayer.h:1708
QString mLegendUrl
WMS legend.
Definition: qgsmaplayer.h:1691
QString mLayerName
Name of the layer - used for display.
Definition: qgsmaplayer.h:1668
void setAttributionUrl(const QString &attribUrl)
Sets the attribution URL of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:386
void renderer3DChanged()
Signal emitted when 3D renderer associated with the layer has changed.
QString dataUrlFormat() const
Returns the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:357
void statusChanged(const QString &status)
Emit a signal with status (e.g. to be caught by QgisApp and display a msg on status bar)
QString mTitle
Definition: qgsmaplayer.h:1671
void setDataUrl(const QString &dataUrl)
Sets the DataUrl of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:330
QgsMapLayer(QgsMapLayer const &)=delete
QgsMapLayer cannot be copied.
void setKeywordList(const QString &keywords)
Sets the keyword list of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:311
void setAttribution(const QString &attrib)
Sets the attribution of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:368
bool isRefreshOnNotifyEnabled() const
Returns true if the refresh on provider nofification is enabled.
Definition: qgsmaplayer.h:1215
QSet< QgsMapLayerDependency > mDependencies
List of layers that may modify this layer on modification.
Definition: qgsmaplayer.h:1698
void setDataUrlFormat(const QString &dataUrlFormat)
Sets the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:348
QString mLegendUrlFormat
Definition: qgsmaplayer.h:1692
virtual QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext)=0
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
QString mProviderKey
Data provider key (name of the data provider)
Definition: qgsmaplayer.h:1711
QString mMetadataUrlType
Definition: qgsmaplayer.h:1687
void styleChanged()
Signal emitted whenever a change affects the layer's style.
void rendererChanged()
Signal emitted when renderer is changed.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:287
void crsChanged()
Emit a signal that layer's CRS has been reset.
QString mAttributionUrl
Definition: qgsmaplayer.h:1683
void dataSourceChanged()
Emitted whenever the layer's data source has been changed.
QString dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:339
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
QString metadataUrlFormat() const
Returns the metadata format of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:451
void setRefreshOnNofifyMessage(const QString &message)
Set the notification message that triggers repaint If refresh on notification is enabled,...
Definition: qgsmaplayer.h:1348
void opacityChanged(double opacity)
Emitted when the layer's opacity is changed, where opacity is a value between 0 (transparent) and 1 (...
void styleLoaded(QgsMapLayer::StyleCategories categories)
Emitted when a style has been loaded.
QString mShortName
Definition: qgsmaplayer.h:1670
void dataChanged()
Data of layer changed.
QString mMetadataUrlFormat
Definition: qgsmaplayer.h:1688
void willBeDeleted()
Emitted in the destructor when the layer is about to be deleted, but it is still in a perfectly valid...
void setMetadataUrlFormat(const QString &metaUrlFormat)
Sets the metadata format of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:442
void blendModeChanged(QPainter::CompositionMode blendMode)
Signal emitted when the blend mode is changed, through QgsMapLayer::setBlendMode()
bool readOnly() const
Returns if this layer is read only.
Definition: qgsmaplayer.h:487
virtual bool readSymbology(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories)=0
Read the symbology for the current layer from the DOM node supplied.
QString metadataUrl() const
Returns the metadata URL of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:415
QString mMetadataUrl
MetadataUrl of the layer.
Definition: qgsmaplayer.h:1686
LayerFlag
Flags for the map layer.
Definition: qgsmaplayer.h:138
void appendError(const QgsErrorMessage &error)
Add error message.
Definition: qgsmaplayer.h:1649
QgsMapLayer & operator=(QgsMapLayer const &)=delete
QgsMapLayer cannot be copied.
QString mDataSource
Data source description string, varies by layer type.
Definition: qgsmaplayer.h:1665
QString refreshOnNotifyMessage() const
Returns the message that should be notified by the provider to triggerRepaint.
Definition: qgsmaplayer.h:1208
virtual bool readSld(const QDomNode &node, QString &errorMessage)
Definition: qgsmaplayer.h:916
ReadFlag
Flags which control project read behavior.
Definition: qgsmaplayer.h:579
QString attributionUrl() const
Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:395
QString mAbstract
Description of the layer.
Definition: qgsmaplayer.h:1674
void customPropertyChanged(const QString &key)
Emitted when a custom property of the layer has been changed or removed.
QString legendUrl() const
Returns the URL for the layer's legend.
Definition: qgsmaplayer.h:1043
QString mDataUrlFormat
Definition: qgsmaplayer.h:1679
void flagsChanged()
Emitted when layer's flags have been modified.
void repaintRequested(bool deferredUpdate=false)
By emitting this signal the layer tells that either appearance or content have been changed and any v...
void setLegendUrlFormat(const QString &legendUrlFormat)
Sets the format for a URL based layer legend.
Definition: qgsmaplayer.h:1048
void beforeResolveReferences(QgsProject *project)
Emitted when all layers are loaded and references can be resolved, just before the references of this...
void setMetadataUrl(const QString &metaUrl)
Sets the metadata URL of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:406
void setMetadataUrlType(const QString &metaUrlType)
Set the metadata type of the layer used by QGIS Server in GetCapabilities request MetadataUrlType ind...
Definition: qgsmaplayer.h:424
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext)=0
Sets the coordinate transform context to transformContext.
virtual QgsMapLayerElevationProperties * elevationProperties()
Returns the layer's elevation properties.
Definition: qgsmaplayer.h:1265
void nameChanged()
Emitted when the name has been changed.
QString mDataUrl
DataUrl of the layer.
Definition: qgsmaplayer.h:1678
StyleCategory
Categories of style to distinguish appropriate sections for import/export.
Definition: qgsmaplayer.h:153
@ AllStyleCategories
Definition: qgsmaplayer.h:172
virtual Q_INVOKABLE void reload()
Synchronises with changes in the datasource.
Definition: qgsmaplayer.h:492
virtual QgsMapLayerTemporalProperties * temporalProperties()
Returns the layer's temporal properties.
Definition: qgsmaplayer.h:1258
QString mAttribution
Attribution of the layer.
Definition: qgsmaplayer.h:1682
QString metadataUrlType() const
Returns the metadata type of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:433
QString keywordList() const
Returns the keyword list of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:319
void setTitle(const QString &title)
Sets the title of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:279
PropertyType
Maplayer has a style and a metadata property.
Definition: qgsmaplayer.h:127
Simple key-value store (keys = strings, values = variants) that supports loading/saving to/from XML i...
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:99
The class is used as a container of context for various read/write operations on other objects.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
Contains information about the context of a rendering operation.
An interface for classes which can visit style entity (e.g.
Represents a vector layer which manages a vector based data sets.
QgsMapLayerType
Types of layers that can be added to a map.
Definition: qgis.h:46
@ PointCloudLayer
Added in 3.18.
@ MeshLayer
Added in 3.2.
@ VectorTileLayer
Added in 3.14.
@ AnnotationLayer
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
#define str(x)
Definition: qgis.cpp:37
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:177
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_OUT
Definition: qgis_sip.h:58
#define SIP_FACTORY
Definition: qgis_sip.h:76
#define SIP_END
Definition: qgis_sip.h:194
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
QPointer< QgsMapLayer > QgsWeakMapLayerPointer
Weak pointer for QgsMapLayer.
Definition: qgsmaplayer.h:1853
QList< QgsWeakMapLayerPointer > QgsWeakMapLayerPointerList
A list of weak pointers to QgsMapLayers.
Definition: qgsmaplayer.h:1860
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
const QgsCoordinateReferenceSystem & crs
Setting options for creating vector data providers.