Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
);
}
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);
}
_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}`
);
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')
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
);
}
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);
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
);
}