src/VTKViewport/Manipulators/customBase.js
/**
 * Initialize any additional publicAPI functions we may need AFTER applying
 * and standard interactor adjustments. In particular apply any mouse handler
 * changes here that should happen AFTER the interactor has had a chance to
 * apply the interaction.
 */
Initialize any additional publicAPI functions we may need AFTER applying
and standard interactor adjustments. In particular apply any mouse handler
changes here that should happen AFTER the interactor has had a chance to
apply the interaction.
Initialize any additional publicAPI functions we may need AFTER applying and standard interactor adjustments . In particular apply any mouse handler changes here that should happen AFTER the interactor has had a chance to apply the interaction .
function finalize(publicAPI, model) {
  const superHandleMouseMove = publicAPI.handleMouseMove;
  publicAPI.handleMouseMove = callData => {
    model.lastClickButton = 0;
    model.lastClickTime = null;
    if (model.state === States.IS_WINDOW_LEVEL) {
      publicAPI.customHandleMouse(callData, 0, false);
    }
    if (superHandleMouseMove) {
      superHandleMouseMove(callData);
    }
  };
  const superHandleLeftButtonPress = publicAPI.handleLeftButtonPress;
  publicAPI.handleLeftButtonPress = callData => {
    model.leftMouse = true;
    if (
      (!model.operation || model.operation.type === null) &&
      callData.shiftKey
    ) {
      model.operation = { type: operations.MOVE_CROSSHAIRS };
      publicAPI.startWindowLevel();
      publicAPI.handleMouseMove(callData);
    }
    else if (superHandleLeftButtonPress) {
      superHandleLeftButtonPress(callData);
    }
    if (model.operation && model.operation.type !== null) {
      model.interactionOperation = InteractionOperations.MOVE_CROSSHAIRS;
    } else if (!callData.shiftKey && !callData.controlKey && !callData.altKey) {
      publicAPI.startWindowLevel();
      publicAPI.handleMouseButton(callData, 1);
    }
  };
  const superHandleMiddleButtonPress = publicAPI.handleMiddleButtonPress;
  publicAPI.handleMiddleButtonPress = callData => {
    model.middleMouse = true;
    if (!callData.shiftKey && !callData.controlKey && !callData.altKey) {
      publicAPI.startWindowLevel();
      publicAPI.handleMouseButton(callData, 2);
    }
    else if (superHandleMiddleButtonPress) {
      superHandleMiddleButtonPress(callData);
    }
  };
  const superHandleRightButtonPress = publicAPI.handleRightButtonPress;
  publicAPI.handleRightButtonPress = callData => {
    model.rightMouse = true;
    if (!callData.shiftKey && !callData.controlKey && !callData.altKey) {
      publicAPI.startWindowLevel();
      publicAPI.handleMouseButton(callData, 3);
    }
    else if (superHandleRightButtonPress) {
      superHandleRightButtonPress(callData);
    }
  };
  const superHandleLeftButtonRelease = publicAPI.handleLeftButtonRelease;
  publicAPI.handleLeftButtonRelease = () => {
    if (superHandleLeftButtonRelease) {
      superHandleLeftButtonRelease();
    }
    publicAPI.clearMouseInteractionOperation(model);
  };
  const superHandleMiddleButtonRelease = publicAPI.handleMiddleButtonRelease;
  publicAPI.handleMiddleButtonRelease = () => {
    if (superHandleMiddleButtonRelease) {
      superHandleMiddleButtonRelease();
    }
    publicAPI.clearMouseInteractionOperation(model);
  };
  const superHandleRightButtonRelease = publicAPI.handleRightButtonRelease;
  publicAPI.handleRightButtonRelease = () => {
    if (superHandleRightButtonRelease) {
      superHandleRightButtonRelease();
    }
    publicAPI.clearMouseInteractionOperation(model);
  };
}
function finalize ( publicAPI , model ) { const superHandleMouseMove = publicAPI . handleMouseMove ; publicAPI . handleMouseMove = callData => { model . lastClickButton = 0 ; model . lastClickTime = null ; if ( model . state === States . IS_WINDOW_LEVEL ) { publicAPI . customHandleMouse ( callData , 0 , false ) ; } if ( superHandleMouseMove ) { superHandleMouseMove ( callData ) ; } } ; const superHandleLeftButtonPress = publicAPI . handleLeftButtonPress ; publicAPI . handleLeftButtonPress = callData => { model . leftMouse = true ; if ( ( ! model . operation || model . operation . type === null ) && callData . shiftKey ) { model . operation = { type : operations . MOVE_CROSSHAIRS } ; publicAPI . startWindowLevel ( ) ; publicAPI . handleMouseMove ( callData ) ; } else if ( superHandleLeftButtonPress ) { superHandleLeftButtonPress ( callData ) ; } if ( model . operation && model . operation . type !== null ) { model . interactionOperation = InteractionOperations . MOVE_CROSSHAIRS ; } else if ( ! callData . shiftKey && ! callData . controlKey && ! callData . altKey ) { publicAPI . startWindowLevel ( ) ; publicAPI . handleMouseButton ( callData , 1 ) ; } } ; const superHandleMiddleButtonPress = publicAPI . handleMiddleButtonPress ; publicAPI . handleMiddleButtonPress = callData => { model . middleMouse = true ; if ( ! callData . shiftKey && ! callData . controlKey && ! callData . altKey ) { publicAPI . startWindowLevel ( ) ; publicAPI . handleMouseButton ( callData , 2 ) ; } else if ( superHandleMiddleButtonPress ) { superHandleMiddleButtonPress ( callData ) ; } } ; const superHandleRightButtonPress = publicAPI . handleRightButtonPress ; publicAPI . handleRightButtonPress = callData => { model . rightMouse = true ; if ( ! callData . shiftKey && ! callData . controlKey && ! callData . altKey ) { publicAPI . startWindowLevel ( ) ; publicAPI . handleMouseButton ( callData , 3 ) ; } else if ( superHandleRightButtonPress ) { superHandleRightButtonPress ( callData ) ; } } ; const superHandleLeftButtonRelease = publicAPI . handleLeftButtonRelease ; publicAPI . handleLeftButtonRelease = ( ) => { if ( superHandleLeftButtonRelease ) { superHandleLeftButtonRelease ( ) ; } publicAPI . clearMouseInteractionOperation ( model ) ; } ; const superHandleMiddleButtonRelease = publicAPI . handleMiddleButtonRelease ; publicAPI . handleMiddleButtonRelease = ( ) => { if ( superHandleMiddleButtonRelease ) { superHandleMiddleButtonRelease ( ) ; } publicAPI . clearMouseInteractionOperation ( model ) ; } ; const superHandleRightButtonRelease = publicAPI . handleRightButtonRelease ; publicAPI . handleRightButtonRelease = ( ) => { if ( superHandleRightButtonRelease ) { superHandleRightButtonRelease ( ) ; } publicAPI . clearMouseInteractionOperation ( model ) ; } ; }
Initialize any additional publicAPI functions we may need AFTER applying
 and standard interactor adjustments.
Initialize any additional publicAPI functions we may need AFTER applying and standard interactor adjustments .
// Clear the double click detection if the mouse has moved. // Process the mouse move. // console.log('handleLeftButtonPress', callData); // Record that the button is down. // A left click with the shift button down will initiate a move crosshair operation // ... even if the click is outside the crosshairs center. // Manually start the MOVE_CROSSHAIRS operation. // Use the handleMouseMove function to move the crosshairs. // Otherwise; call the original handler. // If the user is adjusting the crosshairs set the interaction operation. // console.log('handleMiddleButtonPress', callData); // Record that the button is down. // Otherwise call the original handler. // console.log('handleRightButtonPress', callData); // Record that the button is down. // Otherwise call the original handler. // console.log('handleLeftButtonRelease'); // Always let vtk perform its actions on the release first. // Release all buttons and stop the current interaction operation. // console.log('handleMiddleButtonRelease'); // Always let vtk perform its actions on the release first. // Release all buttons and stop the current interaction operation. // console.log('handleRightButtonRelease'); // Always let vtk perform its actions on the release first. // Release all buttons and stop the current interaction operation.