diff --git a/Sources/Interaction/Style/InteractorStyleImage/index.js b/Sources/Interaction/Style/InteractorStyleImage/index.js index e46c812c6a7..80b13dc33b5 100644 --- a/Sources/Interaction/Style/InteractorStyleImage/index.js +++ b/Sources/Interaction/Style/InteractorStyleImage/index.js @@ -89,16 +89,6 @@ function vtkInteractorStyleImage(publicAPI, model) { } }; - //-------------------------------------------------------------------------- - publicAPI.handleStartMouseWheel = () => { - publicAPI.startSlice(); - }; - - //-------------------------------------------------------------------------- - publicAPI.handleEndMouseWheel = () => { - publicAPI.endSlice(); - }; - //-------------------------------------------------------------------------- publicAPI.handleMouseWheel = (callData) => { const camera = model.getRenderer(callData).getActiveCamera(); diff --git a/Sources/Interaction/Style/InteractorStyleImage/test/testMouseWheel.js b/Sources/Interaction/Style/InteractorStyleImage/test/testMouseWheel.js new file mode 100644 index 00000000000..d693fa07271 --- /dev/null +++ b/Sources/Interaction/Style/InteractorStyleImage/test/testMouseWheel.js @@ -0,0 +1,47 @@ +import { it, expect } from 'vitest'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkInteractorStyleImage from 'vtk.js/Sources/Interaction/Style/InteractorStyleImage'; + +function setup() { + const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0.2, 0.3, 0.4], + }); + const renderWindow = fullScreenRenderer.getRenderWindow(); + const renderer = fullScreenRenderer.getRenderer(); + renderWindow.addRenderer(renderer); + const interactor = fullScreenRenderer.getInteractor(); + const interactorStyle = vtkInteractorStyleImage.newInstance(); + interactor.setInteractorStyle(interactorStyle); + const coneSource = vtkConeSource.newInstance({ height: 1.0 }); + const mapper = vtkMapper.newInstance(); + mapper.setInputConnection(coneSource.getOutputPort()); + const actor = vtkActor.newInstance(); + actor.setMapper(mapper); + renderer.addActor(actor); + renderer.resetCamera(); + renderWindow.render(); + return { renderer, interactorStyle }; +} + +it('Test vtkInteractorStyleImage mouse move during mouse wheel does not slice', () => { + const { renderer, interactorStyle } = setup(); + const camera = renderer.getActiveCamera(); + + const distance = camera.getDistance(); + const focalPoint = [...camera.getFocalPoint()]; + interactorStyle.handleStartMouseWheel(); + interactorStyle.handleMouseMove({ + position: { x: 10, y: 50 }, + pokedRenderer: renderer, + }); + interactorStyle.handleEndMouseWheel(); + + expect( + camera.getDistance(), + 'Make sure moving the mouse while the mouse wheel is handled leaves the camera unchanged.' + ).toEqual(distance); + expect(camera.getFocalPoint()).toEqual(focalPoint); +});