fix(segmentation overlay): update viewport ds list upon seg delete - OHIF-2425 (#5729)

- add segmentationExists check to getSopClassHandlerModule
- now firing SEGMENTATION_REMOVED and SEGMENTATION_REPRESENTATION_REMOVED events
- centralized segmentation removal in a listener
- when a segmentation is deleted (completely), remove it from all viewports it overlays
- when a segmentation is removed from a viewport, remove it as overlay from the viewport

---------

Co-authored-by: Joe Boccanfuso <joe.boccanfuso@radicalimaging.com>
Co-authored-by: Bill Wallace <wayfarer3130@gmail.com>
This commit is contained in:
authored and GitHub committed 2026-02-18 20:31:43 -05:00
1 parent c75cbc2a89
commit b35354120a
11 files changed
+174 -48

No files matched your search

+15 -10
View File
@@ -66,8 +66,8 @@ const commandsModule = ({
*/
addDisplaySetAsLayer: ({ viewportId, displaySetInstanceUID, removeFirst = false }) => {
if (!viewportId) {
const { activeViewportId } = servicesManager.services.viewportGridService.getState();
viewportId = activeViewportId;
const { activeViewportId } = servicesManager.services.viewportGridService.getState();
viewportId = activeViewportId;
}
if (!viewportId || !displaySetInstanceUID) {
@@ -151,6 +151,19 @@ const commandsModule = ({
return;
}
// Check if it's a segmentation and handle accordingly.
// Note that for the sake of hydrated segmentations, we remove the
// segmentation before checking if the display set is indeed in the viewport.
// This is because hydrated segmentations are not in the viewport per se
// {i.e. they are not layered) but are simply referenced by the display
// set in the viewport.
const isSegmentation = DERIVED_OVERLAY_MODALITIES.includes(displaySet.Modality);
if (isSegmentation) {
segmentationService.removeRepresentationsFromViewport(viewportId, {
segmentationId: displaySetInstanceUID,
});
}
// Get current display sets for the viewport
const currentDisplaySetUIDs = viewportGridService.getDisplaySetsUIDsForViewport(viewportId);
@@ -159,14 +172,6 @@ const commandsModule = ({
return;
}
// Check if it's a segmentation and handle accordingly
const isSegmentation = DERIVED_OVERLAY_MODALITIES.includes(displaySet.Modality);
if (isSegmentation) {
segmentationService.removeSegmentationRepresentations(viewportId, {
segmentationId: displaySetInstanceUID,
});
}
const updatedViewports = hangingProtocolService.getViewportsRequireUpdate(
viewportId,
displaySetInstanceUID