Navigation Menu

Skip to content

Commit

Permalink
Don't force a whole layout map to be rasterised just because one
Browse files Browse the repository at this point in the history
vector layer has non 100% opacity

Rather, only rasterise this one layer and leave all the rest as
vectors
  • Loading branch information
nyalldawson committed Oct 19, 2020
1 parent 572e017 commit 2d15a4c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 0 additions & 2 deletions src/core/layout/qgslayoutitemmap.cpp
Expand Up @@ -458,8 +458,6 @@ bool QgsLayoutItemMap::requiresRasterization() const
if ( !containsAdvancedEffects() )
return false;

// TODO layer transparency is probably ok to allow without forcing rasterization

if ( hasBackground() && qgsDoubleNear( backgroundColor().alphaF(), 1.0 ) )
return false;

Expand Down
7 changes: 1 addition & 6 deletions src/core/qgsmapsettingsutils.cpp
Expand Up @@ -52,13 +52,8 @@ QStringList QgsMapSettingsUtils::containsAdvancedEffects( const QgsMapSettings &
layers << layer->name();
}
// if vector layer, check labels and feature blend mode
QgsVectorLayer *currentVectorLayer = qobject_cast<QgsVectorLayer *>( layer );
if ( currentVectorLayer )
if ( QgsVectorLayer *currentVectorLayer = qobject_cast<QgsVectorLayer *>( layer ) )
{
if ( !qgsDoubleNear( currentVectorLayer->opacity(), 1.0 ) && !( flags & EffectsCheckFlag::IgnoreGeoPdfSupportedEffects ) )
{
layers << layer->name();
}
if ( currentVectorLayer->featureBlendMode() != QPainter::CompositionMode_SourceOver )
{
layers << layer->name();
Expand Down
4 changes: 3 additions & 1 deletion tests/src/core/testqgsmapsettingsutils.cpp
Expand Up @@ -93,8 +93,10 @@ void TestQgsMapSettingsUtils::containsAdvancedEffects()
QCOMPARE( QgsMapSettingsUtils::containsAdvancedEffects( mapSettings ).size(), 0 );
QCOMPARE( QgsMapSettingsUtils::containsAdvancedEffects( mapSettings, QgsMapSettingsUtils::EffectsCheckFlag::IgnoreGeoPdfSupportedEffects ).size(), 0 );

// changing an individual layer's opacity is OK -- we don't want to force the whole map to be rasterised just because of this setting!
// (just let that one layer get exported as raster instead)
layer->setOpacity( 0.5 );
QCOMPARE( QgsMapSettingsUtils::containsAdvancedEffects( mapSettings ).size(), 1 );
QCOMPARE( QgsMapSettingsUtils::containsAdvancedEffects( mapSettings ).size(), 0 );
QCOMPARE( QgsMapSettingsUtils::containsAdvancedEffects( mapSettings, QgsMapSettingsUtils::EffectsCheckFlag::IgnoreGeoPdfSupportedEffects ).size(), 0 );
}

Expand Down

0 comments on commit 2d15a4c

Please sign in to comment.