44 QgsDebugMsgLevel( QStringLiteral(
"Preparing list of layer jobs for rendering" ), 5 );
48 mLabelingEngineV2.reset();
56 mLabelingEngineV2->setMapSettings(
mSettings );
59 mLayerJobs =
prepareJobs(
nullptr, mLabelingEngineV2.get(), true );
62 mJobIt = mLayerJobs.begin();
89 if ( mLabelingEngineV2 )
90 return mLabelingEngineV2->takeResults();
102 if ( mJobIt != mLayerJobs.end() )
104 LayerRenderJob &job = *mJobIt;
105 job.renderer->renderContext()->setPainter( painter );
107 if ( job.context.useAdvancedEffects() )
111 painter->setCompositionMode( job.blendMode );
117 job.imageInitialized =
true;
120 job.renderer->render();
125 painter->setOpacity( job.opacity );
126 painter->drawImage( 0, 0, *job.img );
127 painter->setOpacity( 1.0 );
129 job.context.setPainter(
nullptr );
133 if ( !mLabelingEngineV2 )
138 if ( !mPreparedStagedLabelJob || mLabelLayerIt == mLabelingLayers.end() )
141 mLabelJob.context.setPainter( painter );
144 painter->setCompositionMode( QPainter::CompositionMode_SourceOver );
149 mLabelJob.context.setPainter(
nullptr );
153 mLabelJob.context.setPainter( painter );
154 drawLabeling( mLabelJob.context, mLabelingEngineV2.get(), painter );
155 mLabelJob.complete =
true;
156 mLabelJob.participatingLayers = _qgis_listRawToQPointer( mLabelingEngineV2->participatingLayers() );
157 mLabelJob.context.setPainter(
nullptr );
168 if ( mJobIt != mLayerJobs.end() )
171 if ( mJobIt != mLayerJobs.end() )
175 if ( mLabelingEngineV2 )
179 if ( !mPreparedStagedLabelJob )
181 mLabelingEngineV2->run( mLabelJob.context );
182 mPreparedStagedLabelJob =
true;
183 mLabelingLayers = mLabelingEngineV2->participatingLayerIds();
184 mLabelLayerIt = mLabelingLayers.begin();
185 if ( mLabelLayerIt == mLabelingLayers.end() )
195 if ( mLabelLayerIt != mLabelingLayers.end() )
198 if ( mLabelLayerIt != mLabelingLayers.end() )
208 mExportedLabels =
true;
210 else if ( !mExportedLabels )
227 if ( mJobIt != mLayerJobs.end() )
229 LayerRenderJob &job = *mJobIt;
234 if ( mLabelLayerIt != mLabelingLayers.end() )
235 return *mLabelLayerIt;
242 if ( mJobIt != mLayerJobs.end() )
246 if ( !mPreparedStagedLabelJob )
248 if ( mLabelLayerIt != mLabelingLayers.end() )
251 else if ( mNextIsLabel && !mExportedLabels )
QgsMapRendererStagedRenderJob(const QgsMapSettings &settings, Flags flags=nullptr)
Constructor for QgsMapRendererStagedRenderJob, using the given map settings.
QString currentLayerId()
Returns the ID of the current layer about to be rendered in the next render operation.
void cleanupJobs(LayerRenderJobs &jobs)
static Q_DECL_DEPRECATED void drawLabeling(const QgsMapSettings &settings, QgsRenderContext &renderContext, QgsLabelingEngine *labelingEngine2, QPainter *painter)
void preparePainter(QPainter *painter, const QColor &backgroundColor=Qt::transparent)
Prepares the given painter ready for a map render.
Default QgsLabelingEngine implementation, which completes the whole labeling operation (including lab...
Enable drawing of labels on top of the map.
void cancel() override
Stop the rendering job - does not return until the job has terminated.
The QgsMapSettings class contains configuration for rendering of the map.
LabelRenderJob prepareLabelingJob(QPainter *painter, QgsLabelingEngine *labelingEngine2, bool canUseLabelCache=true)
Prepares a labeling job.
~QgsMapRendererStagedRenderJob() override
LayerRenderJobs prepareJobs(QPainter *painter, QgsLabelingEngine *labelingEngine2, bool deferredPainterSet=false)
Creates a list of layer rendering jobs and prepares them for later render.
bool nextPart()
Iterates to the next part to render.
#define QgsDebugMsgLevel(str, level)
Abstract base class for map renderer jobs which use custom painters.
RenderStage
Represents the stages of a rendering job.
void cleanupLabelJob(LabelRenderJob &job)
Handles clean up tasks for a label job, including deletion of images and storing cached label results...
void start() override
Start the rendering job and immediately return.
QgsLabelingResults * takeLabelingResults() override
Gets pointer to internal labeling engine (in order to get access to the results). ...
bool renderCurrentPart(QPainter *painter)
Renders the current part of the map to the specified painter.
A QgsLabelingEngine implementation, which only calculates the labeling solution during its run() meth...
bool isFinished()
Returns true if the job is finished, and nothing remains to render.
Class that stores computed placement from labeling engine.
bool testFlag(Flag flag) const
Check whether a particular flag is enabled.
bool isActive() const override
Tell whether the rendering job is currently running in background.
Rendering layer symbology.
RenderStage currentStage() const
Returns the current stage which will be rendered in the next render operation.
bool usedCachedLabels() const override
Returns true if the render job was able to use a cached labeling solution.
void waitForFinished() override
Block until the job has finished.
void cancelWithoutBlocking() override
Triggers cancellation of the rendering job without blocking.
Labels should be rendered in individual stages by map layer. This allows separation of labels belongi...