| 
    QGIS API Documentation
    3.26.3-Buenos Aires (65e4edfdad)
    
   | 
 
 
 
 
Go to the documentation of this file.
   34   , mTransformContext( options.transformContext )
 
   40   mPaintEffect->setEnabled( 
false );
 
   44   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();
 
   76     mDataProvider->setTransformContext( context );
 
   78   mTransformContext = context;
 
   89   const QList< QgsMapLayer * > currentLayers = _qgis_listRefToRaw( mChildren );
 
   96   const QDomNodeList childLayersElements = layerNode.toElement().elementsByTagName( QStringLiteral( 
"childLayers" ) );
 
   97   const QDomNodeList children = childLayersElements.at( 0 ).childNodes();
 
   98   for ( 
int i = 0; i < children.size(); ++i )
 
  100     const QDomElement childElement = children.at( i ).toElement();
 
  101     const QString 
id = childElement.attribute( QStringLiteral( 
"layerid" ) );
 
  117   QDomElement mapLayerNode = layer_node.toElement();
 
  119   if ( mapLayerNode.isNull() )
 
  127   QDomElement childLayersElement = doc.createElement( QStringLiteral( 
"childLayers" ) );
 
  128   for ( 
auto it = mChildren.constBegin(); it != mChildren.constEnd(); ++it )
 
  130     QDomElement childElement = doc.createElement( QStringLiteral( 
"child" ) );
 
  131     childElement.setAttribute( QStringLiteral( 
"layerid" ), it->layerId );
 
  132     childLayersElement.appendChild( childElement );
 
  134   mapLayerNode.appendChild( childLayersElement );
 
  146     QDomElement layerOpacityElem  = doc.createElement( QStringLiteral( 
"layerOpacity" ) );
 
  147     const QDomText layerOpacityText = doc.createTextNode( QString::number( 
opacity() ) );
 
  148     layerOpacityElem.appendChild( layerOpacityText );
 
  149     node.appendChild( layerOpacityElem );
 
  153       QDomElement paintEffectElement = doc.createElement( QStringLiteral( 
"paintEffect" ) );
 
  154       mPaintEffect->saveProperties( doc, paintEffectElement );
 
  155       node.appendChild( paintEffectElement );
 
  162     QDomElement blendModeElem  = doc.createElement( QStringLiteral( 
"blendMode" ) );
 
  164     blendModeElem.appendChild( blendModeText );
 
  165     node.appendChild( blendModeElem );
 
  175     const QDomNode layerOpacityNode = node.namedItem( QStringLiteral( 
"layerOpacity" ) );
 
  176     if ( !layerOpacityNode.isNull() )
 
  178       const QDomElement e = layerOpacityNode.toElement();
 
  183     const QDomElement effectElem = node.namedItem( QStringLiteral( 
"paintEffect" ) ).toElement();
 
  184     if ( !effectElem.isNull() )
 
  186       const QDomElement effectPropertiesElem = effectElem.firstChildElement( QStringLiteral( 
"effect" ) ).toElement();
 
  192       mPaintEffect->setEnabled( 
false );
 
  199     const QDomNode blendModeNode = node.namedItem( QStringLiteral( 
"blendMode" ) );
 
  200     if ( !blendModeNode.isNull() )
 
  202       const QDomElement e = blendModeNode.toElement();
 
  212   return mDataProvider;
 
  217   return mDataProvider;
 
  222   QString 
metadata = QStringLiteral( 
"<html>\n<body>\n<h1>" ) + tr( 
"General" ) + QStringLiteral( 
"</h1>\n<hr>\n" ) + QStringLiteral( 
"<table class=\"list-view\">\n" );
 
  224   metadata += QStringLiteral( 
"<tr><td class=\"highlight\">" ) + tr( 
"Name" ) + QStringLiteral( 
"</td><td>" ) + 
name() + QStringLiteral( 
"</td></tr>\n" );
 
  227   metadata += QStringLiteral( 
"<tr><td class=\"highlight\">" ) + tr( 
"Extent" ) + QStringLiteral( 
"</td><td>" ) + 
extent().
toString() + QStringLiteral( 
"</td></tr>\n" );
 
  230   metadata += QLatin1String( 
"\n</body>\n</html>\n" );
 
  237   for ( 
int i = 0; i < mChildren.size(); ++i )
 
  239     mChildren[i].resolve( 
project );
 
  241     if ( mChildren[i].layer )
 
  248         setCrs( mChildren[i].layer->crs() );
 
  249         mDataProvider->setCrs( 
crs() );
 
  258   const QList< QgsMapLayer * > currentLayers = _qgis_listRefToRaw( mChildren );
 
  261     if ( !currentLayers.contains( layer ) )
 
  268     if ( !layers.contains( layer ) )
 
  273   mChildren = _qgis_listRawToRef( layers );
 
  278     if ( layer->isValid() && layer->crs().isValid( ) )
 
  281       mDataProvider->setCrs( 
crs() );
 
  291   return _qgis_listRefToRaw( mChildren );
 
  296   return mPaintEffect.get();
 
  301   mPaintEffect.reset( effect );
 
  308 QgsGroupLayerDataProvider::QgsGroupLayerDataProvider(
 
  309   const ProviderOptions &options,
 
  310   QgsDataProvider::ReadFlags flags )
 
  324 QString QgsGroupLayerDataProvider::name()
 const 
  326   return QStringLiteral( 
"annotation" );
 
  329 QString QgsGroupLayerDataProvider::description()
 const 
  339 bool QgsGroupLayerDataProvider::isValid()
 const 
  
