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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | 17x 17x 22x 22x 20x 20x 2x 2x 20x 20x 20x 20x 20x 9x 9x | import { triggerEvent, eventTarget } from '@cornerstonejs/core'; import { Events } from '../../enums'; import { getSegmentationRepresentations, getSegmentations, } from '../../stateManagement/segmentation/segmentationState'; import { SegmentationRepresentationModifiedEventDetail, SegmentationDataModifiedEventDetail, SegmentationModifiedEventDetail, SegmentationRepresentationRemovedEventDetail, SegmentationRemovedEventDetail, } from '../../types/EventTypes'; /** * Trigger an event that a segmentation is removed * @param segmentationId - The Id of segmentation */ function triggerSegmentationRemoved(segmentationId: string): void { const eventDetail: SegmentationRemovedEventDetail = { segmentationId, }; triggerEvent(eventTarget, Events.SEGMENTATION_REMOVED, eventDetail); } /** * Trigger an event that a segmentation representation was removed * @param toolGroupId - The id of the tool group that the segmentation * representation was removed from. * @param segmentationRepresentationUID - The UID of the segmentation * representation that was removed. */ function triggerSegmentationRepresentationRemoved( toolGroupId: string, segmentationRepresentationUID: string ): void { const eventDetail: SegmentationRepresentationRemovedEventDetail = { toolGroupId, segmentationRepresentationUID, }; triggerEvent( eventTarget, Events.SEGMENTATION_REPRESENTATION_REMOVED, eventDetail ); } /** * Trigger an event on the eventTarget that the segmentation representation for * toolGroupId has been updated * @param toolGroupId - The Id of the toolGroup */ function triggerSegmentationRepresentationModified( toolGroupId: string, segmentationRepresentationUID?: string ): void { const eventDetail: SegmentationRepresentationModifiedEventDetail = { toolGroupId, segmentationRepresentationUID, }; if (segmentationRepresentationUID) { triggerEvent( eventTarget, Events.SEGMENTATION_REPRESENTATION_MODIFIED, eventDetail ); return; } // If no segmentationRepresentationUID is provided, then we need to trigger // the event for all segmentation representations in the toolGroup // Get all segmentation representations in the toolGroup const segmentationRepresentations = getSegmentationRepresentations(toolGroupId) || []; segmentationRepresentations.forEach((segmentationRepresentation) => { const { segmentationRepresentationUID } = segmentationRepresentation; const eventDetail: SegmentationRepresentationModifiedEventDetail = { toolGroupId, segmentationRepresentationUID, }; triggerEvent( eventTarget, Events.SEGMENTATION_REPRESENTATION_MODIFIED, eventDetail ); }); } /** * Triggers segmentation global state updated event, notifying all toolGroups * that the global state has been updated, If a segmentationId is provided * the event will only be triggered for that segmentation, otherwise it will * be triggered for all segmentations. * * @param segmentationId - The id of the segmentation that has been updated */ function triggerSegmentationModified(segmentationId?: string): void { let segmentationIds; Eif (segmentationId) { segmentationIds = [segmentationId]; } else { // get all toolGroups segmentationIds = getSegmentations().map( ({ segmentationId }) => segmentationId ); } // 1. Trigger an event notifying all listeners about the segmentationId // that has been updated. segmentationIds.forEach((segmentationId) => { const eventDetail: SegmentationModifiedEventDetail = { segmentationId, }; triggerEvent(eventTarget, Events.SEGMENTATION_MODIFIED, eventDetail); }); // Todo: I don't think we need the following lines of code // // 2. Notify all viewports that render the segmentationId in order to update the // // rendering based on the new global state. // toolGroupIds.forEach((toolGroupId) => { // triggerSegmentationRepresentationModified(toolGroupId) // }) } /** * Trigger an event that a segmentation data has been modified * @param segmentationId - The Id of segmentation */ function triggerSegmentationDataModified( segmentationId: string, modifiedSlicesToUse?: number[] ): void { const eventDetail: SegmentationDataModifiedEventDetail = { segmentationId, modifiedSlicesToUse, }; triggerEvent(eventTarget, Events.SEGMENTATION_DATA_MODIFIED, eventDetail); } export { // ToolGroup Specific triggerSegmentationRepresentationModified, triggerSegmentationRepresentationRemoved, // Global triggerSegmentationDataModified, triggerSegmentationModified, triggerSegmentationRemoved, }; |