How to use the cornerstone-tools.getToolState function in cornerstone-tools

To help you get started, weโ€™ve selected a few cornerstone-tools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sisobus / cornerstoneTools-RotatedEllipticalRoiTool / src / cornerstone-tools-rotated-elliptical-roi-tool.ts View on Github external
renderToolData(evt: any) {
    const toolData = cornerstoneTools.getToolState(evt.currentTarget, this.name)

    if (!toolData) {
      return
    }

    const eventData = evt.detail
    const { image, element } = eventData
    const lineWidth = cornerstoneTools.toolStyle.getToolWidth()
    const { handleRadius, drawHandlesOnHover } = this.configuration
    const context = getNewContext(eventData.canvasContext.canvas)
    const { rowPixelSpacing, colPixelSpacing } = getPixelSpacing(image)

    // Meta
    const seriesModule =
      cornerstone.metaData.get('generalSeriesModule', image.imageId) || {}
github sisobus / cornerstoneTools-RotatedEllipticalRoiTool / src / cornerstone-tools-rotated-elliptical-roi-tool.ts View on Github external
mouseMoveCallback(e: any) {
    const eventData = e.detail
    const { element } = eventData

    cornerstoneTools.toolCoordinates.setCoords(eventData)

    // If we have no tool data for this element, do nothing
    const toolData = cornerstoneTools.getToolState(element, this.name)

    if (!toolData) {
      return
    }

    // We have tool data, search through all data
    // And see if we can activate a handle
    let imageNeedsUpdate = false

    for (let i = 0; i < toolData.data.length; i++) {
      // Get the cursor position in canvas coordinates
      const coords = eventData.currentPoints.canvas

      const data = toolData.data[i]

      if (handleActivator(eventData.element, data.handles, coords) === true) {
github sisobus / cornerstoneTools-RotatedEllipticalRoiTool / src / cornerstone-tools-rotated-elliptical-roi-tool.ts View on Github external
}

      if (handle) {
        handle.moving = false
        handle.selected = true
      }

      setToolCursor(this.element, this.svgCursor)

      cornerstone.updateImage(element)
      element.addEventListener(EVENTS.MOUSE_MOVE, this.mouseMoveCallback)
      element.addEventListener(EVENTS.TOUCH_START, this._moveCallback)
    }

    const coords = eventData.startPoints.canvas
    const toolData = cornerstoneTools.getToolState(e.currentTarget, this.name)

    if (!toolData) {
      return
    }

    let i

    // Now check to see if there is a handle we can move
    for (i = 0; i < toolData.data.length; i++) {
      data = toolData.data[i]
      const distance = 6
      const handle = getHandleNearImagePoint(
        element,
        data.handles,
        coords,
        distance,
github OHIF / react-vtkjs-viewport / examples / VTKCornerstonePaintingSyncExample.js View on Github external
onPaintEnd = strokeBuffer => {
    const element = this.cornerstoneElements[0];
    const enabledElement = cornerstone.getEnabledElement(element);
    const { getters, setters } = cornerstoneTools.getModule('segmentation');
    const labelmap3D = getters.labelmap3D(element);
    const stackState = cornerstoneTools.getToolState(element, 'stack');
    const { rows, columns } = enabledElement.image;

    if (!stackState || !labelmap3D) {
      return;
    }

    const stackData = stackState.data[0];
    const numberOfFrames = stackData.imageIds.length;
    const segmentIndex = labelmap3D.activeSegmentIndex;

    for (let i = 0; i < numberOfFrames; i++) {
      let labelmap2D = labelmap3D.labelmaps2D[i];

      if (labelmap2D && labelmap2D.segmentsOnLabelmap.includes(segmentIndex)) {
        continue;
      }
github OHIF / Viewers / platform / viewer / src / connectedComponents / ConnectedCineDialog.js View on Github external
onClickBackButton: () => {
      const stackData = csTools.getToolState(activeEnabledElement, 'stack');
      if (!stackData || !stackData.data || !stackData.data.length) return;
      const { currentImageIdIndex } = stackData.data[0];
      if (currentImageIdIndex === 0) return;
      scrollToIndex(activeEnabledElement, currentImageIdIndex - 1);
    },
    onClickSkipToStart: () => {
github Kitware / paraview-glance / Sources / externals / MedicalCornerstone / CornerstoneToolManager.js View on Github external
Object.keys(model.tools).forEach((toolName) => {
      const state = cornerstoneTools.getToolState(element, toolName);
      measurements[toolName] = (state || {}).data || [];
    });
    return measurements;
github OHIF / Viewers / extensions / cornerstone / src / commandsModule.js View on Github external
availableToolTypes.forEach(toolType => {
        const elementToolData = cornerstoneTools.getToolState(
          element,
          toolType
        );

        if (!elementToolData) {
          return;
        }

        elementToolData.data.forEach((toolData, index) => {
          let elementToolInstance = cornerstoneTools.getToolForElement(
            element,
            toolType
          );

          if (!elementToolInstance) {
            elementToolInstance = cornerstoneTools.getToolForElement(