Skip to content

Commit 436b05e

Browse files
committedJun 22, 2014
Move QgsRendererJob subclasses to new files (no code changes)
1 parent cfe43c3 commit 436b05e

20 files changed

+1050
-929
lines changed
 

‎python/core/core.sip

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@
5151
%Include qgsmaplayerrenderer.sip
5252
%Include qgsmaprenderer.sip
5353
%Include qgsmaprenderercache.sip
54+
%Include qgsmaprenderercustompainterjob.sip
5455
%Include qgsmaprendererjob.sip
56+
%Include qgsmaprendererparalleljob.sip
57+
%Include qgsmaprenderersequentialjob.sip
5558
%Include qgsmapsettings.sip
5659
%Include qgsmaptopixel.sip
5760
%Include qgsmapunitscale.sip
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
2+
/** job implementation that renders everything sequentially using a custom painter.
3+
* The returned image is always invalid (because there is none available).
4+
*/
5+
class QgsMapRendererCustomPainterJob : QgsMapRendererJob
6+
{
7+
%TypeHeaderCode
8+
#include <qgsmaprenderercustompainterjob.h>
9+
%End
10+
11+
public:
12+
QgsMapRendererCustomPainterJob( const QgsMapSettings& settings, QPainter* painter );
13+
~QgsMapRendererCustomPainterJob();
14+
15+
virtual void start();
16+
virtual void cancel();
17+
virtual void waitForFinished();
18+
virtual bool isActive() const;
19+
virtual QgsLabelingResults* takeLabelingResults() /Transfer/;
20+
21+
//! @note not available in python bindings
22+
// const LayerRenderJobs& jobs() const { return mLayerJobs; }
23+
24+
/**
25+
* Wait for the job to be finished - and keep the thread's event loop running while waiting.
26+
*
27+
* With a call to waitForFinished(), the waiting is done with a synchronization primitive
28+
* and does not involve processing of messages. That may cause issues to code which requires
29+
* some events to be handled in the main thread. Some plugins hooking into the rendering
30+
* pipeline may require this in order to work properly - for example, OpenLayers plugin
31+
* which uses a QWebPage in the main thread.
32+
*
33+
* Ideally the "wait for finished" method should not be used at all. The code triggering
34+
* rendering should not need to actively wait for rendering to finish.
35+
*/
36+
void waitForFinishedWithEventLoop( QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents );
37+
38+
/**
39+
* Render the map synchronously in this thread. The function does not return until the map
40+
* is completely rendered.
41+
*
42+
* This is an alternative to ordinary API (using start() + waiting for finished() signal).
43+
* Users are discouraged to use this method unless they have a strong reason for doing it.
44+
* The synchronous rendering blocks the main thread, making the application unresponsive.
45+
* Also, it is not possible to cancel rendering while it is in progress.
46+
*/
47+
void renderSynchronously();
48+
49+
protected slots:
50+
void futureFinished();
51+
52+
protected:
53+
static void staticRender( QgsMapRendererCustomPainterJob* self ); // function to be used within the thread
54+
55+
// these methods are called within worker thread
56+
void doRender();
57+
};

‎python/core/qgsmaprendererjob.sip

