28 , mLayerOpacity( layer->opacity() )
35 QSet< QString > items = qgis::listToSet( layer->queryIndex( context.
extent() ) );
42 items.unite( layer->mNonIndexedItems );
44 mItems.reserve( items.size() );
45 std::transform( items.begin(), items.end(), std::back_inserter( mItems ),
46 [layer](
const QString &
id ) ->std::pair< QString, std::unique_ptr< QgsAnnotationItem > >
48 return std::make_pair( id, std::unique_ptr< QgsAnnotationItem >( layer->item( id )->clone() ) );
51 std::sort( mItems.begin(), mItems.end(), [](
52 const std::pair< QString, std::unique_ptr< QgsAnnotationItem > > &a,
53 const std::pair< QString, std::unique_ptr< QgsAnnotationItem > > &b )
54 { return a.second->zIndex() < b.second->zIndex(); } );
66 return mFeedback.get();
75 mPaintEffect->begin( context );
78 bool canceled =
false;
79 for (
const std::pair< QString, std::unique_ptr< QgsAnnotationItem > > &item : std::as_const( mItems ) )
81 if ( mFeedback->isCanceled() )
87 std::optional< QgsScopedRenderContextReferenceScaleOverride > referenceScaleOverride;
88 if ( item.second->useSymbologyReferenceScale() )
93 const QgsRectangle bounds = item.second->boundingBox( context );
96 item.second->render( context, mFeedback.get() );
97 std::unique_ptr< QgsRenderedAnnotationItemDetails > details = std::make_unique< QgsRenderedAnnotationItemDetails >(
mLayerID, item.first );
98 details->setBoundingBox( bounds );
105 mPaintEffect->end( context );
@ 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.
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.
void appendRenderedItemDetails(QgsRenderedItemDetails *details)
Appends the details of a rendered item to the renderer.
QgsRenderContext * renderContext()
Returns the render context associated with the renderer.
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
bool enabled() const
Returns whether the effect is enabled.
A rectangle specified with double values.
bool intersects(const QgsRectangle &rect) const SIP_HOLDGIL
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.
bool testFlag(Qgis::RenderContextFlag flag) const
Check whether a particular flag is enabled.
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
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)