Skip to content

Commit

Permalink
Merge pull request #4140 from nyalldawson/label_order
Browse files Browse the repository at this point in the history
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 bd46b78
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/core/qgsmaprendererjob.cpp
Expand Up @@ -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 );

Expand All @@ -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;
}
Expand Down

0 comments on commit bd46b78

Please sign in to comment.