16#ifndef QGSMAPRENDERERJOB_H
17#define QGSMAPRENDERERJOB_H
21#include <QFutureWatcher>
26#include <QElapsedTimer>
57 LayerRenderJob() =
default;
59 LayerRenderJob(
const LayerRenderJob & ) =
delete;
60 LayerRenderJob &operator=(
const LayerRenderJob & ) =
delete;
62 LayerRenderJob( LayerRenderJob && );
63 LayerRenderJob &operator=( LayerRenderJob && );
71 void setContext( std::unique_ptr< QgsRenderContext > context ) { mContext = std::move( context ); }
85 QImage *img =
nullptr;
103 QImage *previewRenderImage =
nullptr;
106 bool imageInitialized =
false;
113 bool previewRenderImageInitialized =
false;
115 bool imageCanBeComposed()
const;
119 QPainter::CompositionMode blendMode = QPainter::CompositionMode_SourceOver;
121 double opacity = 1.0;
127 bool renderAboveLabels =
false;
137 bool completed =
false;
140 int renderingTime = -1;
151 int estimatedRenderingTime = 0;
181 std::unique_ptr<QPainter> maskPainter;
185 std::unique_ptr<QPaintDevice> maskPaintDevice;
191 bool maskRequiresLayerRasterization =
false;
197 LayerRenderJob *firstPassJob =
nullptr;
202 std::unique_ptr<QPicture> picture;
210 QList<QPair<LayerRenderJob *, int>> maskJobs;
213 std::unique_ptr< QgsRenderContext > mContext;
229 QImage *img =
nullptr;
232 std::unique_ptr<QPicture> picture;
235 std::vector< std::unique_ptr<QPainter> > maskPainters;
247 std::vector< std::unique_ptr<QPaintDevice> > maskPaintDevices;
258 bool canUseCache =
false;
260 bool complete =
false;
262 int renderingTime = -1;
264 QList< QPointer< QgsMapLayer > > participatingLayers;
380 Error(
const QString &lid,
const QString &msg )
389 typedef QList<QgsMapRendererJob::Error>
Errors;
431 int renderingTime()
const {
return mRenderingTime; }
451 void setLayerRenderingTimeHints( const QHash< QString,
int > &hints )
SIP_SKIP;
470 static const QString LABEL_PREVIEW_CACHE_ID
SIP_SKIP;
477 static const QString ELEVATION_MAP_CACHE_PREFIX
SIP_SKIP;
531 int mRenderingTime = 0;
551 bool mRecordRenderingTime =
true;
577 std::vector< LayerRenderJob > prepareJobs( QPainter *painter,
QgsLabelingEngine *labelingEngine2,
bool deferredPainterSet = false )
SIP_SKIP;
593 std::vector< LayerRenderJob > prepareSecondPassJobs( std::vector< LayerRenderJob > &firstPassJobs, LabelRenderJob &labelJob )
SIP_SKIP;
608 void initSecondPassJobs( std::vector< LayerRenderJob > &secondPassJobs, LabelRenderJob &labelJob ) const
SIP_SKIP;
612 const std::vector< LayerRenderJob > &jobs,
613 const LabelRenderJob &labelJob,
628 static
void composeSecondPass( std::vector< LayerRenderJob > &secondPassJobs, LabelRenderJob &labelJob,
bool forceVector = false )
SIP_SKIP;
631 void logRenderingTime( const std::vector< LayerRenderJob > &jobs, const std::vector< LayerRenderJob > &secondPassJobs, const LabelRenderJob &labelJob )
SIP_SKIP;
634 void cleanupJobs( std::vector< LayerRenderJob > &jobs )
SIP_SKIP;
637 void cleanupSecondPassJobs( std::vector< LayerRenderJob > &jobs )
SIP_SKIP;
644 void cleanupLabelJob( LabelRenderJob &job )
SIP_SKIP;
673 QImage *allocateImage( QString layerId );
679 QPainter *allocateImageAndPainter( QString layerId, QImage *&image, const
QgsRenderContext *context );
686 virtual
void startPrivate() = 0;
691 typedef std::pair<std::unique_ptr<QPicture>, QPainter * > PictureAndPainter;
694 PictureAndPainter allocatePictureAndPainter( const
QgsRenderContext *context );
Stores digital elevation model in a raster image which may get updated as a part of map layer renderi...
Abstract interface for use by classes that filter the features or attributes of a layer.
Abstract base class that can be used to intercept rendered labels from a labeling / rendering job.
QgsFeedback subclass for granular reporting of labeling engine progress.
The QgsLabelingEngine class provides map labeling functionality.
Class that stores computed placement from labeling engine.
Base class for utility classes that encapsulate information necessary for rendering of map layers.
Base class for all map layer types.
This class is responsible for keeping cache of rendered images resulting from a map rendering job.
Abstract base class for map rendering implementations.
virtual void waitForFinished()=0
Block until the job has finished.
void setCache(QgsMapRendererCache *cache)
Assign a cache to be used for reading and storing rendered images of individual layers.
QHash< QgsMapLayer *, int > perLayerRenderingTime() const
Returns the render time (in ms) per layer.
virtual bool usedCachedLabels() const =0
Returns true if the render job was able to use a cached labeling solution.
void setLabelSink(QgsLabelSink *sink)
Assigns the label sink which will take over responsibility for handling labels during the rendering j...
QHash< QString, int > mLayerRenderingTimeHints
Approximate expected layer rendering time per layer, by layer ID.
std::unique_ptr< QgsRenderedItemResults > mRenderedItemResults
Errors errors() const
List of errors that happened during the rendering job - available when the rendering has been finishe...
void layerRendered(const QString &layerId)
Emitted when a layer has completed rendering.
QList< QPointer< QgsMapLayer > > mAdditionalLabelLayers
Additional layers participating in labeling problem.
void renderingLayersFinished()
Emitted when the layers are rendered.
QElapsedTimer mRenderingStart
void finished()
emitted when asynchronous rendering is finished (or canceled).
const QgsFeatureFilterProvider * featureFilterProvider() const
Returns the feature filter provider used by the QgsRenderContext of each LayerRenderJob.
static const QgsSettingsEntryBool * settingsLogCanvasRefreshEvent
Settings entry log canvas refresh event.
QgsMapRendererJob(const QgsMapSettings &settings)
~QgsMapRendererJob() override
void start()
Start the rendering job and immediately return.
void layerRenderingStarted(const QString &layerId)
Emitted just before rendering starts for a particular layer.
QStringList mLayersRedrawnFromCache
QStringList layersRedrawnFromCache() const
Returns a list of the layer IDs for all layers which were redrawn from cached images.
QList< QgsMapRendererJob::Error > Errors
QHash< QgsWeakMapLayerPointer, int > mPerLayerRenderingTime
Render time (in ms) per layer, by layer ID.
QgsRenderedItemResults * takeRenderedItemResults()
Takes the rendered item results from the map render job and returns them.
virtual bool isActive() const =0
Tell whether the rendering job is currently running in background.
QgsLabelingEngineFeedback * labelingEngineFeedback()
Returns the associated labeling engine feedback object.
virtual QgsLabelingResults * takeLabelingResults()=0
Gets pointer to internal labeling engine (in order to get access to the results).
virtual void cancel()=0
Stop the rendering job - does not return until the job has terminated.
static const QgsSettingsEntryString * settingsMaskBackend
Settings entry for mask painting backend engine.
virtual void cancelWithoutBlocking()=0
Triggers cancellation of the rendering job without blocking.
QgsLabelSink * labelSink() const
Returns the label sink associated to this rendering job.
bool prepareLabelCache() const
Prepares the cache for storing the result of labeling.
Intermediate base class adding functionality that allows client to query the rendered image.
QgsMapRendererQImageJob(const QgsMapSettings &settings)
virtual QImage renderedImage()=0
Gets a preview/resulting image.
The QgsMapSettings class contains configuration for rendering of the map.
This class allows the creation of mask ids based on the different label layers and to give a mask id ...
A rectangle specified with double values.
Contains information about the context of a rendering operation.
Stores collated details of rendered items during a map rendering operation.
A boolean settings entry.
QPointer< QgsMapLayer > QgsWeakMapLayerPointer
Weak pointer for QgsMapLayer.
Error(const QString &lid, const QString &msg)