Skip to content

Commit 60b8d05

Browse files
committedJan 29, 2019
[needs-docs][layouts] Add checkbox to disable raster tiling for PDF/SVG exports
This setting, which is disabled by default and placed into an "advanced" group on PDF/SFG export, disables the built-in raster layer tiled rendering. While the tiling is good for memory usage, it can cause visible "seams" in the rasters for generated PDF/SVG files. The setting has a tooltip warning users that disabling the tiling results in high memory usage during exports. Fixes #19500
1 parent 2752f83 commit 60b8d05

File tree

6 files changed

+81
-15
lines changed

6 files changed

+81
-15
lines changed
 

‎python/core/auto_generated/layout/qgslayoutrendercontext.sip.in

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Stores information relating to the current rendering settings for a layout.
3030
FlagForceVectorOutput,
3131
FlagHideCoverageLayer,
3232
FlagDrawSelection,
33+
FlagDisableTiledRasterLayerRenders,
3334
};
3435
typedef QFlags<QgsLayoutRenderContext::Flag> Flags;
3536

‎src/app/layout/qgslayoutdesignerdialog.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -4034,6 +4034,7 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
40344034
double bottomMargin = 0.0;
40354035
double leftMargin = 0.0;
40364036
bool includeMetadata = true;
4037+
bool disableRasterTiles = false;
40374038
if ( mLayout )
40384039
{
40394040
forceVector = mLayout->customProperty( QStringLiteral( "forceVector" ), false ).toBool();
@@ -4044,6 +4045,7 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
40444045
bottomMargin = mLayout->customProperty( QStringLiteral( "svgCropMarginBottom" ), 0 ).toInt();
40454046
leftMargin = mLayout->customProperty( QStringLiteral( "svgCropMarginLeft" ), 0 ).toInt();
40464047
includeMetadata = mLayout->customProperty( QStringLiteral( "svgIncludeMetadata" ), 1 ).toBool();
4048+
disableRasterTiles = mLayout->customProperty( QStringLiteral( "svgDisableRasterTiles" ), 0 ).toBool();
40474049
const int prevLayoutSettingLabelsAsOutlines = mLayout->customProperty( QStringLiteral( "svgTextFormat" ), -1 ).toInt();
40484050
if ( prevLayoutSettingLabelsAsOutlines >= 0 )
40494051
{
@@ -4069,6 +4071,7 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
40694071
options.mBottomMarginSpinBox->setValue( bottomMargin );
40704072
options.mLeftMarginSpinBox->setValue( leftMargin );
40714073
options.mIncludeMetadataCheckbox->setChecked( includeMetadata );
4074+
options.mDisableRasterTilingCheckBox->setChecked( disableRasterTiles );
40724075

40734076
if ( dialog.exec() != QDialog::Accepted )
40744077
return false;
@@ -4081,6 +4084,7 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
40814084
marginLeft = options.mLeftMarginSpinBox->value();
40824085
includeMetadata = options.mIncludeMetadataCheckbox->isChecked();
40834086
forceVector = options.mForceVectorCheckBox->isChecked();
4087+
disableRasterTiles = options.mDisableRasterTilingCheckBox->isChecked();
40844088
QgsRenderContext::TextRenderFormat textRenderFormat = static_cast< QgsRenderContext::TextRenderFormat >( options.mTextRenderFormatComboBox->currentData().toInt() );
40854089

40864090
if ( mLayout )
@@ -4095,6 +4099,7 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
40954099
mLayout->setCustomProperty( QStringLiteral( "svgIncludeMetadata" ), includeMetadata ? 1 : 0 );
40964100
mLayout->setCustomProperty( QStringLiteral( "forceVector" ), forceVector ? 1 : 0 );
40974101
mLayout->setCustomProperty( QStringLiteral( "svgTextFormat" ), static_cast< int >( textRenderFormat ) );
4102+
mLayout->setCustomProperty( QStringLiteral( "svgDisableRasterTiles" ), disableRasterTiles ? 1 : 0 );
40984103
}
40994104

41004105
settings.cropToContents = clipToContent;
@@ -4104,6 +4109,11 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
41044109
settings.exportMetadata = includeMetadata;
41054110
settings.textRenderFormat = textRenderFormat;
41064111

4112+
if ( disableRasterTiles )
4113+
settings.flags = settings.flags | QgsLayoutRenderContext::FlagDisableTiledRasterLayerRenders;
4114+
else
4115+
settings.flags = settings.flags & ~QgsLayoutRenderContext::FlagDisableTiledRasterLayerRenders;
4116+
41074117
return true;
41084118
}
41094119

