QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
|
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). | |
void | layerRendered (const QString &layerId) |
Emitted when a layer has completed rendering. | |
void | layerRenderingStarted (const QString &layerId) |
Emitted just before rendering starts for a particular layer. | |
void | renderingLayersFinished () |
Emitted when the layers are rendered. | |
Public Member Functions | |
QgsMapRendererJob (const QgsMapSettings &settings) | |
~QgsMapRendererJob () override | |
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. | |
Errors | errors () const |
List of errors that happened during the rendering job - available when the rendering has been finished. | |
const QgsFeatureFilterProvider * | featureFilterProvider () const |
Returns the feature filter provider used by the QgsRenderContext of each LayerRenderJob. | |
virtual bool | isActive () const =0 |
Tell whether the rendering job is currently running in background. | |
QgsLabelingEngineFeedback * | labelingEngineFeedback () |
Returns the associated labeling engine feedback object. | |
QgsLabelSink * | labelSink () const |
Returns the label sink associated to this rendering job. | |
QStringList | layersRedrawnFromCache () const |
Returns a list of the layer IDs for all layers which were redrawn from cached images. | |
const QgsMapSettings & | mapSettings () const |
Returns map settings with which this job was started. | |
QHash< QgsMapLayer *, int > | perLayerRenderingTime () const |
Returns the render time (in ms) per layer. | |
int | renderingTime () const |
Returns the total time it took to finish the job (in milliseconds). | |
void | setCache (QgsMapRendererCache *cache) |
Assign a cache to be used for reading and storing rendered images of individual layers. | |
void | setFeatureFilterProvider (const QgsFeatureFilterProvider *f) |
Set the feature filter provider used by the QgsRenderContext of each LayerRenderJob. | |
void | setLabelSink (QgsLabelSink *sink) |
Assigns the label sink which will take over responsibility for handling labels during the rendering job. | |
void | setLayerRenderingTimeHints (const QHash< QString, int > &hints) |
Sets approximate render times (in ms) for map layers. | |
void | start () |
Start the rendering job and immediately return. | |
virtual QgsLabelingResults * | takeLabelingResults ()=0 |
Gets pointer to internal labeling engine (in order to get access to the results). | |
QgsRenderedItemResults * | takeRenderedItemResults () |
Takes the rendered item results from the map render job and returns them. | |
virtual bool | usedCachedLabels () const =0 |
Returns true if the render job was able to use a cached labeling solution. | |
virtual void | waitForFinished ()=0 |
Block until the job has finished. | |
Static Public Attributes | |
static const QString | ELEVATION_MAP_CACHE_PREFIX |
QgsMapRendererCache prefix string for cached elevation map image. | |
static const QString | LABEL_CACHE_ID |
QgsMapRendererCache ID string for cached label image. | |
static const QString | LABEL_PREVIEW_CACHE_ID |
QgsMapRendererCache ID string for cached label image during preview compositions only. | |
static const QgsSettingsEntryBool * | settingsLogCanvasRefreshEvent = new QgsSettingsEntryBool( QStringLiteral( "logCanvasRefreshEvent" ), QgsSettingsTree::sTreeMap, false ) |
Settings entry log canvas refresh event. | |
static const QgsSettingsEntryString * | settingsMaskBackend = new QgsSettingsEntryString( QStringLiteral( "mask-backend" ), QgsSettingsTree::sTreeMap, QString(), QStringLiteral( "Backend engine to use for selective masking" ) ) |
Settings entry for mask painting backend engine. | |
Protected Member Functions | |
void | cleanupJobs (std::vector< LayerRenderJob > &jobs) |
void | cleanupLabelJob (LabelRenderJob &job) |
Handles clean up tasks for a label job, including deletion of images and storing cached label results. | |
void | cleanupSecondPassJobs (std::vector< LayerRenderJob > &jobs) |
void | initSecondPassJobs (std::vector< LayerRenderJob > &secondPassJobs, LabelRenderJob &labelJob) const |
Initialize secondPassJobs according to what have been rendered (mask clipping path e.g.) in first pass jobs and labelJob. | |
void | logRenderingTime (const std::vector< LayerRenderJob > &jobs, const std::vector< LayerRenderJob > &secondPassJobs, const LabelRenderJob &labelJob) |
QList< QPointer< QgsMapLayer > > | participatingLabelLayers (QgsLabelingEngine *engine) |
Returns a list of the layers participating in the map labeling. | |
std::vector< LayerRenderJob > | prepareJobs (QPainter *painter, QgsLabelingEngine *labelingEngine2, bool deferredPainterSet=false) |
Creates a list of layer rendering jobs and prepares them for later render. | |
bool | prepareLabelCache () const |
Prepares the cache for storing the result of labeling. | |
LabelRenderJob | prepareLabelingJob (QPainter *painter, QgsLabelingEngine *labelingEngine2, bool canUseLabelCache=true) |
Prepares a labeling job. | |
std::vector< LayerRenderJob > | prepareSecondPassJobs (std::vector< LayerRenderJob > &firstPassJobs, LabelRenderJob &labelJob) |
Prepares jobs for a second pass, if selective masks exist (from labels or symbol layers). | |
Static Protected Member Functions | |
static QImage | composeImage (const QgsMapSettings &settings, const std::vector< LayerRenderJob > &jobs, const LabelRenderJob &labelJob, const QgsMapRendererCache *cache=nullptr) |
static void | composeSecondPass (std::vector< LayerRenderJob > &secondPassJobs, LabelRenderJob &labelJob, bool forceVector=false) |
Compose second pass images into first pass images. | |
static Q_DECL_DEPRECATED void | drawLabeling (const QgsMapSettings &settings, QgsRenderContext &renderContext, QgsLabelingEngine *labelingEngine2, QPainter *painter) |
static void | drawLabeling (QgsRenderContext &renderContext, QgsLabelingEngine *labelingEngine2, QPainter *painter) |
static QgsElevationMap | layerElevationToBeComposed (const QgsMapSettings &settings, const LayerRenderJob &job, const QgsMapRendererCache *cache) |
static QImage | layerImageToBeComposed (const QgsMapSettings &settings, const LayerRenderJob &job, const QgsMapRendererCache *cache) |
Protected Attributes | |
QList< QPointer< QgsMapLayer > > | mAdditionalLabelLayers |
Additional layers participating in labeling problem. | |
QgsMapRendererCache * | mCache = nullptr |
Errors | mErrors |
QHash< QString, int > | mLayerRenderingTimeHints |
Approximate expected layer rendering time per layer, by layer ID. | |
QStringList | mLayersRedrawnFromCache |
QHash< QgsWeakMapLayerPointer, int > | mPerLayerRenderingTime |
Render time (in ms) per layer, by layer ID. | |
bool | mRecordRenderingTime = true |
true if layer rendering time should be recorded. | |
std::unique_ptr< QgsRenderedItemResults > | mRenderedItemResults |
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 296 of file qgsmaprendererjob.h.
typedef QList<QgsMapRendererJob::Error> QgsMapRendererJob::Errors |
Definition at line 389 of file qgsmaprendererjob.h.
QgsMapRendererJob::QgsMapRendererJob | ( | const QgsMapSettings & | settings | ) |
|
override |
|
pure virtual |
Stop the rendering job - does not return until the job has terminated.
Does nothing if the rendering is not active.
Implemented in QgsMapRendererCustomPainterJob, QgsMapRendererParallelJob, QgsMapRendererSequentialJob, and QgsMapRendererStagedRenderJob.
|
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 QgsMapRendererCustomPainterJob, QgsMapRendererParallelJob, QgsMapRendererSequentialJob, and QgsMapRendererStagedRenderJob.
|
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 376 of file qgsmaprendererjob.h.
|
signal |
emitted when asynchronous rendering is finished (or canceled).
|
protected |
Initialize secondPassJobs according to what have been rendered (mask clipping path e.g.) in first pass jobs and labelJob.
|
pure virtual |
Tell whether the rendering job is currently running in background.
Implemented in QgsMapRendererCustomPainterJob, QgsMapRendererParallelJob, QgsMapRendererSequentialJob, and QgsMapRendererStagedRenderJob.
QgsLabelingEngineFeedback * QgsMapRendererJob::labelingEngineFeedback | ( | ) |
Returns the associated labeling engine feedback object.
Callers can connect to the signals in this object to receive granular progress reports during the labeling steps.
|
inline |
Returns the label sink associated to this rendering job.
Definition at line 406 of file qgsmaprendererjob.h.
|
staticprotected |
|
staticprotected |
|
signal |
Emitted when a layer has completed rendering.
|
signal |
Emitted just before rendering starts for a particular layer.
QStringList QgsMapRendererJob::layersRedrawnFromCache | ( | ) | const |
Returns a list of the layer IDs for all layers which were redrawn from cached images.
This method should only be called after the render job is completed.
|
protected |
const QgsMapSettings & QgsMapRendererJob::mapSettings | ( | ) | const |
Returns map settings with which this job was started.
|
protected |
Returns a list of the layers participating in the map labeling.
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 431 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 370 of file qgsmaprendererjob.h.
|
inline |
Assigns the label sink which will take over responsibility for handling labels during the rendering job.
Definition at line 415 of file qgsmaprendererjob.h.
void QgsMapRendererJob::setLayerRenderingTimeHints | ( | const QHash< QString, int > & | hints | ) |
Sets approximate render times (in ms) for map layers.
This can be used to specifies hints at the expected render times for layers, so that the individual layer renderers can apply heuristics and determine appropriate update intervals during the render operation.
The keys for hints must be set to the corresponding layer IDs.
void QgsMapRendererJob::start | ( | ) |
Start the rendering job and immediately return.
Does nothing if the rendering is already in progress.
|
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 QgsMapRendererCustomPainterJob, QgsMapRendererParallelJob, QgsMapRendererSequentialJob, and QgsMapRendererStagedRenderJob.
QgsRenderedItemResults * QgsMapRendererJob::takeRenderedItemResults | ( | ) |
Takes the rendered item results from the map render job and returns them.
Ownership is transferred to the caller.
|
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 QgsMapRendererCustomPainterJob, QgsMapRendererParallelJob, QgsMapRendererSequentialJob, and QgsMapRendererStagedRenderJob.
|
pure virtual |
Block until the job has finished.
Implemented in QgsMapRendererCustomPainterJob, QgsMapRendererParallelJob, QgsMapRendererSequentialJob, and QgsMapRendererStagedRenderJob.
|
static |
QgsMapRendererCache prefix string for cached elevation map image.
Definition at line 477 of file qgsmaprendererjob.h.
|
static |
QgsMapRendererCache ID string for cached label image.
Definition at line 463 of file qgsmaprendererjob.h.
|
static |
QgsMapRendererCache ID string for cached label image during preview compositions only.
Definition at line 470 of file qgsmaprendererjob.h.
|
protected |
Additional layers participating in labeling problem.
Definition at line 546 of file qgsmaprendererjob.h.
|
protected |
Definition at line 529 of file qgsmaprendererjob.h.
|
protected |
Definition at line 527 of file qgsmaprendererjob.h.
|
protected |
Approximate expected layer rendering time per layer, by layer ID.
Definition at line 541 of file qgsmaprendererjob.h.
|
protected |
Definition at line 557 of file qgsmaprendererjob.h.
|
protected |
Render time (in ms) per layer, by layer ID.
Definition at line 534 of file qgsmaprendererjob.h.
|
protected |
true
if layer rendering time should be recorded.
Definition at line 551 of file qgsmaprendererjob.h.
|
protected |
Definition at line 554 of file qgsmaprendererjob.h.
|
protected |
Definition at line 526 of file qgsmaprendererjob.h.
|
protected |
Definition at line 531 of file qgsmaprendererjob.h.
|
protected |
Definition at line 525 of file qgsmaprendererjob.h.
|
static |
Settings entry log canvas refresh event.
Definition at line 481 of file qgsmaprendererjob.h.
|
static |
Settings entry for mask painting backend engine.
Definition at line 488 of file qgsmaprendererjob.h.