mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-08 00:05:09 -04:00
progress preview render results while drawing the layer, which differ from the final layer render The immediate use case here is for rendering tiled scene layers. In order to generate the actual final render for these layers, we need to first fetch ALL content for the render and then sort the primitives by z value. But this means that the layer renders can be extremely slow, with no visible changes on the map until all the content fetching is complete. Not great user experience! Instead, here we add the infrastructure so that a layer renderer can get a temporary image to paint to for any partial renders. This image gets used during map composition up until the layer finally finishes rendering, at which time the layer's actual destination image will be used for the composition. This means that tiled scene renderers can now draw all tiles (with unsorted primitives, and the artifacts which come with that) as soon as we fetch each tile. This gives the user an immediate visual reflection that the tiles are being fetched and that how quickly (or slowly) that is happening. As soon as we've got all tiles, the layer render will be immediately switched to the version in which all content is rendered in the correct z order. As a bonus, we draw these temporary in progress renders over any previously transformed cache version of the layer available. So eg when you zoom in, you'll get a zoomed in pixelated version of the last render which gets progressively drawn over with each tile as it is fetched. This same API could be used in future eg with point cloud rendering when points are being sorted by z value to give timely visual feedback.
155 lines
4.9 KiB
Plaintext
155 lines
4.9 KiB
Plaintext
/************************************************************************
|
|
* This file has been generated automatically from *
|
|
* *
|
|
* src/core/qgsmaplayerrenderer.h *
|
|
* *
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
class QgsMapLayerRenderer
|
|
{
|
|
%Docstring(signature="appended")
|
|
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:
|
|
|
|
1. renderer job (doing preparation in the GUI thread) calls :py:func:`QgsMapLayer.createMapRenderer()` and gets instance of this class. The instance is initialized at that point and should not need additional calls to :py:class:`QgsVectorLayer`.
|
|
2. renderer job (still in GUI thread) stores the renderer for later use.
|
|
3. renderer job (in worker thread) calls :py:func:`QgsMapLayerRenderer.render()`
|
|
4. renderer job (again in GUI thread) will check :py:func:`~errors` and report them
|
|
|
|
.. versionadded:: 2.4
|
|
%End
|
|
|
|
%TypeHeaderCode
|
|
#include "qgsmaplayerrenderer.h"
|
|
%End
|
|
public:
|
|
|
|
QgsMapLayerRenderer( const QString &layerID, QgsRenderContext *context = 0 );
|
|
%Docstring
|
|
Constructor for QgsMapLayerRenderer, with the associated ``layerID`` and render ``context``.
|
|
%End
|
|
|
|
virtual ~QgsMapLayerRenderer();
|
|
|
|
virtual bool render() = 0;
|
|
%Docstring
|
|
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).
|
|
%End
|
|
|
|
virtual bool forceRasterRender() const;
|
|
%Docstring
|
|
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.
|
|
|
|
.. versionadded:: 3.18
|
|
%End
|
|
|
|
virtual Qgis::MapLayerRendererFlags flags() const;
|
|
%Docstring
|
|
Returns flags which control how the map layer rendering behaves.
|
|
|
|
.. versionadded:: 3.34
|
|
%End
|
|
|
|
virtual QgsFeedback *feedback() const;
|
|
%Docstring
|
|
Access to feedback object of the layer renderer (may be ``None``)
|
|
|
|
.. versionadded:: 3.0
|
|
%End
|
|
|
|
QStringList errors() const;
|
|
%Docstring
|
|
Returns list of errors (problems) that happened during the rendering
|
|
%End
|
|
|
|
QString layerId() const;
|
|
%Docstring
|
|
Gets access to the ID of the layer rendered by this class
|
|
%End
|
|
|
|
QgsRenderContext *renderContext();
|
|
%Docstring
|
|
Returns the render context associated with the renderer.
|
|
|
|
.. versionadded:: 3.10
|
|
%End
|
|
|
|
|
|
bool isReadyToCompose() const;
|
|
%Docstring
|
|
Returns whether the renderer has already drawn (at
|
|
least partially) some data
|
|
|
|
.. versionadded:: 3.18
|
|
%End
|
|
|
|
|
|
QList< QgsRenderedItemDetails * > takeRenderedItemDetails() /TransferBack/;
|
|
%Docstring
|
|
Takes the list of rendered item details from the renderer.
|
|
|
|
Ownership of items is transferred to the caller.
|
|
|
|
.. seealso:: :py:func:`appendRenderedItemDetails`
|
|
|
|
.. versionadded:: 3.22
|
|
%End
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
void appendRenderedItemDetails( QgsRenderedItemDetails *details /Transfer/ );
|
|
%Docstring
|
|
Appends the ``details`` of a rendered item to the renderer.
|
|
|
|
Rendered item details can be retrieved by calling :py:func:`~QgsMapLayerRenderer.takeRenderedItemDetails`.
|
|
|
|
Ownership of ``details`` is transferred to the renderer.
|
|
|
|
.. seealso:: :py:func:`takeRenderedItemDetails`
|
|
|
|
.. versionadded:: 3.22
|
|
%End
|
|
|
|
};
|
|
|
|
/************************************************************************
|
|
* This file has been generated automatically from *
|
|
* *
|
|
* src/core/qgsmaplayerrenderer.h *
|
|
* *
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
************************************************************************/
|