QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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:
40
41 protected:
47 void preparePainter( QPainter *painter, const QColor &backgroundColor = Qt::transparent );
48};
49
60{
61 Q_OBJECT
62 public:
63 QgsMapRendererCustomPainterJob( const QgsMapSettings &settings, QPainter *painter );
65
66 void cancel() override;
67 void cancelWithoutBlocking() override;
68 void waitForFinished() override;
69 bool isActive() const override;
70 bool usedCachedLabels() const override;
72
74 const std::vector< LayerRenderJob > &jobs() const SIP_SKIP { return mLayerJobs; }
75
88 void waitForFinishedWithEventLoop( QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents );
89
99 void renderSynchronously();
100
112 void prepare();
113
124 void renderPrepared();
125
126
127 private slots:
128 void futureFinished();
129
130 private:
131 static void staticRender( QgsMapRendererCustomPainterJob *self ); // function to be used within the thread
132
133 void startPrivate() override;
134
135 // these methods are called within worker thread
136 void doRender();
137
138 QPainter *mPainter = nullptr;
139 QFuture<void> mFuture;
140 QFutureWatcher<void> mFutureWatcher;
141 std::unique_ptr< QgsLabelingEngine > mLabelingEngineV2;
142
143 bool mActive = false;
144 std::vector< LayerRenderJob > mLayerJobs;
145 LabelRenderJob mLabelJob;
146 bool mRenderSynchronously = false;
147 bool mPrepared = false;
148 bool mPrepareOnly = false;
149
150 std::vector< LayerRenderJob > mSecondPassLayerJobs;
151};
152
153
154#endif // QGSMAPRENDERERCUSTOMPAINTERJOB_H
Stores computed placement from labeling engine.
void preparePainter(QPainter *painter, const QColor &backgroundColor=Qt::transparent)
Prepares the given painter ready for a map render.
QgsMapRendererAbstractCustomPainterJob(const QgsMapSettings &settings)
Constructor for QgsMapRendererAbstractCustomPainterJob, using the given map settings.
Job implementation that renders everything sequentially using a custom painter.
QgsMapRendererCustomPainterJob(const QgsMapSettings &settings, QPainter *painter)
const std::vector< LayerRenderJob > & jobs() const
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.
QgsMapRendererJob(const QgsMapSettings &settings)
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.
Contains configuration for rendering maps.
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_ABSTRACT
Definition qgis_sip.h:220