Skip to content

Commit bd46b78

Browse files
authored
Merge pull request #4140 from nyalldawson/label_order
Add non-stable API call to render a layer above the labels in the map canvas
2 parents e025b58 + e740890 commit bd46b78

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/core/qgsmaprendererjob.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,14 @@ QImage QgsMapRendererJob::composeImage( const QgsMapSettings& settings, const La
457457

458458
QPainter painter( &image );
459459

460+
460461
for ( LayerRenderJobs::const_iterator it = jobs.constBegin(); it != jobs.constEnd(); ++it )
461462
{
462463
const LayerRenderJob& job = *it;
463464

465+
if ( job.layer && job.layer->customProperty( QStringLiteral( "rendering/renderAboveLabels" ) ).toBool() )
466+
continue; // skip layer for now, it will be rendered after labels
467+
464468
painter.setCompositionMode( job.blendMode );
465469
painter.setOpacity( job.opacity );
466470

@@ -479,6 +483,22 @@ QImage QgsMapRendererJob::composeImage( const QgsMapSettings& settings, const La
479483
painter.drawImage( 0, 0, *labelJob.img );
480484
}
481485

486+
// render any layers with the renderAboveLabels flag now
487+
for ( LayerRenderJobs::const_iterator it = jobs.constBegin(); it != jobs.constEnd(); ++it )
488+
{
489+
const LayerRenderJob& job = *it;
490+
491+
if ( !job.layer || !job.layer->customProperty( QStringLiteral( "rendering/renderAboveLabels" ) ).toBool() )
492+
continue;
493+
494+
painter.setCompositionMode( job.blendMode );
495+
painter.setOpacity( job.opacity );
496+
497+
Q_ASSERT( job.img );
498+
499+
painter.drawImage( 0, 0, *job.img );
500+
}
501+
482502
painter.end();
483503
return image;
484504
}

0 commit comments

Comments
 (0)