QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsmaprenderercustompainterjob.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmaprenderercustompainterjob.h
3 --------------------------------------
4 Date : December 2013
5 Copyright : (C) 2013 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSMAPRENDERERCUSTOMPAINTERJOB_H
17#define QGSMAPRENDERERCUSTOMPAINTERJOB_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21#include "qgsmaprendererjob.h"
22
23#include <QEventLoop>
24
32{
33 Q_OBJECT
34 public:
35
41
42 protected:
43
49 void preparePainter( QPainter *painter, const QColor &backgroundColor = Qt::transparent );
50
51};
52
64{
65 Q_OBJECT
66 public:
67 QgsMapRendererCustomPainterJob( const QgsMapSettings &settings, QPainter *painter );
69
70 void cancel() override;
71 void cancelWithoutBlocking() override;
72 void waitForFinished() override;
73 bool isActive() const override;
74 bool usedCachedLabels() const override;
76
78 const std::vector< LayerRenderJob > &jobs() const { return mLayerJobs; } SIP_SKIP
79
92 void waitForFinishedWithEventLoop( QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents );
93
103 void renderSynchronously();
104
116 void prepare();
117
128 void renderPrepared();
129
130
131 private slots:
132 void futureFinished();
133
134 private:
135 static void staticRender( QgsMapRendererCustomPainterJob *self ); // function to be used within the thread
136
137 void startPrivate() override;
138
139 // these methods are called within worker thread
140 void doRender();
141
142 QPainter *mPainter = nullptr;
143 QFuture<void> mFuture;
144 QFutureWatcher<void> mFutureWatcher;
145 std::unique_ptr< QgsLabelingEngine > mLabelingEngineV2;
146
147 bool mActive;
148 std::vector< LayerRenderJob > mLayerJobs;
149 LabelRenderJob mLabelJob;
150 bool mRenderSynchronously = false;
151 bool mPrepared = false;
152 bool mPrepareOnly = false;
153
154 std::vector< LayerRenderJob > mSecondPassLayerJobs;
155};
156
157
158#endif // QGSMAPRENDERERCUSTOMPAINTERJOB_H
Class that stores computed placement from labeling engine.
Abstract base class for map renderer jobs which use custom painters.
Job implementation that renders everything sequentially using a custom painter.
const std::vector< LayerRenderJob > & jobs() const
Abstract base class for map rendering implementations.
virtual void waitForFinished()=0
Block until the job has finished.
virtual bool usedCachedLabels() const =0
Returns true if the render job was able to use a cached labeling solution.
virtual bool isActive() const =0
Tell whether the rendering job is currently running in background.
virtual QgsLabelingResults * takeLabelingResults()=0
Gets pointer to internal labeling engine (in order to get access to the results).
virtual void cancel()=0
Stop the rendering job - does not return until the job has terminated.
virtual void cancelWithoutBlocking()=0
Triggers cancellation of the rendering job without blocking.
The QgsMapSettings class contains configuration for rendering of the map.
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_ABSTRACT
Definition: qgis_sip.h:208