32 , mTransformContext( options.transformContext )
38 mPaintEffect->setEnabled(
false );
42 mDataProvider =
new QgsGroupLayerDataProvider( providerOptions, QgsDataProvider::ReadFlags() );
56 std::unique_ptr< QgsGroupLayer > layer = std::make_unique< QgsGroupLayer >(
name(), options );
58 layer->setChildLayers( _qgis_listRefToRaw( mChildren ) );
59 layer->setPaintEffect( mPaintEffect ? mPaintEffect->clone() :
nullptr );
60 return layer.release();
82 mDataProvider->setTransformContext( context );
84 mTransformContext = context;
97 const QList< QgsMapLayer * > currentLayers = _qgis_listRefToRaw( mChildren );
104 const QDomNodeList childLayersElements = layerNode.toElement().elementsByTagName( QStringLiteral(
"childLayers" ) );
105 const QDomNodeList children = childLayersElements.at( 0 ).childNodes();
106 for (
int i = 0; i < children.size(); ++i )
108 const QDomElement childElement = children.at( i ).toElement();
109 const QString
id = childElement.attribute( QStringLiteral(
"layerid" ) );
127 QDomElement mapLayerNode = layer_node.toElement();
129 if ( mapLayerNode.isNull() )
137 QDomElement childLayersElement = doc.createElement( QStringLiteral(
"childLayers" ) );
138 for (
auto it = mChildren.constBegin(); it != mChildren.constEnd(); ++it )
140 QDomElement childElement = doc.createElement( QStringLiteral(
"child" ) );
141 childElement.setAttribute( QStringLiteral(
"layerid" ), it->layerId );
142 childLayersElement.appendChild( childElement );
144 mapLayerNode.appendChild( childLayersElement );
158 QDomElement layerOpacityElem = doc.createElement( QStringLiteral(
"layerOpacity" ) );
159 const QDomText layerOpacityText = doc.createTextNode( QString::number(
opacity() ) );
160 layerOpacityElem.appendChild( layerOpacityText );
161 node.appendChild( layerOpacityElem );
165 QDomElement paintEffectElement = doc.createElement( QStringLiteral(
"paintEffect" ) );
166 mPaintEffect->saveProperties( doc, paintEffectElement );
167 node.appendChild( paintEffectElement );
174 QDomElement blendModeElem = doc.createElement( QStringLiteral(
"blendMode" ) );
176 blendModeElem.appendChild( blendModeText );
177 node.appendChild( blendModeElem );
189 const QDomNode layerOpacityNode = node.namedItem( QStringLiteral(
"layerOpacity" ) );
190 if ( !layerOpacityNode.isNull() )
192 const QDomElement e = layerOpacityNode.toElement();
197 const QDomElement effectElem = node.namedItem( QStringLiteral(
"paintEffect" ) ).toElement();
198 if ( !effectElem.isNull() )
200 const QDomElement effectPropertiesElem = effectElem.firstChildElement( QStringLiteral(
"effect" ) ).toElement();
206 mPaintEffect->setEnabled(
false );
213 const QDomNode blendModeNode = node.namedItem( QStringLiteral(
"blendMode" ) );
214 if ( !blendModeNode.isNull() )
216 const QDomElement e = blendModeNode.toElement();
228 return mDataProvider;
235 return mDataProvider;
242 QString
metadata = QStringLiteral(
"<html>\n<body>\n<h1>" ) + tr(
"General" ) + QStringLiteral(
"</h1>\n<hr>\n" ) + QStringLiteral(
"<table class=\"list-view\">\n" );
244 metadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Name" ) + QStringLiteral(
"</td><td>" ) +
name() + QStringLiteral(
"</td></tr>\n" );
247 metadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Extent" ) + QStringLiteral(
"</td><td>" ) +
extent().
toString() + QStringLiteral(
"</td></tr>\n" );
250 metadata += QLatin1String(
"\n</body>\n</html>\n" );
259 for (
int i = 0; i < mChildren.size(); ++i )
261 mChildren[i].resolve(
project );
263 if ( mChildren[i].layer )
270 setCrs( mChildren[i].layer->crs() );
271 mDataProvider->setCrs(
crs() );
282 const QList< QgsMapLayer * > currentLayers = _qgis_listRefToRaw( mChildren );
285 if ( !currentLayers.contains( layer ) )
292 if ( layer && !layers.contains( layer ) )
299 layer->setBlendMode( QPainter::CompositionMode_SourceOver );
303 mChildren = _qgis_listRawToRef( layers );
308 if ( layer->isValid() && layer->crs().isValid( ) )
311 mDataProvider->setCrs(
crs() );
323 return _qgis_listRefToRaw( mChildren );
330 return mPaintEffect.get();
337 mPaintEffect.reset( effect );
346 child->setBlendMode( QPainter::CompositionMode_SourceOver );
355QgsGroupLayerDataProvider::QgsGroupLayerDataProvider(
356 const ProviderOptions &options,
357 QgsDataProvider::ReadFlags flags )
375QString QgsGroupLayerDataProvider::name()
const
379 return QStringLiteral(
"annotation" );
382QString QgsGroupLayerDataProvider::description()
const
396bool QgsGroupLayerDataProvider::isValid()
const
The Qgis class provides global constants for use throughout the application.
BlendMode
Blending modes defining the available composition modes that can be used when painting.
static QgsPaintEffectRegistry * paintEffectRegistry()
Returns the application's paint effect registry, used for managing paint effects.
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.
Implementation of threaded rendering for group layers.
A map layer which consists of a set of child layers, where all component layers are rendered as a sin...
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.
QgsGroupLayer * clone() const override
Returns a new instance equivalent to this one except for the id which is still unique.
QList< QgsMapLayer * > childLayers() const
Returns the child layers contained by the group.
~QgsGroupLayer() override
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.
static QString typeToString(Qgis::LayerType type)
Converts a map layer type to a string value.
Base class for utility classes that encapsulate information necessary for rendering of map layers.
static QgsRectangle combinedExtent(const QList< QgsMapLayer * > &layers, const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &transformContext)
Returns the combined extent of a list of layers.
Base class for all map layer types.
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
QgsCoordinateReferenceSystem crs
void triggerRepaint(bool deferredUpdate=false)
Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
QgsLayerMetadata metadata
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
virtual void setOpacity(double opacity)
Sets the opacity for the layer, where opacity is a value between 0 (totally transparent) and 1....
void willBeDeleted()
Emitted in the destructor when the layer is about to be deleted, but it is still in a perfectly valid...
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
virtual void resolveReferences(QgsProject *project)
Resolve references to other layers (kept as layer IDs after reading XML) into layer objects.
@ FlagDontResolveLayers
Don't resolve layer paths or create data providers for layers.
QgsMapLayer::ReadFlags mReadFlags
Read flags. It's up to the subclass to respect these when restoring state from XML.
void repaintRequested(bool deferredUpdate=false)
By emitting this signal the layer tells that either appearance or content have been changed and any v...
QgsProject * project() const
Returns the parent project if this map layer is added to a project.
bool mValid
Indicates if the layer is valid and can be drawn.
@ Rendering
Rendering: scale visibility, simplify method, opacity.
void invalidateWgs84Extent()
Invalidates the WGS84 extent.
bool mShouldValidateCrs
true if the layer's CRS should be validated and invalid CRSes are not permitted.
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects.
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
Base class for visual effects which can be applied to QPicture drawings.
static Qgis::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
static bool isClippingMode(Qgis::BlendMode mode)
Returns true if mode is a clipping blend mode.
static QPainter::CompositionMode getCompositionMode(Qgis::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
The class is used as a container of context for various read/write operations on other objects.
A rectangle specified with double values.
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
Contains information about the context of a rendering operation.
#define QgsDebugMsgLevel(str, level)
_LayerRef< QgsMapLayer > QgsMapLayerRef
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS
const QgsCoordinateReferenceSystem & crs
Setting options for creating vector data providers.
QgsCoordinateTransformContext transformContext
Coordinate transform context.
Setting options for loading group layers.
QgsCoordinateTransformContext transformContext
Coordinate transform context.