src/store/setToolMode.js
function(
  element,
  toolName,
  options,
  interactionTypes
) {
  // If interactionTypes was passed in via options
  if (interactionTypes === undefined && Array.isArray(options)) {
    interactionTypes = options;
    options = null;
  }

  const tool = getToolForElement(element, toolName);

  if (tool) {
    _resolveInputConflicts(element, tool, options, interactionTypes);

    // Iterate over specific interaction types and set active
    // This is used as a secondary check on active tools to find the active "parts" of the tool
    tool.supportedInteractionTypes.forEach(interactionType => {
      if (
        interactionTypes === undefined ||
        interactionTypes.includes(interactionType)
      ) {
        options[`is${interactionType}Active`] = true;
      } else {
        options[`is${interactionType}Active`] = false;
      }
    });

    if (
      globalConfiguration.state.showSVGCursors &&
      tool.supportedInteractionTypes.includes('Mouse')
    ) {
      _setToolCursorIfPrimary(element, options, tool);
    }
  }

  // Resume normal behavior
  setToolModeForElement('active', null, element, toolName, options);
}
function(
  element,
  toolName,
  options,
  interactionTypes
) {
  // If interactionTypes was passed in via options
  if (interactionTypes === undefined && Array.isArray(options)) {
    interactionTypes = options;
    options = null;
  }

  const tool = getToolForElement(element, toolName);

  if (tool) {
    _resolveInputConflicts(element, tool, options, interactionTypes);

    // Iterate over specific interaction types and set active
    // This is used as a secondary check on active tools to find the active "parts" of the tool
    tool.supportedInteractionTypes.forEach(interactionType => {
      if (
        interactionTypes === undefined ||
        interactionTypes.includes(interactionType)
      ) {
        options[`is${interactionType}Active`] = true;
      } else {
        options[`is${interactionType}Active`] = false;
      }
    });

    if (
      globalConfiguration.state.showSVGCursors &&
      tool.supportedInteractionTypes.includes('Mouse')
    ) {
      _setToolCursorIfPrimary(element, options, tool);
    }
  }

  // Resume normal behavior
  setToolModeForElement('active', null, element, toolName, options);
}
function ( element , toolName , options , interactionTypes ) { // If interactionTypes was passed in via options if ( interactionTypes === undefined && Array . isArray ( options ) ) { interactionTypes = options ; options = null ; } const tool = getToolForElement ( element , toolName ) ; if ( tool ) { _resolveInputConflicts ( element , tool , options , interactionTypes ) ; // Iterate over specific interaction types and set active // This is used as a secondary check on active tools to find the active "parts" of the tool tool . supportedInteractionTypes . forEach ( interactionType => { if ( interactionTypes === undefined || interactionTypes . includes ( interactionType ) ) { options [ ` ${ interactionType } ` ] = true ; } else { options [ ` ${ interactionType } ` ] = false ; } } ) ; if ( globalConfiguration . state . showSVGCursors && tool . supportedInteractionTypes . includes ( 'Mouse' ) ) { _setToolCursorIfPrimary ( element , options , tool ) ; } } // Resume normal behavior setToolModeForElement ( 'active' , null , element , toolName , options ) ; }
Sets a tool's state, with the provided toolName and element, to 'active'. Active tools are rendered,
respond to user input, and can create new data.

@public
@function setToolActiveForElement
@memberof CornerstoneTools

@example <caption>Setting a tool 'active' for a specific interaction type.</caption>
// Sets length tool to Active
setToolActiveForElement(element, 'Length', {
mouseButtonMask: 1
}, ['Mouse'])
@example <caption>Setting a tool 'active' for all interaction types.</caption>
// Sets length tool to Active
setToolActiveForElement(element, 'Length', {
mouseButtonMask: 1
})
@param {HTMLElement} element
@param {string} toolName
@param {(Object|string[]|number)} options
@param {(string[])} interactionTypes
@returns {undefined}
Sets a tool s state with the provided toolName and element to active . Active tools are rendered respond to user input and can create new data .