From c4599e9853e5aacc1214f8e071570fd38ffa9f37 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Wed, 2 Jul 2025 11:58:53 +1000 Subject: [PATCH] Add (hidden) setting to force raster clip masks for layout exports (cherry picked from commit 4936e775b794fcf7ac6ddcceac7e0efff71930ee) --- .../core/auto_generated/layout/qgslayoutitemmap.sip.in | 1 + python/core/auto_generated/layout/qgslayoutitemmap.sip.in | 1 + src/core/layout/qgslayoutitemmap.cpp | 7 +++++++ src/core/layout/qgslayoutitemmap.h | 7 +++++++ 4 files changed, 16 insertions(+) diff --git a/python/PyQt6/core/auto_generated/layout/qgslayoutitemmap.sip.in b/python/PyQt6/core/auto_generated/layout/qgslayoutitemmap.sip.in index 880a15027b9..66a7abfef09 100644 --- a/python/PyQt6/core/auto_generated/layout/qgslayoutitemmap.sip.in +++ b/python/PyQt6/core/auto_generated/layout/qgslayoutitemmap.sip.in @@ -314,6 +314,7 @@ Layout graphical items for displaying a map. %End public: + enum AtlasScalingMode /BaseType=IntEnum/ { Fixed, diff --git a/python/core/auto_generated/layout/qgslayoutitemmap.sip.in b/python/core/auto_generated/layout/qgslayoutitemmap.sip.in index f042e970d35..759356855f8 100644 --- a/python/core/auto_generated/layout/qgslayoutitemmap.sip.in +++ b/python/core/auto_generated/layout/qgslayoutitemmap.sip.in @@ -314,6 +314,7 @@ Layout graphical items for displaying a map. %End public: + enum AtlasScalingMode { Fixed, diff --git a/src/core/layout/qgslayoutitemmap.cpp b/src/core/layout/qgslayoutitemmap.cpp index 7d760d7f169..1766d0f8eec 100644 --- a/src/core/layout/qgslayoutitemmap.cpp +++ b/src/core/layout/qgslayoutitemmap.cpp @@ -40,6 +40,7 @@ #include "qgslabelingresults.h" #include "qgsvectortileutils.h" #include "qgsunittypes.h" +#include "qgssettingstree.h" #include #include @@ -47,6 +48,8 @@ #include #include +const QgsSettingsEntryBool *QgsLayoutItemMap::settingForceRasterMasks = new QgsSettingsEntryBool( QStringLiteral( "force-raster-masks" ), QgsSettingsTree::sTreeLayout, false, QStringLiteral( "Whether to force rasterised clipping masks, regardless of output format." ) ); + QgsLayoutItemMap::QgsLayoutItemMap( QgsLayout *layout ) : QgsLayoutItem( layout ) , mAtlasClippingSettings( new QgsLayoutItemMapAtlasClippingSettings( this ) ) @@ -1751,6 +1754,10 @@ QgsMapSettings QgsLayoutItemMap::mapSettings( const QgsRectangle &extent, QSizeF jobMapSettings.setSimplifyMethod( mLayout->renderContext().simplifyMethod() ); jobMapSettings.setMaskSettings( mLayout->renderContext().maskSettings() ); jobMapSettings.setRendererUsage( Qgis::RendererUsage::Export ); + if ( settingForceRasterMasks->value() ) + { + jobMapSettings.setFlag( Qgis::MapSettingsFlag::ForceRasterMasks, true ); + } } else { diff --git a/src/core/layout/qgslayoutitemmap.h b/src/core/layout/qgslayoutitemmap.h index 8da0c73f56a..3d0006d9a31 100644 --- a/src/core/layout/qgslayoutitemmap.h +++ b/src/core/layout/qgslayoutitemmap.h @@ -321,6 +321,13 @@ class CORE_EXPORT QgsLayoutItemMap : public QgsLayoutItem, public QgsTemporalRan public: + /** + * Settings entry - Whether to force rasterised clipping masks, regardless of output format. + * + * \since QGIS 4.0 + */ + static const QgsSettingsEntryBool *settingForceRasterMasks SIP_SKIP; + /** * Scaling modes used for the serial rendering (atlas) */