QGIS API Documentation 4.1.0-Master (60fea48833c)
Loading...
Searching...
No Matches
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 "qgsmaplayerref.h"
25#include "qgsmaplayerrenderer.h"
26
27#include <QString>
28
29using namespace Qt::StringLiterals;
30
31class QgsGroupLayerDataProvider;
32class QgsPaintEffect;
33
45class CORE_EXPORT QgsGroupLayer : public QgsMapLayer
46{
47 Q_OBJECT
48
49 public:
68
74 QgsGroupLayer( const QString &name, const QgsGroupLayer::LayerOptions &options );
75 ~QgsGroupLayer() override;
76
77#ifdef SIP_RUN
78 // clang-format off
79 SIP_PYOBJECT __repr__();
80 % MethodCode
81 QString str = u"<QgsGroupLayer: '%1'>"_s.arg( sipCpp->name() );
82 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
83 % End
84// clang-format on
85#endif
86
87 QgsGroupLayer *clone() const override SIP_FACTORY;
89 QgsRectangle extent() const override;
90 void setTransformContext( const QgsCoordinateTransformContext &context ) override;
91 bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override;
92 bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
93 bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &, StyleCategories categories = AllStyleCategories ) const override;
94 bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override;
95 QgsDataProvider *dataProvider() override;
96 const QgsDataProvider *dataProvider() const override SIP_SKIP;
97 QString htmlMetadata() const override;
98 void resolveReferences( QgsProject *project ) override;
99
108 void setChildLayers( const QList< QgsMapLayer * > &layers );
109
115 QList< QgsMapLayer * > childLayers() const;
116
122
131
142
143 private:
144 std::unique_ptr<QgsGroupLayerDataProvider> mDataProvider;
145 QgsCoordinateTransformContext mTransformContext;
146
147 QList< QgsMapLayerRef > mChildren;
148 std::unique_ptr< QgsPaintEffect > mPaintEffect;
149};
150
151#ifndef SIP_RUN
153
159class QgsGroupLayerDataProvider : public QgsDataProvider
160{
161 Q_OBJECT
162
163 public:
164 QgsGroupLayerDataProvider( const QgsDataProvider::ProviderOptions &providerOptions, Qgis::DataProviderReadFlags flags );
166 QgsCoordinateReferenceSystem crs() const override;
167 QString name() const override;
168 QString description() const override;
169 QgsRectangle extent() const override;
170 bool isValid() const override;
171
172 private:
174};
176#endif
177
178#endif // QGSGROUPLAYER_H
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:512
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.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the renderer.
void resolveReferences(QgsProject *project) override
Resolve references to other layers (kept as layer IDs after reading XML) into layer objects.
bool readSymbology(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) override
Read the symbology for the current layer from the DOM node supplied.
QgsGroupLayer(const QString &name, const QgsGroupLayer::LayerOptions &options)
Constructor for a new QgsGroupLayer with the specified layer name.
void prepareLayersForRemovalFromGroup()
Prepares all child layers in the group prior to removal from the group.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the group layer.
QList< QgsMapLayer * > childLayers() const
Returns the child layers contained by the group.
QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
QgsDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
void setChildLayers(const QList< QgsMapLayer * > &layers)
Sets the child layers contained by the group.
bool writeXml(QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context) const override
Called by writeLayerXML(), used by children to write state specific to them to project files.
void setTransformContext(const QgsCoordinateTransformContext &context) override
Sets the coordinate transform context to transformContext.
bool readXml(const QDomNode &layerNode, QgsReadWriteContext &context) override
Called by readLayerXML(), used by children to read state specific to them from project files.
bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &, StyleCategories categories=AllStyleCategories) const override
Write the style for the layer into the document provided.
QString htmlMetadata() const override
Obtain a formatted HTML string containing assorted metadata for this layer.
QgsRectangle extent() const override
Returns the extent of the layer.
Base class for utility classes that encapsulate information necessary for rendering of map layers.
QString name
Definition qgsmaplayer.h:87
QgsCoordinateReferenceSystem crs
Definition qgsmaplayer.h:90
QgsMapLayer(Qgis::LayerType type=Qgis::LayerType::Vector, const QString &name=QString(), const QString &source=QString())
Constructor for QgsMapLayer.
QFlags< StyleCategory > StyleCategories
QgsMapLayer::LayerFlags flags
Definition qgsmaplayer.h:99
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
QgsProject * project() const
Returns the parent project if this map layer is added to a project.
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
Base class for visual effects which can be applied to QPicture drawings.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:113
A container for the context for various read/write operations on objects.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_FACTORY
Definition qgis_sip.h:83
_LayerRef< QgsMapLayer > QgsMapLayerRef
Setting options for creating vector data providers.
Setting options for loading group layers.
LayerOptions(const QgsCoordinateTransformContext &transformContext)
Constructor for LayerOptions.
QgsCoordinateTransformContext transformContext
Coordinate transform context.