@cornerstonejs/tools 2.0.0-beta.16 → 2.0.0-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/eventListeners/segmentation/imageChangeEventListener.js +11 -14
- package/dist/esm/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.js +26 -27
- package/dist/esm/eventListeners/segmentation/segmentationDataModifiedEventListener.js +1 -4
- package/dist/esm/eventListeners/segmentation/segmentationModifiedEventListener.js +2 -11
- package/dist/esm/eventListeners/segmentation/segmentationRepresentationModifiedEventListener.js +10 -2
- package/dist/esm/eventListeners/segmentation/segmentationRepresentationRemovedEventListener.js +2 -2
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/stateManagement/index.d.ts +3 -3
- package/dist/esm/stateManagement/index.js +2 -2
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.d.ts +19 -18
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +87 -130
- package/dist/esm/stateManagement/segmentation/activeSegmentation.d.ts +4 -5
- package/dist/esm/stateManagement/segmentation/activeSegmentation.js +6 -23
- package/dist/esm/stateManagement/segmentation/addRepresentation.d.ts +3 -0
- package/dist/esm/stateManagement/segmentation/addRepresentation.js +51 -0
- package/dist/esm/stateManagement/segmentation/addRepresentations.d.ts +3 -0
- package/dist/esm/stateManagement/segmentation/addRepresentations.js +9 -0
- package/dist/esm/stateManagement/segmentation/config/index.d.ts +2 -2
- package/dist/esm/stateManagement/segmentation/config/index.js +2 -2
- package/dist/esm/stateManagement/segmentation/config/segmentationColor.d.ts +4 -4
- package/dist/esm/stateManagement/segmentation/config/segmentationColor.js +10 -10
- package/dist/esm/stateManagement/segmentation/config/segmentationConfig.d.ts +8 -8
- package/dist/esm/stateManagement/segmentation/config/segmentationConfig.js +19 -13
- package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.d.ts +7 -6
- package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.js +29 -54
- package/dist/esm/stateManagement/segmentation/convertStackToVolumeSegmentation.d.ts +1 -1
- package/dist/esm/stateManagement/segmentation/convertStackToVolumeSegmentation.js +5 -5
- package/dist/esm/stateManagement/segmentation/convertVolumeToStackSegmentation.d.ts +3 -3
- package/dist/esm/stateManagement/segmentation/convertVolumeToStackSegmentation.js +5 -5
- package/dist/esm/stateManagement/segmentation/helpers/getRepresentationRenderingConfig.d.ts +2 -0
- package/dist/esm/stateManagement/segmentation/helpers/{getRepresentationSpecificConfig.js → getRepresentationRenderingConfig.js} +1 -1
- package/dist/esm/stateManagement/segmentation/index.d.ts +3 -3
- package/dist/esm/stateManagement/segmentation/index.js +3 -3
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.js +2 -4
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/createAndCacheSurfacesFromRaw.js +5 -6
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/updateSurfaceData.js +4 -4
- package/dist/esm/stateManagement/segmentation/polySeg/canComputeRequestedRepresentation.js +2 -6
- package/dist/esm/stateManagement/segmentation/removeRepresentationsFromViewport.d.ts +2 -0
- package/dist/esm/stateManagement/segmentation/removeRepresentationsFromViewport.js +23 -0
- package/dist/esm/stateManagement/segmentation/segmentIndex.js +6 -4
- package/dist/esm/stateManagement/segmentation/segmentationState.d.ts +23 -20
- package/dist/esm/stateManagement/segmentation/segmentationState.js +68 -95
- package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.d.ts +2 -2
- package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.js +4 -18
- package/dist/esm/store/ToolGroupManager/destroyToolGroup.js +0 -4
- package/dist/esm/tools/AdvancedMagnifyViewport.js +3 -3
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js +0 -2
- package/dist/esm/tools/base/ContourSegmentationBaseTool.d.ts +0 -1
- package/dist/esm/tools/base/ContourSegmentationBaseTool.js +42 -33
- package/dist/esm/tools/displayTools/Contour/contourDisplay.d.ts +4 -4
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js +17 -30
- package/dist/esm/tools/displayTools/Contour/contourHandler/handleContourSegmentation.d.ts +4 -4
- package/dist/esm/tools/displayTools/Contour/contourHandler/handleContourSegmentation.js +20 -11
- package/dist/esm/tools/displayTools/Contour/contourHandler/utils.d.ts +0 -2
- package/dist/esm/tools/displayTools/Contour/contourHandler/utils.js +0 -11
- package/dist/esm/tools/displayTools/Contour/removeContourFromElement.d.ts +1 -1
- package/dist/esm/tools/displayTools/Contour/removeContourFromElement.js +3 -3
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.d.ts +5 -5
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +51 -54
- package/dist/esm/tools/displayTools/SegmentationRenderingEngine.d.ts +19 -0
- package/dist/esm/tools/displayTools/SegmentationRenderingEngine.js +136 -0
- package/dist/esm/tools/displayTools/Surface/surfaceDisplay.d.ts +5 -5
- package/dist/esm/tools/displayTools/Surface/surfaceDisplay.js +14 -25
- package/dist/esm/tools/index.d.ts +1 -2
- package/dist/esm/tools/index.js +1 -2
- package/dist/esm/tools/segmentation/BrushTool.d.ts +15 -2
- package/dist/esm/tools/segmentation/BrushTool.js +13 -14
- package/dist/esm/tools/segmentation/CircleScissorsTool.js +3 -4
- package/dist/esm/tools/segmentation/PaintFillTool.js +1 -2
- package/dist/esm/tools/segmentation/RectangleScissorsTool.js +3 -4
- package/dist/esm/tools/segmentation/SegmentSelectTool.d.ts +3 -2
- package/dist/esm/tools/segmentation/SegmentSelectTool.js +5 -5
- package/dist/esm/tools/segmentation/SphereScissorsTool.js +4 -5
- package/dist/esm/tools/segmentation/strategies/compositions/preview.js +2 -2
- package/dist/esm/types/EventTypes.d.ts +0 -3
- package/dist/esm/types/SegmentationStateTypes.d.ts +24 -23
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/esm/utilities/segmentation/getSegmentIndexAtLabelmapBorder.d.ts +7 -0
- package/dist/esm/utilities/segmentation/{getSegmentAtLabelmapBorder.js → getSegmentIndexAtLabelmapBorder.js} +3 -3
- package/dist/esm/utilities/segmentation/getSegmentIndexAtWorldPoint.d.ts +11 -0
- package/dist/esm/utilities/segmentation/{getSegmentAtWorldPoint.js → getSegmentIndexAtWorldPoint.js} +7 -7
- package/dist/esm/utilities/segmentation/index.d.ts +3 -3
- package/dist/esm/utilities/segmentation/index.js +3 -3
- package/dist/esm/utilities/segmentation/triggerSegmentationRender.d.ts +2 -17
- package/dist/esm/utilities/segmentation/triggerSegmentationRender.js +4 -106
- package/dist/esm/utilities/segmentation/triggerSegmentationRenderForViewports.d.ts +3 -0
- package/dist/esm/utilities/segmentation/triggerSegmentationRenderForViewports.js +6 -0
- package/dist/esm/utilities/triggerAnnotationRenderForViewportIds.js +7 -2
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -4
- package/dist/esm/stateManagement/segmentation/addSegmentationRepresentation.d.ts +0 -3
- package/dist/esm/stateManagement/segmentation/addSegmentationRepresentation.js +0 -63
- package/dist/esm/stateManagement/segmentation/addSegmentationRepresentations.d.ts +0 -3
- package/dist/esm/stateManagement/segmentation/addSegmentationRepresentations.js +0 -14
- package/dist/esm/stateManagement/segmentation/helpers/getRepresentationSpecificConfig.d.ts +0 -2
- package/dist/esm/stateManagement/segmentation/removeSegmentationsFromToolGroup.d.ts +0 -2
- package/dist/esm/stateManagement/segmentation/removeSegmentationsFromToolGroup.js +0 -39
- package/dist/esm/tools/displayTools/SegmentationDisplayTool.d.ts +0 -13
- package/dist/esm/tools/displayTools/SegmentationDisplayTool.js +0 -101
- package/dist/esm/utilities/segmentation/getSegmentAtLabelmapBorder.d.ts +0 -7
- package/dist/esm/utilities/segmentation/getSegmentAtWorldPoint.d.ts +0 -11
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';
|
|
2
2
|
import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
|
|
3
3
|
import { BaseVolumeViewport, getEnabledElement, Enums, getEnabledElementByIds, cache, utilities, } from '@cornerstonejs/core';
|
|
4
|
-
import { getToolGroupForViewport } from '../../store/ToolGroupManager';
|
|
5
4
|
import Representations from '../../enums/SegmentationRepresentations';
|
|
6
5
|
import * as SegmentationState from '../../stateManagement/segmentation/segmentationState';
|
|
7
6
|
import { isVolumeSegmentation } from '../../tools/segmentation/strategies/utils/stackVolumeCheck';
|
|
8
7
|
import triggerSegmentationRender from '../../utilities/segmentation/triggerSegmentationRender';
|
|
8
|
+
import triggerSegmentationRenderForViewports from '../../utilities/segmentation/triggerSegmentationRenderForViewports';
|
|
9
9
|
const enable = function (element) {
|
|
10
10
|
const { viewport } = getEnabledElement(element);
|
|
11
11
|
if (viewport instanceof BaseVolumeViewport) {
|
|
@@ -18,23 +18,20 @@ const disable = function (element) {
|
|
|
18
18
|
element.removeEventListener(Enums.Events.STACK_NEW_IMAGE, _imageChangeEventListener);
|
|
19
19
|
element.removeEventListener(Enums.Events.IMAGE_RENDERED, _imageChangeEventListener);
|
|
20
20
|
};
|
|
21
|
-
const
|
|
21
|
+
const perViewportManualTriggers = new Map();
|
|
22
22
|
function _imageChangeEventListener(evt) {
|
|
23
23
|
const eventData = evt.detail;
|
|
24
24
|
const { viewportId, renderingEngineId } = eventData;
|
|
25
25
|
const { viewport } = getEnabledElementByIds(viewportId, renderingEngineId);
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
26
|
+
const segmentationRepresentations = SegmentationState.getRepresentationsForViewport(viewportId);
|
|
27
|
+
if (!segmentationRepresentations?.length) {
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
toolGroupSegmentationRepresentations.filter((representation) => representation.type === Representations.Labelmap);
|
|
33
|
-
if (!toolGroupSegmentationRepresentations?.length) {
|
|
30
|
+
const labelmapRepresentations = segmentationRepresentations.filter((representation) => representation.type === Representations.Labelmap);
|
|
31
|
+
if (!labelmapRepresentations.length) {
|
|
34
32
|
return;
|
|
35
33
|
}
|
|
36
|
-
|
|
37
|
-
toolGroupSegmentationRepresentations.forEach((representation) => {
|
|
34
|
+
labelmapRepresentations.forEach((representation) => {
|
|
38
35
|
const segmentation = SegmentationState.getSegmentation(representation.segmentationId);
|
|
39
36
|
if (!segmentation || !segmentation.representationData?.LABELMAP) {
|
|
40
37
|
return;
|
|
@@ -59,9 +56,9 @@ function _imageChangeEventListener(evt) {
|
|
|
59
56
|
return true;
|
|
60
57
|
});
|
|
61
58
|
if (!segmentationFound) {
|
|
62
|
-
if (!
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
if (!perViewportManualTriggers.has(viewportId)) {
|
|
60
|
+
perViewportManualTriggers.set(viewportId, true);
|
|
61
|
+
triggerSegmentationRenderForViewports([viewportId]);
|
|
65
62
|
}
|
|
66
63
|
return;
|
|
67
64
|
}
|
|
@@ -121,7 +118,7 @@ function _imageChangeEventListener(evt) {
|
|
|
121
118
|
},
|
|
122
119
|
},
|
|
123
120
|
]);
|
|
124
|
-
triggerSegmentationRender(
|
|
121
|
+
triggerSegmentationRender();
|
|
125
122
|
return;
|
|
126
123
|
}
|
|
127
124
|
if (segmentationImageData.setDerivedImage) {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { cache,
|
|
1
|
+
import { cache, utilities as csUtils, VolumeViewport, getEnabledElementByViewportId, } from '@cornerstonejs/core';
|
|
2
2
|
import * as SegmentationState from '../../../stateManagement/segmentation/segmentationState';
|
|
3
|
-
import { getToolGroup } from '../../../store/ToolGroupManager';
|
|
4
3
|
const onLabelmapSegmentationDataModified = function (evt) {
|
|
5
4
|
const { segmentationId, modifiedSlicesToUse } = evt.detail;
|
|
6
5
|
const { representationData, type } = SegmentationState.getSegmentation(segmentationId);
|
|
7
|
-
const toolGroupIds = SegmentationState.getToolGroupIdsWithSegmentation(segmentationId);
|
|
8
6
|
const labelmapRepresentationData = representationData[type];
|
|
9
7
|
if ('volumeId' in labelmapRepresentationData) {
|
|
10
8
|
performVolumeLabelmapUpdate({
|
|
@@ -13,9 +11,10 @@ const onLabelmapSegmentationDataModified = function (evt) {
|
|
|
13
11
|
type,
|
|
14
12
|
});
|
|
15
13
|
}
|
|
14
|
+
const viewportIds = SegmentationState.getViewportIdsWithSegmentationId(segmentationId);
|
|
16
15
|
if ('imageIdReferenceMap' in labelmapRepresentationData) {
|
|
17
16
|
performStackLabelmapUpdate({
|
|
18
|
-
|
|
17
|
+
viewportIds,
|
|
19
18
|
segmentationId,
|
|
20
19
|
representationData,
|
|
21
20
|
type,
|
|
@@ -42,32 +41,32 @@ function performVolumeLabelmapUpdate({ modifiedSlicesToUse, representationData,
|
|
|
42
41
|
});
|
|
43
42
|
imageData.modified();
|
|
44
43
|
}
|
|
45
|
-
function performStackLabelmapUpdate({
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
const viewportsInfo = toolGroup.getViewportsInfo();
|
|
50
|
-
toolGroupSegmentationRepresentations.forEach((representation) => {
|
|
44
|
+
function performStackLabelmapUpdate({ viewportIds, segmentationId, representationData, type, }) {
|
|
45
|
+
viewportIds.forEach((viewportId) => {
|
|
46
|
+
const viewportSegReps = SegmentationState.getRepresentationsForViewport(viewportId);
|
|
47
|
+
viewportSegReps.forEach((representation) => {
|
|
51
48
|
if (representation.segmentationId !== segmentationId) {
|
|
52
49
|
return;
|
|
53
50
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
51
|
+
const enabledElement = getEnabledElementByViewportId(viewportId);
|
|
52
|
+
if (!enabledElement) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const { viewport } = enabledElement;
|
|
56
|
+
if (viewport instanceof VolumeViewport) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const actorEntry = viewport.getActor(representation.segmentationRepresentationUID);
|
|
60
|
+
if (!actorEntry) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const currentImageId = viewport.getCurrentImageId();
|
|
64
|
+
const segImageData = actorEntry.actor.getMapper().getInputData();
|
|
65
|
+
const { imageIdReferenceMap } = representationData[type];
|
|
66
|
+
const currentSegmentationImageId = imageIdReferenceMap.get(currentImageId);
|
|
67
|
+
const segmentationImage = cache.getImage(currentSegmentationImageId);
|
|
68
|
+
segImageData.modified();
|
|
69
|
+
csUtils.updateVTKImageDataWithCornerstoneImage(segImageData, segmentationImage);
|
|
71
70
|
});
|
|
72
71
|
});
|
|
73
72
|
}
|
|
@@ -5,12 +5,9 @@ import onLabelmapSegmentationDataModified from './labelmap/onLabelmapSegmentatio
|
|
|
5
5
|
const onSegmentationDataModified = function (evt) {
|
|
6
6
|
const { segmentationId } = evt.detail;
|
|
7
7
|
const { type } = SegmentationState.getSegmentation(segmentationId);
|
|
8
|
-
const toolGroupIds = SegmentationState.getToolGroupIdsWithSegmentation(segmentationId);
|
|
9
8
|
if (type === SegmentationRepresentations.Labelmap) {
|
|
10
9
|
onLabelmapSegmentationDataModified(evt);
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
triggerSegmentationRender(toolGroupId);
|
|
14
|
-
});
|
|
11
|
+
triggerSegmentationRender(segmentationId);
|
|
15
12
|
};
|
|
16
13
|
export default onSegmentationDataModified;
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { triggerSegmentationRepresentationModified } from '../../stateManagement/segmentation/triggerSegmentationEvents';
|
|
1
|
+
import { triggerSegmentationRender } from '../../utilities/segmentation';
|
|
3
2
|
const segmentationModifiedListener = function (evt) {
|
|
4
3
|
const { segmentationId } = evt.detail;
|
|
5
|
-
|
|
6
|
-
toolGroupIds.forEach((toolGroupId) => {
|
|
7
|
-
const segRepresentations = getSegmentationRepresentations(toolGroupId);
|
|
8
|
-
segRepresentations.forEach((representation) => {
|
|
9
|
-
if (representation.segmentationId === segmentationId) {
|
|
10
|
-
triggerSegmentationRepresentationModified(toolGroupId, representation.segmentationRepresentationUID);
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
});
|
|
4
|
+
triggerSegmentationRender(segmentationId);
|
|
14
5
|
};
|
|
15
6
|
export default segmentationModifiedListener;
|
package/dist/esm/eventListeners/segmentation/segmentationRepresentationModifiedEventListener.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import triggerSegmentationRender from '../../utilities/segmentation/triggerSegmentationRender';
|
|
2
|
+
import { getRepresentation } from '../../stateManagement/segmentation/segmentationState';
|
|
2
3
|
const segmentationRepresentationModifiedListener = function (evt) {
|
|
3
|
-
const {
|
|
4
|
-
|
|
4
|
+
const { segmentationRepresentationUID } = evt.detail;
|
|
5
|
+
const segmentationRepresentation = getRepresentation
|
|
6
|
+
? getRepresentation(segmentationRepresentationUID)
|
|
7
|
+
: null;
|
|
8
|
+
if (!segmentationRepresentation) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const segmentationId = segmentationRepresentation?.segmentationId;
|
|
12
|
+
triggerSegmentationRender(segmentationId);
|
|
5
13
|
};
|
|
6
14
|
export default segmentationRepresentationModifiedListener;
|
package/dist/esm/eventListeners/segmentation/segmentationRepresentationRemovedEventListener.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import triggerSegmentationRender from '../../utilities/segmentation/triggerSegmentationRender';
|
|
2
2
|
const segmentationRepresentationRemovedEventListener = function (evt) {
|
|
3
|
-
const {
|
|
4
|
-
triggerSegmentationRender(
|
|
3
|
+
const { segmentationRepresentationUID } = evt.detail;
|
|
4
|
+
triggerSegmentationRender();
|
|
5
5
|
};
|
|
6
6
|
export default segmentationRepresentationRemovedEventListener;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import * as cursors from './cursors';
|
|
|
8
8
|
import * as Types from './types';
|
|
9
9
|
import * as annotation from './stateManagement/annotation';
|
|
10
10
|
import * as segmentation from './stateManagement/segmentation';
|
|
11
|
-
import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, PlanarRotateTool, StackScrollMouseWheelTool, VolumeRotateMouseWheelTool, MIPJumpToClickTool, LengthTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool,
|
|
11
|
+
import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, PlanarRotateTool, StackScrollMouseWheelTool, VolumeRotateMouseWheelTool, MIPJumpToClickTool, LengthTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ReferenceLines, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool } from './tools';
|
|
12
12
|
import VideoRedactionTool from './tools/annotation/VideoRedactionTool';
|
|
13
13
|
import * as Enums from './enums';
|
|
14
|
-
export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, StackScrollMouseWheelTool, VolumeRotateMouseWheelTool, MIPJumpToClickTool, LengthTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ReferenceLines, ScaleOverlayTool, SculptorTool, EraserTool,
|
|
14
|
+
export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, StackScrollMouseWheelTool, VolumeRotateMouseWheelTool, MIPJumpToClickTool, LengthTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ReferenceLines, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, };
|
package/dist/esm/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import * as cursors from './cursors';
|
|
|
8
8
|
import * as Types from './types';
|
|
9
9
|
import * as annotation from './stateManagement/annotation';
|
|
10
10
|
import * as segmentation from './stateManagement/segmentation';
|
|
11
|
-
import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, PlanarRotateTool, StackScrollMouseWheelTool, VolumeRotateMouseWheelTool, MIPJumpToClickTool, LengthTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool,
|
|
11
|
+
import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, PlanarRotateTool, StackScrollMouseWheelTool, VolumeRotateMouseWheelTool, MIPJumpToClickTool, LengthTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ReferenceLines, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, } from './tools';
|
|
12
12
|
import VideoRedactionTool from './tools/annotation/VideoRedactionTool';
|
|
13
13
|
import * as Enums from './enums';
|
|
14
|
-
export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, StackScrollMouseWheelTool, VolumeRotateMouseWheelTool, MIPJumpToClickTool, LengthTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ReferenceLines, ScaleOverlayTool, SculptorTool, EraserTool,
|
|
14
|
+
export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, StackScrollMouseWheelTool, VolumeRotateMouseWheelTool, MIPJumpToClickTool, LengthTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ReferenceLines, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, };
|
|
@@ -15,6 +15,6 @@ import { setAnnotationManager } from './annotation/annotationState';
|
|
|
15
15
|
import { getAnnotationManager } from './annotation/annotationState';
|
|
16
16
|
import { resetAnnotationManager } from './annotation/annotationState';
|
|
17
17
|
import { invalidateAnnotation } from './annotation/annotationState';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
export { FrameOfReferenceSpecificAnnotationManager, defaultFrameOfReferenceSpecificAnnotationManager, annotationLocking, annotationSelection, getAnnotations, addAnnotation, getNumberOfAnnotations, removeAnnotation, getAnnotation, getParentAnnotation, getChildAnnotations, clearParentAnnotation, addChildAnnotation, setAnnotationManager, getAnnotationManager, resetAnnotationManager, invalidateAnnotation,
|
|
18
|
+
import { addRepresentations } from './segmentation';
|
|
19
|
+
import { removeRepresentationsFromViewport } from './segmentation';
|
|
20
|
+
export { FrameOfReferenceSpecificAnnotationManager, defaultFrameOfReferenceSpecificAnnotationManager, annotationLocking, annotationSelection, getAnnotations, addAnnotation, getNumberOfAnnotations, removeAnnotation, getAnnotation, getParentAnnotation, getChildAnnotations, clearParentAnnotation, addChildAnnotation, setAnnotationManager, getAnnotationManager, resetAnnotationManager, invalidateAnnotation, addRepresentations, removeRepresentationsFromViewport };
|
|
@@ -2,5 +2,5 @@ import FrameOfReferenceSpecificAnnotationManager, { defaultFrameOfReferenceSpeci
|
|
|
2
2
|
import * as annotationLocking from './annotation/annotationLocking';
|
|
3
3
|
import * as annotationSelection from './annotation/annotationSelection';
|
|
4
4
|
import { getAnnotations, addAnnotation, removeAnnotation, getAnnotation, getParentAnnotation, getChildAnnotations, clearParentAnnotation, addChildAnnotation, getNumberOfAnnotations, setAnnotationManager, getAnnotationManager, resetAnnotationManager, invalidateAnnotation, } from './annotation/annotationState';
|
|
5
|
-
import {
|
|
6
|
-
export { FrameOfReferenceSpecificAnnotationManager, defaultFrameOfReferenceSpecificAnnotationManager, annotationLocking, annotationSelection, getAnnotations, addAnnotation, getNumberOfAnnotations, removeAnnotation, getAnnotation, getParentAnnotation, getChildAnnotations, clearParentAnnotation, addChildAnnotation, setAnnotationManager, getAnnotationManager, resetAnnotationManager, invalidateAnnotation,
|
|
5
|
+
import { addRepresentations, removeRepresentationsFromViewport, } from './segmentation';
|
|
6
|
+
export { FrameOfReferenceSpecificAnnotationManager, defaultFrameOfReferenceSpecificAnnotationManager, annotationLocking, annotationSelection, getAnnotations, addAnnotation, getNumberOfAnnotations, removeAnnotation, getAnnotation, getParentAnnotation, getChildAnnotations, clearParentAnnotation, addChildAnnotation, setAnnotationManager, getAnnotationManager, resetAnnotationManager, invalidateAnnotation, addRepresentations, removeRepresentationsFromViewport, };
|
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
import type { Types } from '@cornerstonejs/core';
|
|
2
|
-
import type { RepresentationConfig,
|
|
2
|
+
import type { RepresentationConfig, SegmentRepresentationConfig, Segmentation, SegmentationRepresentation, SegmentationRepresentationConfig, SegmentationState } from '../../types/SegmentationStateTypes';
|
|
3
3
|
export default class SegmentationStateManager {
|
|
4
4
|
private state;
|
|
5
5
|
readonly uid: string;
|
|
6
6
|
constructor(uid?: string);
|
|
7
7
|
getState(): SegmentationState;
|
|
8
|
-
getToolGroups(): string[];
|
|
9
8
|
getColorLUT(lutIndex: number): Types.ColorLUT | undefined;
|
|
10
9
|
getNextColorLUTIndex(): number;
|
|
11
10
|
resetState(): void;
|
|
12
11
|
getSegmentation(segmentationId: string): Segmentation | undefined;
|
|
13
12
|
addSegmentation(segmentation: Segmentation): void;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
removeSegmentation(segmentationId: string): void;
|
|
14
|
+
getRepresentation(segmentationRepresentationUID: string): SegmentationRepresentation | undefined;
|
|
15
|
+
addRepresentation(segmentationRepresentation: SegmentationRepresentation): void;
|
|
16
|
+
addRepresentationToViewport(viewportId: string, segmentationRepresentationUID: string): void;
|
|
17
|
+
getRepresentationsForViewport(viewportId: string): SegmentationRepresentation[];
|
|
18
|
+
removeRepresentation(segmentationRepresentationUID: string): void;
|
|
19
|
+
setActiveRepresentation(viewportId: string, segmentationRepresentationUID: string): void;
|
|
20
|
+
getActiveRepresentation(viewportId: string): SegmentationRepresentation | undefined;
|
|
17
21
|
getGlobalConfig(): SegmentationRepresentationConfig;
|
|
18
22
|
setGlobalConfig(config: SegmentationRepresentationConfig): void;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}): void;
|
|
30
|
-
setSegmentationRepresentationConfig(toolGroupId: string, config: SegmentationRepresentationConfig): void;
|
|
23
|
+
_getRepresentationConfig(segmentationRepresentationUID: string): {
|
|
24
|
+
allSegments?: RepresentationConfig;
|
|
25
|
+
perSegment?: SegmentRepresentationConfig;
|
|
26
|
+
};
|
|
27
|
+
getAllSegmentsConfig(segmentationRepresentationUID: string): RepresentationConfig;
|
|
28
|
+
getPerSegmentConfig(segmentationRepresentationUID: string): SegmentRepresentationConfig;
|
|
29
|
+
setAllSegmentsConfig(segmentationRepresentationUID: string, config: RepresentationConfig): void;
|
|
30
|
+
setPerSegmentConfig(segmentationRepresentationUID: string, config: SegmentRepresentationConfig): void;
|
|
31
|
+
getRepresentationVisibility(viewportId: string, segmentationRepresentationUID: string): boolean;
|
|
32
|
+
setRepresentationVisibility(viewportId: string, segmentationRepresentationUID: string, visible: boolean): void;
|
|
31
33
|
addColorLUT(colorLUT: Types.ColorLUT, lutIndex: number): void;
|
|
32
34
|
removeColorLUT(colorLUTIndex: number): void;
|
|
33
|
-
_handleActiveSegmentation(toolGroupId: string, recentlyAddedOrRemovedSegmentationRepresentation: ToolGroupSpecificRepresentation): void;
|
|
34
35
|
}
|
|
35
36
|
declare const defaultSegmentationStateManager: SegmentationStateManager;
|
|
36
37
|
export { defaultSegmentationStateManager };
|
|
@@ -3,22 +3,20 @@ import { SegmentationRepresentations } from '../../enums';
|
|
|
3
3
|
import getDefaultContourConfig from '../../tools/displayTools/Contour/contourConfig';
|
|
4
4
|
import getDefaultLabelmapConfig from '../../tools/displayTools/Labelmap/labelmapConfig';
|
|
5
5
|
import getDefaultSurfaceConfig from '../../tools/displayTools/Surface/surfaceConfig';
|
|
6
|
-
const defaultLabelmapConfig = getDefaultLabelmapConfig();
|
|
7
|
-
const defaultContourConfig = getDefaultContourConfig();
|
|
8
|
-
const defaultSurfaceConfig = getDefaultSurfaceConfig();
|
|
9
6
|
const newGlobalConfig = {
|
|
10
|
-
|
|
7
|
+
renderInactiveRepresentations: true,
|
|
11
8
|
representations: {
|
|
12
|
-
[SegmentationRepresentations.Labelmap]:
|
|
13
|
-
[SegmentationRepresentations.Contour]:
|
|
14
|
-
[SegmentationRepresentations.Surface]:
|
|
9
|
+
[SegmentationRepresentations.Labelmap]: getDefaultLabelmapConfig(),
|
|
10
|
+
[SegmentationRepresentations.Contour]: getDefaultContourConfig(),
|
|
11
|
+
[SegmentationRepresentations.Surface]: getDefaultSurfaceConfig(),
|
|
15
12
|
},
|
|
16
13
|
};
|
|
17
14
|
const initialDefaultState = {
|
|
18
15
|
colorLUT: [],
|
|
19
16
|
segmentations: [],
|
|
20
17
|
globalConfig: newGlobalConfig,
|
|
21
|
-
|
|
18
|
+
representations: {},
|
|
19
|
+
viewports: {},
|
|
22
20
|
};
|
|
23
21
|
export default class SegmentationStateManager {
|
|
24
22
|
constructor(uid) {
|
|
@@ -31,9 +29,6 @@ export default class SegmentationStateManager {
|
|
|
31
29
|
getState() {
|
|
32
30
|
return this.state;
|
|
33
31
|
}
|
|
34
|
-
getToolGroups() {
|
|
35
|
-
return Object.keys(this.state.toolGroups);
|
|
36
|
-
}
|
|
37
32
|
getColorLUT(lutIndex) {
|
|
38
33
|
return this.state.colorLUT[lutIndex];
|
|
39
34
|
}
|
|
@@ -52,30 +47,64 @@ export default class SegmentationStateManager {
|
|
|
52
47
|
}
|
|
53
48
|
this.state.segmentations.push(segmentation);
|
|
54
49
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
removeSegmentation(segmentationId) {
|
|
51
|
+
this.state.segmentations = this.state.segmentations.filter((segmentation) => segmentation.segmentationId !== segmentationId);
|
|
52
|
+
}
|
|
53
|
+
getRepresentation(segmentationRepresentationUID) {
|
|
54
|
+
return this.state.representations[segmentationRepresentationUID];
|
|
55
|
+
}
|
|
56
|
+
addRepresentation(segmentationRepresentation) {
|
|
57
|
+
const { segmentationRepresentationUID } = segmentationRepresentation;
|
|
58
|
+
this.state.representations[segmentationRepresentationUID] =
|
|
59
|
+
segmentationRepresentation;
|
|
60
|
+
}
|
|
61
|
+
addRepresentationToViewport(viewportId, segmentationRepresentationUID) {
|
|
62
|
+
if (!this.state.viewports[viewportId]) {
|
|
63
|
+
this.state.viewports[viewportId] = {};
|
|
59
64
|
}
|
|
60
|
-
|
|
65
|
+
this.setActiveRepresentation(viewportId, segmentationRepresentationUID);
|
|
61
66
|
}
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
getRepresentationsForViewport(viewportId) {
|
|
68
|
+
const viewport = this.state.viewports[viewportId];
|
|
69
|
+
if (!viewport) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
return Object.keys(viewport).map((segRepUID) => {
|
|
73
|
+
return this.getRepresentation(segRepUID);
|
|
67
74
|
});
|
|
68
|
-
return toolGroupSegReps;
|
|
69
75
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
removeRepresentation(segmentationRepresentationUID) {
|
|
77
|
+
delete this.state.representations[segmentationRepresentationUID];
|
|
78
|
+
Object.keys(this.state.viewports).forEach((viewportId) => {
|
|
79
|
+
delete this.state.viewports[viewportId][segmentationRepresentationUID];
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
setActiveRepresentation(viewportId, segmentationRepresentationUID) {
|
|
83
|
+
Object.keys(this.state.viewports[viewportId]).forEach((segRepUID) => {
|
|
84
|
+
this.state.viewports[viewportId][segRepUID].active = false;
|
|
85
|
+
});
|
|
86
|
+
if (!this.state.viewports[viewportId]) {
|
|
87
|
+
this.state.viewports[viewportId] = {};
|
|
88
|
+
}
|
|
89
|
+
if (!this.state.viewports[viewportId][segmentationRepresentationUID]) {
|
|
90
|
+
this.state.viewports[viewportId][segmentationRepresentationUID] = {
|
|
91
|
+
active: false,
|
|
92
|
+
visible: true,
|
|
93
|
+
segmentsHidden: new Set(),
|
|
75
94
|
};
|
|
76
95
|
}
|
|
77
|
-
this.state.
|
|
78
|
-
|
|
96
|
+
this.state.viewports[viewportId][segmentationRepresentationUID].active =
|
|
97
|
+
true;
|
|
98
|
+
}
|
|
99
|
+
getActiveRepresentation(viewportId) {
|
|
100
|
+
if (!this.state.viewports?.[viewportId]) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const activeSegRep = Object.entries(this.state.viewports[viewportId]).find(([, value]) => value.active);
|
|
104
|
+
if (!activeSegRep) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
return this.getRepresentation(activeSegRep[0]);
|
|
79
108
|
}
|
|
80
109
|
getGlobalConfig() {
|
|
81
110
|
return this.state.globalConfig;
|
|
@@ -83,100 +112,51 @@ export default class SegmentationStateManager {
|
|
|
83
112
|
setGlobalConfig(config) {
|
|
84
113
|
this.state.globalConfig = config;
|
|
85
114
|
}
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
segmentationRepresentationUID);
|
|
90
|
-
return segmentationData;
|
|
91
|
-
}
|
|
92
|
-
removeSegmentation(segmentationId) {
|
|
93
|
-
this.state.segmentations = this.state.segmentations.filter((segmentation) => segmentation.segmentationId !== segmentationId);
|
|
94
|
-
}
|
|
95
|
-
removeSegmentationRepresentation(toolGroupId, segmentationRepresentationUID) {
|
|
96
|
-
const toolGroupSegmentationRepresentations = this.getSegmentationRepresentations(toolGroupId);
|
|
97
|
-
if (!toolGroupSegmentationRepresentations ||
|
|
98
|
-
!toolGroupSegmentationRepresentations.length) {
|
|
99
|
-
throw new Error(`No viewport specific segmentation state found for viewport ${toolGroupId}`);
|
|
100
|
-
}
|
|
101
|
-
const state = toolGroupSegmentationRepresentations;
|
|
102
|
-
const index = state.findIndex((segData) => segData.segmentationRepresentationUID === segmentationRepresentationUID);
|
|
103
|
-
if (index === -1) {
|
|
104
|
-
console.warn(`No viewport specific segmentation state data found for viewport ${toolGroupId} and segmentation data UID ${segmentationRepresentationUID}`);
|
|
105
|
-
}
|
|
106
|
-
const removedSegmentationRepresentation = toolGroupSegmentationRepresentations[index];
|
|
107
|
-
toolGroupSegmentationRepresentations.splice(index, 1);
|
|
108
|
-
this._handleActiveSegmentation(toolGroupId, removedSegmentationRepresentation);
|
|
109
|
-
}
|
|
110
|
-
setActiveSegmentationRepresentation(toolGroupId, segmentationRepresentationUID) {
|
|
111
|
-
const toolGroupSegmentations = this.getSegmentationRepresentations(toolGroupId);
|
|
112
|
-
if (!toolGroupSegmentations || !toolGroupSegmentations.length) {
|
|
113
|
-
throw new Error(`No segmentation data found for toolGroupId: ${toolGroupId}`);
|
|
114
|
-
}
|
|
115
|
-
const segmentationData = toolGroupSegmentations.find((segmentationData) => segmentationData.segmentationRepresentationUID ===
|
|
116
|
-
segmentationRepresentationUID);
|
|
117
|
-
if (!segmentationData) {
|
|
118
|
-
throw new Error(`No segmentation data found for segmentation data UID ${segmentationRepresentationUID}`);
|
|
119
|
-
}
|
|
120
|
-
segmentationData.active = true;
|
|
121
|
-
this._handleActiveSegmentation(toolGroupId, segmentationData);
|
|
122
|
-
}
|
|
123
|
-
getToolGroupSpecificConfig(toolGroupId) {
|
|
124
|
-
const toolGroupStateWithConfig = this.state.toolGroups[toolGroupId];
|
|
125
|
-
if (!toolGroupStateWithConfig) {
|
|
115
|
+
_getRepresentationConfig(segmentationRepresentationUID) {
|
|
116
|
+
const segmentationRepresentation = this.getRepresentation(segmentationRepresentationUID);
|
|
117
|
+
if (!segmentationRepresentation) {
|
|
126
118
|
return;
|
|
127
119
|
}
|
|
128
|
-
return
|
|
120
|
+
return segmentationRepresentation.config;
|
|
129
121
|
}
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
if (!
|
|
122
|
+
getAllSegmentsConfig(segmentationRepresentationUID) {
|
|
123
|
+
const config = this._getRepresentationConfig(segmentationRepresentationUID);
|
|
124
|
+
if (!config) {
|
|
133
125
|
return;
|
|
134
126
|
}
|
|
135
|
-
return
|
|
127
|
+
return config.allSegments;
|
|
136
128
|
}
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
if (!
|
|
129
|
+
getPerSegmentConfig(segmentationRepresentationUID) {
|
|
130
|
+
const config = this._getRepresentationConfig(segmentationRepresentationUID);
|
|
131
|
+
if (!config) {
|
|
140
132
|
return;
|
|
141
133
|
}
|
|
142
|
-
|
|
143
|
-
config;
|
|
134
|
+
return config.perSegment;
|
|
144
135
|
}
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
if (!
|
|
136
|
+
setAllSegmentsConfig(segmentationRepresentationUID, config) {
|
|
137
|
+
const _config = this._getRepresentationConfig(segmentationRepresentationUID);
|
|
138
|
+
if (!_config) {
|
|
148
139
|
return;
|
|
149
140
|
}
|
|
150
|
-
|
|
141
|
+
_config.allSegments = config;
|
|
151
142
|
}
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
if (!
|
|
143
|
+
setPerSegmentConfig(segmentationRepresentationUID, config) {
|
|
144
|
+
const _config = this._getRepresentationConfig(segmentationRepresentationUID);
|
|
145
|
+
if (!_config) {
|
|
155
146
|
return;
|
|
156
147
|
}
|
|
157
|
-
|
|
158
|
-
segmentationRepresentation.segmentSpecificConfig = {};
|
|
159
|
-
}
|
|
160
|
-
Object.keys(config).forEach((key) => {
|
|
161
|
-
segmentationRepresentation.segmentSpecificConfig[key] = config[key];
|
|
162
|
-
});
|
|
148
|
+
_config.perSegment = config;
|
|
163
149
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
representations: {},
|
|
172
|
-
},
|
|
173
|
-
};
|
|
174
|
-
toolGroupStateWithConfig = this.state.toolGroups[toolGroupId];
|
|
150
|
+
getRepresentationVisibility(viewportId, segmentationRepresentationUID) {
|
|
151
|
+
const viewport = this.state.viewports[viewportId];
|
|
152
|
+
return viewport && viewport[segmentationRepresentationUID]?.visible;
|
|
153
|
+
}
|
|
154
|
+
setRepresentationVisibility(viewportId, segmentationRepresentationUID, visible) {
|
|
155
|
+
if (!this.state.viewports[viewportId]) {
|
|
156
|
+
this.state.viewports[viewportId] = {};
|
|
175
157
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
...config,
|
|
179
|
-
};
|
|
158
|
+
this.state.viewports[viewportId][segmentationRepresentationUID].visible =
|
|
159
|
+
visible;
|
|
180
160
|
}
|
|
181
161
|
addColorLUT(colorLUT, lutIndex) {
|
|
182
162
|
if (this.state.colorLUT[lutIndex]) {
|
|
@@ -187,29 +167,6 @@ export default class SegmentationStateManager {
|
|
|
187
167
|
removeColorLUT(colorLUTIndex) {
|
|
188
168
|
delete this.state.colorLUT[colorLUTIndex];
|
|
189
169
|
}
|
|
190
|
-
_handleActiveSegmentation(toolGroupId, recentlyAddedOrRemovedSegmentationRepresentation) {
|
|
191
|
-
const segmentationRepresentations = this.getSegmentationRepresentations(toolGroupId);
|
|
192
|
-
if (segmentationRepresentations.length === 0) {
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
if (segmentationRepresentations.length === 1) {
|
|
196
|
-
segmentationRepresentations[0].active = true;
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
const activeSegmentationRepresentations = segmentationRepresentations.filter((representation) => representation.active);
|
|
200
|
-
if (activeSegmentationRepresentations.length === 0) {
|
|
201
|
-
segmentationRepresentations[0].active = true;
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
if (recentlyAddedOrRemovedSegmentationRepresentation.active) {
|
|
205
|
-
segmentationRepresentations.forEach((representation) => {
|
|
206
|
-
if (representation.segmentationRepresentationUID !==
|
|
207
|
-
recentlyAddedOrRemovedSegmentationRepresentation.segmentationRepresentationUID) {
|
|
208
|
-
representation.active = false;
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
170
|
}
|
|
214
171
|
const defaultSegmentationStateManager = new SegmentationStateManager('DEFAULT');
|
|
215
172
|
export { defaultSegmentationStateManager };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare function
|
|
3
|
-
declare function
|
|
4
|
-
|
|
5
|
-
export { getActiveSegmentationRepresentation, getActiveSegmentation, setActiveSegmentationRepresentation, };
|
|
1
|
+
import { SegmentationRepresentation } from '../../types/SegmentationStateTypes';
|
|
2
|
+
declare function getActiveRepresentation(viewportId: any): SegmentationRepresentation;
|
|
3
|
+
declare function setActiveRepresentation(viewportId: any, segmentationRepresentationUID: any, suppressEvent?: boolean): void;
|
|
4
|
+
export { getActiveRepresentation, setActiveRepresentation, };
|