/
qgsmaprendererstagedrenderjob.h
134 lines (113 loc) · 4.31 KB
/
qgsmaprendererstagedrenderjob.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/***************************************************************************
qgsmaprendererstagedrenderjob.h
--------------------------------------
Date : August 2019
Copyright : (C) 2019 by Nyall Dawson
Email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSMAPRENDERERSTAGEDRENDERJOB_H
#define QGSMAPRENDERERSTAGEDRENDERJOB_H
#include "qgis_core.h"
#include "qgis_sip.h"
#include "qgsmaprenderercustompainterjob.h"
#define SIP_NO_FILE
/**
* \ingroup core
* \brief Render job implementation that renders maps in stages, allowing different stages (e.g. individual map
* layers) to be rendered to different paint devices.
*
* \since QGIS 3.10
*/
class CORE_EXPORT QgsMapRendererStagedRenderJob : public QgsMapRendererAbstractCustomPainterJob
{
Q_OBJECT
public:
/**
* Flags which control the staged render job behavior.
*/
enum Flag
{
RenderLabelsByMapLayer = 0x01, //!< Labels should be rendered in individual stages by map layer. This allows separation of labels belonging to different layers, but may affect label stacking order as the order will become layer-dependent, instead of per-label-dependent.
};
Q_DECLARE_FLAGS( Flags, Flag )
/**
* Represents the stages of a rendering job.
*/
enum RenderStage
{
Symbology, //!< Rendering layer symbology
Labels, //!< Rendering labels
Finished, //!< Rendering is finished
};
/**
* Constructor for QgsMapRendererStagedRenderJob, using the given
* map \a settings.
*
* The optional \a flags argument can be used to control the staged render job behavior.
*/
QgsMapRendererStagedRenderJob( const QgsMapSettings &settings, Flags flags = Flags() );
~QgsMapRendererStagedRenderJob() override;
void cancel() override;
void cancelWithoutBlocking() override;
void waitForFinished() override;
bool isActive() const override;
bool usedCachedLabels() const override;
QgsLabelingResults *takeLabelingResults() SIP_TRANSFER override;
/**
* Renders the current part of the map to the specified \a painter.
*
* Returns TRUE if a part was rendered or FALSE if nothing was rendered.
*/
bool renderCurrentPart( QPainter *painter );
/**
* Iterates to the next part to render.
*
* Returns TRUE if another part exists to render, or FALSE if all parts
* have been rendered and nothing remains.
*/
bool nextPart();
/**
* Returns TRUE if the job is finished, and nothing remains to render.
*/
bool isFinished() const;
/**
* Returns the ID of the current layer about to be rendered in the next render operation.
*/
QString currentLayerId() const;
/**
* Returns the opacity for the current layer about to be rendered in the next render operation.
*
* \since QGIS 3.14
*/
double currentLayerOpacity() const;
/**
* Returns the composition mode for the current layer about to be rendered in the next render operation.
*
* \since QGIS 3.14
*/
QPainter::CompositionMode currentLayerCompositionMode() const;
/**
* Returns the current stage which will be rendered in the next render operation.
*/
RenderStage currentStage() const;
private:
void startPrivate() override;
std::unique_ptr< QgsLabelingEngine > mLabelingEngineV2;
LayerRenderJobs mLayerJobs;
LabelRenderJob mLabelJob;
LayerRenderJobs::iterator mJobIt;
bool mNextIsLabel = false;
bool mExportedLabels = false;
Flags mFlags = Flags();
bool mPreparedStagedLabelJob = false;
QStringList mLabelingLayers;
QStringList::iterator mLabelLayerIt;
};
#endif // QGSMAPRENDERERSTAGEDRENDERJOB_H