28 , mLayerOpacity( layer->opacity() )
29 , mLayerBlendMode( layer->blendMode() )
33 if ( !context.
customProperties().value( QStringLiteral(
"visible_layer_ids" ) ).toList().contains( linkedLayer->id() ) )
45 const QStringList itemsList = layer->queryIndex( context.
extent() );
46 QSet< QString > items( itemsList.begin(), itemsList.end() );
53 items.unite( layer->mNonIndexedItems );
55 mItems.reserve( items.size() );
56 std::transform( items.begin(), items.end(), std::back_inserter( mItems ),
57 [layer](
const QString &
id ) ->std::pair< QString, std::unique_ptr< QgsAnnotationItem > >
59 return std::make_pair( id, std::unique_ptr< QgsAnnotationItem >( layer->item( id )->clone() ) );
62 std::sort( mItems.begin(), mItems.end(), [](
63 const std::pair< QString, std::unique_ptr< QgsAnnotationItem > > &a,
64 const std::pair< QString, std::unique_ptr< QgsAnnotationItem > > &b )
65 { return a.second->zIndex() < b.second->zIndex(); } );
77 return mFeedback.get();
86 mPaintEffect->begin( context );
89 bool canceled =
false;
90 for (
const std::pair< QString, std::unique_ptr< QgsAnnotationItem > > &item : std::as_const( mItems ) )
92 if ( mFeedback->isCanceled() )
98 if ( !item.second->enabled() )
101 std::optional< QgsScopedRenderContextReferenceScaleOverride > referenceScaleOverride;
107 const QgsRectangle bounds = item.second->boundingBox( context );
110 item.second->render( context, mFeedback.get() );
111 std::unique_ptr< QgsRenderedAnnotationItemDetails > details = std::make_unique< QgsRenderedAnnotationItemDetails >(
mLayerID, item.first );
112 details->setBoundingBox( bounds );
119 mPaintEffect->end( context );
133 if ( mLayerBlendMode != QPainter::CompositionMode_SourceOver )
@ SupportsReferenceScale
Item supports reference scale based rendering.
@ UseAdvancedEffects
Enable layer opacity and blending effects.
bool forceRasterRender() const override
Returns true if the renderer must be rendered to a raster paint device (e.g.
~QgsAnnotationLayerRenderer() override
bool render() override
Do the rendering (based on data stored in the class).
QgsFeedback * feedback() const override
Access to feedback object of the layer renderer (may be nullptr)
QgsAnnotationLayerRenderer(QgsAnnotationLayer *layer, QgsRenderContext &context)
Constructor for a QgsAnnotationLayerRenderer, for the specified layer.
Represents a map layer containing a set of georeferenced annotations, e.g.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the layer.
QgsMapLayer * linkedVisibilityLayer()
Returns a linked layer, where the items in this annotation layer will only be visible when the linked...
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Base class for utility classes that encapsulate information necessary for rendering of map layers.
bool mReadyToCompose
The flag must be set to false in renderer's constructor if wants to use the smarter map redraws funct...
void appendRenderedItemDetails(QgsRenderedItemDetails *details)
Appends the details of a rendered item to the renderer.
QgsRenderContext * renderContext()
Returns the render context associated with the renderer.
Base class for all map layer types.
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.
bool intersects(const QgsRectangle &rect) const
Returns true when rectangle intersects with other rectangle.
Contains information about the context of a rendering operation.
double symbologyReferenceScale() const
Returns the symbology reference scale.
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
QVariantMap customProperties() const
Returns custom rendering properties.
Scoped object for temporary override of the symbologyReferenceScale property of a QgsRenderContext.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)