-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
New layer tree insertion methods (on top of tree, optimal) and sorting of drag and dropped layers #50381
Conversation
Does this fix in mean time this #49539 ? |
How does this behave in a project where there is a custom layer rendering order defined in the Layer Order panel? A (minor) current frustration is that when such a custom order is currently active, new layers get added above the current layer in the Layer Tree, but always at the bottom of the Layer Order panel, and so almost invariably need reordering there. It would be wonderful if this fixed that as well. Or, if that is out of scope, just making sure it doesn't do anything worse or counterintuitive. |
a479a2b
to
928b20f
Compare
to insure maximum features visibility. Because adding a pair of polygon and point layers should never result in polygons covering the points. The sorting logic is from top to bottom: - vector: point - vector: line - vector: polygon - point cloud - mesh - vector tile - raster
@Houska1 , apologies for the long delay in answering your valid comment. The custom layer order panel handling will be addressed shortly in a separate PR. Since this is an advanced feature and people are most likely interested in manually refining the order, we'll apply a simple fix here: instead of pick the bottom of the stack as the arbitrary insertion point, we will go for the top of the stack, which is a much better default to begin with as users will more likely be able to see the new layer before manually changing the custom order in the panel. |
Makes sense, thanks. I assume if several layers are added it will use the same smart logic pts > lines > … > rasters. And at top of custom order is super - will allow me to drop my kloogey trapping of the new layer signal emitted and moving the new layer to top, as I do now. |
@Houska1 , you are correct, if several layers are added in one go, those will be smart sorted prior to being inserted at the very top. |
@nirvn A documentation ticket will be opened at https://github.com/qgis/QGIS-Documentation when this PR is merged. Please update the description (not the comments) with helpful description and screenshot to help the work from documentors. Thank you! |
@nirvn |
Hi @nirvn, it looks like the functionality introduced with this PR has been broken for layers added by processing algorithms probably since QGIS 3.32 or QGIS 3.34. See working in QGIS 3.30.3 Video_2024-02-19_210638.mp4while not working in QGIS 3.35.0 Video_2024-02-19_211018.mp4 |
Description
This PR improves the addition of datasets into the layer tree in three ways.
Sorting of a group of layers being drag and dropped into the map
Newly added group of layers to a project via drag and drag are now sorted in such a way as to increase the chance of their stacking being logical and features being visible. Whereas before the layers stacking would be dictated by the file manager (o browser panel) order of selection, the code now sorts using the following logic (top to bottom):
Here's a practical example. This video shows the old behavior when drag and dropping a few layers from the file manager onto QGIS:
bad-dragndrop-Peek.2022-09-28.09-36.mp4
Note the bad stacking, where lines and points are hidden below the polygon.
Same action, using the introduced sorting logic:
god-dragndrop-Peek.2022-09-28.09-37.mp4
Visibility of features increased, and likelihood of the current stacking being desirable higher
New layer tree insertion methods
The PR also adds two new layer tree insertion methods (in addition to the pre-existing behavior). The three insertion methods are:
The second method, on top of the layer tree, doesn't need much explaining. Layers are just thrown on top of the tree, so content never risks being inserted below (and covered by) a basemap.
The third method is more exciting. The method inserts newly added layers in an "optimal" fashion by insuring that point layers sit on top, followed by line layers, polygon layers, etc. It essentially matches the sorting discussed above, except it extents it to the whole layer tree, not only the layers being added within one drag and drop.
This screencast should do a better job than the above paragraph at explaining the method:
optimal-Peek.2022-09-28.09-09.mp4
This is super handy, and should come in as a life changer for newcomers and novice GIS users who are mostly interested in consuming a few datasets at a time.
Users can pick their favored layer tree insertion method in the options dialog's canvas & legend panel:
I've taken the opportunity to clean up widget alignment in that panel.
Inserting datasets at location dropped over the layer tree
It is quite counterintuitive to drag datasets (from the browser panel or file manager) onto a specific position within the layer tree only to see those added in different location. Counterintuitive no more! The PR addresses this UX shortcoming.
Screencast:
Peek.2022-09-28.16-50.mp4
Funded by the QGIS user group Switzerland.