16 #ifndef QGSMAPRENDERERJOB_H 
   17 #define QGSMAPRENDERERJOB_H 
   19 #include "qgis_core.h" 
   21 #include <QFutureWatcher> 
   26 #include <QElapsedTimer> 
   53     LayerRenderJob() = 
default;
 
   56     LayerRenderJob( 
const LayerRenderJob & ) = 
delete;
 
   59     LayerRenderJob &operator=( 
const LayerRenderJob & ) = 
delete;
 
   61     LayerRenderJob( LayerRenderJob && );
 
   62     LayerRenderJob &operator=( LayerRenderJob && );
 
   70     void setContext( std::unique_ptr< QgsRenderContext > context ) { mContext = std::move( context ); }
 
   84     QImage *img = 
nullptr;
 
   87     bool imageInitialized = 
false;
 
   89     bool imageCanBeComposed() 
const;
 
   93     QPainter::CompositionMode blendMode = QPainter::CompositionMode_SourceOver;
 
  108     bool completed = 
false;
 
  111     int renderingTime = -1;
 
  122     int estimatedRenderingTime = 0;
 
  152     QImage *maskImage = 
nullptr;
 
  158     LayerRenderJob *firstPassJob = 
nullptr;
 
  166     QList<QPair<LayerRenderJob *, int>> maskJobs;
 
  169     std::unique_ptr< QgsRenderContext > mContext;
 
  177 struct LabelRenderJob
 
  185   QImage *img = 
nullptr;
 
  197   QVector<QImage *> maskImages;
 
  208   bool canUseCache = 
false;
 
  210   bool complete = 
false;
 
  212   int renderingTime = -1;
 
  214   QList< QPointer< QgsMapLayer > > participatingLayers;
 
  334       Error( 
const QString &lid, 
const QString &msg )
 
  343     typedef QList<QgsMapRendererJob::Error> 
Errors;
 
  380     void setLayerRenderingTimeHints( const QHash< QString, 
int > &hints ) 
SIP_SKIP;
 
  400     static const QString LABEL_PREVIEW_CACHE_ID 
SIP_SKIP;
 
  429     int mRenderingTime = 0;
 
  444     bool mRecordRenderingTime = 
true;
 
  470     std::vector< LayerRenderJob > prepareJobs( QPainter *painter, 
QgsLabelingEngine *labelingEngine2, 
bool deferredPainterSet = false ) 
SIP_SKIP;
 
  487     std::vector< LayerRenderJob > prepareSecondPassJobs( std::vector< LayerRenderJob > &firstPassJobs, LabelRenderJob &labelJob ) 
SIP_SKIP;
 
  491                                 const std::vector< LayerRenderJob > &jobs,
 
  492                                 const LabelRenderJob &labelJob,
 
  504     static 
void composeSecondPass( std::vector< LayerRenderJob > &secondPassJobs, LabelRenderJob &labelJob ) 
SIP_SKIP;
 
  507     void logRenderingTime( const std::vector< LayerRenderJob > &jobs, const std::vector< LayerRenderJob > &secondPassJobs, const LabelRenderJob &labelJob ) 
SIP_SKIP;
 
  510     void cleanupJobs( std::vector< LayerRenderJob > &jobs ) 
SIP_SKIP;
 
  513     void cleanupSecondPassJobs( std::vector< LayerRenderJob > &jobs ) 
SIP_SKIP;
 
  521     void cleanupLabelJob( LabelRenderJob &job ) 
SIP_SKIP;
 
  550     QImage *allocateImage( QString layerId );
 
  553     QPainter *allocateImageAndPainter( QString layerId, QImage *&image );
 
  560     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.
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 renderingLayersFinished()
Emitted when the layers are rendered.
QElapsedTimer mRenderingStart
void finished()
emitted when asynchronous rendering is finished (or canceled).
QgsMapRendererJob(const QgsMapSettings &settings)
~QgsMapRendererJob() override
void start()
Start the rendering job and immediately return.
int renderingTime() const
Returns the total time it took to finish the job (in milliseconds).
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.
virtual bool isActive() const =0
Tell whether the rendering job is currently running in background.
virtual void cancel()=0
Stop the rendering job - does not return until the job has terminated.
QgsRenderedItemResults * takeRenderedItemResults()
Takes the rendered item results from the map render job and returns them.
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.
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)