Skip to content

fix(InteractorStyleImage): stop mouse move slicing during wheel - #3676

Open
cpruijsen wants to merge 1 commit into
Kitware:masterfrom
cpruijsen:fix/issue-3642-9b0f2341
Open

cpruijsen wants to merge 1 commit into
Kitware:masterfrom
cpruijsen:fix/issue-3642-9b0f2341

Conversation

@cpruijsen

Copy link
Copy Markdown
Contributor

Title: fix(InteractorStyleImage): stop mouse move slicing during wheel

### Context

Fixes #3642.

This removes the wheel start/end overrides from `vtkInteractorStyleImage`, so a mouse move during a wheel gesture no longer changes the camera distance.

`handleStartMouseWheel` called `startSlice()` and `handleEndMouseWheel` called `endSlice()`, so `model.state` stayed `IS_SLICE` for the whole gesture, including the wheel-end debounce window. `handleMouseMove` then sent each pointer move to `slice()`, which calls `camera.setDistance`. As discussed in the issue, `startSlice()`/`endSlice()` should only be used for the ctrl + left button interaction.

### Results

The new test `Sources/Interaction/Style/InteractorStyleImage/test/testMouseWheel.js` runs start wheel, mouse move, end wheel and checks that the camera distance and focal point do not change. It fails without the fix (distance 3.2036 becomes 3.2994) and passes with it.

### Changes

- `Sources/Interaction/Style/InteractorStyleImage/index.js`: removed the `handleStartMouseWheel` and `handleEndMouseWheel` overrides. The style now inherits them from `vtkInteractorStyleTrackballCamera`, which sets `wheelDolly` and ignores pointer movement while it is set. `endDolly()` still renders at the end of the gesture.
- Ctrl + left button slicing and `handleMouseWheel` (camera distance and reslice plane scroll) are unchanged.
- Event change: a wheel gesture now fires `StartDollyEvent`/`EndDollyEvent`, the same as `vtkInteractorStyleTrackballCamera`, and no longer fires `StartSliceEvent`/`EndSliceEvent`. `StartInteractionEvent`/`EndInteractionEvent` still fire.
- No API or TypeScript change: both methods still exist through inheritance.

Empty overrides would also fix the bug, but they would drop the render at the end of the gesture. I can switch to that if you prefer.

### PR Checklist

- [ ] GitHub Actions CI passed: semantic-release commit messages, lint, and tests
- [x] Test coverage added
- [x] Documentation and TypeScript definitions are updated to match these changes (no API change)

handleStartMouseWheel and handleEndMouseWheel called startSlice and
endSlice, which set model.state to IS_SLICE for the whole wheel
gesture. Any mouse move in that window was routed to slice() and
dragged the camera distance. Deleting the overrides lets the
trackball parent handle the wheel with its wheelDolly guard, so
wheel zoom and mouse move stay independent. Ctrl plus left button
still starts a slice.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant