QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Abstract base class for map rendering implementations. More...
#include <qgsmaprendererjob.h>
Classes | |
struct | Error |
Public Types | |
typedef QList< QgsMapRendererJob::Error > | Errors |
Signals | |
void | finished () |
emitted when asynchronous rendering is finished (or canceled). More... | |
void | renderingLayersFinished () |
Emitted when the layers are rendered. More... | |
Public Member Functions | |
QgsMapRendererJob (const QgsMapSettings &settings) | |
virtual void | cancel ()=0 |
Stop the rendering job - does not return until the job has terminated. More... | |
virtual void | cancelWithoutBlocking ()=0 |
Triggers cancellation of the rendering job without blocking. More... | |
Errors | errors () const |
List of errors that happened during the rendering job - available when the rendering has been finished. More... | |
const QgsFeatureFilterProvider * | featureFilterProvider () const |
Returns the feature filter provider used by the QgsRenderContext of each LayerRenderJob. More... | |
virtual bool | isActive () const =0 |
Tell whether the rendering job is currently running in background. More... | |
const QgsMapSettings & | mapSettings () const |
Returns map settings with which this job was started. More... | |
QHash< QgsMapLayer *, int > | perLayerRenderingTime () const |
Returns the render time (in ms) per layer. More... | |
int | renderingTime () const |
Returns the total time it took to finish the job (in milliseconds). More... | |
void | setCache (QgsMapRendererCache *cache) |
Assign a cache to be used for reading and storing rendered images of individual layers. More... | |
void | setFeatureFilterProvider (const QgsFeatureFilterProvider *f) |
Set the feature filter provider used by the QgsRenderContext of each LayerRenderJob. More... | |
virtual void | start ()=0 |
Start the rendering job and immediately return. More... | |
virtual QgsLabelingResults * | takeLabelingResults ()=0 |
Gets pointer to internal labeling engine (in order to get access to the results). More... | |
virtual bool | usedCachedLabels () const =0 |
Returns true if the render job was able to use a cached labeling solution. More... | |
virtual void | waitForFinished ()=0 |
Block until the job has finished. More... | |
Static Public Attributes | |
static const QString | LABEL_CACHE_ID |
QgsMapRendererCache ID string for cached label image. More... | |
Protected Member Functions | |
void | cleanupJobs (LayerRenderJobs &jobs) |
void | cleanupLabelJob (LabelRenderJob &job) |
Handles clean up tasks for a label job, including deletion of images and storing cached label results. More... | |
void | cleanupSecondPassJobs (LayerRenderJobs &jobs) |
void | logRenderingTime (const LayerRenderJobs &jobs, const LayerRenderJobs &secondPassJobs, const LabelRenderJob &labelJob) |
LayerRenderJobs | prepareJobs (QPainter *painter, QgsLabelingEngine *labelingEngine2, bool deferredPainterSet=false) |
Creates a list of layer rendering jobs and prepares them for later render. More... | |
bool | prepareLabelCache () const |
Prepares the cache for storing the result of labeling. More... | |
LabelRenderJob | prepareLabelingJob (QPainter *painter, QgsLabelingEngine *labelingEngine2, bool canUseLabelCache=true) |
Prepares a labeling job. More... | |
LayerRenderJobs | prepareSecondPassJobs (LayerRenderJobs &firstPassJobs, LabelRenderJob &labelJob) |
Prepares jobs for a second pass, if selective masks exist (from labels or symbol layers). More... | |
Static Protected Member Functions | |
static QImage | composeImage (const QgsMapSettings &settings, const LayerRenderJobs &jobs, const LabelRenderJob &labelJob) |
static void | composeSecondPass (LayerRenderJobs &secondPassJobs, LabelRenderJob &labelJob) |
Compose second pass images into first pass images. More... | |
static Q_DECL_DEPRECATED void | drawLabeling (const QgsMapSettings &settings, QgsRenderContext &renderContext, QgsLabelingEngine *labelingEngine2, QPainter *painter) |
static void | drawLabeling (QgsRenderContext &renderContext, QgsLabelingEngine *labelingEngine2, QPainter *painter) |
Protected Attributes | |
QgsMapRendererCache * | mCache = nullptr |
Errors | mErrors |
QHash< QgsWeakMapLayerPointer, int > | mPerLayerRenderingTime |
Render time (in ms) per layer, by layer ID. More... | |
bool | mRecordRenderingTime = true |
true if layer rendering time should be recorded. More... | |
QElapsedTimer | mRenderingStart |
int | mRenderingTime = 0 |
QgsMapSettings | mSettings |
Abstract base class for map rendering implementations.
The API is designed in a way that rendering is done asynchronously, therefore the caller is not blocked while the rendering is in progress. Non-blocking operation is quite important because the rendering can take considerable amount of time.
Common use case:
It is possible to cancel the rendering job while it is active by calling cancel() function.
The following subclasses are available:
Definition at line 186 of file qgsmaprendererjob.h.
typedef QList<QgsMapRendererJob::Error> QgsMapRendererJob::Errors |
Definition at line 261 of file qgsmaprendererjob.h.
QgsMapRendererJob::QgsMapRendererJob | ( | const QgsMapSettings & | settings | ) |
|
pure virtual |
Stop the rendering job - does not return until the job has terminated.
Does nothing if the rendering is not active.
Implemented in QgsMapRendererStagedRenderJob, QgsMapRendererSequentialJob, QgsMapRendererParallelJob, and QgsMapRendererCustomPainterJob.
|
pure virtual |
Triggers cancellation of the rendering job without blocking.
The render job will continue to operate until it is able to cancel, at which stage the finished() signal will be emitted. Does nothing if the rendering is not active.
Implemented in QgsMapRendererStagedRenderJob, QgsMapRendererSequentialJob, QgsMapRendererParallelJob, and QgsMapRendererCustomPainterJob.
|
protected |
|
protected |
Handles clean up tasks for a label job, including deletion of images and storing cached label results.
|
protected |
|
staticprotected |
|
staticprotected |
Compose second pass images into first pass images.
First pass jobs pointed to by the second pass jobs must still exist.
|
staticprotected |
|
staticprotected |
Errors QgsMapRendererJob::errors | ( | ) | const |
List of errors that happened during the rendering job - available when the rendering has been finished.
|
inline |
Returns the feature filter provider used by the QgsRenderContext of each LayerRenderJob.
Definition at line 248 of file qgsmaprendererjob.h.
|
signal |
emitted when asynchronous rendering is finished (or canceled).
|
pure virtual |
Tell whether the rendering job is currently running in background.
Implemented in QgsMapRendererStagedRenderJob, QgsMapRendererSequentialJob, QgsMapRendererParallelJob, and QgsMapRendererCustomPainterJob.
|
protected |
const QgsMapSettings& QgsMapRendererJob::mapSettings | ( | ) | const |
Returns map settings with which this job was started.
QHash< QgsMapLayer *, int > QgsMapRendererJob::perLayerRenderingTime | ( | ) | const |
Returns the render time (in ms) per layer.
|
protected |
Creates a list of layer rendering jobs and prepares them for later render.
The painter argument specifies the destination painter. If not set, the jobs will be rendered to temporary images. Alternatively, if the deferredPainterSet flag is true
, then a painter value of nullptr
skips this default temporary image creation. In this case, it is the caller's responsibility to correctly set a painter for all rendered jobs prior to rendering them.
|
protected |
Prepares the cache for storing the result of labeling.
Returns false
if the render cannot use cached labels and should not cache the result.
|
protected |
Prepares a labeling job.
|
protected |
Prepares jobs for a second pass, if selective masks exist (from labels or symbol layers).
Must be called after prepareJobs and prepareLabelingJob. It returns a list of new jobs for a second pass and also modifies labelJob and firstPassJobs if needed (image and mask image allocation if needed)
|
signal |
Emitted when the layers are rendered.
Rendering labels is not yet done. If the fully rendered layer including labels is required use finished() instead.
|
inline |
Returns the total time it took to finish the job (in milliseconds).
Definition at line 277 of file qgsmaprendererjob.h.
void QgsMapRendererJob::setCache | ( | QgsMapRendererCache * | cache | ) |
Assign a cache to be used for reading and storing rendered images of individual layers.
Does not take ownership of the object.
|
inline |
Set the feature filter provider used by the QgsRenderContext of each LayerRenderJob.
Ownership is not transferred and the provider must not be deleted before the render job.
Definition at line 241 of file qgsmaprendererjob.h.
|
pure virtual |
Start the rendering job and immediately return.
Does nothing if the rendering is already in progress.
Implemented in QgsMapRendererStagedRenderJob, QgsMapRendererSequentialJob, QgsMapRendererParallelJob, and QgsMapRendererCustomPainterJob.
|
pure virtual |
Gets pointer to internal labeling engine (in order to get access to the results).
This should not be used if cached labeling was redrawn - see usedCachedLabels().
Implemented in QgsMapRendererStagedRenderJob, QgsMapRendererSequentialJob, QgsMapRendererParallelJob, and QgsMapRendererCustomPainterJob.
|
pure virtual |
Returns true
if the render job was able to use a cached labeling solution.
If so, any previously stored labeling results (see takeLabelingResults()) should be retained.
Implemented in QgsMapRendererStagedRenderJob, QgsMapRendererSequentialJob, QgsMapRendererParallelJob, and QgsMapRendererCustomPainterJob.
|
pure virtual |
Block until the job has finished.
Implemented in QgsMapRendererStagedRenderJob, QgsMapRendererSequentialJob, QgsMapRendererParallelJob, and QgsMapRendererCustomPainterJob.
|
static |
QgsMapRendererCache ID string for cached label image.
Definition at line 297 of file qgsmaprendererjob.h.
|
protected |
Definition at line 319 of file qgsmaprendererjob.h.
|
protected |
Definition at line 317 of file qgsmaprendererjob.h.
|
protected |
Render time (in ms) per layer, by layer ID.
Definition at line 324 of file qgsmaprendererjob.h.
|
protected |
true
if layer rendering time should be recorded.
Definition at line 329 of file qgsmaprendererjob.h.
|
protected |
Definition at line 316 of file qgsmaprendererjob.h.
|
protected |
Definition at line 321 of file qgsmaprendererjob.h.
|
protected |
Definition at line 315 of file qgsmaprendererjob.h.