30using namespace Qt::StringLiterals;
35 , mLayerOpacity( layer->opacity() )
37 const QList< QgsMapLayer * > layers = layer->
childLayers();
49 context.
setExtent( extentInChildLayerCrs );
53 QgsDebugError( u
"Error transforming extent of %1 to destination CRS"_s.arg( childLayer->id() ) );
57 mChildRenderers.emplace_back( childLayer->createMapRenderer( context ) );
58 mRendererCompositionModes.emplace_back( childLayer->blendMode() );
60 mTransforms.emplace_back( layerToDestTransform );
65 mForceRasterRender = layer->
blendMode() != QPainter::CompositionMode_SourceOver;
72 return mFeedback.get();
82 mPaintEffect->begin( context );
86 bool canceled =
false;
88 for (
const std::unique_ptr< QgsMapLayerRenderer > &renderer : std::as_const( mChildRenderers ) )
90 if ( mFeedback->isCanceled() )
100 context.
setExtent( extentInChildLayerCrs );
105 context.
painter()->setCompositionMode( mRendererCompositionModes[i] );
108 QPainter *prevPainter = context.
painter();
109 std::unique_ptr< QPainter > imagePainter;
110 if ( renderer->forceRasterRender() )
113 image.setDevicePixelRatio(
static_cast<qreal
>( context.
devicePixelRatio() ) );
115 imagePainter = std::make_unique< QPainter >( &image );
127 context.
painter()->setOpacity( mRendererOpacity[i] );
128 context.
painter()->drawImage( 0, 0, image );
129 context.
painter()->setOpacity( 1.0 );
131 context.
painter()->setCompositionMode( QPainter::CompositionMode_SourceOver );
137 mPaintEffect->end( context );
157 if ( mForceRasterRender || !
qgsDoubleNear( mLayerOpacity, 1.0 ) )
160 for ( QPainter::CompositionMode mode : mRendererCompositionModes )
162 if ( mode != QPainter::CompositionMode_SourceOver )
@ Default
Allow raster-based rendering in situations where it is required for correct rendering or where it wil...
@ PreferVector
Prefer vector-based rendering, when the result will still be visually near-identical to a raster-base...
@ ForceVector
Always force vector-based rendering, even when the result will be visually different to a raster-base...
@ Reverse
Reverse/inverse transform (from destination to source).
Represents a coordinate reference system (CRS).
Custom exception class for Coordinate Reference System related exceptions.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
~QgsGroupLayerRenderer() override
QgsGroupLayerRenderer(QgsGroupLayer *layer, QgsRenderContext &context)
Constructor for a QgsGroupLayerRenderer, for the specified layer.
bool forceRasterRender() const override
Returns true if the renderer must be rendered to a raster paint device (e.g.
QgsFeedback * feedback() const override
Access to feedback object of the layer renderer (may be nullptr).
bool render() override
Do the rendering (based on data stored in the class).
A map layer which consists of a set of child layers, where all component layers are rendered as a sin...
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the group layer.
QList< QgsMapLayer * > childLayers() const
Returns the child layers contained by the group.
QgsRenderContext * renderContext()
Returns the render context associated with the renderer.
QgsMapLayerRenderer(const QString &layerID, QgsRenderContext *context=nullptr)
Constructor for QgsMapLayerRenderer, with the associated layerID and render context.
Base class for all map layer types.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
bool enabled() const
Returns whether the effect is enabled.
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
void setCoordinateTransform(const QgsCoordinateTransform &t)
Sets the current coordinate transform for the context.
QPainter * painter()
Returns the destination QPainter for the render operation.
void setPainterFlagsUsingContext(QPainter *painter=nullptr) const
Sets relevant flags on a destination painter, using the flags and settings currently defined for the ...
QgsCoordinateTransformContext transformContext() const
Returns the context's coordinate transform context, which stores various information regarding which ...
float devicePixelRatio() const
Returns the device pixel ratio.
QgsRectangle mapExtent() const
Returns the original extent of the map being rendered.
void setExtent(const QgsRectangle &extent)
When rendering a map layer, calling this method sets the "clipping" extent for the layer (in the laye...
Qgis::RasterizedRenderingPolicy rasterizedRenderingPolicy() const
Returns the policy controlling when rasterisation of content during renders is permitted.
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
QSize deviceOutputSize() const
Returns the device output size of the render.
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
QImage::Format imageFormat() const
Returns the QImage format which should be used for QImages created during rendering.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
#define QgsDebugError(str)