QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
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
63{
64 Q_OBJECT
65 public:
66 QgsMapRendererCustomPainterJob( const QgsMapSettings &settings, QPainter *painter );
68
69 void cancel() override;
70 void cancelWithoutBlocking() override;
71 void waitForFinished() override;
72 bool isActive() const override;
73 bool usedCachedLabels() const override;
75
77 const std::vector< LayerRenderJob > &jobs() const { return mLayerJobs; } SIP_SKIP
78
91 void waitForFinishedWithEventLoop( QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents );
92
102 void renderSynchronously();
103
115 void prepare();
116
127 void renderPrepared();
128
129
130 private slots:
131 void futureFinished();
132
133 private:
134 static void staticRender( QgsMapRendererCustomPainterJob *self ); // function to be used within the thread
135
136 void startPrivate() override;
137
138 // these methods are called within worker thread
139 void doRender();
140
141 QPainter *mPainter = nullptr;
142 QFuture<void> mFuture;
143 QFutureWatcher<void> mFutureWatcher;
144 std::unique_ptr< QgsLabelingEngine > mLabelingEngineV2;
145
146 bool mActive;
147 std::vector< LayerRenderJob > mLayerJobs;
148 LabelRenderJob mLabelJob;
149 bool mRenderSynchronously = false;
150 bool mPrepared = false;
151 bool mPrepareOnly = false;
152
153 std::vector< LayerRenderJob > mSecondPassLayerJobs;
154};
155
156
157#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:213