@cornerstonejs/tools 2.0.0-beta.17 → 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.
Files changed (103) hide show
  1. package/dist/esm/eventListeners/segmentation/imageChangeEventListener.js +11 -14
  2. package/dist/esm/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.js +26 -27
  3. package/dist/esm/eventListeners/segmentation/segmentationDataModifiedEventListener.js +1 -4
  4. package/dist/esm/eventListeners/segmentation/segmentationModifiedEventListener.js +2 -11
  5. package/dist/esm/eventListeners/segmentation/segmentationRepresentationModifiedEventListener.js +10 -2
  6. package/dist/esm/eventListeners/segmentation/segmentationRepresentationRemovedEventListener.js +2 -2
  7. package/dist/esm/index.d.ts +2 -2
  8. package/dist/esm/index.js +2 -2
  9. package/dist/esm/stateManagement/index.d.ts +3 -3
  10. package/dist/esm/stateManagement/index.js +2 -2
  11. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.d.ts +19 -18
  12. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +87 -130
  13. package/dist/esm/stateManagement/segmentation/activeSegmentation.d.ts +4 -5
  14. package/dist/esm/stateManagement/segmentation/activeSegmentation.js +6 -23
  15. package/dist/esm/stateManagement/segmentation/addRepresentation.d.ts +3 -0
  16. package/dist/esm/stateManagement/segmentation/addRepresentation.js +51 -0
  17. package/dist/esm/stateManagement/segmentation/addRepresentations.d.ts +3 -0
  18. package/dist/esm/stateManagement/segmentation/addRepresentations.js +9 -0
  19. package/dist/esm/stateManagement/segmentation/config/index.d.ts +2 -2
  20. package/dist/esm/stateManagement/segmentation/config/index.js +2 -2
  21. package/dist/esm/stateManagement/segmentation/config/segmentationColor.d.ts +4 -4
  22. package/dist/esm/stateManagement/segmentation/config/segmentationColor.js +10 -10
  23. package/dist/esm/stateManagement/segmentation/config/segmentationConfig.d.ts +8 -8
  24. package/dist/esm/stateManagement/segmentation/config/segmentationConfig.js +19 -13
  25. package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.d.ts +7 -6
  26. package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.js +29 -54
  27. package/dist/esm/stateManagement/segmentation/convertStackToVolumeSegmentation.d.ts +1 -1
  28. package/dist/esm/stateManagement/segmentation/convertStackToVolumeSegmentation.js +5 -5
  29. package/dist/esm/stateManagement/segmentation/convertVolumeToStackSegmentation.d.ts +3 -3
  30. package/dist/esm/stateManagement/segmentation/convertVolumeToStackSegmentation.js +5 -5
  31. package/dist/esm/stateManagement/segmentation/helpers/getRepresentationRenderingConfig.d.ts +2 -0
  32. package/dist/esm/stateManagement/segmentation/helpers/{getRepresentationSpecificConfig.js → getRepresentationRenderingConfig.js} +1 -1
  33. package/dist/esm/stateManagement/segmentation/index.d.ts +3 -3
  34. package/dist/esm/stateManagement/segmentation/index.js +3 -3
  35. package/dist/esm/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.js +2 -4
  36. package/dist/esm/stateManagement/segmentation/polySeg/Surface/createAndCacheSurfacesFromRaw.js +5 -6
  37. package/dist/esm/stateManagement/segmentation/polySeg/Surface/updateSurfaceData.js +4 -4
  38. package/dist/esm/stateManagement/segmentation/polySeg/canComputeRequestedRepresentation.js +2 -6
  39. package/dist/esm/stateManagement/segmentation/removeRepresentationsFromViewport.d.ts +2 -0
  40. package/dist/esm/stateManagement/segmentation/removeRepresentationsFromViewport.js +23 -0
  41. package/dist/esm/stateManagement/segmentation/segmentIndex.js +6 -4
  42. package/dist/esm/stateManagement/segmentation/segmentationState.d.ts +23 -20
  43. package/dist/esm/stateManagement/segmentation/segmentationState.js +68 -95
  44. package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.d.ts +2 -2
  45. package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.js +4 -18
  46. package/dist/esm/store/ToolGroupManager/destroyToolGroup.js +0 -4
  47. package/dist/esm/tools/AdvancedMagnifyViewport.js +3 -3
  48. package/dist/esm/tools/annotation/PlanarFreehandROITool.js +0 -2
  49. package/dist/esm/tools/base/ContourSegmentationBaseTool.d.ts +0 -1
  50. package/dist/esm/tools/base/ContourSegmentationBaseTool.js +42 -33
  51. package/dist/esm/tools/displayTools/Contour/contourDisplay.d.ts +4 -4
  52. package/dist/esm/tools/displayTools/Contour/contourDisplay.js +17 -30
  53. package/dist/esm/tools/displayTools/Contour/contourHandler/handleContourSegmentation.d.ts +4 -4
  54. package/dist/esm/tools/displayTools/Contour/contourHandler/handleContourSegmentation.js +20 -11
  55. package/dist/esm/tools/displayTools/Contour/contourHandler/utils.d.ts +0 -2
  56. package/dist/esm/tools/displayTools/Contour/contourHandler/utils.js +0 -11
  57. package/dist/esm/tools/displayTools/Contour/removeContourFromElement.d.ts +1 -1
  58. package/dist/esm/tools/displayTools/Contour/removeContourFromElement.js +3 -3
  59. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.d.ts +5 -5
  60. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +51 -54
  61. package/dist/esm/tools/displayTools/SegmentationRenderingEngine.d.ts +19 -0
  62. package/dist/esm/tools/displayTools/SegmentationRenderingEngine.js +136 -0
  63. package/dist/esm/tools/displayTools/Surface/surfaceDisplay.d.ts +5 -5
  64. package/dist/esm/tools/displayTools/Surface/surfaceDisplay.js +14 -25
  65. package/dist/esm/tools/index.d.ts +1 -2
  66. package/dist/esm/tools/index.js +1 -2
  67. package/dist/esm/tools/segmentation/BrushTool.d.ts +15 -2
  68. package/dist/esm/tools/segmentation/BrushTool.js +13 -14
  69. package/dist/esm/tools/segmentation/CircleScissorsTool.js +3 -4
  70. package/dist/esm/tools/segmentation/PaintFillTool.js +1 -2
  71. package/dist/esm/tools/segmentation/RectangleScissorsTool.js +3 -4
  72. package/dist/esm/tools/segmentation/SegmentSelectTool.d.ts +3 -2
  73. package/dist/esm/tools/segmentation/SegmentSelectTool.js +5 -5
  74. package/dist/esm/tools/segmentation/SphereScissorsTool.js +4 -5
  75. package/dist/esm/tools/segmentation/strategies/compositions/preview.js +2 -2
  76. package/dist/esm/types/EventTypes.d.ts +0 -3
  77. package/dist/esm/types/SegmentationStateTypes.d.ts +24 -23
  78. package/dist/esm/types/index.d.ts +2 -2
  79. package/dist/esm/utilities/segmentation/getSegmentIndexAtLabelmapBorder.d.ts +7 -0
  80. package/dist/esm/utilities/segmentation/{getSegmentAtLabelmapBorder.js → getSegmentIndexAtLabelmapBorder.js} +3 -3
  81. package/dist/esm/utilities/segmentation/getSegmentIndexAtWorldPoint.d.ts +11 -0
  82. package/dist/esm/utilities/segmentation/{getSegmentAtWorldPoint.js → getSegmentIndexAtWorldPoint.js} +7 -7
  83. package/dist/esm/utilities/segmentation/index.d.ts +3 -3
  84. package/dist/esm/utilities/segmentation/index.js +3 -3
  85. package/dist/esm/utilities/segmentation/triggerSegmentationRender.d.ts +2 -17
  86. package/dist/esm/utilities/segmentation/triggerSegmentationRender.js +4 -106
  87. package/dist/esm/utilities/segmentation/triggerSegmentationRenderForViewports.d.ts +3 -0
  88. package/dist/esm/utilities/segmentation/triggerSegmentationRenderForViewports.js +6 -0
  89. package/dist/esm/utilities/triggerAnnotationRenderForViewportIds.js +7 -2
  90. package/dist/umd/index.js +1 -1
  91. package/dist/umd/index.js.map +1 -1
  92. package/package.json +3 -4
  93. package/dist/esm/stateManagement/segmentation/addSegmentationRepresentation.d.ts +0 -3
  94. package/dist/esm/stateManagement/segmentation/addSegmentationRepresentation.js +0 -63
  95. package/dist/esm/stateManagement/segmentation/addSegmentationRepresentations.d.ts +0 -3
  96. package/dist/esm/stateManagement/segmentation/addSegmentationRepresentations.js +0 -14
  97. package/dist/esm/stateManagement/segmentation/helpers/getRepresentationSpecificConfig.d.ts +0 -2
  98. package/dist/esm/stateManagement/segmentation/removeSegmentationsFromToolGroup.d.ts +0 -2
  99. package/dist/esm/stateManagement/segmentation/removeSegmentationsFromToolGroup.js +0 -39
  100. package/dist/esm/tools/displayTools/SegmentationDisplayTool.d.ts +0 -13
  101. package/dist/esm/tools/displayTools/SegmentationDisplayTool.js +0 -101
  102. package/dist/esm/utilities/segmentation/getSegmentAtLabelmapBorder.d.ts +0 -7
  103. package/dist/esm/utilities/segmentation/getSegmentAtWorldPoint.d.ts +0 -11
