src/VTKViewport/Manipulators/customSlice.js
/**
 * Adjust the window level based on the mouse movement.
 */
Adjust the window level based on the mouse movement.
Adjust the window level based on the mouse movement .
function onMove(publicAPI, model, callData) {
  const position = callData.position;
  if (!position) {
    return;
  }
  const dy = position.y - model.previousPosition.y;
  const range = publicAPI.getSliceRange();
  let slice = publicAPI.getSlice();
  const scrollSpeed = 0.0005;
  slice += dy * scrollSpeed * (range[1] - range[0]);
  if (slice < range[0]) slice = range[0];
  if (slice > range[1]) slice = range[1];
  publicAPI.scrollToSlice(slice);
  model.previousPosition = position;
}
function onMove ( publicAPI , model , callData ) { const position = callData . position ; if ( ! position ) { return ; } const dy = position . y - model . previousPosition . y ; const range = publicAPI . getSliceRange ( ) ; let slice = publicAPI . getSlice ( ) ; const scrollSpeed = 0.0005 ; slice += dy * scrollSpeed * ( range [ 1 ] - range [ 0 ] ) ; if ( slice < range [ 0 ] ) slice = range [ 0 ] ; if ( slice > range [ 1 ] ) slice = range [ 1 ] ; publicAPI . scrollToSlice ( slice ) ; model . previousPosition = position ; }
Adjust the window level based on the mouse movement.
Adjust the window level based on the mouse movement .
// Get the change in mouse Y position. // Get the slice range. // Get the current slice. // Adjust this constant to adjust how much the slice changes per pixel of mouse movement. // Adjust the slice and limit the range. // Actually adjust the slice. // Remember this mouse position.