1 /***************************************************************************
2   qgsmaprenderersequentialjob.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 QGSMAPRENDERERSEQUENTIALJOB_H
17 #define QGSMAPRENDERERSEQUENTIALJOB_H
18 
19 #include "qgis_core.h"
20 #include "qgsmaprendererjob.h"
21 
22 class QgsMapRendererCustomPainterJob;
23 
24 /**
25  * \ingroup core
26  * \brief Job implementation that renders everything sequentially in one thread.
27  *
28  * The resulting map image can be retrieved with renderedImage() function.
29  * It is safe to call that function while rendering is active to see preview of the map.
30  *
31  * \since QGIS 2.4
32  */
33 class CORE_EXPORT QgsMapRendererSequentialJob : public QgsMapRendererQImageJob
34 {
35     Q_OBJECT
36   public:
37     QgsMapRendererSequentialJob( const QgsMapSettings &settings );
38     ~QgsMapRendererSequentialJob() override;
39 
40     void start() override;
41     void cancel() override;
42     void cancelWithoutBlocking() override;
43     void waitForFinished() override;
44     bool isActive() const override;
45 
46     bool usedCachedLabels() const override;
47     QgsLabelingResults *takeLabelingResults() SIP_TRANSFER override;
48 
49     // from QgsMapRendererJobWithPreview
50     QImage renderedImage() override;
51 
52   public slots:
53 
54     void internalFinished();
55 
56   private:
57 
58     QgsMapRendererCustomPainterJob *mInternalJob = nullptr;
59     QImage mImage;
60     QPainter *mPainter = nullptr;
61     std::unique_ptr< QgsLabelingResults > mLabelingResults;
62     bool mUsedCachedLabels = false;
63 
64 };
65 
66 
67 #endif // QGSMAPRENDERERSEQUENTIALJOB_H
68