-
-
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
base: master
Are you sure you want to change the base?
Conversation
…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
🪟 Windows Qt6 buildsDownload Windows Qt6 builds of this PR for testing. 🍎 MacOS Qt6 buildsDownload MacOS Qt6 builds of this PR for testing. |
|
I didn't have the time yet to look deep into this PR but do you think it's gonna work well with #63580 which was trying to fix some issue in theme export. I see that you are reworking quite a bit the createCompositionXml method, Ideally I would have liked to merge the fix pull request before adding a new feature on top of this. |
|
To add to @troopa81 's comments, this one will need very careful review. This code is complex and I am concerned about regressions. |
@troopa81, thanks for mentioning this.
Regarding the construction of the composition XML file, the difference between the existent option (which I'm calling In other words, I didn't touch any existing behavior, I reused it as much as I could (that's why parts like Metadata, Georeferencing, and Page dimension were moved to common methods), and when the new option required a different logic, I created new methods. On the other hand, analyzing the changes you propose in the other PR: yes, they will work well together! Your changes are located in the method that corresponds to the existent option (i.e., |
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