QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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 
36 {
37  Q_OBJECT
38  public:
39  QgsMapRendererCustomPainterJob( const QgsMapSettings &settings, QPainter *painter );
41 
42  void start() override;
43  void cancel() override;
44  void cancelWithoutBlocking() override;
45  void waitForFinished() override;
46  bool isActive() const override;
47  bool usedCachedLabels() const override;
49 
51  const LayerRenderJobs &jobs() const { return mLayerJobs; } SIP_SKIP
52 
65  void waitForFinishedWithEventLoop( QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents );
66 
76  void renderSynchronously();
77 
78  private slots:
79  void futureFinished();
80 
81  private:
82  static void staticRender( QgsMapRendererCustomPainterJob *self ); // function to be used within the thread
83 
84  // these methods are called within worker thread
85  void doRender();
86 
87  QPainter *mPainter = nullptr;
88  QFuture<void> mFuture;
89  QFutureWatcher<void> mFutureWatcher;
90  std::unique_ptr< QgsLabelingEngine > mLabelingEngineV2;
91 
92  bool mActive;
93  LayerRenderJobs mLayerJobs;
94  LabelRenderJob mLabelJob;
95  bool mRenderSynchronously;
96 
97 };
98 
99 
100 #endif // QGSMAPRENDERERCUSTOMPAINTERJOB_H
const LayerRenderJobs & jobs() const
Job implementation that renders everything sequentially using a custom painter.
Abstract base class for map rendering implementations.
The QgsMapSettings class contains configuration for rendering of the map.
#define SIP_SKIP
Definition: qgis_sip.h:119
virtual void waitForFinished()=0
Block until the job has finished.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
virtual void start()=0
Start the rendering job and immediately return.
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.
Class that stores computed placement from labeling engine.
virtual QgsLabelingResults * takeLabelingResults()=0
Gets pointer to internal labeling engine (in order to get access to the results). ...
virtual bool isActive() const =0
Tell whether the rendering job is currently running in background.
virtual bool usedCachedLabels() const =0
Returns true if the render job was able to use a cached labeling solution.