28 , mLayerOpacity( layer->opacity() )
35 const QStringList itemsList = layer->queryIndex( context.
extent() );
36 QSet< QString > items( itemsList.begin(), itemsList.end() );
43 items.unite( layer->mNonIndexedItems );
45 mItems.reserve( items.size() );
46 std::transform( items.begin(), items.end(), std::back_inserter( mItems ),
47 [layer](
const QString &
id ) ->std::pair< QString, std::unique_ptr< QgsAnnotationItem > >
49 return std::make_pair( id, std::unique_ptr< QgsAnnotationItem >( layer->item( id )->clone() ) );
52 std::sort( mItems.begin(), mItems.end(), [](
53 const std::pair< QString, std::unique_ptr< QgsAnnotationItem > > &a,
54 const std::pair< QString, std::unique_ptr< QgsAnnotationItem > > &b )
55 { return a.second->zIndex() < b.second->zIndex(); } );
67 return mFeedback.get();
76 mPaintEffect->begin( context );
79 bool canceled =
false;
80 for (
const std::pair< QString, std::unique_ptr< QgsAnnotationItem > > &item : std::as_const( mItems ) )
82 if ( mFeedback->isCanceled() )
88 std::optional< QgsScopedRenderContextReferenceScaleOverride > referenceScaleOverride;
89 if ( item.second->useSymbologyReferenceScale() )
94 const QgsRectangle bounds = item.second->boundingBox( context );
97 item.second->render( context, mFeedback.get() );
98 std::unique_ptr< QgsRenderedAnnotationItemDetails > details = std::make_unique< QgsRenderedAnnotationItemDetails >(
mLayerID, item.first );
99 details->setBoundingBox( bounds );
106 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.
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...
bool testFlag(Qgis::RenderContextFlag flag) const
Check whether a particular flag is enabled.
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)