40 void QgsMapRendererStagedRenderJob::startPrivate()
45 QgsDebugMsgLevel( QStringLiteral(
"Preparing list of layer jobs for rendering" ), 5 );
46 QElapsedTimer prepareTime;
49 mLabelingEngineV2.reset();
57 mLabelingEngineV2->setMapSettings(
mSettings );
60 mLayerJobs =
prepareJobs(
nullptr, mLabelingEngineV2.get(),
true );
63 mJobIt = mLayerJobs.begin();
90 if ( mLabelingEngineV2 )
91 return mLabelingEngineV2->takeResults();
103 if ( mJobIt != mLayerJobs.end() )
105 LayerRenderJob &job = *mJobIt;
106 job.renderer->renderContext()->setPainter( painter );
108 if ( job.context()->useAdvancedEffects() )
112 painter->setCompositionMode( job.blendMode );
118 job.imageInitialized =
true;
121 job.completed = job.renderer->render();
126 painter->setOpacity( job.opacity );
127 painter->drawImage( 0, 0, *job.img );
128 painter->setOpacity( 1.0 );
130 job.context()->setPainter(
nullptr );
134 if ( !mLabelingEngineV2 )
139 if ( !mPreparedStagedLabelJob || mLabelLayerIt == mLabelingLayers.end() )
142 mLabelJob.context.setPainter( painter );
145 painter->setCompositionMode( QPainter::CompositionMode_SourceOver );
150 mLabelJob.context.setPainter(
nullptr );
154 mLabelJob.context.setPainter( painter );
155 drawLabeling( mLabelJob.context, mLabelingEngineV2.get(), painter );
156 mLabelJob.complete =
true;
157 mLabelJob.participatingLayers = _qgis_listRawToQPointer( mLabelingEngineV2->participatingLayers() );
158 mLabelJob.context.setPainter(
nullptr );
169 if ( mJobIt != mLayerJobs.end() )
172 if ( mJobIt != mLayerJobs.end() )
176 if ( mLabelingEngineV2 )
180 if ( !mPreparedStagedLabelJob )
182 mLabelingEngineV2->run( mLabelJob.context );
183 mPreparedStagedLabelJob =
true;
184 mLabelingLayers = mLabelingEngineV2->participatingLayerIds();
185 mLabelLayerIt = mLabelingLayers.begin();
186 if ( mLabelLayerIt == mLabelingLayers.end() )
196 if ( mLabelLayerIt != mLabelingLayers.end() )
199 if ( mLabelLayerIt != mLabelingLayers.end() )
209 mExportedLabels =
true;
211 else if ( !mExportedLabels )
228 if ( mJobIt != mLayerJobs.end() )
230 const LayerRenderJob &job = *mJobIt;
235 if ( mLabelLayerIt != mLabelingLayers.end() )
236 return *mLabelLayerIt;
243 if ( mJobIt != mLayerJobs.end() )
245 const LayerRenderJob &job = *mJobIt;
253 if ( mJobIt != mLayerJobs.end() )
255 const LayerRenderJob &job = *mJobIt;
256 return job.blendMode;
258 return QPainter::CompositionMode_SourceOver;
263 if ( mJobIt != mLayerJobs.end() )
267 if ( !mPreparedStagedLabelJob )
269 if ( mLabelLayerIt != mLabelingLayers.end() )
272 else if ( mNextIsLabel && !mExportedLabels )
@ DrawLabeling
Enable drawing of labels on top of the map.
Default QgsLabelingEngine implementation, which completes the whole labeling operation (including lab...
Class that stores computed placement from labeling engine.
Abstract base class for map renderer jobs which use custom painters.
void preparePainter(QPainter *painter, const QColor &backgroundColor=Qt::transparent)
Prepares the given painter ready for a map render.
static Q_DECL_DEPRECATED void drawLabeling(const QgsMapSettings &settings, QgsRenderContext &renderContext, QgsLabelingEngine *labelingEngine2, QPainter *painter)
std::vector< LayerRenderJob > prepareJobs(QPainter *painter, QgsLabelingEngine *labelingEngine2, bool deferredPainterSet=false)
Creates a list of layer rendering jobs and prepares them for later render.
void cleanupJobs(std::vector< LayerRenderJob > &jobs)
QElapsedTimer mRenderingStart
LabelRenderJob prepareLabelingJob(QPainter *painter, QgsLabelingEngine *labelingEngine2, bool canUseLabelCache=true)
Prepares a labeling job.
void cleanupLabelJob(LabelRenderJob &job)
Handles clean up tasks for a label job, including deletion of images and storing cached label results...
double currentLayerOpacity() const
Returns the opacity for the current layer about to be rendered in the next render operation.
void cancel() override
Stop the rendering job - does not return until the job has terminated.
~QgsMapRendererStagedRenderJob() override
@ RenderLabelsByMapLayer
Labels should be rendered in individual stages by map layer. This allows separation of labels belongi...
bool usedCachedLabels() const override
Returns true if the render job was able to use a cached labeling solution.
RenderStage currentStage() const
Returns the current stage which will be rendered in the next render operation.
void waitForFinished() override
Block until the job has finished.
QPainter::CompositionMode currentLayerCompositionMode() const
Returns the composition mode for the current layer about to be rendered in the next render operation.
QString currentLayerId() const
Returns the ID of the current layer about to be rendered in the next render operation.
QgsLabelingResults * takeLabelingResults() override
Gets pointer to internal labeling engine (in order to get access to the results).
bool isActive() const override
Tell whether the rendering job is currently running in background.
QgsMapRendererStagedRenderJob(const QgsMapSettings &settings, Flags flags=Flags())
Constructor for QgsMapRendererStagedRenderJob, using the given map settings.
bool isFinished() const
Returns true if the job is finished, and nothing remains to render.
RenderStage
Represents the stages of a rendering job.
@ Finished
Rendering is finished.
@ Symbology
Rendering layer symbology.
@ Labels
Rendering labels.
bool nextPart()
Iterates to the next part to render.
bool renderCurrentPart(QPainter *painter)
Renders the current part of the map to the specified painter.
void cancelWithoutBlocking() override
Triggers cancellation of the rendering job without blocking.
The QgsMapSettings class contains configuration for rendering of the map.
bool testFlag(Qgis::MapSettingsFlag flag) const
Check whether a particular flag is enabled.
A QgsLabelingEngine implementation, which only calculates the labeling solution during its run() meth...
#define QgsDebugMsgLevel(str, level)