All files / tools/src/stateManagement/segmentation/events triggerSegmentationDataModified.ts

100% Statements 3/3
100% Branches 0/0
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28                              2191x               2191x   2191x    
import { triggerEvent, eventTarget } from '@cornerstonejs/core';
 
import { Events } from '../../../enums';
import type { SegmentationDataModifiedEventDetail } from '../../../types/EventTypes';
import { setSegmentationDirty } from '../../../utilities/segmentation/utilities';
 
/**
 * Trigger an event that a segmentation data has been modified
 * @param segmentationId - The Id of segmentation
 */
export function triggerSegmentationDataModified(
  segmentationId: string,
  modifiedSlicesToUse?: number[],
  segmentIndex?: number
): void {
  const eventDetail: SegmentationDataModifiedEventDetail = {
    segmentationId,
    modifiedSlicesToUse,
    segmentIndex,
  };
 
  // set it to dirty to force the next call to getUniqueSegmentIndices to
  // recalculate the segment indices
  setSegmentationDirty(segmentationId);
 
  triggerEvent(eventTarget, Events.SEGMENTATION_DATA_MODIFIED, eventDetail);
}