@@ -1,6 +1,6 @@
1
1
  import { SegmentationRepresentations } from '../../../enums';
2
2
  import { validateLabelmap } from '../../../tools/displayTools/Labelmap';
3
- import { findSegmentationRepresentationByUID, getSegmentation, } from '../segmentationState';
3
+ import { getRepresentation, getSegmentation } from '../segmentationState';
4
4
  const conversionPaths = new Map([
5
5
  [
6
6
  SegmentationRepresentations.Labelmap,
@@ -22,11 +22,7 @@ const conversionPaths = new Map([
22
22
  ],
23
23
  ]);
24
24
  function canComputeRequestedRepresentation(segmentationRepresentationUID) {
25
- const representationInfo = findSegmentationRepresentationByUID(segmentationRepresentationUID);
26
- if (!representationInfo?.segmentationRepresentation) {
27
- return false;
28
- }
29
- const { segmentationRepresentation } = representationInfo;
25
+ const segmentationRepresentation = getRepresentation(segmentationRepresentationUID);
30
26
  const { type: representationType, polySeg } = segmentationRepresentation;
31
27
  if (!polySeg || !polySeg.enabled) {
32
28
  return false;
@@ -0,0 +1,2 @@
1
+ declare function removeRepresentationsFromViewport(viewportId: string, segmentationRepresentationUIDs?: string[] | undefined, immediate?: boolean): void;
2
+ export default removeRepresentationsFromViewport;
@@ -0,0 +1,23 @@
1
+ import SegmentationRepresentations from '../../enums/SegmentationRepresentations';
2
+ import { labelmapDisplay } from '../../tools/displayTools/Labelmap';
3
+ import { contourDisplay } from '../../tools/displayTools/Contour';
4
+ import { getRepresentation } from './segmentationState';
5
+ function removeRepresentationsFromViewport(viewportId, segmentationRepresentationUIDs, immediate) {
6
+ segmentationRepresentationUIDs.forEach((segmentationDataUID) => {
7
+ _removeSegmentation(viewportId, segmentationDataUID, immediate);
8
+ });
9
+ }
10
+ function _removeSegmentation(viewportId, segmentationRepresentationUID, immediate) {
11
+ const segmentationRepresentation = getRepresentation(segmentationRepresentationUID);
12
+ const { type } = segmentationRepresentation;
13
+ if (type === SegmentationRepresentations.Labelmap) {
14
+ labelmapDisplay.removeRepresentation(viewportId, segmentationRepresentationUID, immediate);
15
+ }
16
+ else if (type === SegmentationRepresentations.Contour) {
17
+ contourDisplay.removeRepresentation(viewportId, segmentationRepresentationUID, immediate);
18
+ }
19
+ else {
20
+ throw new Error(`The representation ${type} is not supported yet`);
21
+ }
22
+ }
23
+ export default removeRepresentationsFromViewport;
@@ -1,5 +1,6 @@
1
+ import { getToolGroupForViewport } from '../../store/ToolGroupManager';
1
2
  import { invalidateBrushCursor } from '../../utilities/segmentation/';
2
- import { getSegmentation, getToolGroupIdsWithSegmentation, } from './segmentationState';
3
+ import { getSegmentation, getViewportIdsWithSegmentationId, } from './segmentationState';
3
4
  import { triggerSegmentationModified } from './triggerSegmentationEvents';
4
5
  function setActiveSegmentIndex(segmentationId, segmentIndex) {
5
6
  const segmentation = getSegmentation(segmentationId);
@@ -11,9 +12,10 @@ function setActiveSegmentIndex(segmentationId, segmentIndex) {
11
12
  segmentation.activeSegmentIndex = segmentIndex;
12
13
  triggerSegmentationModified(segmentationId);
13
14
  }
14
- const toolGroups = getToolGroupIdsWithSegmentation(segmentationId);
15
- toolGroups.forEach((toolGroupId) => {
16
- invalidateBrushCursor(toolGroupId);
15
+ const viewportIds = getViewportIdsWithSegmentationId(segmentationId);
16
+ viewportIds.forEach((viewportId) => {
17
+ const toolGroup = getToolGroupForViewport(viewportId);
18
+ invalidateBrushCursor(toolGroup.id);
17
19
  });
18
20
  }
19
21
  function getActiveSegmentIndex(segmentationId) {
@@ -1,33 +1,36 @@
1
1
  import type { Types } from '@cornerstonejs/core';
2
- import type { RepresentationConfig, Segmentation, SegmentationPublicInput, SegmentationRepresentationConfig, SegmentSpecificRepresentationConfig, ToolGroupSpecificRepresentation, ToolGroupSpecificRepresentations } from '../../types/SegmentationStateTypes';
2
+ import type { RepresentationConfig, Segmentation, SegmentationPublicInput, SegmentationRepresentationConfig, SegmentRepresentationConfig, SegmentationRepresentation } from '../../types/SegmentationStateTypes';
3
3
  declare function getDefaultSegmentationStateManager(): import("./SegmentationStateManager").default;
4
4
  declare function getSegmentation(segmentationId: string): Segmentation | undefined;
5
5
  declare function getSegmentations(): Segmentation[] | [];
6
6
  declare function addSegmentation(segmentationInput: SegmentationPublicInput, suppressEvents?: boolean): void;
7
- declare function getSegmentationRepresentations(toolGroupId: string): ToolGroupSpecificRepresentations | [];
8
- declare function getAllSegmentationRepresentations(): Record<string, ToolGroupSpecificRepresentation[]>;
9
- declare function getSegmentationIdRepresentations(segmentationId: any): any[];
10
- declare function findSegmentationRepresentationByUID(segmentationRepresentationUID: string): {
11
- toolGroupId: string;
12
- segmentationRepresentation: ToolGroupSpecificRepresentation;
7
+ declare function getRepresentations(): SegmentationRepresentation[];
8
+ declare function getRepresentation(segmentationRepresentationUID: string): SegmentationRepresentation | undefined;
9
+ declare function getRepresentationsBySegmentationId(segmentationId: string): SegmentationRepresentation[];
10
+ declare function getAllSegmentsConfig(segmentationRepresentationUID: string): RepresentationConfig;
11
+ declare function setAllSegmentsConfig(segmentationRepresentationUID: string, config: RepresentationConfig, suppressEvents?: boolean): void;
12
+ declare function getPerSegmentConfig(segmentationRepresentationUID: string): SegmentRepresentationConfig;
13
+ declare function setPerSegmentConfig(segmentationRepresentationUID: string, config: SegmentRepresentationConfig, suppressEvents?: boolean): void;
14
+ declare function getViewportIdsWithSegmentationId(segmentationId: string): string[];
15
+ declare function getRepresentationsForViewport(viewportId: string): SegmentationRepresentation[] | [];
16
+ declare function getRepresentationsRenderingStateForViewport(viewportId: string): {
17
+ [segRepUID: string]: {
18
+ visible: boolean;
19
+ segmentsHidden: Set<number>;
20
+ active: boolean;
21
+ };
13
22
  };
14
- declare function getToolGroupIdsWithSegmentation(segmentationId: string): string[];
15
- declare function getToolGroupSpecificConfig(toolGroupId: string): SegmentationRepresentationConfig;
16
- declare function setToolGroupSpecificConfig(toolGroupId: string, config: SegmentationRepresentationConfig, suppressEvents?: boolean): void;
17
- declare function setSegmentationRepresentationSpecificConfig(toolGroupId: string, segmentationRepresentationUID: string, config: RepresentationConfig, suppressEvents?: boolean): void;
18
- declare function getSegmentationRepresentationSpecificConfig(toolGroupId: string, segmentationRepresentationUID: string): RepresentationConfig;
19
- declare function getSegmentSpecificRepresentationConfig(toolGroupId: string, segmentationRepresentationUID: string, segmentIndex: number): RepresentationConfig;
20
- declare function setSegmentSpecificRepresentationConfig(toolGroupId: string, segmentationRepresentationUID: string, config: SegmentSpecificRepresentationConfig, suppressEvents?: boolean): void;
21
- declare function getToolGroupIdFromSegmentationRepresentationUID(segmentationRepresentationUID: string): string;
22
- declare function addSegmentationRepresentation(toolGroupId: string, segmentationRepresentation: ToolGroupSpecificRepresentation, suppressEvents?: boolean): void;
23
+ declare function addRepresentationToViewport(viewportId: string, segmentationRepresentation: SegmentationRepresentation, suppressEvents?: boolean): void;
23
24
  declare function getGlobalConfig(): SegmentationRepresentationConfig;
24
25
  declare function setGlobalConfig(config: SegmentationRepresentationConfig, suppressEvents?: boolean): void;
25
- declare function getSegmentationRepresentationByUID(toolGroupId: string, segmentationRepresentationUID: string): ToolGroupSpecificRepresentation | undefined;
26
26
  declare function removeSegmentation(segmentationId: string): void;
27
- declare function removeSegmentationRepresentation(toolGroupId: string, segmentationRepresentationUID: string): void;
28
- declare function removeSegmentationRepresentations(toolGroupId: string): void;
27
+ declare function removeRepresentation(segmentationRepresentationUID: string, suppressEvents?: boolean): void;
29
28
  declare function removeColorLUT(colorLUTIndex: number): void;
30
29
  declare function getColorLUT(index: number): Types.ColorLUT | undefined;
31
30
  declare function getNextColorLUTIndex(): number;
32
31
  declare function addColorLUT(colorLUT: Types.ColorLUT, index: number): void;
33
- export { getDefaultSegmentationStateManager, getSegmentation, getSegmentations, addSegmentation, removeSegmentation, getSegmentationRepresentations, addSegmentationRepresentation, removeSegmentationRepresentation, removeSegmentationRepresentations, getToolGroupSpecificConfig, setToolGroupSpecificConfig, getGlobalConfig, setGlobalConfig, getSegmentationRepresentationSpecificConfig, setSegmentationRepresentationSpecificConfig, getSegmentSpecificRepresentationConfig, setSegmentSpecificRepresentationConfig, getToolGroupIdsWithSegmentation, getAllSegmentationRepresentations, getSegmentationRepresentationByUID, getSegmentationIdRepresentations, addColorLUT, getColorLUT, getNextColorLUTIndex, removeColorLUT, findSegmentationRepresentationByUID, getToolGroupIdFromSegmentationRepresentationUID, };
32
+ declare function getRepresentationVisibility(viewportId: string, segmentationRepresentationUID: string): boolean;
33
+ declare function setRepresentationVisibility(viewportId: string, segmentationRepresentationUID: string, visible: boolean): void;
34
+ declare function getActiveRepresentation(viewportId: string): SegmentationRepresentation | undefined;
35
+ declare function setActiveRepresentation(viewportId: string, segmentationRepresentationUID: string, suppressEvents?: boolean): void;
36
+ export { getDefaultSegmentationStateManager, getSegmentation, getSegmentations, addSegmentation, removeSegmentation, getRepresentations, getRepresentation, removeRepresentation, getGlobalConfig, setGlobalConfig, getAllSegmentsConfig, setAllSegmentsConfig, getPerSegmentConfig, setPerSegmentConfig, getRepresentationsForViewport, addRepresentationToViewport, getRepresentationsRenderingStateForViewport, addColorLUT, getColorLUT, getNextColorLUTIndex, removeColorLUT, getRepresentationsBySegmentationId, getRepresentationVisibility, setRepresentationVisibility, getViewportIdsWithSegmentationId, getActiveRepresentation, setActiveRepresentation, };
@@ -21,109 +21,71 @@ function addSegmentation(segmentationInput, suppressEvents) {
21
21
  triggerSegmentationModified(segmentation.segmentationId);
22
22
  }
23
23
  }
24
- function getSegmentationRepresentations(toolGroupId) {
24
+ function getRepresentations() {
25
25
  const segmentationStateManager = getDefaultSegmentationStateManager();
26
- return segmentationStateManager.getSegmentationRepresentations(toolGroupId);
26
+ const state = segmentationStateManager.getState();
27
+ return Object.values(state.representations);
27
28
  }
28
- function getAllSegmentationRepresentations() {
29
+ function getRepresentation(segmentationRepresentationUID) {
29
30
  const segmentationStateManager = getDefaultSegmentationStateManager();
30
- return segmentationStateManager.getAllSegmentationRepresentations();
31
+ return segmentationStateManager.getRepresentation(segmentationRepresentationUID);
31
32
  }
32
- function getSegmentationIdRepresentations(segmentationId) {
33
- const allRepresentations = getAllSegmentationRepresentations() || {};
34
- const foundRepresentations = [];
35
- for (const toolGroupId in allRepresentations) {
36
- const toolGroupRepresentations = allRepresentations[toolGroupId];
37
- const foundRepresentation = toolGroupRepresentations.find((representation) => representation.segmentationId === segmentationId);
38
- if (foundRepresentation) {
39
- foundRepresentations.push(foundRepresentation);
40
- }
41
- }
42
- return foundRepresentations;
43
- }
44
- function findSegmentationRepresentationByUID(segmentationRepresentationUID) {
45
- const allToolGroupRepresentations = getAllSegmentationRepresentations() || [];
46
- const toolGroupIds = Object.keys(allToolGroupRepresentations);
47
- for (const toolGroupId of toolGroupIds) {
48
- const toolGroupRepresentations = getAllSegmentationRepresentations()[toolGroupId];
49
- const foundRepresentation = toolGroupRepresentations.find((representation) => representation.segmentationRepresentationUID ===
50
- segmentationRepresentationUID);
51
- if (foundRepresentation) {
52
- return {
53
- segmentationRepresentation: foundRepresentation,
54
- toolGroupId,
55
- };
56
- }
57
- }
33
+ function getRepresentationsBySegmentationId(segmentationId) {
34
+ const allRepresentations = getRepresentations();
35
+ return allRepresentations.filter((representation) => representation.segmentationId === segmentationId);
58
36
  }
59
- function getToolGroupIdsWithSegmentation(segmentationId) {
60
- if (!segmentationId) {
61
- throw new Error('getToolGroupIdsWithSegmentation: segmentationId is empty');
62
- }
37
+ function getAllSegmentsConfig(segmentationRepresentationUID) {
63
38
  const segmentationStateManager = getDefaultSegmentationStateManager();
64
- const state = segmentationStateManager.getState();
65
- const toolGroupIds = Object.keys(state.toolGroups);
66
- const foundToolGroupIds = [];
67
- toolGroupIds.forEach((toolGroupId) => {
68
- const toolGroupSegmentationRepresentations = segmentationStateManager.getSegmentationRepresentations(toolGroupId);
69
- toolGroupSegmentationRepresentations.forEach((representation) => {
70
- if (representation.segmentationId === segmentationId) {
71
- foundToolGroupIds.push(toolGroupId);
72
- }
73
- });
74
- });
75
- return foundToolGroupIds;
76
- }
77
- function getToolGroupSpecificConfig(toolGroupId) {
78
- const segmentationStateManager = getDefaultSegmentationStateManager();
79
- return segmentationStateManager.getToolGroupSpecificConfig(toolGroupId);
39
+ return segmentationStateManager.getAllSegmentsConfig(segmentationRepresentationUID);
80
40
  }
81
- function setToolGroupSpecificConfig(toolGroupId, config, suppressEvents) {
41
+ function setAllSegmentsConfig(segmentationRepresentationUID, config, suppressEvents) {
82
42
  const segmentationStateManager = getDefaultSegmentationStateManager();
83
- segmentationStateManager.setSegmentationRepresentationConfig(toolGroupId, config);
43
+ segmentationStateManager.setAllSegmentsConfig(segmentationRepresentationUID, config);
84
44
  if (!suppressEvents) {
85
- triggerSegmentationRepresentationModified(toolGroupId);
45
+ triggerSegmentationRepresentationModified(segmentationRepresentationUID);
86
46
  }
87
47
  }
88
- function setSegmentationRepresentationSpecificConfig(toolGroupId, segmentationRepresentationUID, config, suppressEvents = false) {
48
+ function getPerSegmentConfig(segmentationRepresentationUID) {
89
49
  const segmentationStateManager = getDefaultSegmentationStateManager();
90
- segmentationStateManager.setSegmentationRepresentationSpecificConfig(toolGroupId, segmentationRepresentationUID, config);
91
- if (!suppressEvents) {
92
- triggerSegmentationRepresentationModified(toolGroupId, segmentationRepresentationUID);
93
- }
50
+ return segmentationStateManager.getPerSegmentConfig(segmentationRepresentationUID);
94
51
  }
95
- function getSegmentationRepresentationSpecificConfig(toolGroupId, segmentationRepresentationUID) {
52
+ function setPerSegmentConfig(segmentationRepresentationUID, config, suppressEvents) {
96
53
  const segmentationStateManager = getDefaultSegmentationStateManager();
97
- return segmentationStateManager.getSegmentationRepresentationSpecificConfig(toolGroupId, segmentationRepresentationUID);
54
+ segmentationStateManager.setPerSegmentConfig(segmentationRepresentationUID, config);
55
+ if (!suppressEvents) {
56
+ triggerSegmentationRepresentationModified(segmentationRepresentationUID);
57
+ }
98
58
  }
99
- function getSegmentSpecificRepresentationConfig(toolGroupId, segmentationRepresentationUID, segmentIndex) {
59
+ function getViewportIdsWithSegmentationId(segmentationId) {
100
60
  const segmentationStateManager = getDefaultSegmentationStateManager();
101
- return segmentationStateManager.getSegmentSpecificConfig(toolGroupId, segmentationRepresentationUID, segmentIndex);
61
+ const state = segmentationStateManager.getState();
62
+ const viewports = state.viewports;
63
+ return Object.keys(viewports).filter((viewportId) => {
64
+ const viewport = viewports[viewportId];
65
+ return Object.keys(viewport).some((segRepUID) => state.representations[segRepUID].segmentationId === segmentationId);
66
+ });
102
67
  }
103
- function setSegmentSpecificRepresentationConfig(toolGroupId, segmentationRepresentationUID, config, suppressEvents = false) {
104
- const segmentationStateManager = getDefaultSegmentationStateManager();
105
- segmentationStateManager.setSegmentSpecificConfig(toolGroupId, segmentationRepresentationUID, config);
106
- if (!suppressEvents) {
107
- triggerSegmentationRepresentationModified(toolGroupId, segmentationRepresentationUID);
68
+ function getRepresentationsForViewport(viewportId) {
69
+ const viewportRenderingState = getRepresentationsRenderingStateForViewport(viewportId);
70
+ if (!viewportRenderingState) {
71
+ return [];
108
72
  }
73
+ const segRepUIDs = Object.keys(viewportRenderingState);
74
+ return segRepUIDs
75
+ .map((segRepUID) => getRepresentation(segRepUID))
76
+ .filter(Boolean);
109
77
  }
110
- function getToolGroupIdFromSegmentationRepresentationUID(segmentationRepresentationUID) {
111
- const allToolGroupRepresentations = getAllSegmentationRepresentations() || [];
112
- const toolGroupIds = Object.keys(allToolGroupRepresentations);
113
- for (const toolGroupId of toolGroupIds) {
114
- const toolGroupRepresentations = getAllSegmentationRepresentations()[toolGroupId];
115
- const foundRepresentation = toolGroupRepresentations.find((representation) => representation.segmentationRepresentationUID ===
116
- segmentationRepresentationUID);
117
- if (foundRepresentation) {
118
- return toolGroupId;
119
- }
120
- }
78
+ function getRepresentationsRenderingStateForViewport(viewportId) {
79
+ const segmentationStateManager = getDefaultSegmentationStateManager();
80
+ const state = segmentationStateManager.getState();
81
+ return state.viewports?.[viewportId] || {};
121
82
  }
122
- function addSegmentationRepresentation(toolGroupId, segmentationRepresentation, suppressEvents) {
83
+ function addRepresentationToViewport(viewportId, segmentationRepresentation, suppressEvents) {
123
84
  const segmentationStateManager = getDefaultSegmentationStateManager();
124
- segmentationStateManager.addSegmentationRepresentation(toolGroupId, segmentationRepresentation);
85
+ segmentationStateManager.addRepresentation(segmentationRepresentation);
86
+ segmentationStateManager.addRepresentationToViewport(viewportId, segmentationRepresentation.segmentationRepresentationUID);
125
87
  if (!suppressEvents) {
126
- triggerSegmentationRepresentationModified(toolGroupId, segmentationRepresentation.segmentationRepresentationUID);
88
+ triggerSegmentationRepresentationModified(segmentationRepresentation.segmentationRepresentationUID);
127
89
  }
128
90
  }
129
91
  function getGlobalConfig() {
@@ -137,25 +99,17 @@ function setGlobalConfig(config, suppressEvents) {
137
99
  triggerSegmentationModified();
138
100
  }
139
101
  }
140
- function getSegmentationRepresentationByUID(toolGroupId, segmentationRepresentationUID) {
141
- const segmentationStateManager = getDefaultSegmentationStateManager();
142
- return segmentationStateManager.getSegmentationRepresentationByUID(toolGroupId, segmentationRepresentationUID);
143
- }
144
102
  function removeSegmentation(segmentationId) {
145
103
  const segmentationStateManager = getDefaultSegmentationStateManager();
146
104
  segmentationStateManager.removeSegmentation(segmentationId);
147
105
  triggerSegmentationRemoved(segmentationId);
148
106
  }
149
- function removeSegmentationRepresentation(toolGroupId, segmentationRepresentationUID) {
107
+ function removeRepresentation(segmentationRepresentationUID, suppressEvents) {
150
108
  const segmentationStateManager = getDefaultSegmentationStateManager();
151
- segmentationStateManager.removeSegmentationRepresentation(toolGroupId, segmentationRepresentationUID);
152
- triggerSegmentationRepresentationRemoved(toolGroupId, segmentationRepresentationUID);
153
- }
154
- function removeSegmentationRepresentations(toolGroupId) {
155
- const segmentationRepresentations = getSegmentationRepresentations(toolGroupId) || [];
156
- segmentationRepresentations.forEach((representation) => {
157
- removeSegmentationRepresentation(toolGroupId, representation.segmentationRepresentationUID);
158
- });
109
+ segmentationStateManager.removeRepresentation(segmentationRepresentationUID);
110
+ if (!suppressEvents) {
111
+ triggerSegmentationRepresentationRemoved(segmentationRepresentationUID);
112
+ }
159
113
  }
160
114
  function removeColorLUT(colorLUTIndex) {
161
115
  const segmentationStateManager = getDefaultSegmentationStateManager();
@@ -173,4 +127,23 @@ function addColorLUT(colorLUT, index) {
173
127
  const segmentationStateManager = getDefaultSegmentationStateManager();
174
128
  segmentationStateManager.addColorLUT(colorLUT, index);
175
129
  }
176
- export { getDefaultSegmentationStateManager, getSegmentation, getSegmentations, addSegmentation, removeSegmentation, getSegmentationRepresentations, addSegmentationRepresentation, removeSegmentationRepresentation, removeSegmentationRepresentations, getToolGroupSpecificConfig, setToolGroupSpecificConfig, getGlobalConfig, setGlobalConfig, getSegmentationRepresentationSpecificConfig, setSegmentationRepresentationSpecificConfig, getSegmentSpecificRepresentationConfig, setSegmentSpecificRepresentationConfig, getToolGroupIdsWithSegmentation, getAllSegmentationRepresentations, getSegmentationRepresentationByUID, getSegmentationIdRepresentations, addColorLUT, getColorLUT, getNextColorLUTIndex, removeColorLUT, findSegmentationRepresentationByUID, getToolGroupIdFromSegmentationRepresentationUID, };
130
+ function getRepresentationVisibility(viewportId, segmentationRepresentationUID) {
131
+ const segmentationStateManager = getDefaultSegmentationStateManager();
132
+ return segmentationStateManager.getRepresentationVisibility(viewportId, segmentationRepresentationUID);
133
+ }
134
+ function setRepresentationVisibility(viewportId, segmentationRepresentationUID, visible) {
135
+ const segmentationStateManager = getDefaultSegmentationStateManager();
136
+ segmentationStateManager.setRepresentationVisibility(viewportId, segmentationRepresentationUID, visible);
137
+ }
138
+ function getActiveRepresentation(viewportId) {
139
+ const segmentationStateManager = getDefaultSegmentationStateManager();
140
+ return segmentationStateManager.getActiveRepresentation(viewportId);
141
+ }
142
+ function setActiveRepresentation(viewportId, segmentationRepresentationUID, suppressEvents) {
143
+ const segmentationStateManager = getDefaultSegmentationStateManager();
144
+ segmentationStateManager.setActiveRepresentation(viewportId, segmentationRepresentationUID);
145
+ if (!suppressEvents) {
146
+ triggerSegmentationRepresentationModified(segmentationRepresentationUID);
147
+ }
148
+ }
149
+ export { getDefaultSegmentationStateManager, getSegmentation, getSegmentations, addSegmentation, removeSegmentation, getRepresentations, getRepresentation, removeRepresentation, getGlobalConfig, setGlobalConfig, getAllSegmentsConfig, setAllSegmentsConfig, getPerSegmentConfig, setPerSegmentConfig, getRepresentationsForViewport, addRepresentationToViewport, getRepresentationsRenderingStateForViewport, addColorLUT, getColorLUT, getNextColorLUTIndex, removeColorLUT, getRepresentationsBySegmentationId, getRepresentationVisibility, setRepresentationVisibility, getViewportIdsWithSegmentationId, getActiveRepresentation, setActiveRepresentation, };
@@ -1,6 +1,6 @@
1
1
  declare function triggerSegmentationRemoved(segmentationId: string): void;
2
- declare function triggerSegmentationRepresentationRemoved(toolGroupId: string, segmentationRepresentationUID: string): void;
3
- declare function triggerSegmentationRepresentationModified(toolGroupId: string, segmentationRepresentationUID?: string): void;
2
+ declare function triggerSegmentationRepresentationRemoved(segmentationRepresentationUID: string): void;
3
+ declare function triggerSegmentationRepresentationModified(segmentationRepresentationUID: string): void;
4
4
  declare function triggerSegmentationModified(segmentationId?: string): void;
5
5
  declare function triggerSegmentationDataModified(segmentationId: string, modifiedSlicesToUse?: number[]): void;
6
6
  export { triggerSegmentationRepresentationModified, triggerSegmentationRepresentationRemoved, triggerSegmentationDataModified, triggerSegmentationModified, triggerSegmentationRemoved, };
@@ -1,6 +1,6 @@
1
1
  import { triggerEvent, eventTarget } from '@cornerstonejs/core';
2
2
  import { Events } from '../../enums';
3
- import { getSegmentationRepresentations, getSegmentations, } from '../../stateManagement/segmentation/segmentationState';
3
+ import { getSegmentations } from '../../stateManagement/segmentation/segmentationState';
4
4
  import { setSegmentationDirty } from '../../utilities/segmentation/getUniqueSegmentIndices';
5
5
  function triggerSegmentationRemoved(segmentationId) {
6
6
  const eventDetail = {
@@ -8,31 +8,17 @@ function triggerSegmentationRemoved(segmentationId) {
8
8
  };
9
9
  triggerEvent(eventTarget, Events.SEGMENTATION_REMOVED, eventDetail);
10
10
  }
11
- function triggerSegmentationRepresentationRemoved(toolGroupId, segmentationRepresentationUID) {
11
+ function triggerSegmentationRepresentationRemoved(segmentationRepresentationUID) {
12
12
  const eventDetail = {
13
- toolGroupId,
14
13
  segmentationRepresentationUID,
15
14
  };
16
15
  triggerEvent(eventTarget, Events.SEGMENTATION_REPRESENTATION_REMOVED, eventDetail);
17
16
  }
18
- function triggerSegmentationRepresentationModified(toolGroupId, segmentationRepresentationUID) {
17
+ function triggerSegmentationRepresentationModified(segmentationRepresentationUID) {
19
18
  const eventDetail = {
20
- toolGroupId,
21
19
  segmentationRepresentationUID,
22
20
  };
23
- if (segmentationRepresentationUID) {
24
- triggerEvent(eventTarget, Events.SEGMENTATION_REPRESENTATION_MODIFIED, eventDetail);
25
- return;
26
- }
27
- const segmentationRepresentations = getSegmentationRepresentations(toolGroupId) || [];
28
- segmentationRepresentations.forEach((segmentationRepresentation) => {
29
- const { segmentationRepresentationUID } = segmentationRepresentation;
30
- const eventDetail = {
31
- toolGroupId,
32
- segmentationRepresentationUID,
33
- };
34
- triggerEvent(eventTarget, Events.SEGMENTATION_REPRESENTATION_MODIFIED, eventDetail);
35
- });
21
+ triggerEvent(eventTarget, Events.SEGMENTATION_REPRESENTATION_MODIFIED, eventDetail);
36
22
  }
37
23
  function triggerSegmentationModified(segmentationId) {
38
24
  let segmentationIds;
@@ -1,11 +1,7 @@
1
1
  import { state } from '../index';
2
- import { removeSegmentationsFromToolGroup } from '../../stateManagement/segmentation';
3
- import { segmentationRenderingEngine } from '../../utilities/segmentation/triggerSegmentationRender';
4
2
  function destroyToolGroup(toolGroupId) {
5
3
  const toolGroupIndex = state.toolGroups.findIndex((tg) => tg.id === toolGroupId);
6
4
  if (toolGroupIndex > -1) {
7
- segmentationRenderingEngine.removeToolGroup(toolGroupId);
8
- removeSegmentationsFromToolGroup(toolGroupId);
9
5
  state.toolGroups.splice(toolGroupIndex, 1);
10
6
  }
11
7
  }
@@ -4,7 +4,7 @@ import { SegmentationRepresentations, ToolModes, Events as cstEvents, } from '..
4
4
  import { ToolGroupManager, state } from '../store';
5
5
  import { debounce } from '../utilities';
6
6
  import { segmentation } from '..';
7
- import { AnnotationTool, AdvancedMagnifyTool, SegmentationDisplayTool, } from './';
7
+ import { AnnotationTool, AdvancedMagnifyTool } from './';
8
8
  import { distanceToPoint } from '../utilities/math/point';
9
9
  const MAGNIFY_CLASSNAME = 'advancedMagnifyTool';
10
10
  const MAGNIFY_VIEWPORT_INITIAL_RADIUS = 125;
@@ -147,11 +147,11 @@ class AdvancedMagnifyViewport {
147
147
  const toolInstance = sourceToolGroup.getToolInstance(toolName);
148
148
  const isAnnotationTool = toolInstance instanceof AnnotationTool &&
149
149
  !(toolInstance instanceof AdvancedMagnifyTool);
150
- return (isAnnotationTool || toolName === SegmentationDisplayTool.toolName);
150
+ return isAnnotationTool;
151
151
  });
152
152
  magnifyToolGroup.addViewport(magnifyViewport.id, magnifyViewport.renderingEngineId);
153
153
  sourceActors.filter(isSegmentation).forEach((actor) => {
154
- segmentation.addSegmentationRepresentations(magnifyToolGroupId, [
154
+ segmentation.addRepresentations(this.viewportId, [
155
155
  {
156
156
  segmentationId: actor.referencedId,
157
157
  type: SegmentationRepresentations.Labelmap,
@@ -70,8 +70,6 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
70
70
  this.addNewAnnotation = (evt) => {
71
71
  const eventDetail = evt.detail;
72
72
  const { element } = eventDetail;
73
- const enabledElement = getEnabledElement(element);
74
- const { renderingEngine } = enabledElement;
75
73
  const annotation = this.createAnnotation(evt);
76
74
  this.addAnnotation(annotation, element);
77
75
  const viewportIdsToRender = getViewportIdsWithToolToRender(element, this.getToolName());
@@ -13,6 +13,5 @@ declare abstract class ContourSegmentationBaseTool extends ContourBaseTool {
13
13
  }): any;
14
14
  protected renderAnnotationInstance(renderContext: AnnotationRenderContext): boolean;
15
15
  private _getContourSegmentationStyle;
16
- private _getSegmentationRepresentation;
17
16
  }
18
17
  export { ContourSegmentationBaseTool as default, ContourSegmentationBaseTool };
@@ -1,12 +1,13 @@
1
- import { utilities } from '@cornerstonejs/core';
1
+ import { getEnabledElement, utilities } from '@cornerstonejs/core';
2
2
  import { config as segmentationConfig, state as segmentationState, segmentLocking, segmentIndex as segmentIndexController, activeSegmentation, } from '../../stateManagement/segmentation';
3
3
  import { SegmentationRepresentations } from '../../enums';
4
4
  import ContourBaseTool from './ContourBaseTool';
5
5
  import { triggerSegmentationDataModified } from '../../stateManagement/segmentation/triggerSegmentationEvents';
6
6
  import { InterpolationManager } from '../../utilities/contours/interpolation';
7
7
  import { addContourSegmentationAnnotation, removeContourSegmentationAnnotation, } from '../../utilities/contourSegmentation';
8
- import { getToolGroupIdsWithSegmentation } from '../../stateManagement/segmentation/segmentationState';
9
8
  import { triggerAnnotationRenderForToolGroupIds } from '../../utilities';
9
+ import { getActiveRepresentation, getRepresentationsBySegmentationId, getRepresentationsForViewport, getViewportIdsWithSegmentationId, } from '../../stateManagement/segmentation/segmentationState';
10
+ import { getToolGroupForViewport } from '../../store/ToolGroupManager';
10
11
  class ContourSegmentationBaseTool extends ContourBaseTool {
11
12
  constructor(toolProps, defaultToolProps) {
12
13
  super(toolProps, defaultToolProps);
@@ -18,20 +19,26 @@ class ContourSegmentationBaseTool extends ContourBaseTool {
18
19
  return true;
19
20
  }
20
21
  createAnnotation(evt) {
21
- const { toolGroupId } = this;
22
+ const eventDetail = evt.detail;
23
+ const { element } = eventDetail;
24
+ const enabledElement = getEnabledElement(element);
25
+ if (!enabledElement) {
26
+ return;
27
+ }
28
+ const { viewport } = enabledElement;
22
29
  const contourAnnotation = super.createAnnotation(evt);
23
30
  if (!this.isContourSegmentationTool()) {
24
31
  return contourAnnotation;
25
32
  }
26
- const activeSegmentationRepresentation = activeSegmentation.getActiveSegmentationRepresentation(toolGroupId);
27
- if (!activeSegmentationRepresentation) {
33
+ const activeSeg = activeSegmentation.getActiveRepresentation(viewport.id);
34
+ if (!activeSeg) {
28
35
  throw new Error('No active segmentation detected, create one before using scissors tool');
29
36
  }
30
- const { type: segmentationType } = activeSegmentationRepresentation;
37
+ const { type: segmentationType } = activeSeg;
31
38
  if (segmentationType !== SegmentationRepresentations.Contour) {
32
39
  throw new Error(`A contour segmentation must be active`);
33
40
  }
34
- const { segmentationId } = activeSegmentationRepresentation;
41
+ const { segmentationId } = activeSeg;
35
42
  const segmentIndex = segmentIndexController.getActiveSegmentIndex(segmentationId);
36
43
  return utilities.deepMerge(contourAnnotation, {
37
44
  data: {
@@ -71,33 +78,48 @@ class ContourSegmentationBaseTool extends ContourBaseTool {
71
78
  if (invalidated && this.isContourSegmentationTool()) {
72
79
  const { segmentationId } = (annotation).data.segmentation;
73
80
  triggerSegmentationDataModified(segmentationId);
74
- const toolGroupIds = getToolGroupIdsWithSegmentation(segmentationId);
81
+ const viewportIds = getViewportIdsWithSegmentationId(segmentationId);
82
+ const toolGroupIds = viewportIds.map((viewportId) => {
83
+ const toolGroup = getToolGroupForViewport(viewportId);
84
+ return toolGroup.id;
85
+ });
75
86
  triggerAnnotationRenderForToolGroupIds(toolGroupIds);
76
87
  }
77
88
  return renderResult;
78
89
  }
79
90
  _getContourSegmentationStyle(context) {
80
- const { toolGroupId } = this;
81
91
  const annotation = context.annotation;
82
92
  const { segmentationId, segmentIndex } = annotation.data.segmentation;
83
93
  const segmentation = segmentationState.getSegmentation(segmentationId);
84
- const segmentationRepresentation = this._getSegmentationRepresentation(segmentationId);
85
- if (!segmentationRepresentation) {
94
+ const segmentationRepresentations = getRepresentationsBySegmentationId(segmentationId);
95
+ if (!segmentationRepresentations?.length) {
86
96
  return {};
87
97
  }
98
+ const allUIDs = segmentationRepresentations.map((rep) => rep.segmentationRepresentationUID);
99
+ let segmentationRepresentation;
100
+ if (segmentationRepresentations.length > 1) {
101
+ const viewportReps = getRepresentationsForViewport(context.styleSpecifier.viewportId);
102
+ segmentationRepresentation = viewportReps.find((rep) => rep.segmentationId === segmentationId &&
103
+ allUIDs.includes(rep.segmentationRepresentationUID));
104
+ }
105
+ else {
106
+ segmentationRepresentation = segmentationRepresentations[0];
107
+ }
88
108
  const { segmentationRepresentationUID } = segmentationRepresentation;
89
- const { active } = segmentationRepresentation;
90
109
  const { autoGenerated } = annotation;
91
110
  const segmentsLocked = segmentLocking.getLockedSegments(segmentationId);
92
111
  const annotationLocked = segmentsLocked.includes(segmentIndex);
93
- const segmentColor = segmentationConfig.color.getColorForSegmentIndex(toolGroupId, segmentationRepresentationUID, segmentIndex);
94
- const segmentationVisible = segmentationConfig.visibility.getSegmentationVisibility(toolGroupId, segmentationRepresentationUID);
112
+ const segmentColor = segmentationConfig.color.getSegmentIndexColor(segmentationRepresentationUID, segmentIndex);
113
+ const viewportId = context.styleSpecifier.viewportId;
114
+ const segmentationVisible = segmentationConfig.visibility.getRepresentationVisibility(viewportId, segmentationRepresentationUID);
95
115
  const globalConfig = segmentationConfig.getGlobalConfig();
96
- const toolGroupConfig = segmentationConfig.getToolGroupSpecificConfig(toolGroupId);
97
- const segmentationRepresentationConfig = segmentationConfig.getSegmentationRepresentationSpecificConfig(toolGroupId, segmentationRepresentationUID);
98
- const segmentConfig = segmentationConfig.getSegmentSpecificConfig(toolGroupId, segmentationRepresentationUID, segmentIndex);
99
- const segmentVisible = segmentationConfig.visibility.getSegmentVisibility(toolGroupId, segmentationRepresentationUID, segmentIndex);
100
- const mergedConfig = Object.assign({}, globalConfig?.representations?.CONTOUR ?? {}, toolGroupConfig?.representations?.CONTOUR ?? {}, segmentationRepresentationConfig?.CONTOUR ?? {}, segmentConfig?.CONTOUR ?? {});
116
+ const getAllSegmentsConfig = segmentationConfig.getAllSegmentsConfig(segmentationRepresentationUID);
117
+ const segmentConfig = segmentationConfig.getSegmentIndexConfig(segmentationRepresentationUID, segmentIndex);
118
+ const segmentVisible = segmentationConfig.visibility.getSegmentIndexVisibility(viewportId, segmentationRepresentationUID, segmentIndex);
119
+ const activeSegRep = getActiveRepresentation(viewportId);
120
+ const isActive = activeSegRep.segmentationRepresentationUID ===
121
+ segmentationRepresentationUID;
122
+ const mergedConfig = Object.assign({}, globalConfig?.representations?.CONTOUR ?? {}, getAllSegmentsConfig?.CONTOUR ?? {}, segmentConfig?.CONTOUR ?? {});
101
123
  let lineWidth = 1;
102
124
  let lineDash = undefined;
103
125
  let lineOpacity = 1;
@@ -108,7 +130,7 @@ class ContourSegmentationBaseTool extends ContourBaseTool {
108
130
  lineOpacity = mergedConfig.outlineOpacity ?? lineOpacity;
109
131
  fillOpacity = mergedConfig.fillAlphaAutoGenerated ?? fillOpacity;
110
132
  }
111
- else if (active) {
133
+ else if (isActive) {
112
134
  lineWidth = mergedConfig.outlineWidthActive ?? lineWidth;
113
135
  lineDash = mergedConfig.outlineDashActive ?? lineDash;
114
136
  lineOpacity = mergedConfig.outlineOpacity ?? lineOpacity;
@@ -140,18 +162,5 @@ class ContourSegmentationBaseTool extends ContourBaseTool {
140
162
  locked: annotationLocked,
141
163
  };
142
164
  }
143
- _getSegmentationRepresentation(segmentationId) {
144
- const segmentationRepresentations = segmentationState.getSegmentationRepresentations(this.toolGroupId);
145
- const validSegmentationRepresentations = segmentationRepresentations.filter((representation) => representation.segmentationId === segmentationId);
146
- if (!validSegmentationRepresentations) {
147
- console.warn(`No segmentation representation found for toolGroupId: ${this.toolGroupId}`);
148
- return;
149
- }
150
- if (segmentationState.getSegmentationRepresentations(this.toolGroupId)
151
- .length > 1) {
152
- console.warn('Multiple segmentation representations detected for this tool group. The first one will be used.');
153
- }
154
- return validSegmentationRepresentations[0];
155
- }
156
165
  }
157
166
  export { ContourSegmentationBaseTool as default, ContourSegmentationBaseTool };
@@ -1,9 +1,9 @@
1
1
  import { StackViewport, Types } from '@cornerstonejs/core';
2
- import { SegmentationRepresentationConfig, ToolGroupSpecificRepresentation } from '../../../types/SegmentationStateTypes';
3
- declare function removeSegmentationRepresentation(toolGroupId: string, segmentationRepresentationUID: string, renderImmediate?: boolean): void;
4
- declare function render(viewport: StackViewport | Types.IVolumeViewport, representationConfig: ToolGroupSpecificRepresentation, toolGroupConfig: SegmentationRepresentationConfig): Promise<void>;
2
+ import { ContourRepresentation } from '../../../types/SegmentationStateTypes';
3
+ declare function removeRepresentation(viewportId: string, segmentationRepresentationUID: string, renderImmediate?: boolean): void;
4
+ declare function render(viewport: StackViewport | Types.IVolumeViewport, contourRepresentation: ContourRepresentation): Promise<void>;
5
5
  declare const _default: {
6
6
  render: typeof render;
7
- removeSegmentationRepresentation: typeof removeSegmentationRepresentation;
7
+ removeRepresentation: typeof removeRepresentation;
8
8
  };
9
9
  export default _default;