src/VTKViewport/Manipulators/customBase.js
/**
 * Initialize any additional publicAPI functions we may need.
 */
Initialize any additional publicAPI functions we may need.
Initialize any additional publicAPI functions we may need .
function initialize(publicAPI, model) {
  publicAPI.handleMouseButton = (callData, button) => {
    let isDoubleClick = false;
    if (button > 0) {
      const time = new Date().getTime();
      if (
        model.lastClickButton === button &&
        model.lastClickTime !== null &&
        time - model.lastClickTime < 400
      ) {
        isDoubleClick = true;
        model.lastClickButton = 0;
        model.lastClickTime = null;
      }
      else {
        model.lastClickButton = button;
        model.lastClickTime = time;
      }
    }
    publicAPI.customHandleMouse(callData, button, isDoubleClick);
  };
  publicAPI.clearMouseInteractionOperation = model => {
    model.interactionOperation = InteractionOperations.NONE;
    model.leftMouse = false;
    model.middleMouse = false;
    model.rightMouse = false;
    if (model.state == States.IS_WINDOW_LEVEL) {
      publicAPI.endWindowLevel();
    }
  };
  publicAPI.updateCrosshairs = model => {
    const { apis, apiIndex } = model;
    const thisApi = apis[apiIndex];
    const worldPos = thisApi.get('cachedCrosshairWorldPosition');
    if (thisApi.svgWidgets && thisApi.svgWidgets.crosshairsWidget) {
      thisApi.svgWidgets.crosshairsWidget.moveCrosshairs(
        worldPos,
        apis,
        apiIndex
      );
    }
    if (thisApi.svgWidgets && thisApi.svgWidgets.rotatableCrosshairsWidget) {
      thisApi.svgWidgets.rotatableCrosshairsWidget.moveCrosshairs(
        worldPos,
        apis,
        apiIndex
      );
    }
  };
}
function initialize ( publicAPI , model ) { publicAPI . handleMouseButton = ( callData , button ) => { let isDoubleClick = false ; if ( button > 0 ) { const time = new Date ( ) . getTime ( ) ; if ( model . lastClickButton === button && model . lastClickTime !== null && time - model . lastClickTime < 400 ) { isDoubleClick = true ; model . lastClickButton = 0 ; model . lastClickTime = null ; } else { model . lastClickButton = button ; model . lastClickTime = time ; } } publicAPI . customHandleMouse ( callData , button , isDoubleClick ) ; } ; publicAPI . clearMouseInteractionOperation = model => { model . interactionOperation = InteractionOperations . NONE ; model . leftMouse = false ; model . middleMouse = false ; model . rightMouse = false ; if ( model . state == States . IS_WINDOW_LEVEL ) { publicAPI . endWindowLevel ( ) ; } } ; publicAPI . updateCrosshairs = model => { const { apis , apiIndex } = model ; const thisApi = apis [ apiIndex ] ; const worldPos = thisApi . get ( 'cachedCrosshairWorldPosition' ) ; if ( thisApi . svgWidgets && thisApi . svgWidgets . crosshairsWidget ) { thisApi . svgWidgets . crosshairsWidget . moveCrosshairs ( worldPos , apis , apiIndex ) ; } if ( thisApi . svgWidgets && thisApi . svgWidgets . rotatableCrosshairsWidget ) { thisApi . svgWidgets . rotatableCrosshairsWidget . moveCrosshairs ( worldPos , apis , apiIndex ) ; } } ; }
Initialize any additional publicAPI functions we may need.
Initialize any additional publicAPI functions we may need .
/**
   * Perform so additional procession on the mouse event to detect double clicks.
   */ // Double click detection. // Check if this is a double click. // Reset the click button and time. // Otherwise rememeber the click button and time. // Process as a normal mouse down event. /**
   * Clear all mouse state information and stop the current interaction operation.
   */ // console.log('clearMouseInteractionOperation: all buttons released'); // Clear the interaction operation NONE. // Release all buttons. // End the hold on the window. /**
   * After a pan or zoom the crosshairs on that view need to be updated, call this is re-render them in the correct spot.
   */