Lines changed: 0 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -115,126 +115,3 @@ class QgsMapRendererQImageJob : QgsMapRendererJob
115115
//! Get a preview/resulting image
116116
virtual QImage renderedImage() = 0;
117117
};
118-
119-
120-
121-
/** job implementation that renders everything sequentially in one thread */
122-
class QgsMapRendererSequentialJob : QgsMapRendererQImageJob
123-
{
124-
%TypeHeaderCode
125-
#include <qgsmaprendererjob.h>
126-
%End
127-
128-
public:
129-
QgsMapRendererSequentialJob( const QgsMapSettings& settings );
130-
~QgsMapRendererSequentialJob();
131-
132-
virtual void start();
133-
virtual void cancel();
134-
virtual void waitForFinished();
135-
virtual bool isActive() const;
136-
137-
virtual QgsLabelingResults* takeLabelingResults() /Transfer/;
138-
139-
// from QgsMapRendererJobWithPreview
140-
virtual QImage renderedImage();
141-
142-
public slots:
143-
144-
void internalFinished();
145-
};
146-
147-
148-
149-
150-
/** job implementation that renders all layers in parallel */
151-
class QgsMapRendererParallelJob : QgsMapRendererQImageJob
152-
{
153-
%TypeHeaderCode
154-
#include <qgsmaprendererjob.h>
155-
%End
156-
157-
public:
158-
QgsMapRendererParallelJob( const QgsMapSettings& settings );
159-
~QgsMapRendererParallelJob();
160-
161-
virtual void start();
162-
virtual void cancel();
163-
virtual void waitForFinished();
164-
virtual bool isActive() const;
165-
166-
virtual QgsLabelingResults* takeLabelingResults() /Transfer/;
167-
168-
// from QgsMapRendererJobWithPreview
169-
virtual QImage renderedImage();
170-
171-
protected slots:
172-
//! layers are rendered, labeling is still pending
173-
void renderLayersFinished();
174-
//! all rendering is finished, including labeling
175-
void renderingFinished();
176-
177-
protected:
178-
179-
static void renderLayerStatic( LayerRenderJob& job );
180-
static void renderLabelsStatic( QgsMapRendererParallelJob* self );
181-
};
182-
183-
184-
185-
/** job implementation that renders everything sequentially using a custom painter.
186-
* The returned image is always invalid (because there is none available).
187-
*/
188-
class QgsMapRendererCustomPainterJob : QgsMapRendererJob
189-
{
190-
%TypeHeaderCode
191-
#include <qgsmaprendererjob.h>
192-
%End
193-
194-
public:
195-
QgsMapRendererCustomPainterJob( const QgsMapSettings& settings, QPainter* painter );
196-
~QgsMapRendererCustomPainterJob();
197-
198-
virtual void start();
199-
virtual void cancel();
200-
virtual void waitForFinished();
201-
virtual bool isActive() const;
202-
virtual QgsLabelingResults* takeLabelingResults() /Transfer/;
203-
204-
//! @note not available in python bindings
205-
// const LayerRenderJobs& jobs() const { return mLayerJobs; }
206-
207-
/**
208-
* Wait for the job to be finished - and keep the thread's event loop running while waiting.
209-
*
210-
* With a call to waitForFinished(), the waiting is done with a synchronization primitive
211-
* and does not involve processing of messages. That may cause issues to code which requires
212-
* some events to be handled in the main thread. Some plugins hooking into the rendering
213-
* pipeline may require this in order to work properly - for example, OpenLayers plugin
214-
* which uses a QWebPage in the main thread.
215-
*
216-
* Ideally the "wait for finished" method should not be used at all. The code triggering
217-
* rendering should not need to actively wait for rendering to finish.
218-
*/
219-
void waitForFinishedWithEventLoop( QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents );
220-
221-
/**
222-
* Render the map synchronously in this thread. The function does not return until the map
223-
* is completely rendered.
224-
*
225-
* This is an alternative to ordinary API (using start() + waiting for finished() signal).
226-
* Users are discouraged to use this method unless they have a strong reason for doing it.
227-
* The synchronous rendering blocks the main thread, making the application unresponsive.
228-
* Also, it is not possible to cancel rendering while it is in progress.
229-
*/
230-
void renderSynchronously();
231-
232-
protected slots:
233-
void futureFinished();
234-
235-
protected:
236-
static void staticRender( QgsMapRendererCustomPainterJob* self ); // function to be used within the thread
237-
238-
// these methods are called within worker thread
239-
void doRender();
240-
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
/** job implementation that renders all layers in parallel */
3+
class QgsMapRendererParallelJob : QgsMapRendererQImageJob
4+
{
5+
%TypeHeaderCode
6+
#include <qgsmaprendererparalleljob.h>
7+
%End
8+
9+
public:
10+
QgsMapRendererParallelJob( const QgsMapSettings& settings );
11+
~QgsMapRendererParallelJob();
12+
13+
virtual void start();
14+
virtual void cancel();
15+
virtual void waitForFinished();
16+
virtual bool isActive() const;
17+
18+
virtual QgsLabelingResults* takeLabelingResults() /Transfer/;
19+
20+
// from QgsMapRendererJobWithPreview
21+
virtual QImage renderedImage();
22+
23+
protected slots:
24+
//! layers are rendered, labeling is still pending
25+
void renderLayersFinished();
26+
//! all rendering is finished, including labeling
27+
void renderingFinished();
28+
29+
protected:
30+
31+
static void renderLayerStatic( LayerRenderJob& job );
32+
static void renderLabelsStatic( QgsMapRendererParallelJob* self );
33+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
3+
/** job implementation that renders everything sequentially in one thread */
4+
class QgsMapRendererSequentialJob : QgsMapRendererQImageJob
5+
{
6+
%TypeHeaderCode
7+
#include <qgsmaprenderersequentialjob.h>
8+
%End
9+
10+
public:
11+
QgsMapRendererSequentialJob( const QgsMapSettings& settings );
12+
~QgsMapRendererSequentialJob();
13+
14+
virtual void start();
15+
virtual void cancel();
16+
virtual void waitForFinished();
17+
virtual bool isActive() const;
18+
19+
virtual QgsLabelingResults* takeLabelingResults() /Transfer/;
20+
21+
// from QgsMapRendererJobWithPreview
22+
virtual QImage renderedImage();
23+
24+
public slots:
25+
26+
void internalFinished();
27+
};

‎src/app/maprenderertest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "qgsmapsettings.h"
1010
#include "qgsmaplayer.h"
1111

12-
#include "qgsmaprendererjob.h"
12+
#include "qgsmaprenderersequentialjob.h"
1313

1414
class TestWidget : public QLabel
1515
{

‎src/core/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ SET(QGIS_CORE_SRCS
77
qgsxmlutils.cpp
88
qgsmapsettings.cpp
99
qgsmaprendererjob.cpp
10+
qgsmaprenderercustompainterjob.cpp
11+
qgsmaprendererparalleljob.cpp
12+
qgsmaprenderersequentialjob.cpp
1013
qgsvectorlayerrenderer.cpp
1114
raster/qgsrasterlayerrenderer.cpp
1215

@@ -323,6 +326,9 @@ SET(QGIS_CORE_MOC_HDRS
323326

324327
qgsmaprenderercache.h
325328
qgsmaprendererjob.h
329+
qgsmaprenderercustompainterjob.h
330+
qgsmaprendererparalleljob.h
331+
qgsmaprenderersequentialjob.h
326332

327333
qgsapplication.h
328334
qgsbrowsermodel.h

‎src/core/composer/qgscomposermap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "qgscoordinatetransform.h"
2121
#include "qgslogger.h"
2222
#include "qgsmaprenderer.h"
23-
#include "qgsmaprendererjob.h"
23+
#include "qgsmaprenderercustompainterjob.h"
2424
#include "qgsmaplayerregistry.h"
2525
#include "qgsmaptopixel.h"
2626
#include "qgsproject.h"

0 commit comments

Comments
 (0)