16 #ifndef QGSMAPRENDERERJOB_H
17 #define QGSMAPRENDERERJOB_H
19 #include "qgis_core.h"
21 #include <QFutureWatcher>
26 #include <QElapsedTimer>
32 #include "qgssettingsentry.h"
59 bool imageInitialized =
false;
61 bool imageCanBeComposed()
const;
65 QPainter::CompositionMode blendMode;
77 bool completed =
false;
90 int estimatedRenderingTime = 0;
120 QImage *maskImage =
nullptr;
126 LayerRenderJob *firstPassJob =
nullptr;
134 QList<QPair<LayerRenderJob *, int>> maskJobs;
137 typedef QList<LayerRenderJob> LayerRenderJobs;
143 struct LabelRenderJob
151 QImage *img =
nullptr;
163 QVector<QImage *> maskImages;
174 bool canUseCache =
false;
176 bool complete =
false;
178 int renderingTime = -1;
180 QList< QPointer< QgsMapLayer > > participatingLayers;
279 Error(
const QString &lid,
const QString &msg )
288 typedef QList<QgsMapRendererJob::Error>
Errors;
325 void setLayerRenderingTimeHints( const QHash< QString,
int > &hints )
SIP_SKIP;
345 static const QString LABEL_PREVIEW_CACHE_ID
SIP_SKIP;
349 static const inline QgsSettingsEntryBool settingsLogCanvasRefreshEvent = QgsSettingsEntryBool( QStringLiteral(
"Map/logCanvasRefreshEvent" ), QgsSettings::NoSection,
false );
374 int mRenderingTime = 0;
389 bool mRecordRenderingTime =
true;
426 LayerRenderJobs prepareSecondPassJobs( LayerRenderJobs &firstPassJobs, LabelRenderJob &labelJob )
SIP_SKIP;
430 const LayerRenderJobs &jobs,
431 const LabelRenderJob &labelJob,
443 static
void composeSecondPass( LayerRenderJobs &secondPassJobs, LabelRenderJob &labelJob )
SIP_SKIP;
446 void logRenderingTime( const LayerRenderJobs &jobs, const LayerRenderJobs &secondPassJobs, const LabelRenderJob &labelJob )
SIP_SKIP;
449 void cleanupJobs( LayerRenderJobs &jobs )
SIP_SKIP;
452 void cleanupSecondPassJobs( LayerRenderJobs &jobs )
SIP_SKIP;
460 void cleanupLabelJob( LabelRenderJob &job )
SIP_SKIP;
489 QImage *allocateImage( QString layerId );
492 QPainter *allocateImageAndPainter( QString layerId, QImage *&image );
499 virtual
void startPrivate() = 0;
Abstract interface for use by classes that filter the features or attributes of a layer.
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.
virtual QgsLabelingResults * takeLabelingResults()=0
Gets pointer to internal labeling engine (in order to get access to the results).
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.
QHash< QString, int > mLayerRenderingTimeHints
Approximate expected layer rendering time per layer, by layer ID.
const QgsFeatureFilterProvider * featureFilterProvider() const
Returns the feature filter provider used by the QgsRenderContext of each LayerRenderJob.
Errors errors() const
List of errors that happened during the rendering job - available when the rendering has been finishe...
void renderingLayersFinished()
Emitted when the layers are rendered.
QElapsedTimer mRenderingStart
void finished()
emitted when asynchronous rendering is finished (or canceled).
QgsMapRendererJob(const QgsMapSettings &settings)
void start()
Start the rendering job and immediately return.
int renderingTime() const
Returns the total time it took to finish the job (in milliseconds).
QList< QgsMapRendererJob::Error > Errors
QHash< QgsWeakMapLayerPointer, int > mPerLayerRenderingTime
Render time (in ms) per layer, by layer ID.
virtual bool isActive() const =0
Tell whether the rendering job is currently running in background.
void setFeatureFilterProvider(const QgsFeatureFilterProvider *f)
Set the feature filter provider used by the QgsRenderContext of each LayerRenderJob.
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.
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.
QPointer< QgsMapLayer > QgsWeakMapLayerPointer
Weak pointer for QgsMapLayer.
Error(const QString &lid, const QString &msg)