-
-
Notifications
You must be signed in to change notification settings - Fork 422
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
Lock dimensions / axes while rolling #5986
Conversation
for more information, see https://pre-commit.ci
I would be happy about some input whether my approach is fine or if I should change the way the settings value is connected to the Furthermore, there is a bug that appears sporadic. If one selects viewer then |
Thanks for the PR and the detailed description! Will try to leave more detailed comments in the future, but for now, I had some high level comments and thoughts. SummaryOverall, this is a convenient feature that changes what the roll action does - specifically which dimensions are rollable. That action is bound to The rollable dimensions are defined through a combination of the Suggestion 1: define
|
Also, the video in the description doesn't play for me (tried on macOS with Chrome and Safari). Not a big deal because I just pulled down the PR and tried it out, but you may want/need to update it for others to quickly understand this feature. |
napari/components/dims.py
Outdated
return self.ndim | ||
return nmdims | ||
|
||
@n_moveable_dims.setter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't used anywhere in this PR, which might explain why you're having problems with the event associated with this mutable property. EventedModel
can support events for derived attributes using __field_dependents__
, but I think that won't work here since one dependency is on the global settings.
@andy-sweet thanks for the review. I'm not certain if it is a good idea to try and build the logic around dimension individual locking without investigating the solution on the GUI side further. I will make Moving the control of Defining rollable as a |
You are absolutely right, the video is shown and "plays" but nothing happens. Not sure why xD |
Agreed. Right now, it feels a little like we're using a setting here because it gives us a GUI widget for free. Adding a spin box to the dimension order dialog should be fairly easy, but could be a little clunky/ugly. I think this is another advantage of the |
I'm fairly busy next week, but I'll try to find some time to take another look here. Also happy to make a PR with suggestions if that's helpful. |
Feel free :) |
I tried adding |
@andy-sweet I like your solution a lot and worked on it a little bit. I made a pull request to your fork. Could you take a look? If you like it, it would be perfect if you change the draft to a pull request. I will merge it into this draft then. |
I think I found the reason for some event related errors! -> there is no error with the move_indices function itself, but with the QtDimsSorter / axes_list generation |
Great! I did both things you asked. |
Rollable instead of n_moveable dims
I think we can just move |
@psobolewskiPhD and @andy-sweet thanks for the reviews. Peter: I totally agree but the BIG problem with the selectable flag is that the moment we add this we can't take it away easily. What I mean is, if the object is clicked to lock it and raise the flag, it can not be clicked anymore to unlock it. Tried it, couldn't make it work. If you have an idea how to implement this I'm open to add it. Andy 1: Waited for a reply on the comment. I can resolve it as it is the current practice of the other pop-ups though. |
Re: Andy's question, I'm more of the 'more is more' kinda guy, so adding
Wait, that's really bad...but I can't reproduce that. The other thing is that while you can't drag the locked dim, but you can drag the others above and below, which is equivalent to moving the locked dim... Not sure that's intended or not, but frankly I feel that the lock should just prevent the roll button from rolling the layer--this is really useful!--but if I want to move it to a different place I should be able to, whether I unlock first or not? It's hard to do it by accident.
And just adding Qt.ItemFlag.ItemIsDragEnabled to flags. I did run into one other thing--sorry--that bothers me a bit more: I've gone through everything and I'm ready to approve: it's useful and the implementation is clear. But I would like to hear your thoughts on the dragging bit and the persistence of the lock state. |
@psobolewskiPhD I was talking about the isSelectable flag. When you add this to an object you can no longer do the unlocking by clicking the lock icon or at least it did not work for me. Maybe I did something wrong. I thought about ways to prevent moving the objects by moving their surroundings but I found no easy solution. We can just drop the drag lock from the locked items sure. @andy-sweet what do you think about this? It seems that with the last update the behavior of Dims changed thought that it lost axes when the largest layer was removed, but this is no longer the case. Thus, it keeps the state of the axes. We could add this but this would need some tinkering with the Dims object. |
Thanks for the input - that's enough to convince me as a
I think that's because you could just do Anyway, there is definitely a GUI case for having fixed/unrollable dimensions and I think it's in the spirit of napari to mirror GUI functionality as closely as possible in the viewer model, so I think we're good to keep @Chris-N-K : My last request is to make
I also could not reproduce this. My guess is that there may be some OS / Qt version dependence here? I tried on macOS, and Windows with PyQt5.
That works for me! So to summarize, I'll approve once |
I'm in agreement with Andy, so I think this is very close to getting merged! 🎉 |
This could be done easily in So I don't have an issue with this side-effect because there are existing related side-effects when removing the last layer. @Chris-N-K : we've already asked so much of you here, so this is a non-blocking request. If you feel like adding it when making the latest updates, go for it! Otherwise, @psobolewskiPhD and I can make a follow up PR. |
Will implement the last two points. The other idea might be better as an additional PR. This could be bigger then one expects. |
Should be ready now. :) |
I took the liberty to push some typing fixes (we dropped python 3.8) and fix the test for the flag changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pulled this down again and it works smoothly now.
The question of what to do when all layers are removed can be addressed later.
I took the liberty of fixing some typing and test. The windows 3.12 seg fault (if it happens again) is unrelated.
So everything looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now!
@Chris-N-K: thanks for all your patience on this marathon PR!
@psobolewskiPhD : thanks for providing a second look here!
I'll file two issues regarding the other points raised in this PR (popup references, resetting rollable). Done in #6792 and #6793
# References and relevant issues Depends on napari/napari#5986 # Description This PR adds basic documentation for the new feature added by @Chris-N-K napari/napari#5986 to the Viewer tutorial in the `Roll dimensions` section.
# References and relevant issues Closes #6792 # Description This is a follow-up to #5986 that resets all dimensions to rollable when all layers are removed. Given that this not necessarily a bug and more of a preferred behavior, I did not add a test to cover it to avoid future maintenance of that test.
Description
The ability to roll through dimensions is a useful functionality in
napari
. However, in many use cases, it is desirable to only roll through or reorder the spatial dimensions. Particularly when dealing with time-resolved data, the time dimension should remain fixed most of the time. Currently, achieving this requires manually reordering the dimensions, which can be a tedious process.Original Behaviour
In the current version, all dimensions are in the reorder dimensions pop-up window are draggable, and users can freely reorder or roll through them.
New Behaviour
The dimensions in the reorder dimensions pop-up window have a lock symbol in front of there name. If clicked the lock closes and the item is no longer draggable. When rolling these dimensions will stay in place while the other dimensions are rolled.
lock_dimensions_demo.mp4
References
Type of change
How has this been tested?
QtDimsSorter
QtDimsSorter
to match new structureFinal checklist:
trans.
to make them localizable.For more information see our translations guide.