How to use the cornerstone-tools.EVENTS 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 cornerstonejs / react-cornerstone-viewport / src / CornerstoneViewport / CornerstoneViewport.js View on Github external
this.element[addOrRemoveEventListener](
      cornerstone.EVENTS.IMAGE_RENDERED,
      this.onImageRendered
    );

    // Set Viewport Active
    this.element[addOrRemoveEventListener](
      cornerstoneTools.EVENTS.MOUSE_CLICK,
      this.setViewportActive
    );
    this.element[addOrRemoveEventListener](
      cornerstoneTools.EVENTS.MOUSE_DOWN,
      this.setViewportActive
    );
    this.element[addOrRemoveEventListener](
      cornerstoneTools.EVENTS.TOUCH_PRESS,
      this.setViewportActive
    );
    this.element[addOrRemoveEventListener](
      cornerstoneTools.EVENTS.TOUCH_START,
      this.setViewportActive
    );
    this.element[addOrRemoveEventListener](
      cornerstoneTools.EVENTS.STACK_SCROLL,
      this.setViewportActive
    );
  }
github OHIF / Viewers / platform / viewer / src / appExtensions / MeasurementsPanel / init.js View on Github external
function elementDisabledHandler(evt) {
    const element = evt.detail.element;

    element.removeEventListener(
      csTools.EVENTS.MEASUREMENT_ADDED,
      onMeasurementAdded
    );
    element.removeEventListener(
      csTools.EVENTS.MEASUREMENT_REMOVED,
      onMeasurementRemoved
    );
    element.removeEventListener(
      csTools.EVENTS.MEASUREMENT_MODIFIED,
      onMeasurementModified
    );
    element.removeEventListener(
      csTools.EVENTS.LABELMAP_MODIFIED,
      onLabelmapModified
    );

    element.removeEventListener(csTools.EVENTS.TOUCH_PRESS, onTouchPress);
    element.removeEventListener(csTools.EVENTS.MOUSE_CLICK, handleClick);
    element.removeEventListener(csTools.EVENTS.TOUCH_START, onTouchStart);

    // TODO: This makes scrolling painfully slow
    // element.removeEventListener(cornerstone.EVENTS.NEW_IMAGE, onNewImage);
  }
github cornerstonejs / react-cornerstone-viewport / src / CornerstoneViewport / CornerstoneViewport.js View on Github external
_bindExternalEventListeners(clear = false) {
    if (!this.eventListeners) {
      return;
    }

    const cornerstoneEvents = Object.values(cornerstone.EVENTS);
    const cornerstoneToolsEvents = Object.values(cornerstoneTools.EVENTS);
    const addOrRemoveEventListener = clear
      ? 'removeEventListener'
      : 'addEventListener';

    for (let i = 0; i < this.eventListeners.length; i++) {
      const { target: targetType, eventName, handler } = this.eventListeners[i];
      const target =
        targetType === 'element' ? this.element : cornerstone.events;

      if (
        !cornerstoneEvents.includes(eventName) &&
        !cornerstoneToolsEvents.includes(eventName)
      ) {
        console.warn(
          `No cornerstone or cornerstone-tools event exists for event name: ${eventName}`
        );
github sisobus / cornerstoneTools-RotatedEllipticalRoiTool / src / cornerstone-tools-rotated-elliptical-roi-tool.ts View on Github external
import cornerstone from 'cornerstone-core'
import cornerstoneTools from 'cornerstone-tools'
import { rotatedEllipticalRoiCursor } from './cursor'
import pointInRotatedEllipse from './util/pointInRotatedEllipse'
import movePerpendicularHandle from './manipulators/movePerpendicularHandle'
import drawRotatedEllipse from './drawing/drawRotatedEllipse'
import getROITextBoxCoords from './util/getROITextBoxCoords'
import calculateRotatedEllipseStatistics from './util/calculateRotatedEllipseStatistics'
import { setToolCursor } from './setToolCursor'

const BaseAnnotationTool = cornerstoneTools.import('base/BaseAnnotationTool')
const throttle = cornerstoneTools.import('util/throttle')
const EVENTS = cornerstoneTools.EVENTS
const getLogger = cornerstoneTools.import('util/getLogger')
const logger = getLogger('tools:annotation:RotatedEllipticalRoiTool')
const handleActivator = cornerstoneTools.import('manipulators/handleActivator')
const anyHandlesOutsideImage = cornerstoneTools.import(
  'manipulators/anyHandlesOutsideImage',
)
const getHandleNearImagePoint = cornerstoneTools.import(
  'manipulators/getHandleNearImagePoint',
)
const moveAllHandles = cornerstoneTools.import('manipulators/moveAllHandles')
const moveNewHandle = cornerstoneTools.import('manipulators/moveNewHandle')
const getPixelSpacing = cornerstoneTools.import('util/getPixelSpacing')
const getNewContext = cornerstoneTools.import('drawing/getNewContext')
const draw = cornerstoneTools.import('drawing/draw')
const setShadow = cornerstoneTools.import('drawing/setShadow')
const drawHandles = cornerstoneTools.import('drawing/drawHandles')
github Kitware / paraview-glance / Sources / externals / MedicalCornerstone / CornerstoneToolManager.js View on Github external
function attachListeners(element, shouldBind) {
    const method = shouldBind ? 'addEventListener' : 'removeEventListener';
    element[method](
      cornerstoneTools.EVENTS.MEASUREMENT_ADDED,
      publicAPI.invokeMeasurementAdded
    );
    element[method](
      cornerstoneTools.EVENTS.MEASUREMENT_MODIFIED,
      publicAPI.invokeMeasurementModified
    );
    element[method](
      cornerstoneTools.EVENTS.MEASUREMENT_REMOVED,
      publicAPI.invokeMeasurementRemoved
    );
  }
github OHIF / Viewers / platform / viewer / src / appExtensions / MeasurementsPanel / init.js View on Github external
function elementEnabledHandler(evt) {
    const element = evt.detail.element;

    element.addEventListener(
      csTools.EVENTS.MEASUREMENT_ADDED,
      onMeasurementAdded
    );
    element.addEventListener(
      csTools.EVENTS.MEASUREMENT_REMOVED,
      onMeasurementRemoved
    );
    element.addEventListener(
      csTools.EVENTS.MEASUREMENT_MODIFIED,
      onMeasurementModified
    );
    element.addEventListener(
      csTools.EVENTS.LABELMAP_MODIFIED,
      onLabelmapModified
    );

    element.addEventListener(csTools.EVENTS.TOUCH_PRESS, onTouchPress);
github Kitware / paraview-glance / Sources / externals / MedicalCornerstone / CornerstoneToolManager.js View on Github external
function attachListeners(element, shouldBind) {
    const method = shouldBind ? 'addEventListener' : 'removeEventListener';
    element[method](
      cornerstoneTools.EVENTS.MEASUREMENT_ADDED,
      publicAPI.invokeMeasurementAdded
    );
    element[method](
      cornerstoneTools.EVENTS.MEASUREMENT_MODIFIED,
      publicAPI.invokeMeasurementModified
    );
    element[method](
      cornerstoneTools.EVENTS.MEASUREMENT_REMOVED,
      publicAPI.invokeMeasurementRemoved
    );
  }