Skip to content
Permalink
Browse files

Merge pull request #4140 from nyalldawson/label_order

Add non-stable API call to render a layer above the labels in the map canvas
  • Loading branch information
nyalldawson committed Feb 14, 2017
2 parents e025b58 + e740890 commit bd46b7809bdd3c7e1b0412b75724e2c5f39e0fcf
Showing with 20 additions and 0 deletions.
  1. +20 −0 src/core/qgsmaprendererjob.cpp
@@ -457,10 +457,14 @@ QImage QgsMapRendererJob::composeImage( const QgsMapSettings& settings, const La

QPainter painter( &image );


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

if ( job.layer && job.layer->customProperty( QStringLiteral( "rendering/renderAboveLabels" ) ).toBool() )
continue; // skip layer for now, it will be rendered after labels

painter.setCompositionMode( job.blendMode );
painter.setOpacity( job.opacity );

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

// render any layers with the renderAboveLabels flag now
for ( LayerRenderJobs::const_iterator it = jobs.constBegin(); it != jobs.constEnd(); ++it )
{
const LayerRenderJob& job = *it;

if ( !job.layer || !job.layer->customProperty( QStringLiteral( "rendering/renderAboveLabels" ) ).toBool() )
continue;

painter.setCompositionMode( job.blendMode );
painter.setOpacity( job.opacity );

Q_ASSERT( job.img );

painter.drawImage( 0, 0, *job.img );
}

painter.end();
return image;
}

0 comments on commit bd46b78

Please sign in to comment.
You can’t perform that action at this time.