QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 start() override;
71  void cancel() override;
72  void cancelWithoutBlocking() override;
73  void waitForFinished() override;
74  bool isActive() const override;
75  bool usedCachedLabels() const override;
77 
79  const LayerRenderJobs &jobs() const { return mLayerJobs; } SIP_SKIP
80 
93  void waitForFinishedWithEventLoop( QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents );
94 
104  void renderSynchronously();
105 
117  void prepare();
118 
129  void renderPrepared();
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  // these methods are called within worker thread
138  void doRender();
139 
140  QPainter *mPainter = nullptr;
141  QFuture<void> mFuture;
142  QFutureWatcher<void> mFutureWatcher;
143  std::unique_ptr< QgsLabelingEngine > mLabelingEngineV2;
144 
145  bool mActive;
146  LayerRenderJobs mLayerJobs;
147  LabelRenderJob mLabelJob;
148  bool mRenderSynchronously = false;
149  bool mPrepared = false;
150  bool mPrepareOnly = false;
151 
152  LayerRenderJobs mSecondPassLayerJobs;
153 };
154 
155 
156 #endif // QGSMAPRENDERERCUSTOMPAINTERJOB_H
QgsMapRendererJob::usedCachedLabels
virtual bool usedCachedLabels() const =0
Returns true if the render job was able to use a cached labeling solution.
QgsMapRendererJob::isActive
virtual bool isActive() const =0
Tell whether the rendering job is currently running in background.
QgsMapRendererAbstractCustomPainterJob
Abstract base class for map renderer jobs which use custom painters.
Definition: qgsmaprenderercustompainterjob.h:32
QgsLabelingResults
Class that stores computed placement from labeling engine.
Definition: qgspallabeling.h:1224
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsMapRendererJob::waitForFinished
virtual void waitForFinished()=0
Block until the job has finished.
qgis_sip.h
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
qgsmaprendererjob.h
QgsMapRendererJob::start
virtual void start()=0
Start the rendering job and immediately return.
QgsMapRendererCustomPainterJob
Job implementation that renders everything sequentially using a custom painter.
Definition: qgsmaprenderercustompainterjob.h:64
QgsMapRendererJob::cancelWithoutBlocking
virtual void cancelWithoutBlocking()=0
Triggers cancellation of the rendering job without blocking.
QgsMapRendererCustomPainterJob::jobs
const LayerRenderJobs & jobs() const
Definition: qgsmaprenderercustompainterjob.h:79
QgsMapRendererJob
Abstract base class for map rendering implementations.
Definition: qgsmaprendererjob.h:187
QgsMapRendererJob::takeLabelingResults
virtual QgsLabelingResults * takeLabelingResults()=0
Gets pointer to internal labeling engine (in order to get access to the results).
QgsMapRendererJob::cancel
virtual void cancel()=0
Stop the rendering job - does not return until the job has terminated.
QgsMapSettings
The QgsMapSettings class contains configuration for rendering of the map.
Definition: qgsmapsettings.h:88