Class: QgsMapRendererJob¶
- class qgis.core.QgsMapRendererJob¶
Bases:
PyQt5.QtCore.QObject
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:
Prepare
QgsMapSettings
with rendering configuration (extent, layer, map size, …)Create
QgsMapRendererJob
subclass withQgsMapSettings
instanceConnect to job’s
finished()
signalCall
start()
. Map rendering will start in background, the function immediately returnsAt some point, slot connected to
finished()
signal is called, map rendering is done
It is possible to cancel the rendering job while it is active by calling
cancel()
function.The following subclasses are available:
QgsMapRendererSequentialJob
- renders map in one background thread to an imageQgsMapRendererParallelJob
- renders map in multiple background threads to an imageQgsMapRendererCustomPainterJob
- renders map with given QPainter in one background thread
Methods
Stop the rendering job - does not return until the job has terminated.
Triggers cancellation of the rendering job without blocking.
List of errors that happened during the rendering job - available when the rendering has been finished
Returns the feature filter provider used by the
QgsRenderContext
of each LayerRenderJob.Tell whether the rendering job is currently running in background.
Returns a list of the layer IDs for all layers which were redrawn from cached images.
Returns map settings with which this job was started.
Returns the total time it took to finish the job (in milliseconds).
Assign a cache to be used for reading and storing rendered images of individual layers.
Set the feature filter provider used by the
QgsRenderContext
of each LayerRenderJob.Start the rendering job and immediately return.
Gets pointer to internal labeling engine (in order to get access to the results).
Takes the rendered item results from the map render job and returns them.
Returns
True
if the render job was able to use a cached labeling solution.Block until the job has finished.
Signals
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
- class Error(lid: str, msg: str)¶
- class Error(QgsMapRendererJob.Error)
Bases:
sip.wrapper
- layerID¶
- message¶
- cancel(self)¶
Stop the rendering job - does not return until the job has terminated. Does nothing if the rendering is not active.
- cancelWithoutBlocking(self)¶
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.
- errors(self) List[QgsMapRendererJob.Error] ¶
List of errors that happened during the rendering job - available when the rendering has been finished
- Return type:
List[QgsMapRendererJob.Error]
- featureFilterProvider(self) QgsFeatureFilterProvider ¶
Returns the feature filter provider used by the
QgsRenderContext
of each LayerRenderJob.- Return type:
- finished¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Parameters:
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type:
PYQT_SIGNAL
- isActive(self) bool ¶
Tell whether the rendering job is currently running in background.
- Return type:
bool
- layerRendered¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Parameters:
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type:
PYQT_SIGNAL
- layerRenderingStarted¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Parameters:
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type:
PYQT_SIGNAL
- layersRedrawnFromCache(self) List[str] ¶
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.
New in version 3.22.
- Return type:
List[str]
- mapSettings(self) QgsMapSettings ¶
Returns map settings with which this job was started.
- Return type:
- Returns:
A
QgsMapSettings
instance with render settings
- renderingLayersFinished¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Parameters:
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type:
PYQT_SIGNAL
- renderingTime(self) int ¶
Returns the total time it took to finish the job (in milliseconds).
See also
perLayerRenderingTime()
- Return type:
int
- setCache(self, cache: QgsMapRendererCache)¶
Assign a cache to be used for reading and storing rendered images of individual layers. Does not take ownership of the object.
- Parameters:
cache (QgsMapRendererCache) –
- setFeatureFilterProvider(self, f: QgsFeatureFilterProvider)¶
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.- Parameters:
f (QgsFeatureFilterProvider) –
- start(self)¶
Start the rendering job and immediately return. Does nothing if the rendering is already in progress.
- takeLabelingResults(self) QgsLabelingResults ¶
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()
.See also
- Return type:
- takeRenderedItemResults(self) QgsRenderedItemResults ¶
Takes the rendered item results from the map render job and returns them.
Ownership is transferred to the caller.
New in version 3.22.
- Return type:
- usedCachedLabels(self) bool ¶
Returns
True
if the render job was able to use a cached labeling solution. If so, any previously stored labeling results (seetakeLabelingResults()
) should be retained.See also
- Return type:
bool
- waitForFinished(self)¶
Block until the job has finished.