QGIS API Documentation
3.20.0-Odense (decaadbb31)
|
Base class for utility classes that encapsulate information necessary for rendering of map layers. More...
#include <qgsmaplayerrenderer.h>
Public Member Functions | |
QgsMapLayerRenderer (const QString &layerID, QgsRenderContext *context=nullptr) | |
Constructor for QgsMapLayerRenderer, with the associated layerID and render context. More... | |
virtual | ~QgsMapLayerRenderer ()=default |
QStringList | errors () const |
Returns list of errors (problems) that happened during the rendering. More... | |
virtual QgsFeedback * | feedback () const |
Access to feedback object of the layer renderer (may be nullptr ) More... | |
virtual bool | forceRasterRender () const |
Returns true if the renderer must be rendered to a raster paint device (e.g. More... | |
bool | isReadyToCompose () const |
Returns whether the renderer has already drawn (at least partially) some data. More... | |
QString | layerId () const |
Gets access to the ID of the layer rendered by this class. More... | |
virtual bool | render ()=0 |
Do the rendering (based on data stored in the class). More... | |
QgsRenderContext * | renderContext () |
Returns the render context associated with the renderer. More... | |
const QgsRenderContext * | renderContext () const |
Returns the render context associated with the renderer. More... | |
virtual void | setLayerRenderingTimeHint (int time) |
Sets approximate render time (in ms) for the layer to render. More... | |
Protected Attributes | |
QStringList | mErrors |
QString | mLayerID |
bool | mReadyToCompose = true |
The flag must be set to false in renderer's constructor if wants to use the smarter map redraws functionality https://github.com/qgis/QGIS-Enhancement-Proposals/issues/181. More... | |
Static Protected Attributes | |
static constexpr int | MAX_TIME_TO_USE_CACHED_PREVIEW_IMAGE = 3000 |
Maximum time (in ms) to allow display of a previously cached preview image while rendering layers, before switching to a progressive rendering display. More... | |
Base class for utility classes that encapsulate information necessary for rendering of map layers.
The rendering is typically done in a background thread, so it is necessary to keep all structures required for rendering away from the original map layer because it may change any time.
Because the data needs to be copied (to avoid the need for locking), it is highly desirable to use copy-on-write where possible. This way, the overhead of copying (both memory and CPU) will be kept low. Qt containers and various Qt classes use implicit sharing.
The scenario will be:
QgsMapLayer::createMapRenderer() and gets instance of this class. The instance is initialized at that point and should not need additional calls to QgsVectorLayer.
Definition at line 53 of file qgsmaplayerrenderer.h.
|
inline |
Constructor for QgsMapLayerRenderer, with the associated layerID and render context.
Definition at line 60 of file qgsmaplayerrenderer.h.
|
virtualdefault |
|
inline |
Returns list of errors (problems) that happened during the rendering.
Definition at line 100 of file qgsmaplayerrenderer.h.
|
inlinevirtual |
Access to feedback object of the layer renderer (may be nullptr
)
Reimplemented in QgsVectorTileLayerRenderer, QgsVectorLayerRenderer, QgsRasterLayerRenderer, QgsPointCloudLayerRenderer, QgsMeshLayerRenderer, and QgsAnnotationLayerRenderer.
Definition at line 97 of file qgsmaplayerrenderer.h.
|
inlinevirtual |
Returns true
if the renderer must be rendered to a raster paint device (e.g.
QImage).
Some layer settings require layers to be effectively "flattened" while rendering maps, which is achieved by first rendering the layer onto a raster paint device and then compositing the resultant image onto the final map render.
E.g. if a layer contains features with transparency or alternative blending modes, and the effects of these opacity or blending modes should be restricted to only affect other features within the SAME layer, then a flattened raster based render is required.
Subclasses should return true
whenever their corresponding layer settings require the layer to always be rendered using a raster paint device.
Reimplemented in QgsVectorTileLayerRenderer, QgsVectorLayerRenderer, QgsRasterLayerRenderer, QgsPointCloudLayerRenderer, QgsMeshLayerRenderer, and QgsAnnotationLayerRenderer.
Definition at line 91 of file qgsmaplayerrenderer.h.
|
inline |
Returns whether the renderer has already drawn (at least partially) some data.
Definition at line 126 of file qgsmaplayerrenderer.h.
|
inline |
Gets access to the ID of the layer rendered by this class.
Definition at line 103 of file qgsmaplayerrenderer.h.
|
pure virtual |
Do the rendering (based on data stored in the class).
Returns true
if the layer was completely rendered successfully (i.e. the render was not canceled early).
Implemented in QgsVectorTileLayerRenderer, QgsVectorLayerRenderer, QgsRasterLayerRenderer, QgsPointCloudLayerRenderer, QgsMeshLayerRenderer, and QgsAnnotationLayerRenderer.
|
inline |
Returns the render context associated with the renderer.
Definition at line 110 of file qgsmaplayerrenderer.h.
|
inline |
Returns the render context associated with the renderer.
Definition at line 118 of file qgsmaplayerrenderer.h.
|
inlinevirtual |
Sets approximate render time (in ms) for the layer to render.
This can be used to specifies a hint at the expected render times for the layer, so that the individual layer renderer subclasses can apply heuristics and determine appropriate update intervals during the render operation.
Reimplemented in QgsVectorLayerRenderer, and QgsPointCloudLayerRenderer.
Definition at line 138 of file qgsmaplayerrenderer.h.
|
staticconstexprprotected |
Maximum time (in ms) to allow display of a previously cached preview image while rendering layers, before switching to a progressive rendering display.
Definition at line 170 of file qgsmaplayerrenderer.h.
|
protected |
Definition at line 141 of file qgsmaplayerrenderer.h.
|
protected |
Definition at line 142 of file qgsmaplayerrenderer.h.
|
protected |
The flag must be set to false in renderer's constructor if wants to use the smarter map redraws functionality https://github.com/qgis/QGIS-Enhancement-Proposals/issues/181.
The flag must be set to true by renderer when the data is fetched and the renderer actually started to update the destination image.
When the flag is set to false, the image from QgsMapRendererCache is used instead to avoid flickering.
Definition at line 160 of file qgsmaplayerrenderer.h.