@@ -4112,10 +4122,12 @@ bool QgsLayoutDesignerDialog::getPdfExportSettings( QgsLayoutExporter::PdfExport
41124122
QgsRenderContext::TextRenderFormat prevTextRenderFormat = mMasterLayout->layoutProject()->labelingEngineSettings().defaultTextRenderFormat();
41134123
bool forceVector = false;
41144124
bool includeMetadata = true;
4125+
bool disableRasterTiles = false;
41154126
if ( mLayout )
41164127
{
41174128
forceVector = mLayout->customProperty( QStringLiteral( "forceVector" ), 0 ).toBool();
41184129
includeMetadata = mLayout->customProperty( QStringLiteral( "pdfIncludeMetadata" ), 1 ).toBool();
4130+
disableRasterTiles = mLayout->customProperty( QStringLiteral( "pdfDisableRasterTiles" ), 0 ).toBool();
41194131
const int prevLayoutSettingLabelsAsOutlines = mLayout->customProperty( QStringLiteral( "pdfTextFormat" ), -1 ).toInt();
41204132
if ( prevLayoutSettingLabelsAsOutlines >= 0 )
41214133
{
@@ -4135,25 +4147,32 @@ bool QgsLayoutDesignerDialog::getPdfExportSettings( QgsLayoutExporter::PdfExport
41354147
options.mTextRenderFormatComboBox->setCurrentIndex( options.mTextRenderFormatComboBox->findData( prevTextRenderFormat ) );
41364148
options.mForceVectorCheckBox->setChecked( forceVector );
41374149
options.mIncludeMetadataCheckbox->setChecked( includeMetadata );
4150+
options.mDisableRasterTilingCheckBox->setChecked( disableRasterTiles );
41384151

41394152
if ( dialog.exec() != QDialog::Accepted )
41404153
return false;
41414154

41424155
includeMetadata = options.mIncludeMetadataCheckbox->isChecked();
41434156
forceVector = options.mForceVectorCheckBox->isChecked();
4157+
disableRasterTiles = options.mDisableRasterTilingCheckBox->isChecked();
41444158
QgsRenderContext::TextRenderFormat textRenderFormat = static_cast< QgsRenderContext::TextRenderFormat >( options.mTextRenderFormatComboBox->currentData().toInt() );
41454159

41464160
if ( mLayout )
41474161
{
41484162
//save dialog settings
41494163
mLayout->setCustomProperty( QStringLiteral( "forceVector" ), forceVector ? 1 : 0 );
41504164
mLayout->setCustomProperty( QStringLiteral( "pdfIncludeMetadata" ), includeMetadata ? 1 : 0 );
4165+
mLayout->setCustomProperty( QStringLiteral( "pdfDisableRasterTiles" ), disableRasterTiles ? 1 : 0 );
41514166
mLayout->setCustomProperty( QStringLiteral( "pdfTextFormat" ), static_cast< int >( textRenderFormat ) );
41524167
}
41534168

41544169
settings.forceVectorOutput = forceVector;
41554170
settings.exportMetadata = includeMetadata;
41564171
settings.textRenderFormat = textRenderFormat;
4172+
if ( disableRasterTiles )
4173+
settings.flags = settings.flags | QgsLayoutRenderContext::FlagDisableTiledRasterLayerRenders;
4174+
else
4175+
settings.flags = settings.flags & ~QgsLayoutRenderContext::FlagDisableTiledRasterLayerRenders;
41574176

41584177
return true;
41594178
}

‎src/core/layout/qgslayoutitemmap.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,7 @@ QgsMapSettings QgsLayoutItemMap::mapSettings( const QgsRectangle &extent, QSizeF
11821182
jobMapSettings.setFlag( QgsMapSettings::DrawEditingInfo, false );
11831183
jobMapSettings.setSelectionColor( mLayout->renderContext().selectionColor() );
11841184
jobMapSettings.setFlag( QgsMapSettings::DrawSelection, mLayout->renderContext().flags() & QgsLayoutRenderContext::FlagDrawSelection );
1185+
jobMapSettings.setFlag( QgsMapSettings::RenderPartialOutput, mLayout->renderContext().flags() & QgsLayoutRenderContext::FlagDisableTiledRasterLayerRenders );
11851186
jobMapSettings.setFlag( QgsMapSettings::UseAdvancedEffects, mLayout->renderContext().flags() & QgsLayoutRenderContext::FlagUseAdvancedEffects );
11861187
jobMapSettings.setTransformContext( mLayout->project()->transformContext() );
11871188
jobMapSettings.setPathResolver( mLayout->project()->pathResolver() );

‎src/core/layout/qgslayoutrendercontext.h

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class CORE_EXPORT QgsLayoutRenderContext : public QObject
4646
FlagForceVectorOutput = 1 << 5, //!< Force output in vector format where possible, even if items require rasterization to keep their correct appearance.
4747
FlagHideCoverageLayer = 1 << 6, //!< Hide coverage layer in outputs
4848
FlagDrawSelection = 1 << 7, //!< Draw selection
49+
FlagDisableTiledRasterLayerRenders = 1 << 8, //!< If set, then raster layers will not be drawn as separate tiles. This may improve the appearance in exported files, at the cost of much higher memory usage during exports.
4950
};
5051
Q_DECLARE_FLAGS( Flags, Flag )
5152

‎src/ui/layout/qgspdfexportoptions.ui

+36-14
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>489</width>
10-
<height>197</height>
10+
<height>276</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -20,33 +20,55 @@
2020
<string>Export Options</string>
2121
</property>
2222
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1">
23-
<item row="1" column="0" colspan="2">
24-
<widget class="QCheckBox" name="mIncludeMetadataCheckbox">
25-
<property name="text">
26-
<string>Export RDF metadata</string>
23+
<item row="3" column="1">
24+
<widget class="QComboBox" name="mTextRenderFormatComboBox"/>
25+
</item>
26+
<item row="0" column="0" colspan="2">
27+
<widget class="QCheckBox" name="mForceVectorCheckBox">
28+
<property name="toolTip">
29+
<string>If checked, the layout will always be kept as vector objects when exported to a compatible format, even if the appearance of the resultant file does not match the layouts settings. If unchecked, some elements in the layout may be rasterized in order to keep their appearance intact.</string>
2730
</property>
28-
<property name="checked">
29-
<bool>true</bool>
31+
<property name="text">
32+
<string>Always export as vectors</string>
3033
</property>
3134
</widget>
3235
</item>
33-
<item row="2" column="1">
34-
<widget class="QComboBox" name="mTextRenderFormatComboBox"/>
35-
</item>
36-
<item row="2" column="0">
36+
<item row="3" column="0">
3737
<widget class="QLabel" name="label_6">
3838
<property name="text">
3939
<string>Text export</string>
4040
</property>
4141
</widget>
4242
</item>
43+
<item row="1" column="0" colspan="2">
44+
<widget class="QCheckBox" name="mIncludeMetadataCheckbox">
45+
<property name="text">
46+
<string>Export RDF metadata</string>
47+
</property>
48+
<property name="checked">
49+
<bool>true</bool>
50+
</property>
51+
</widget>
52+
</item>
53+
</layout>
54+
</widget>
55+
</item>
56+
<item>
57+
<widget class="QgsCollapsibleGroupBoxBasic" name="groupBox_2">
58+
<property name="title">
59+
<string>Advanced Options</string>
60+
</property>
61+
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0">
4362
<item row="0" column="0" colspan="2">
44-
<widget class="QCheckBox" name="mForceVectorCheckBox">
63+
<widget class="QCheckBox" name="mDisableRasterTilingCheckBox">
4564
<property name="toolTip">
46-
<string>If checked, the layout will always be kept as vector objects when exported to a compatible format, even if the appearance of the resultant file does not match the layouts settings. If unchecked, some elements in the layout may be rasterized in order to keep their appearance intact.</string>
65+
<string>Disables tiled rendering of raster layers. This setting may improve the export quality in some circumstances, at the cost of much greater memory usage during exports.</string>
4766
</property>
4867
<property name="text">
49-
<string>Always export as vectors</string>
68+
<string>Disable tiled raster layer exports</string>
69+
</property>
70+
<property name="checked">
71+
<bool>false</bool>
5072
</property>
5173
</widget>
5274
</item>

‎src/ui/layout/qgssvgexportoptions.ui

+23-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>489</width>
10-
<height>385</height>
10+
<height>464</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -181,6 +181,28 @@
181181
</property>
182182
</spacer>
183183
</item>
184+
<item>
185+
<widget class="QgsCollapsibleGroupBoxBasic" name="groupBox_2">
186+
<property name="title">
187+
<string>Advanced Options</string>
188+
</property>
189+
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0">
190+
<item row="0" column="0" colspan="2">
191+
<widget class="QCheckBox" name="mDisableRasterTilingCheckBox">
192+
<property name="toolTip">
193+
<string>Disables tiled rendering of raster layers. This setting may improve the export quality in some circumstances, at the cost of much greater memory usage during exports.</string>
194+
</property>
195+
<property name="text">
196+
<string>Disable tiled raster layer exports</string>
197+
</property>
198+
<property name="checked">
199+
<bool>false</bool>
200+
</property>
201+
</widget>
202+
</item>
203+
</layout>
204+
</widget>
205+
</item>
184206
<item>
185207
<widget class="QDialogButtonBox" name="buttonBox">
186208
<property name="orientation">

0 commit comments

Comments
 (0)
Please sign in to comment.