QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsgrouplayer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgrouplayer.h
3  ----------------
4  Date : September 2021
5  Copyright : (C) 2021 by Nyall Dawson
6  Email : nyall dot dawson at gmail dot 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 QGSGROUPLAYER_H
19 #define QGSGROUPLAYER_H
20 
21 #include "qgis_core.h"
22 #include "qgis_sip.h"
23 #include "qgsmaplayer.h"
24 #include "qgsmaplayerrenderer.h"
25 #include "qgsmaplayerref.h"
26 
27 class QgsGroupLayerDataProvider;
28 class QgsPaintEffect;
29 
41 class CORE_EXPORT QgsGroupLayer : public QgsMapLayer
42 {
43  Q_OBJECT
44 
45  public:
46 
51  struct LayerOptions
52  {
53 
57  explicit LayerOptions( const QgsCoordinateTransformContext &transformContext )
58  : transformContext( transformContext )
59  {}
60 
65 
66  };
67 
73  QgsGroupLayer( const QString &name, const QgsGroupLayer::LayerOptions &options );
74  ~QgsGroupLayer() override;
75 
76 #ifdef SIP_RUN
77  SIP_PYOBJECT __repr__();
78  % MethodCode
79  QString str = QStringLiteral( "<QgsGroupLayer: '%1'>" ).arg( sipCpp->name() );
80  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
81  % End
82 #endif
83 
84  QgsGroupLayer *clone() const override SIP_FACTORY;
85  QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
86  QgsRectangle extent() const override;
87  void setTransformContext( const QgsCoordinateTransformContext &context ) override;
88  bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override;
89  bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
90  bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &, StyleCategories categories = AllStyleCategories ) const override;
91  bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override;
92  QgsDataProvider *dataProvider() override;
93  const QgsDataProvider *dataProvider() const override SIP_SKIP;
94  QString htmlMetadata() const override;
95  void resolveReferences( QgsProject *project ) override;
96 
105  void setChildLayers( const QList< QgsMapLayer * > &layers );
106 
112  QList< QgsMapLayer * > childLayers() const;
113 
118  QgsPaintEffect *paintEffect() const;
119 
127  void setPaintEffect( QgsPaintEffect *effect SIP_TRANSFER );
128 
129  private:
130 
131  QgsGroupLayerDataProvider *mDataProvider = nullptr;
132  QgsCoordinateTransformContext mTransformContext;
133 
134  QList< QgsMapLayerRef > mChildren;
135  std::unique_ptr< QgsPaintEffect > mPaintEffect;
136 
137 };
138 
139 #ifndef SIP_RUN
140 
147 class QgsGroupLayerDataProvider : public QgsDataProvider
148 {
149  Q_OBJECT
150 
151  public:
152  QgsGroupLayerDataProvider( const QgsDataProvider::ProviderOptions &providerOptions,
153  QgsDataProvider::ReadFlags flags );
154  void setCrs( const QgsCoordinateReferenceSystem &crs );
155  QgsCoordinateReferenceSystem crs() const override;
156  QString name() const override;
157  QString description() const override;
158  QgsRectangle extent() const override;
159  bool isValid() const override;
160 
161  private:
162 
164 
165 };
167 #endif
168 
169 #endif // QGSGROUPLAYER_H
QgsCoordinateTransformContext
Contains information about the context in which a coordinate transform is executed.
Definition: qgscoordinatetransformcontext.h:57
QgsDataProvider::ProviderOptions
Setting options for creating vector data providers.
Definition: qgsdataprovider.h:107
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
QgsDataProvider
Abstract base class for spatial data provider implementations.
Definition: qgsdataprovider.h:40
QgsGroupLayer::LayerOptions::LayerOptions
LayerOptions(const QgsCoordinateTransformContext &transformContext)
Constructor for LayerOptions.
Definition: qgsgrouplayer.h:57
QgsMapLayer::clone
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:59
QgsGroupLayer
A map layer which consists of a set of child layers, where all component layers are rendered as a sin...
Definition: qgsgrouplayer.h:41
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsGroupLayer::LayerOptions
Setting options for loading group layers.
Definition: qgsgrouplayer.h:51
QgsProject
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:103
QgsMapLayerRenderer
Base class for utility classes that encapsulate information necessary for rendering of map layers.
Definition: qgsmaplayerrenderer.h:54
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
geos::unique_ptr
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:79
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
qgsmaplayer.h
qgis_sip.h
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
qgsmaplayerrenderer.h
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
str
#define str(x)
Definition: qgis.cpp:37
QgsMapLayer
Base class for all map layer types. This is the base class for all map layer types (vector,...
Definition: qgsmaplayer.h:72
QgsPaintEffect
Base class for visual effects which can be applied to QPicture drawings.
Definition: qgspainteffect.h:52
QgsGroupLayer::LayerOptions::transformContext
QgsCoordinateTransformContext transformContext
Coordinate transform context.
Definition: qgsgrouplayer.h:64
qgsmaplayerref.h
_LayerRef< QgsMapLayer >