-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move QgsRendererJob subclasses to new files (no code changes)
- Loading branch information
Showing
20 changed files
with
1,050 additions
and
929 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
/** job implementation that renders everything sequentially using a custom painter. | ||
* The returned image is always invalid (because there is none available). | ||
*/ | ||
class QgsMapRendererCustomPainterJob : QgsMapRendererJob | ||
{ | ||
%TypeHeaderCode | ||
#include <qgsmaprenderercustompainterjob.h> | ||
%End | ||
|
||
public: | ||
QgsMapRendererCustomPainterJob( const QgsMapSettings& settings, QPainter* painter ); | ||
~QgsMapRendererCustomPainterJob(); | ||
|
||
virtual void start(); | ||
virtual void cancel(); | ||
virtual void waitForFinished(); | ||
virtual bool isActive() const; | ||
virtual QgsLabelingResults* takeLabelingResults() /Transfer/; | ||
|
||
//! @note not available in python bindings | ||
// const LayerRenderJobs& jobs() const { return mLayerJobs; } | ||
|
||
/** | ||
* Wait for the job to be finished - and keep the thread's event loop running while waiting. | ||
* | ||
* With a call to waitForFinished(), the waiting is done with a synchronization primitive | ||
* and does not involve processing of messages. That may cause issues to code which requires | ||
* some events to be handled in the main thread. Some plugins hooking into the rendering | ||
* pipeline may require this in order to work properly - for example, OpenLayers plugin | ||
* which uses a QWebPage in the main thread. | ||
* | ||
* Ideally the "wait for finished" method should not be used at all. The code triggering | ||
* rendering should not need to actively wait for rendering to finish. | ||
*/ | ||
void waitForFinishedWithEventLoop( QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents ); | ||
|
||
/** | ||
* Render the map synchronously in this thread. The function does not return until the map | ||
* is completely rendered. | ||
* | ||
* This is an alternative to ordinary API (using start() + waiting for finished() signal). | ||
* Users are discouraged to use this method unless they have a strong reason for doing it. | ||
* The synchronous rendering blocks the main thread, making the application unresponsive. | ||
* Also, it is not possible to cancel rendering while it is in progress. | ||
*/ | ||
void renderSynchronously(); | ||
|
||
protected slots: | ||
void futureFinished(); | ||
|
||
protected: | ||
static void staticRender( QgsMapRendererCustomPainterJob* self ); // function to be used within the thread | ||
|
||
// these methods are called within worker thread | ||
void doRender(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
/** job implementation that renders all layers in parallel */ | ||
class QgsMapRendererParallelJob : QgsMapRendererQImageJob | ||
{ | ||
%TypeHeaderCode | ||
#include <qgsmaprendererparalleljob.h> | ||
%End | ||
|
||
public: | ||
QgsMapRendererParallelJob( const QgsMapSettings& settings ); | ||
~QgsMapRendererParallelJob(); | ||
|
||
virtual void start(); | ||
virtual void cancel(); | ||
virtual void waitForFinished(); | ||
virtual bool isActive() const; | ||
|
||
virtual QgsLabelingResults* takeLabelingResults() /Transfer/; | ||
|
||
// from QgsMapRendererJobWithPreview | ||
virtual QImage renderedImage(); | ||
|
||
protected slots: | ||
//! layers are rendered, labeling is still pending | ||
void renderLayersFinished(); | ||
//! all rendering is finished, including labeling | ||
void renderingFinished(); | ||
|
||
protected: | ||
|
||
static void renderLayerStatic( LayerRenderJob& job ); | ||
static void renderLabelsStatic( QgsMapRendererParallelJob* self ); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
|
||
/** job implementation that renders everything sequentially in one thread */ | ||
class QgsMapRendererSequentialJob : QgsMapRendererQImageJob | ||
{ | ||
%TypeHeaderCode | ||
#include <qgsmaprenderersequentialjob.h> | ||
%End | ||
|
||
public: | ||
QgsMapRendererSequentialJob( const QgsMapSettings& settings ); | ||
~QgsMapRendererSequentialJob(); | ||
|
||
virtual void start(); | ||
virtual void cancel(); | ||
virtual void waitForFinished(); | ||
virtual bool isActive() const; | ||
|
||
virtual QgsLabelingResults* takeLabelingResults() /Transfer/; | ||
|
||
// from QgsMapRendererJobWithPreview | ||
virtual QImage renderedImage(); | ||
|
||
public slots: | ||
|
||
void internalFinished(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.