function newImageIdSpecificToolStateManager() {
  var toolState = {};

  // Here we add tool state, this is done by tools as well
  // As modules that restore saved state

  function saveImageIdToolState(imageId) {
    return toolState[imageId];
  }

  function restoreImageIdToolState(imageId, imageIdToolState) {
    toolState[imageId] = imageIdToolState;
  }

  function saveToolState() {
    return toolState;
  }

  function restoreToolState(savedToolState) {
    toolState = savedToolState;
  }

  // Here we add tool state, this is done by tools as well
  // As modules that restore saved state
  function addImageIdSpecificToolState(element, toolType, data) {
    var enabledImage = _externalModules2.default.cornerstone.getEnabledElement(element);
    // If we don't have any tool state for this imageId, add an empty object

    if (!enabledImage.image || toolState.hasOwnProperty(enabledImage.image.imageId) === false) {
      toolState[enabledImage.image.imageId] = {};
    }

    var imageIdToolState = toolState[enabledImage.image.imageId];

    // If we don't have tool state for this type of tool, add an empty object
    if (imageIdToolState.hasOwnProperty(toolType) === false) {
      imageIdToolState[toolType] = {
        data: []
      };
    }

    var toolData = imageIdToolState[toolType];

    // Finally, add this new tool to the state
    toolData.data.push(data);
  }

  // Here you can get state - used by tools as well as modules
  // That save state persistently
  function getImageIdSpecificToolState(element, toolType) {
    var enabledImage = _externalModules2.default.cornerstone.getEnabledElement(element);
    // If we don't have any tool state for this imageId, return undefined

    if (!enabledImage.image || toolState.hasOwnProperty(enabledImage.image.imageId) === false) {
      return;
    }

    var imageIdToolState = toolState[enabledImage.image.imageId];

    // If we don't have tool state for this type of tool, return undefined
    if (imageIdToolState.hasOwnProperty(toolType) === false) {
      return;
    }

    var toolData = imageIdToolState[toolType];

    return toolData;
  }

  // Clears all tool data from this toolStateManager.
  function clearImageIdSpecificToolStateManager(element) {
    var enabledImage = _externalModules2.default.cornerstone.getEnabledElement(element);

    if (!enabledImage.image || toolState.hasOwnProperty(enabledImage.image.imageId) === false) {
      return;
    }

    delete toolState[enabledImage.image.imageId];
  }

  return {
    get: getImageIdSpecificToolState,
    add: addImageIdSpecificToolState,
    clear: clearImageIdSpecificToolStateManager,
    saveImageIdToolState: saveImageIdToolState,
    restoreImageIdToolState: restoreImageIdToolState,
    saveToolState: saveToolState,
    restoreToolState: restoreToolState,
    toolState: toolState
  };
}
// That are displaying that imageId.
That are displaying that imageId.
That are displaying that imageId .
function newImageIdSpecificToolStateManager() {
  var toolState = {};
  function saveImageIdToolState(imageId) {
    return toolState[imageId];
  }
  function restoreImageIdToolState(imageId, imageIdToolState) {
    toolState[imageId] = imageIdToolState;
  }
  function saveToolState() {
    return toolState;
  }
  function restoreToolState(savedToolState) {
    toolState = savedToolState;
  }
  function addImageIdSpecificToolState(element, toolType, data) {
    var enabledImage = _externalModules2.default.cornerstone.getEnabledElement(element);
    if (!enabledImage.image || toolState.hasOwnProperty(enabledImage.image.imageId) === false) {
      toolState[enabledImage.image.imageId] = {};
    }
    var imageIdToolState = toolState[enabledImage.image.imageId];
    if (imageIdToolState.hasOwnProperty(toolType) === false) {
      imageIdToolState[toolType] = {
        data: []
      };
    }
    var toolData = imageIdToolState[toolType];
    toolData.data.push(data);
  }
  function getImageIdSpecificToolState(element, toolType) {
    var enabledImage = _externalModules2.default.cornerstone.getEnabledElement(element);
    if (!enabledImage.image || toolState.hasOwnProperty(enabledImage.image.imageId) === false) {
      return;
    }
    var imageIdToolState = toolState[enabledImage.image.imageId];
    if (imageIdToolState.hasOwnProperty(toolType) === false) {
      return;
    }
    var toolData = imageIdToolState[toolType];
    return toolData;
  }
  function clearImageIdSpecificToolStateManager(element) {
    var enabledImage = _externalModules2.default.cornerstone.getEnabledElement(element);
    if (!enabledImage.image || toolState.hasOwnProperty(enabledImage.image.imageId) === false) {
      return;
    }
    delete toolState[enabledImage.image.imageId];
  }
  return {
    get: getImageIdSpecificToolState,
    add: addImageIdSpecificToolState,
    clear: clearImageIdSpecificToolStateManager,
    saveImageIdToolState: saveImageIdToolState,
    restoreImageIdToolState: restoreImageIdToolState,
    saveToolState: saveToolState,
    restoreToolState: restoreToolState,
    toolState: toolState
  };
}
function newImageIdSpecificToolStateManager ( ) { var toolState = { } ; function saveImageIdToolState ( imageId ) { return toolState [ imageId ] ; } function restoreImageIdToolState ( imageId , imageIdToolState ) { toolState [ imageId ] = imageIdToolState ; } function saveToolState ( ) { return toolState ; } function restoreToolState ( savedToolState ) { toolState = savedToolState ; } function addImageIdSpecificToolState ( element , toolType , data ) { var enabledImage = _externalModules2 . default . cornerstone . getEnabledElement ( element ) ; if ( ! enabledImage . image || toolState . hasOwnProperty ( enabledImage . image . imageId ) === false ) { toolState [ enabledImage . image . imageId ] = { } ; } var imageIdToolState = toolState [ enabledImage . image . imageId ] ; if ( imageIdToolState . hasOwnProperty ( toolType ) === false ) { imageIdToolState [ toolType ] = { data : [ ] } ; } var toolData = imageIdToolState [ toolType ] ; toolData . data . push ( data ) ; } function getImageIdSpecificToolState ( element , toolType ) { var enabledImage = _externalModules2 . default . cornerstone . getEnabledElement ( element ) ; if ( ! enabledImage . image || toolState . hasOwnProperty ( enabledImage . image . imageId ) === false ) { return ; } var imageIdToolState = toolState [ enabledImage . image . imageId ] ; if ( imageIdToolState . hasOwnProperty ( toolType ) === false ) { return ; } var toolData = imageIdToolState [ toolType ] ; return toolData ; } function clearImageIdSpecificToolStateManager ( element ) { var enabledImage = _externalModules2 . default . cornerstone . getEnabledElement ( element ) ; if ( ! enabledImage . image || toolState . hasOwnProperty ( enabledImage . image . imageId ) === false ) { return ; } delete toolState [ enabledImage . image . imageId ] ; } return { get : getImageIdSpecificToolState , add : addImageIdSpecificToolState , clear : clearImageIdSpecificToolStateManager , saveImageIdToolState : saveImageIdToolState , restoreImageIdToolState : restoreImageIdToolState , saveToolState : saveToolState , restoreToolState : restoreToolState , toolState : toolState } ; }
That are displaying that imageId.
That are displaying that imageId .
// Here we add tool state, this is done by tools as well // As modules that restore saved state // Here we add tool state, this is done by tools as well // As modules that restore saved state // If we don't have any tool state for this imageId, add an empty object // If we don't have tool state for this type of tool, add an empty object // Finally, add this new tool to the state // Here you can get state - used by tools as well as modules // That save state persistently // If we don't have any tool state for this imageId, return undefined // If we don't have tool state for this type of tool, return undefined // Clears all tool data from this toolStateManager.