void setTransformContext(const QgsCoordinateTransformContext &context) override
Sets the coordinate transform context to transformContext.
 
void willBeDeleted()
Emitted in the destructor when the layer is about to be deleted, but it is still in a perfectly valid...
 
QgsCoordinateReferenceSystem crs
 
virtual void resolveReferences(QgsProject *project)
Resolve references to other layers (kept as layer IDs after reading XML) into layer objects.
 
Contains information about the context in which a coordinate transform is executed.
 
Setting options for creating vector data providers.
 
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer.
 
The class is used as a container of context for various read/write operations on other objects.
 
Abstract base class for spatial data provider implementations.
 
#define QgsDebugMsgLevel(str, level)
 
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
 
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
 
QgsMapLayer::ReadFlags mReadFlags
Read flags. It's up to the subclass to respect these when restoring state from XML.
 
const QgsCoordinateReferenceSystem & crs
 
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the renderer.
 
QgsMapLayerType
Types of layers that can be added to a map.
 
bool readXml(const QDomNode &layerNode, QgsReadWriteContext &context) override
Called by readLayerXML(), used by children to read state specific to them from project files.
 
Contains information about the context of a rendering operation.
 
A map layer which consists of a set of child layers, where all component layers are rendered as a sin...
 
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
 
_LayerRef< QgsMapLayer > QgsMapLayerRef
 
QString htmlMetadata() const override
Obtain a formatted HTML string containing assorted metadata for this layer.
 
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects.
 
void resolveReferences(QgsProject *project) override
Resolve references to other layers (kept as layer IDs after reading XML) into layer objects.
 
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the group layer.
 
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
 
A rectangle specified with double values.
 
QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
 
bool mShouldValidateCrs
true if the layer's CRS should be validated and invalid CRSes are not permitted.
 
QgsRectangle extent() const override
Returns the extent of the layer.
 
Setting options for loading group layers.
 
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
 
@ Rendering
Rendering: scale visibility, simplify method, opacity.
 
Base class for utility classes that encapsulate information necessary for rendering of map layers.
 
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.
 
static QgsPainting::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
 
Implementation of threaded rendering for group layers.
 
void triggerRepaint(bool deferredUpdate=false)
Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
 
@ FlagDontResolveLayers
Don't resolve layer paths or create data providers for layers.
 
static QString typeToString(QgsMapLayerType type)
Converts a map layer type to a string value.
 
QgsLayerMetadata metadata
 
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
 
bool mValid
Indicates if the layer is valid and can be drawn.
 
~QgsGroupLayer() override
 
@ GroupLayer
Composite group layer. Added in QGIS 3.24.
 
void repaintRequested(bool deferredUpdate=false)
By emitting this signal the layer tells that either appearance or content have been changed and any v...
 
static QPainter::CompositionMode getCompositionMode(QgsPainting::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
 
virtual void setOpacity(double opacity)
Sets the opacity for the layer, where opacity is a value between 0 (totally transparent) and 1....
 
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.
 
static QgsRectangle combinedExtent(const QList< QgsMapLayer * > &layers, const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &transformContext)
Returns the combined extent of a list of layers.
 
QList< QgsMapLayer * > childLayers() const
Returns the child layers contained by the group.
 
This class represents a coordinate reference system (CRS).
 
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
 
void setChildLayers(const QList< QgsMapLayer * > &layers)
Sets the child layers contained by the group.
 
static QgsPaintEffectRegistry * paintEffectRegistry()
Returns the application's paint effect registry, used for managing paint effects.
 
QgsDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
 
QgsGroupLayer * clone() const override
Returns a new instance equivalent to this one except for the id which is still unique.
 
Base class for all map layer types. This is the base class for all map layer types (vector,...
 
void invalidateWgs84Extent()
Invalidates the WGS84 extent.
 
Base class for visual effects which can be applied to QPicture drawings.
 
QgsCoordinateTransformContext transformContext
Coordinate transform context.
 
QgsCoordinateTransformContext transformContext
Coordinate transform context.
 
QgsProject * project() const
Returns the parent project if this map layer is added to a project.
 
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.