QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
src
core
annotations
qgsannotationlayerrenderer.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsannotationlayerrenderer.cpp
3
------------------
4
copyright : (C) 2019 by Sandro Mani
5
email : smani at sourcepole dot ch
6
***************************************************************************/
7
8
/***************************************************************************
9
* *
10
* This program is free software; you can redistribute it and/or modify *
11
* it under the terms of the GNU General Public License as published by *
12
* the Free Software Foundation; either version 2 of the License, or *
13
* (at your option) any later version. *
14
* *
15
***************************************************************************/
16
17
#include "
qgsannotationlayerrenderer.h
"
18
#include "
qgsannotationlayer.h
"
19
#include "
qgsfeedback.h
"
20
21
QgsAnnotationLayerRenderer::QgsAnnotationLayerRenderer
(
QgsAnnotationLayer
*layer,
QgsRenderContext
&context )
22
:
QgsMapLayerRenderer
( layer->id(), &context )
23
, mFeedback( qgis::make_unique<
QgsFeedback
>() )
24
{
25
// clone items from layer
26
const
QMap< QString, QgsAnnotationItem * > items = layer->
items
();
27
mItems.reserve( items.size() );
28
for
(
auto
it = items.constBegin(); it != items.constEnd(); ++it )
29
{
30
if
( it.value() )
31
mItems << ( *it )->clone();
32
}
33
34
std::sort( mItems.begin(), mItems.end(), [](
QgsAnnotationItem
* a,
QgsAnnotationItem
* b ) { return a->zIndex() < b->zIndex(); } );
//clazy:exclude=detaching-member
35
}
36
37
QgsAnnotationLayerRenderer::~QgsAnnotationLayerRenderer
()
38
{
39
qDeleteAll( mItems );
40
}
41
42
QgsFeedback
*
QgsAnnotationLayerRenderer::feedback
()
const
43
{
44
return
mFeedback.get();
45
}
46
47
bool
QgsAnnotationLayerRenderer::render
()
48
{
49
QgsRenderContext
&context = *
renderContext
();
50
51
for
(
QgsAnnotationItem
*item : qgis::as_const( mItems ) )
52
{
53
if
( mFeedback->isCanceled() )
54
break
;
55
56
item->render( context, mFeedback.get() );
57
}
58
return
true
;
59
}
QgsAnnotationLayerRenderer::QgsAnnotationLayerRenderer
QgsAnnotationLayerRenderer(QgsAnnotationLayer *layer, QgsRenderContext &context)
Constructor for a QgsAnnotationLayerRenderer, for the specified layer.
Definition:
qgsannotationlayerrenderer.cpp:21
QgsRenderContext
Contains information about the context of a rendering operation.
Definition:
qgsrendercontext.h:58
QgsMapLayerRenderer::renderContext
QgsRenderContext * renderContext()
Returns the render context associated with the renderer.
Definition:
qgsmaplayerrenderer.h:84
qgsannotationlayerrenderer.h
QgsMapLayerRenderer
Base class for utility classes that encapsulate information necessary for rendering of map layers.
Definition:
qgsmaplayerrenderer.h:51
QgsAnnotationLayerRenderer::render
bool render() override
Do the rendering (based on data stored in the class)
Definition:
qgsannotationlayerrenderer.cpp:47
QgsAnnotationLayerRenderer::~QgsAnnotationLayerRenderer
~QgsAnnotationLayerRenderer() override
Definition:
qgsannotationlayerrenderer.cpp:37
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition:
qgsfeedback.h:44
QgsAnnotationLayerRenderer::feedback
QgsFeedback * feedback() const override
Access to feedback object of the layer renderer (may be nullptr)
Definition:
qgsannotationlayerrenderer.cpp:42
qgsannotationlayer.h
QgsAnnotationLayer::items
QMap< QString, QgsAnnotationItem * > items() const
Returns a map of items contained in the layer, by unique item ID.
Definition:
qgsannotationlayer.h:110
QgsAnnotationLayer
Represents a map layer containing a set of georeferenced annotations, e.g.
Definition:
qgsannotationlayer.h:40
qgsfeedback.h
QgsAnnotationItem
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
Definition:
qgsannotationitem.h:39
Generated on Sat Oct 24 2020 17:43:09 for QGIS API Documentation by
1.8.20