ohif-viewer/extensions/cornerstone/src/utils/setUpAnnotationEventHandlers.ts
2025-11-11 08:19:45 -05:00

27 lines
839 B
TypeScript

import * as csTools from '@cornerstonejs/tools';
import { eventTarget } from '@cornerstonejs/core';
const { Enums: csToolsEnums } = csTools;
const _autoAcceptAnnotationInterpolationHandler = evt => {
const { element } = evt.detail;
csTools.utilities.contours.acceptAutogeneratedInterpolations(element, {});
};
export const setUpAnnotationEventHandlers = (): [() => void] => {
eventTarget.addEventListener(
csToolsEnums.Events.ANNOTATION_INTERPOLATION_PROCESS_COMPLETED,
_autoAcceptAnnotationInterpolationHandler
);
const annotationInterpolationProcessCompletedUnsubscribe = () => {
eventTarget.removeEventListener(
csToolsEnums.Events.ANNOTATION_INTERPOLATION_PROCESS_COMPLETED,
_autoAcceptAnnotationInterpolationHandler
);
};
return [annotationInterpolationProcessCompletedUnsubscribe];
};