Kitware / vtk-js

Visualization Toolkit for the Web
https://kitware.github.io/vtk-js/
BSD 3-Clause "New" or "Revised" License
1.23k stars 371 forks source link

Manipulators presets : slice, range and zoomToMouse not working #684

Closed AndreFrelicot closed 6 years ago

AndreFrelicot commented 6 years ago

I've a custom View2DProxy in which I apply a custom preset : myInteractionPresets.applyPreset('2D', model.interactorStyle2D);

the changes in the preset is applied correctly (i've changed key modifiers for zoom/pan for example). But the slice, range and zoomToMouse does nothing. Is there more "plumbing" needed ? I know that the vtkMouseRangeManipulator works (https://kitware.github.io/vtk-js/examples/MouseRangeManipulator.html) but it would be great if it worked directly with the presets/ViewProxy2D system.

jourdain commented 6 years ago

Could you share your preset code so we could understand what you are saying that does not work? If you use the 2D interactor style, the missing part for slicing through the volume is probably sliceAtFocalPoint that needs to be turned on?

https://github.com/Kitware/vtk-js/blob/master/Sources/Rendering/Core/ImageMapper/index.js#L460

AndreFrelicot commented 6 years ago

I've just copied and edited the presets from : https://github.com/Kitware/vtk-js/blob/2fbe464ba1e7b8d5d8d5d72db7d5397d2521e545/Sources/Interaction/Style/InteractorStyleManipulator/Presets.js

  '2D': [
    // { type: 'pan' },
    // { type: 'slice', options: {shift: true } },
    { type: 'slice', options: {alt: true, scrollEnabled: true } },

    // { type: 'zoomToMouse', options: {shift: true, control: true }},
    // { type: 'roll', options: { shift: true } },
    // { type: 'zoom', options: { control: true } },
    // { type: 'zoom', options: { alt: true } },
    // { type: 'zoom', options: { dragEnabled: false, scrollEnabled: true } },
    // { type: 'range', options: { shift: true, alt: true } },
    { type: 'range' },

    //{ type: 'vrPan' },
  ],

I've changed the default value of sliceAtFocalPoint to true directly in the vtkjs source vtk.js/Sources/Rendering/Core/ImageMapper/index.js for testing (I don't know how to set it properly yet in the View2DProxy. NB : I'm testing with paraview glance). The slices are now changing, but it breaks the slice slider of paraview glance (the value always go back to the value set by the manipulator preset system).

For now I'll handle this without using the preset system.

thank you