Skip to content
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

Merged
merged 11 commits into from
Oct 26, 2022

Conversation

nirvn
Copy link
Contributor

@nirvn nirvn commented Sep 28, 2022

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):

  • vector point
  • vector line
  • vector polygon
  • point cloud
  • mesh
  • raster

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:

  • Above of the currently active layer (pre-existing)
  • On top of the layer tree (new)
  • Optimal index/position within the currently active layer's group (new and exciting 😄 )

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:

image

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.

@nirvn nirvn added Feature GUI/UX Related to QGIS application GUI or User Experience labels Sep 28, 2022
@github-actions github-actions bot added this to the 3.28.0 milestone Sep 28, 2022
@nicogodet
Copy link
Member

Does this fix in mean time this #49539 ?

@Houska1
Copy link
Contributor

Houska1 commented Sep 28, 2022

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.

@nyalldawson nyalldawson added the Frozen Feature freeze - Do not merge! label Sep 28, 2022
@nyalldawson nyalldawson removed the Frozen Feature freeze - Do not merge! label Oct 22, 2022
@nirvn nirvn modified the milestones: 3.28.0, 3.30.0 Oct 24, 2022
@nirvn nirvn force-pushed the sort_sort_sort branch 2 times, most recently from a479a2b to 928b20f Compare October 24, 2022 07:06
@nirvn nirvn merged commit 087e55d into qgis:master Oct 26, 2022
@nirvn
Copy link
Contributor Author

nirvn commented Oct 26, 2022

@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.

@Houska1
Copy link
Contributor

Houska1 commented Oct 26, 2022

@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.

@nirvn
Copy link
Contributor Author

nirvn commented Oct 26, 2022

@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.

@DelazJ DelazJ added Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo. Changelog Items that are queued to appear in the visual changelog - remove after harvesting labels Feb 9, 2023
@github-actions
Copy link

github-actions bot commented Feb 9, 2023

@nirvn
This pull request has been tagged as requiring documentation.

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.
Also, any commit having [needs-doc] or [Needs Documentation] in will see its message pushed to the issue, so please be as verbose as you can.

Thank you!

@github-actions
Copy link

github-actions bot commented Feb 9, 2023

@nirvn
A documentation ticket has been opened at qgis/QGIS-Documentation#8038
It is your responsibility to visit this ticket and add as much detail as possible for the documentation team to correctly document this change.
Thank you!

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Feb 19, 2024

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.mp4

while not working in QGIS 3.35.0

Video_2024-02-19_211018.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ChangelogHarvested This PR description has been harvested in the Changelog already. Feature GUI/UX Related to QGIS application GUI or User Experience Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants