-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Geospatial PDF: Add option to follow the QGIS layer tree configuration (groups, order, names, visibility, grouplayers) #64684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gacarrillor
wants to merge
14
commits into
qgis:master
Choose a base branch
from
gacarrillor:pdf_qgis_layer_tree
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,394
−254
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…on making the main method much more readable
…orter::PdfExportSettings and QgsAbstractGeospatialPdfExporter::ExportDetails to export a PDF following the main QGIS layer tree configuration properties (e.g., name, order, visibility). Add QgsAbstractGeospatialPdfExporter::createLayerTreeAndContentXmlSectionsFromLayerTree() with initial logic to export qgis layers and groupsfollowing the QGIS layer tree (only valid for layout exports, and not for exports made using a map renderer task).
…end, pictures, and the like) are grouped according to their 'Properties->Rendering->Geospatial PDF group' setting. This includes the option to add graphical layout items to an existent group coming from the QGIS layer tree. Note that in all cases, graphical layout items are not shown in the PDF layer tree individually (but they'll be visible in the PDF pages). Instead, groups of graphical layout items are always shown in the PDF layer tree (note: if a PDF group is composed of graphical layout items only, it will be seen as a layer, that is, it'll not have children nodes).
…DF TreeNode, and for other Treenode methods
… on the QGIS Layer Tree
…nfo, and with and without (grouped) layout items (e.g., scale, picture, title, etc.)
…tion for the export instead of a custom configuration (i.e., layer and group names, orer, etc., as well as map themes)
…invalid or geometryless layers) and invalid/geometryless layers in the PDF layer tree
…p item layers to match project layers (including invisible ones) before rendering the layers to intermediate PDFs. After the rendering operation, restore the layers that map items had before we set the project layers. We only set project layers to those map items that don't follow map themes nor locked layers/styles, and if there's no map where we can set project layers (because all maps follow presets), then we exit the export operation with an error message.
…ation in GUI if there is at least one map item that is not following map themes nor locked layers.
…ayer tree properties (note: the GroupLayer is handled as a single map layer in the exported PDF)
…he Composition XML file (avoiding duplicate code)
…and for obtaining PrintError when all layout map items follow either map themes or locked layers
Contributor
🪟 Windows Qt6 buildsDownload Windows Qt6 builds of this PR for testing. 🍎 MacOS Qt6 buildsDownload MacOS Qt6 builds of this PR for testing. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Feature
Print Layouts
Related to QGIS Print Layouts, Atlas or Reporting frameworks
Table of contents
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR allows users to preserve the layer structure (including nested groups) when exporting to Geospatial PDF. It is handy for users that want to export their QGIS layer/group configuration (names, order, visibility) in one go, rather than set a different custom layer/group configuration.
This feature will only be available for layouts and not for map rendering tasks (i.e.,
Project->Import/Export->Export Map to PDF). Currently, the latter always outputs Geospatial PDFs with a flat layer list anyways.It is only enabled if there is at least one map item in the layout that is not following map themes nor locked layers, because those are not compatible with the QGIS project's layer tree configuration.
Both visible and invisible layers from the QGIS project are included in the output PDF.
If a user has set a custom layer order (via QGIS' Layer Order Panel) overriding the layer tree order, layers are rendered in the PDF following the custom order. However, the PDF layer tree structure will match the QGIS layer tree structure.
The export will either include feature info (attributes) for ALL layers or ignore feature info (attributes) for ALL layers. This depends on the
PdfExportSettings::includeGeoPdfFeaturesvalue. (In an eventual follow-up, users could choose which layers should include feature info.)GroupLayers are supported and are treated as single map layers in the exported PDF.
When a Geospatial PDF Group has been set for layout items (via
Item Properties -> Rendering -> Geospatial PDF Group), there are two options:Mutually exclusive groups are currently not supported.
Unit tests have been added.
Screenshot:
Funded by the city of Bern