feat: Add extensibility for tmtv and segmentation modes (#6128)

* feat: Add extensibility for tmtv and segmentation modes

* Fixes for ordering issues on laod

* Remove unnecessary reference lookup

* Chane side panel timing to fix tests

* PR comments - change how mode definitions get created

* Improvements to mode customizations

* Start organizing customizations

* Misc fixes for a customization demo page

* Security fixes

* PR requested changes to naming
This commit is contained in:
Bill Wallace authored and GitHub committed 2026-07-10 12:43:17 -04:00
1 parent f79055f98e
commit b266c0a86a
49 files changed
+2653 -1215

No files matched your search

@@ -0,0 +1,48 @@
// URL-loaded customization: segmentationAnnotationTools
//
// Enables the measurement/annotation tools inside the segmentation mode by
// composing capability packs the cornerstone extension already exports:
//
// - the annotation buttons are already registered by the mode (its
// `toolbarButtons` composition includes `cornerstone.toolbarButtons`), so
// the toolbar only needs a `MeasurementTools` section added to the primary
// bar,
// - the annotation tools themselves are added to the mode's tool groups via
// `cornerstone.annotationTools`,
// - and the measurement panel is appended so annotations can be reviewed.
//
// Everything is per-mode, so it all lives in the `mode` phase keyed by the
// segmentation mode's route name. The section tweak patches the mode's toolbar
// layout pack at Mode scope (reset on mode exit), and the tools/panels `$push`
// onto the values the mode seeds on enter.
//
// Load it with `?customization=segmentation/segmentationAnnotationTools`.
{
"mode": {
"segmentation": {
"cornerstone.segmentationModeToolbarSections": {
"primary": { "$unshift": ["MeasurementTools"] },
"MeasurementTools": {
"$set": [
"Length",
"Bidirectional",
"ArrowAnnotate",
"EllipticalROI",
"RectangleROI",
"CircleROI",
"PlanarFreehandROI",
"SplineROI",
"LivewireContour"
]
}
},
"toolGroupAdditions": {
"default": { "$push": [{ "$reference": "cornerstone.annotationTools" }] },
"mpr": { "$push": [{ "$reference": "cornerstone.annotationTools" }] }
},
"rightPanels": {
"$push": ["@ohif/extension-cornerstone.panelModule.panelMeasurement"]
}
}
}
}
@@ -0,0 +1,59 @@
// URL-loaded customization: segmentationEditing
//
// Adds segmentation editing to the basic and longitudinal (viewer) modes by
// composing the capability packs the cornerstone extension already exports:
//
// - the segmentation editing toolbar buttons and toolbox section wiring
// (`cornerstone.segmentationToolbarButtons` / `cornerstone.segmentationToolbarSections`),
// - the segmentation editing tools for the modes' tool groups
// (`cornerstone.segmentationTools`),
// - the segmentation panels that render the editing toolbox
// (`panelSegmentationWithToolsLabelMap` / `panelSegmentationWithToolsContour`),
// - and enables editing in the segmentation panel.
//
// Composition is per-mode, so every patch lives in the `mode` phase keyed by
// the target mode's route name (`basic`, `viewer`). Each mode seeds its own
// `toolbarButtons` / `toolbarSections` / `toolGroupAdditions` / `rightPanels`
// onto the Mode scope on enter; these blocks `$push` / `$set` on top of that,
// exactly like the panel swaps. No app-wide `global` keys are needed.
//
// Load it with `?customization=segmentation/segmentationEditing`.
{
"mode": {
"basic": {
"toolbarButtons": { "$push": [{ "$reference": "cornerstone.segmentationToolbarButtons" }] },
"toolbarSections": { "$push": [{ "$reference": "cornerstone.segmentationToolbarSections" }] },
"toolGroupAdditions": {
"default": { "$push": [{ "$reference": "cornerstone.segmentationTools" }] },
"mpr": { "$push": [{ "$reference": "cornerstone.segmentationTools" }] }
},
// The basic/longitudinal modes seed `panelSegmentation.disableEditing: true`
// from their own `modeCustomizations`; this `mode` phase value is applied
// after that (both Mode scope) and enables editing.
"panelSegmentation.disableEditing": { "$set": false },
"rightPanels": {
"$set": [
"@ohif/extension-cornerstone.panelModule.panelSegmentationWithToolsLabelMap",
"@ohif/extension-cornerstone.panelModule.panelSegmentationWithToolsContour",
"@ohif/extension-cornerstone.panelModule.panelMeasurement"
]
}
},
"viewer": {
"toolbarButtons": { "$push": [{ "$reference": "cornerstone.segmentationToolbarButtons" }] },
"toolbarSections": { "$push": [{ "$reference": "cornerstone.segmentationToolbarSections" }] },
"toolGroupAdditions": {
"default": { "$push": [{ "$reference": "cornerstone.segmentationTools" }] },
"mpr": { "$push": [{ "$reference": "cornerstone.segmentationTools" }] }
},
"panelSegmentation.disableEditing": { "$set": false },
"rightPanels": {
"$set": [
"@ohif/extension-cornerstone.panelModule.panelSegmentationWithToolsLabelMap",
"@ohif/extension-cornerstone.panelModule.panelSegmentationWithToolsContour",
"@ohif/extension-measurement-tracking.panelModule.trackedMeasurements"
]
}
}
}
}