QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
29 , mLayerOpacity( layer->opacity() )
31 const QList< QgsMapLayer * > layers = layer->
childLayers();
43 context.
setExtent( extentInChildLayerCrs );
47 QgsDebugMsg( QStringLiteral(
"Error transforming extent of %1 to destination CRS" ).arg( childLayer->id() ) );
51 mChildRenderers.emplace_back( childLayer->createMapRenderer( context ) );
52 mRendererCompositionModes.emplace_back( childLayer->blendMode() );
54 mTransforms.emplace_back( layerToDestTransform );
59 mForceRasterRender = layer->
blendMode() != QPainter::CompositionMode_SourceOver;
66 return mFeedback.get();
76 mPaintEffect->begin( context );
80 bool canceled =
false;
82 for (
const std::unique_ptr< QgsMapLayerRenderer > &renderer : std::as_const( mChildRenderers ) )
84 if ( mFeedback->isCanceled() )
93 const QgsRectangle extentInChildLayerCrs = mTransforms[i].transformBoundingBox( context.
mapExtent(), Qgis::TransformDirection::Reverse );
94 context.
setExtent( extentInChildLayerCrs );
98 context.
painter()->setCompositionMode( mRendererCompositionModes[i] );
100 QPainter *prevPainter = context.
painter();
101 std::unique_ptr< QPainter > imagePainter;
102 if ( renderer->forceRasterRender() )
105 image.setDevicePixelRatio(
static_cast<qreal
>( context.
devicePixelRatio() ) );
107 imagePainter = std::make_unique< QPainter >( &image );
119 context.
painter()->setOpacity( mRendererOpacity[i] );
120 context.
painter()->drawImage( 0, 0, image );
121 context.
painter()->setOpacity( 1.0 );
123 context.
painter()->setCompositionMode( QPainter::CompositionMode_SourceOver );
129 mPaintEffect->end( context );
142 if ( mForceRasterRender || !
qgsDoubleNear( mLayerOpacity, 1.0 ) )
145 for ( QPainter::CompositionMode mode : mRendererCompositionModes )
147 if ( mode != QPainter::CompositionMode_SourceOver )
QgsGroupLayerRenderer(QgsGroupLayer *layer, QgsRenderContext &context)
Constructor for a QgsGroupLayerRenderer, for the specified layer.
QSize deviceOutputSize() const
Returns the device output size of the render.
void setPainterFlagsUsingContext(QPainter *painter=nullptr) const
Sets relevant flags on a destination painter, using the flags and settings currently defined for the ...
QImage::Format imageFormat() const
Returns the QImage format which should be used for QImages created during rendering.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
Contains information about the context of a rendering operation.
QgsRenderContext * renderContext()
Returns the render context associated with the renderer.
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.
A rectangle specified with double values.
~QgsGroupLayerRenderer() override
Base class for utility classes that encapsulate information necessary for rendering of map layers.
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
Custom exception class for Coordinate Reference System related exceptions.
bool useAdvancedEffects() const
Returns true if advanced effects such as blend modes such be used.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Base class for feedback objects to be used for cancellation of something running in a worker thread.
void setExtent(const QgsRectangle &extent)
When rendering a map layer, calling this method sets the "clipping" extent for the layer (in the laye...
void setCoordinateTransform(const QgsCoordinateTransform &t)
Sets the current coordinate transform for the context.
bool forceRasterRender() const override
Returns true if the renderer must be rendered to a raster paint device (e.g.
@ RasterLayer
Raster layer.
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
bool render() override
Do the rendering (based on data stored in the class).
QList< QgsMapLayer * > childLayers() const
Returns the child layers contained by the group.
This class represents a coordinate reference system (CRS).
QgsRectangle mapExtent() const
Returns the original extent of the map being rendered.
QgsCoordinateTransformContext transformContext() const
Returns the context's coordinate transform context, which stores various information regarding which ...
Base class for all map layer types. This is the base class for all map layer types (vector,...
QPainter * painter()
Returns the destination QPainter for the render operation.
bool enabled() const
Returns whether the effect is enabled.
@ UseAdvancedEffects
Enable layer opacity and blending effects.
float devicePixelRatio() const
Returns the device pixel ratio.
QgsFeedback * feedback() const override
Access to feedback object of the layer renderer (may be nullptr)