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

Fix camera 3D absolute rotation bug #5726

Merged
merged 1 commit into from
Apr 15, 2023
Merged

Fix camera 3D absolute rotation bug #5726

merged 1 commit into from
Apr 15, 2023

Conversation

brisvag
Copy link
Contributor

@brisvag brisvag commented Apr 14, 2023

Fixes/Closes

Closes #5725

Description

We were ignoring mouse release events.

Type of change

  • Bug-fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

@jni
Copy link
Member

jni commented Apr 14, 2023

Ha! Nice! I'd gone with my quick fix (just use arcball) and was about to open a PR. This is better. 😃 (Though I think zooming is less useful in 3D anyway, because you can't change the center of the zoom.)

@brisvag
Copy link
Contributor Author

brisvag commented Apr 14, 2023

I did not review the previous PR, so I don't know exactly what was the purpose of these lines. At least this fixes the problem, but someone who reviewed and understood should take a look and make sure (for example) that there's no other events we're ignoring unnecessarily. @jni @alisterburt

@jni
Copy link
Member

jni commented Apr 14, 2023

I think the point is to not ignore the mouse wheel if zoom is active and not ignore relevant mouse events if pan is active. I did a git grep event.type in vispy and didn't find other mouse events, but the fly camera uses keyboard events that we would mask if we used it in this way:

vispy/scene/cameras/fly.py:            if event.type == 'key_release':
vispy/scene/cameras/fly.py:        if event.type == 'mouse_wheel':
vispy/scene/cameras/fly.py:        if event.type == 'mouse_press':
vispy/scene/cameras/fly.py:        if event.type == 'mouse_release':
vispy/scene/cameras/fly.py:        if event.type == 'mouse_move':
vispy/scene/cameras/magnify.py:        if event.type == 'mouse_wheel':
vispy/scene/cameras/panzoom.py:        if event.type == 'mouse_wheel':
vispy/scene/cameras/panzoom.py:        elif event.type == 'mouse_move':
vispy/scene/cameras/panzoom.py:        elif event.type == 'mouse_press':
vispy/scene/cameras/perspective.py:        if event.type == 'mouse_wheel':
vispy/scene/cameras/perspective.py:        if event.type == 'mouse_release':
vispy/scene/cameras/perspective.py:        elif event.type == 'mouse_press':
vispy/scene/cameras/perspective.py:        elif event.type == 'mouse_move':

Something to watch out for... I think @kevinyamauchi and @alisterburt played around with the fly camera in the Dresden hackathon?

@brisvag
Copy link
Contributor Author

brisvag commented Apr 14, 2023

I think we're fine, this function is only handling mouse events, right? viewbox_mouse_event()

@jni
Copy link
Member

jni commented Apr 14, 2023

Hey look just because your mouse doesn't have a full-size keyboard on it... 😜

@codecov
Copy link

codecov bot commented Apr 14, 2023

Codecov Report

Merging #5726 (c133f0a) into main (4f77ae8) will increase coverage by 0.00%.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #5726   +/-   ##
=======================================
  Coverage   89.83%   89.84%           
=======================================
  Files         608      608           
  Lines       51856    51856           
=======================================
+ Hits        46587    46592    +5     
+ Misses       5269     5264    -5     
Impacted Files Coverage Δ
napari/_vispy/camera.py 93.89% <ø> (ø)

... and 4 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Comment on lines +245 to +246
and event.type
in ('mouse_move', 'mouse_press', 'mouse_release')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of managing allow list maybe revert logic of this if and use deny list for block calling super implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to reverse this in a sensible way... Something like this?

if 
	(not self.mouse_zoom and event.type == 'mouse_wheel')
	or (not self.mouse_pan and event.type in ('mouse_move', 'mouse_press', 'mouse_release')
):
	event.handled = False
else:
	super().viewbox_mouse_event(event)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but this logical clause not looking like full reverse

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just played around with other 3D mouse operations in this PR (shift+drag = move rotation centre, shift+right-click-drag = perspective projection) and they work fine:

Screenshot 2023-04-15 at 12 10 03 pm

(I call this composition "inside the asteroid field" 😜)

so I suggest we merge this as is for now, and iterate in future PRs if we encounter issues. I think it's important that our 3D camera on main gets fixed ASAP.

@brisvag
Copy link
Contributor Author

brisvag commented Apr 14, 2023

Now that I think about it, in 3D we probably only want to block events that have no modifier (rotate) or exactly shift (pan), and let through everything else. And maybe distringuish between pan and rotate...

Or maybe we should just revert the change to 3D cameras ^^'

@jni
Copy link
Member

jni commented Apr 15, 2023

In line with my comment above, I'm going to merge this to fix main, we can continue to iterate on the conditions in future PRs if we discover more issues with this approach! 🙏

@jni jni merged commit d475d84 into napari:main Apr 15, 2023
@Czaki
Copy link
Collaborator

Czaki commented Apr 15, 2023

@jni If you think that something should be improved on follow-up PR then please open a proper followup issue on merge of PR to not lost knowledge.

@Czaki Czaki mentioned this pull request Jun 7, 2023
@Czaki Czaki added this to the 0.4.18 milestone Jun 16, 2023
@Czaki Czaki added the bugfix PR with bugfix label Jun 16, 2023
@Czaki Czaki modified the milestones: 0.4.18, 0.5.0 Jun 19, 2023
@Czaki Czaki added the triaged-0.4.18 To mark PR that is triaged in 0.4.18 release process label Jun 19, 2023
@Czaki Czaki modified the milestones: 0.5.0, 0.4.18 Jun 19, 2023
Czaki pushed a commit that referenced this pull request Jun 19, 2023
# Fixes/Closes
Closes #5725

# Description
We were ignoring mouse release events.

## Type of change
<!-- Please delete options that are not relevant. -->
- [x] Bug-fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update
Czaki pushed a commit that referenced this pull request Jun 21, 2023
# Fixes/Closes
Closes #5725

# Description
We were ignoring mouse release events.

## Type of change
<!-- Please delete options that are not relevant. -->
- [x] Bug-fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update
Czaki pushed a commit that referenced this pull request Jun 21, 2023
# Fixes/Closes
Closes #5725

# Description
We were ignoring mouse release events.

## Type of change
<!-- Please delete options that are not relevant. -->
- [x] Bug-fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update
Czaki pushed a commit that referenced this pull request Jun 21, 2023
# Fixes/Closes
Closes #5725

# Description
We were ignoring mouse release events.

## Type of change
<!-- Please delete options that are not relevant. -->
- [x] Bug-fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix PR with bugfix triaged-0.4.18 To mark PR that is triaged in 0.4.18 release process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3D camera rotation is broken
3 participants