@cornerstonejs/tools 2.0.0-beta.24 → 2.0.0-beta.26

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 (55) hide show
  1. package/dist/esm/enums/SegmentationRepresentations.d.ts +3 -3
  2. package/dist/esm/enums/SegmentationRepresentations.js +3 -3
  3. package/dist/esm/eventDispatchers/mouseEventHandlers/mouseMove.js +4 -0
  4. package/dist/esm/stateManagement/index.d.ts +3 -2
  5. package/dist/esm/stateManagement/index.js +2 -2
  6. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.d.ts +6 -6
  7. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +14 -14
  8. package/dist/esm/stateManagement/segmentation/addSegmentationRepresentations.d.ts +8 -3
  9. package/dist/esm/stateManagement/segmentation/addSegmentationRepresentations.js +14 -4
  10. package/dist/esm/stateManagement/segmentation/config/segmentationConfig.d.ts +8 -7
  11. package/dist/esm/stateManagement/segmentation/convertVolumeToStackSegmentation.js +1 -1
  12. package/dist/esm/stateManagement/segmentation/getGlobalConfig.d.ts +2 -2
  13. package/dist/esm/stateManagement/segmentation/getPerSegmentConfig.d.ts +2 -2
  14. package/dist/esm/stateManagement/segmentation/helpers/updateStackSegmentationState.js +5 -5
  15. package/dist/esm/stateManagement/segmentation/index.d.ts +2 -2
  16. package/dist/esm/stateManagement/segmentation/index.js +2 -2
  17. package/dist/esm/stateManagement/segmentation/internalAddSegmentationRepresentation.d.ts +3 -0
  18. package/dist/esm/stateManagement/segmentation/{addSegmentationRepresentation.js → internalAddSegmentationRepresentation.js} +4 -3
  19. package/dist/esm/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.js +4 -4
  20. package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/labelmapComputationStrategies.js +4 -4
  21. package/dist/esm/stateManagement/segmentation/polySeg/Surface/createAndCacheSurfacesFromRaw.js +1 -1
  22. package/dist/esm/stateManagement/segmentation/polySeg/Surface/surfaceComputationStrategies.js +6 -6
  23. package/dist/esm/stateManagement/segmentation/polySeg/Surface/updateSurfaceData.js +2 -2
  24. package/dist/esm/stateManagement/segmentation/segmentationState.d.ts +1 -2
  25. package/dist/esm/stateManagement/segmentation/segmentationState.js +1 -2
  26. package/dist/esm/stateManagement/segmentation/setGlobalConfig.d.ts +2 -2
  27. package/dist/esm/stateManagement/segmentation/setPerSegmentConfig.d.ts +2 -2
  28. package/dist/esm/store/ToolGroupManager/ToolGroup.d.ts +1 -1
  29. package/dist/esm/tools/AdvancedMagnifyTool.js +2 -2
  30. package/dist/esm/tools/ScaleOverlayTool.js +23 -20
  31. package/dist/esm/tools/annotation/LivewireContourTool.d.ts +5 -0
  32. package/dist/esm/tools/annotation/LivewireContourTool.js +156 -8
  33. package/dist/esm/tools/base/BaseTool.d.ts +1 -13
  34. package/dist/esm/tools/base/ContourSegmentationBaseTool.js +1 -1
  35. package/dist/esm/tools/displayTools/Contour/contourHandler/handleContourSegmentation.js +4 -4
  36. package/dist/esm/tools/displayTools/Contour/contourHandler/utils.js +1 -1
  37. package/dist/esm/tools/displayTools/Contour/removeContourFromElement.js +1 -1
  38. package/dist/esm/tools/segmentation/CircleROIStartEndThresholdTool.js +23 -15
  39. package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js +12 -0
  40. package/dist/esm/types/EventTypes.d.ts +1 -2
  41. package/dist/esm/types/IBaseTool.d.ts +2 -0
  42. package/dist/esm/types/IBaseTool.js +1 -0
  43. package/dist/esm/types/IToolGroup.d.ts +3 -63
  44. package/dist/esm/types/SegmentationStateTypes.d.ts +22 -22
  45. package/dist/esm/types/index.d.ts +3 -2
  46. package/dist/esm/utilities/contourSegmentation/addContourSegmentationAnnotation.js +3 -3
  47. package/dist/esm/utilities/contourSegmentation/removeContourSegmentationAnnotation.js +1 -1
  48. package/dist/esm/utilities/segmentation/getHoveredContourSegmentationAnnotation.js +1 -1
  49. package/dist/esm/utilities/segmentation/getSegmentIndexAtLabelmapBorder.js +1 -1
  50. package/dist/esm/utilities/segmentation/getSegmentIndexAtWorldPoint.js +2 -2
  51. package/dist/esm/utilities/segmentation/getUniqueSegmentIndices.js +2 -2
  52. package/dist/umd/index.js +1 -1
  53. package/dist/umd/index.js.map +1 -1
  54. package/package.json +16 -7
  55. package/dist/esm/stateManagement/segmentation/addSegmentationRepresentation.d.ts +0 -3
@@ -1,6 +1,6 @@
1
1
  declare enum SegmentationRepresentations {
2
- Labelmap = "LABELMAP",
3
- Contour = "CONTOUR",
4
- Surface = "SURFACE"
2
+ Labelmap = "Labelmap",
3
+ Contour = "Contour",
4
+ Surface = "Surface"
5
5
  }
6
6
  export default SegmentationRepresentations;
@@ -1,7 +1,7 @@
1
1
  var SegmentationRepresentations;
2
2
  (function (SegmentationRepresentations) {
3
- SegmentationRepresentations["Labelmap"] = "LABELMAP";
4
- SegmentationRepresentations["Contour"] = "CONTOUR";
5
- SegmentationRepresentations["Surface"] = "SURFACE";
3
+ SegmentationRepresentations["Labelmap"] = "Labelmap";
4
+ SegmentationRepresentations["Contour"] = "Contour";
5
+ SegmentationRepresentations["Surface"] = "Surface";
6
6
  })(SegmentationRepresentations || (SegmentationRepresentations = {}));
7
7
  export default SegmentationRepresentations;
@@ -3,6 +3,7 @@ import { ToolModes } from '../../enums';
3
3
  import filterToolsWithAnnotationsForElement from '../../store/filterToolsWithAnnotationsForElement';
4
4
  import getToolsWithModesForMouseEvent from '../shared/getToolsWithModesForMouseEvent';
5
5
  import triggerAnnotationRender from '../../utilities/triggerAnnotationRender';
6
+ import { initElementCursor } from '../../cursors/elementCursor';
6
7
  const { Active, Passive } = ToolModes;
7
8
  export default function mouseMove(evt) {
8
9
  if (state.isInteractingWithTool || state.isMultiPartToolActive) {
@@ -34,4 +35,7 @@ export default function mouseMove(evt) {
34
35
  if (annotationsNeedToBeRedrawn === true) {
35
36
  triggerAnnotationRender(element);
36
37
  }
38
+ if (!state.isInteractingWithTool) {
39
+ initElementCursor(element, null);
40
+ }
37
41
  }
@@ -15,6 +15,7 @@ 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 addSegmentationRepresentations from './segmentation/addSegmentationRepresentations';
18
+ import { addSegmentationRepresentations } from './segmentation/addSegmentationRepresentations';
19
+ import { addMultiViewportSegmentationRepresentations } from './segmentation/addSegmentationRepresentations';
19
20
  import removeSegmentationRepresentations from './segmentation/removeSegmentationRepresentations';
20
- export { FrameOfReferenceSpecificAnnotationManager, defaultFrameOfReferenceSpecificAnnotationManager, annotationLocking, annotationSelection, getAnnotations, addAnnotation, getNumberOfAnnotations, removeAnnotation, getAnnotation, getParentAnnotation, getChildAnnotations, clearParentAnnotation, addChildAnnotation, setAnnotationManager, getAnnotationManager, resetAnnotationManager, invalidateAnnotation, addSegmentationRepresentations, removeSegmentationRepresentations };
21
+ export { FrameOfReferenceSpecificAnnotationManager, defaultFrameOfReferenceSpecificAnnotationManager, annotationLocking, annotationSelection, getAnnotations, addAnnotation, getNumberOfAnnotations, removeAnnotation, getAnnotation, getParentAnnotation, getChildAnnotations, clearParentAnnotation, addChildAnnotation, setAnnotationManager, getAnnotationManager, resetAnnotationManager, invalidateAnnotation, addSegmentationRepresentations, addMultiViewportSegmentationRepresentations, removeSegmentationRepresentations };
@@ -2,6 +2,6 @@ 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 addSegmentationRepresentations from './segmentation/addSegmentationRepresentations';
5
+ import { addSegmentationRepresentations, addMultiViewportSegmentationRepresentations, } from './segmentation/addSegmentationRepresentations';
6
6
  import removeSegmentationRepresentations from './segmentation/removeSegmentationRepresentations';
7
- export { FrameOfReferenceSpecificAnnotationManager, defaultFrameOfReferenceSpecificAnnotationManager, annotationLocking, annotationSelection, getAnnotations, addAnnotation, getNumberOfAnnotations, removeAnnotation, getAnnotation, getParentAnnotation, getChildAnnotations, clearParentAnnotation, addChildAnnotation, setAnnotationManager, getAnnotationManager, resetAnnotationManager, invalidateAnnotation, addSegmentationRepresentations, removeSegmentationRepresentations, };
7
+ export { FrameOfReferenceSpecificAnnotationManager, defaultFrameOfReferenceSpecificAnnotationManager, annotationLocking, annotationSelection, getAnnotations, addAnnotation, getNumberOfAnnotations, removeAnnotation, getAnnotation, getParentAnnotation, getChildAnnotations, clearParentAnnotation, addChildAnnotation, setAnnotationManager, getAnnotationManager, resetAnnotationManager, invalidateAnnotation, addSegmentationRepresentations, addMultiViewportSegmentationRepresentations, removeSegmentationRepresentations, };
@@ -1,5 +1,5 @@
1
1
  import type { Types } from '@cornerstonejs/core';
2
- import type { RepresentationConfig, SegmentRepresentationConfig, Segmentation, SegmentationRepresentation, SegmentationRepresentationConfig, SegmentationState } from '../../types/SegmentationStateTypes';
2
+ import type { GlobalConfig, RepresentationConfig, Segmentation, SegmentationRepresentation, SegmentationState } from '../../types/SegmentationStateTypes';
3
3
  export default class SegmentationStateManager {
4
4
  private state;
5
5
  readonly uid: string;
@@ -25,16 +25,16 @@ export default class SegmentationStateManager {
25
25
  removeRepresentation(segmentationRepresentationUID: string): void;
26
26
  setActiveSegmentationRepresentation(viewportId: string, segmentationRepresentationUID: string): void;
27
27
  getActiveSegmentationRepresentation(viewportId: string): SegmentationRepresentation | undefined;
28
- getGlobalConfig(): SegmentationRepresentationConfig;
29
- setGlobalConfig(config: SegmentationRepresentationConfig): void;
28
+ getGlobalConfig(): GlobalConfig;
29
+ setGlobalConfig(config: GlobalConfig): void;
30
30
  _getRepresentationConfig(segmentationRepresentationUID: string): {
31
31
  allSegments?: RepresentationConfig;
32
- perSegment?: SegmentRepresentationConfig;
32
+ perSegment?: RepresentationConfig;
33
33
  };
34
34
  getSegmentationRepresentationConfig(segmentationRepresentationUID: string): RepresentationConfig;
35
- getPerSegmentConfig(segmentationRepresentationUID: string): SegmentRepresentationConfig;
35
+ getPerSegmentConfig(segmentationRepresentationUID: string): RepresentationConfig;
36
36
  setSegmentationRepresentationConfig(segmentationRepresentationUID: string, config: RepresentationConfig): void;
37
- setPerSegmentConfig(segmentationRepresentationUID: string, config: SegmentRepresentationConfig): void;
37
+ setPerSegmentConfig(segmentationRepresentationUID: string, config: RepresentationConfig): void;
38
38
  getSegmentationRepresentationVisibility(viewportId: string, segmentationRepresentationUID: string): boolean;
39
39
  setSegmentationRepresentationVisibility(viewportId: string, segmentationRepresentationUID: string, visible: boolean): void;
40
40
  addColorLUT(colorLUT: Types.ColorLUT, lutIndex: number): void;
@@ -47,12 +47,12 @@ export default class SegmentationStateManager {
47
47
  if (this.getSegmentation(segmentation.segmentationId)) {
48
48
  throw new Error(`Segmentation with id ${segmentation.segmentationId} already exists`);
49
49
  }
50
- if (segmentation.representationData.LABELMAP &&
51
- 'volumeId' in segmentation.representationData.LABELMAP &&
52
- !('imageIds' in segmentation.representationData.LABELMAP)) {
50
+ if (segmentation.representationData.Labelmap &&
51
+ 'volumeId' in segmentation.representationData.Labelmap &&
52
+ !('imageIds' in segmentation.representationData.Labelmap)) {
53
53
  const imageIds = this.getLabelmapImageIds(segmentation.representationData);
54
54
  segmentation.representationData
55
- .LABELMAP.imageIds = imageIds;
55
+ .Labelmap.imageIds = imageIds;
56
56
  }
57
57
  this.state.segmentations.push(segmentation);
58
58
  }
@@ -83,12 +83,12 @@ export default class SegmentationStateManager {
83
83
  const volumeViewport = enabledElement.viewport instanceof BaseVolumeViewport;
84
84
  const segmentation = this.getSegmentation(representation.segmentationId);
85
85
  const { representationData } = segmentation;
86
- const isLabelmap = representationData.LABELMAP;
86
+ const isLabelmap = representationData.Labelmap;
87
87
  if (!isLabelmap) {
88
88
  this.setActiveSegmentationRepresentation(viewportId, segmentationRepresentationUID);
89
89
  return;
90
90
  }
91
- const isBaseVolumeSegmentation = 'volumeId' in representationData.LABELMAP;
91
+ const isBaseVolumeSegmentation = 'volumeId' in representationData.Labelmap;
92
92
  if (!volumeViewport) {
93
93
  if (isBaseVolumeSegmentation) {
94
94
  }
@@ -137,7 +137,7 @@ export default class SegmentationStateManager {
137
137
  this._stackLabelmapImageIdReferenceMap.set(segmentationId, new Map());
138
138
  }
139
139
  const { representationData } = segmentation;
140
- if (!representationData.LABELMAP) {
140
+ if (!representationData.Labelmap) {
141
141
  return;
142
142
  }
143
143
  const labelmapImageIds = this.getLabelmapImageIds(representationData);
@@ -154,7 +154,7 @@ export default class SegmentationStateManager {
154
154
  this._stackLabelmapImageIdReferenceMap.set(segmentationId, new Map());
155
155
  }
156
156
  const { representationData } = segmentation;
157
- if (!representationData.LABELMAP) {
157
+ if (!representationData.Labelmap) {
158
158
  return;
159
159
  }
160
160
  const labelmapImageIds = this.getLabelmapImageIds(representationData);
@@ -175,7 +175,7 @@ export default class SegmentationStateManager {
175
175
  });
176
176
  }
177
177
  getLabelmapImageIds(representationData) {
178
- const labelmapData = representationData.LABELMAP;
178
+ const labelmapData = representationData.Labelmap;
179
179
  let labelmapImageIds;
180
180
  if (labelmapData.imageIds) {
181
181
  labelmapImageIds = labelmapData
@@ -334,7 +334,7 @@ async function computeVolumeSegmentationFromStack({ imageIds, options, }) {
334
334
  async function convertStackToVolumeSegmentation({ segmentationId, options, }) {
335
335
  const segmentation = defaultSegmentationStateManager.getSegmentation(segmentationId);
336
336
  const data = segmentation.representationData
337
- .LABELMAP;
337
+ .Labelmap;
338
338
  const { volumeId } = await computeVolumeSegmentationFromStack({
339
339
  imageIds: data.imageIds,
340
340
  options,
@@ -350,18 +350,18 @@ async function updateSegmentationState({ segmentationId, viewportId, volumeId, o
350
350
  const segmentation = defaultSegmentationStateManager.getSegmentation(segmentationId);
351
351
  if (options?.removeOriginal) {
352
352
  const data = segmentation.representationData
353
- .LABELMAP;
353
+ .Labelmap;
354
354
  const { imageIds } = data;
355
355
  imageIds.forEach((imageId) => {
356
356
  cache.removeImageLoadObject(imageId);
357
357
  });
358
- segmentation.representationData.LABELMAP = {
358
+ segmentation.representationData.Labelmap = {
359
359
  volumeId,
360
360
  };
361
361
  }
362
362
  else {
363
- segmentation.representationData.LABELMAP = {
364
- ...segmentation.representationData.LABELMAP,
363
+ segmentation.representationData.Labelmap = {
364
+ ...segmentation.representationData.Labelmap,
365
365
  volumeId,
366
366
  };
367
367
  }
@@ -1,3 +1,8 @@
1
- import type { SegmentationRepresentationConfig, RepresentationPublicInput } from '../../types/SegmentationStateTypes';
2
- declare function addSegmentationRepresentations(viewportId: string, representationInputArray: RepresentationPublicInput[], segmentationRepresentationConfig?: SegmentationRepresentationConfig): Promise<string[]>;
3
- export default addSegmentationRepresentations;
1
+ import type { RepresentationPublicInput } from '../../types/SegmentationStateTypes';
2
+ declare function addSegmentationRepresentations(viewportId: string, representationInputArray: RepresentationPublicInput[]): Promise<string[]>;
3
+ declare function addMultiViewportSegmentationRepresentations(viewportInputMap: {
4
+ [viewportId: string]: RepresentationPublicInput[];
5
+ }): Promise<{
6
+ [viewportId: string]: string[];
7
+ }>;
8
+ export { addSegmentationRepresentations, addMultiViewportSegmentationRepresentations, };
@@ -1,9 +1,19 @@
1
- import { addSegmentationRepresentation } from './addSegmentationRepresentation';
2
- async function addSegmentationRepresentations(viewportId, representationInputArray, segmentationRepresentationConfig) {
1
+ import { internalAddSegmentationRepresentation } from './internalAddSegmentationRepresentation';
2
+ async function addSegmentationRepresentations(viewportId, representationInputArray) {
3
3
  const promises = representationInputArray.map((representationInput) => {
4
- return addSegmentationRepresentation(viewportId, representationInput, segmentationRepresentationConfig);
4
+ return internalAddSegmentationRepresentation(viewportId, representationInput);
5
5
  });
6
6
  const segmentationRepresentationUIDs = await Promise.all(promises);
7
7
  return segmentationRepresentationUIDs;
8
8
  }
9
- export default addSegmentationRepresentations;
9
+ async function addMultiViewportSegmentationRepresentations(viewportInputMap) {
10
+ const results = {};
11
+ for (const [viewportId, inputArray] of Object.entries(viewportInputMap)) {
12
+ const promises = inputArray.map((representationInput) => {
13
+ return internalAddSegmentationRepresentation(viewportId, representationInput);
14
+ });
15
+ results[viewportId] = await Promise.all(promises);
16
+ }
17
+ return results;
18
+ }
19
+ export { addSegmentationRepresentations, addMultiViewportSegmentationRepresentations, };
@@ -1,13 +1,14 @@
1
1
  import type SegmentationRepresentations from '../../../enums/SegmentationRepresentations';
2
- import type { RepresentationConfig, SegmentationRepresentationConfig, SegmentRepresentationConfig } from '../../../types/SegmentationStateTypes';
3
- declare function getGlobalConfig(): SegmentationRepresentationConfig;
4
- declare function setGlobalConfig(segmentationConfig: SegmentationRepresentationConfig): void;
5
- declare function getGlobalRepresentationConfig(representationType: SegmentationRepresentations): RepresentationConfig['LABELMAP'];
6
- declare function setGlobalRepresentationConfig(representationType: SegmentationRepresentations, config: RepresentationConfig['LABELMAP']): void;
2
+ import type { GlobalConfig, RepresentationConfig } from '../../../types/SegmentationStateTypes';
3
+ import type { LabelmapConfig } from '../../../types/LabelmapTypes';
4
+ declare function getGlobalConfig(): GlobalConfig;
5
+ declare function setGlobalConfig(segmentationConfig: GlobalConfig): void;
6
+ declare function getGlobalRepresentationConfig(representationType: SegmentationRepresentations): LabelmapConfig;
7
+ declare function setGlobalRepresentationConfig(representationType: SegmentationRepresentations, config: LabelmapConfig): void;
7
8
  declare function getSegmentationRepresentationConfig(segmentationRepresentationUID: string): RepresentationConfig;
8
9
  declare function setSegmentationRepresentationConfig(segmentationRepresentationUID: string, config: RepresentationConfig): void;
9
- declare function setPerSegmentConfig(segmentationRepresentationUID: string, config: SegmentRepresentationConfig): void;
10
- declare function getPerSegmentConfig(segmentationRepresentationUID: string): SegmentRepresentationConfig;
10
+ declare function setPerSegmentConfig(segmentationRepresentationUID: string, config: RepresentationConfig): void;
11
+ declare function getPerSegmentConfig(segmentationRepresentationUID: string): RepresentationConfig;
11
12
  declare function setSegmentIndexConfig(segmentationRepresentationUID: string, segmentIndex: number, config: RepresentationConfig, suppressEvent?: boolean): void;
12
13
  declare function getSegmentIndexConfig(segmentationRepresentationUID: string, segmentIndex: number): RepresentationConfig;
13
14
  export { getGlobalConfig, setGlobalConfig, getGlobalRepresentationConfig, setGlobalRepresentationConfig, getSegmentationRepresentationConfig, setSegmentationRepresentationConfig, setPerSegmentConfig, getPerSegmentConfig, setSegmentIndexConfig, getSegmentIndexConfig, };
@@ -8,7 +8,7 @@ export async function computeStackSegmentationFromVolume({ volumeId, }) {
8
8
  export async function convertVolumeToStackSegmentation({ segmentationId, options, }) {
9
9
  const segmentation = getSegmentation(segmentationId);
10
10
  const { volumeId } = segmentation.representationData
11
- .LABELMAP;
11
+ .Labelmap;
12
12
  const segmentationVolume = cache.getVolume(volumeId);
13
13
  await updateStackSegmentationState({
14
14
  segmentationId,
@@ -1,2 +1,2 @@
1
- import type { SegmentationRepresentationConfig } from '../../types';
2
- export declare function getGlobalConfig(): SegmentationRepresentationConfig;
1
+ import type { GlobalConfig } from '../../types';
2
+ export declare function getGlobalConfig(): GlobalConfig;
@@ -1,2 +1,2 @@
1
- import type { SegmentRepresentationConfig } from '../../types/SegmentationStateTypes';
2
- export declare function getPerSegmentConfig(segmentationRepresentationUID: string): SegmentRepresentationConfig;
1
+ import type { RepresentationConfig } from '../../types/SegmentationStateTypes';
2
+ export declare function getPerSegmentConfig(segmentationRepresentationUID: string): RepresentationConfig;
@@ -2,22 +2,22 @@ import { cache, eventTarget } from '@cornerstonejs/core';
2
2
  import { Events, SegmentationRepresentations } from '../../../enums';
3
3
  import { getSegmentation } from '../getSegmentation';
4
4
  import { triggerSegmentationDataModified } from '../triggerSegmentationEvents';
5
- import addSegmentationRepresentations from '../addSegmentationRepresentations';
5
+ import { addSegmentationRepresentations } from '../addSegmentationRepresentations';
6
6
  export async function updateStackSegmentationState({ segmentationId, viewportId, imageIds, options, }) {
7
7
  const segmentation = getSegmentation(segmentationId);
8
8
  if (options?.removeOriginal) {
9
9
  const data = segmentation.representationData
10
- .LABELMAP;
10
+ .Labelmap;
11
11
  if (cache.getVolume(data.volumeId)) {
12
12
  cache.removeVolumeLoadObject(data.volumeId);
13
13
  }
14
- segmentation.representationData.LABELMAP = {
14
+ segmentation.representationData.Labelmap = {
15
15
  imageIds,
16
16
  };
17
17
  }
18
18
  else {
19
- segmentation.representationData.LABELMAP = {
20
- ...segmentation.representationData.LABELMAP,
19
+ segmentation.representationData.Labelmap = {
20
+ ...segmentation.representationData.Labelmap,
21
21
  imageIds,
22
22
  };
23
23
  }
@@ -1,6 +1,6 @@
1
1
  import removeSegmentationRepresentations from './removeSegmentationRepresentations';
2
2
  import addSegmentations from './addSegmentations';
3
- import addSegmentationRepresentations from './addSegmentationRepresentations';
3
+ import { addSegmentationRepresentations, addMultiViewportSegmentationRepresentations } from './addSegmentationRepresentations';
4
4
  import addRepresentationData from './addRepresentationData';
5
5
  import { convertVolumeToStackSegmentation } from './convertVolumeToStackSegmentation';
6
6
  import * as activeSegmentation from './activeSegmentation';
@@ -11,4 +11,4 @@ import * as segmentIndex from './segmentIndex';
11
11
  import * as triggerSegmentationEvents from './triggerSegmentationEvents';
12
12
  import { convertStackToVolumeSegmentation } from './SegmentationStateManager';
13
13
  import * as polySegManager from './polySeg';
14
- export { addSegmentations, addSegmentationRepresentations, removeSegmentationRepresentations, addRepresentationData, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, convertStackToVolumeSegmentation, convertVolumeToStackSegmentation, polySegManager as polySeg, };
14
+ export { addSegmentations, addSegmentationRepresentations, removeSegmentationRepresentations, addRepresentationData, addMultiViewportSegmentationRepresentations, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, convertStackToVolumeSegmentation, convertVolumeToStackSegmentation, polySegManager as polySeg, };
@@ -1,6 +1,6 @@
1
1
  import removeSegmentationRepresentations from './removeSegmentationRepresentations';
2
2
  import addSegmentations from './addSegmentations';
3
- import addSegmentationRepresentations from './addSegmentationRepresentations';
3
+ import { addSegmentationRepresentations, addMultiViewportSegmentationRepresentations, } from './addSegmentationRepresentations';
4
4
  import addRepresentationData from './addRepresentationData';
5
5
  import { convertVolumeToStackSegmentation } from './convertVolumeToStackSegmentation';
6
6
  import * as activeSegmentation from './activeSegmentation';
@@ -11,4 +11,4 @@ import * as segmentIndex from './segmentIndex';
11
11
  import * as triggerSegmentationEvents from './triggerSegmentationEvents';
12
12
  import { convertStackToVolumeSegmentation } from './SegmentationStateManager';
13
13
  import * as polySegManager from './polySeg';
14
- export { addSegmentations, addSegmentationRepresentations, removeSegmentationRepresentations, addRepresentationData, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, convertStackToVolumeSegmentation, convertVolumeToStackSegmentation, polySegManager as polySeg, };
14
+ export { addSegmentations, addSegmentationRepresentations, removeSegmentationRepresentations, addRepresentationData, addMultiViewportSegmentationRepresentations, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, convertStackToVolumeSegmentation, convertVolumeToStackSegmentation, polySegManager as polySeg, };
@@ -0,0 +1,3 @@
1
+ import type { RepresentationPublicInput } from '../../types/SegmentationStateTypes';
2
+ declare function internalAddSegmentationRepresentation(viewportId: string, representationInput: RepresentationPublicInput): Promise<string>;
3
+ export { internalAddSegmentationRepresentation };
@@ -18,7 +18,7 @@ function getLabelmapSegmentationRepresentationRenderingConfig() {
18
18
  cfun,
19
19
  };
20
20
  }
21
- async function addSegmentationRepresentation(viewportId, representationInput, initialConfig) {
21
+ async function internalAddSegmentationRepresentation(viewportId, representationInput) {
22
22
  const { segmentationId, options = {} } = representationInput;
23
23
  const segmentationRepresentationUID = representationInput.options?.segmentationRepresentationUID ||
24
24
  utilities.uuidv4();
@@ -44,8 +44,9 @@ async function addSegmentationRepresentation(viewportId, representationInput, in
44
44
  },
45
45
  };
46
46
  addSegmentationRepresentationState(viewportId, representation);
47
+ const initialConfig = representationInput.config;
47
48
  if (initialConfig) {
48
- setSegmentationRepresentationConfig(segmentationRepresentationUID, initialConfig.representations);
49
+ setSegmentationRepresentationConfig(segmentationRepresentationUID, initialConfig);
49
50
  }
50
51
  if (representationInput.type === SegmentationRepresentations.Contour) {
51
52
  triggerAnnotationRenderForViewportIds([viewportId]);
@@ -69,4 +70,4 @@ function getColorLUTIndex(options = {}) {
69
70
  }
70
71
  return colorLUTIndexToUse;
71
72
  }
72
- export { addSegmentationRepresentation };
73
+ export { internalAddSegmentationRepresentation };
@@ -14,13 +14,13 @@ export async function computeContourData(segmentationId, options = {}) {
14
14
  const segmentation = getSegmentation(segmentationId);
15
15
  const representationData = segmentation.representationData;
16
16
  try {
17
- if (representationData.SURFACE) {
17
+ if (representationData.Surface) {
18
18
  rawContourData = await computeContourFromSurfaceSegmentation(segmentationId, {
19
19
  segmentIndices,
20
20
  ...options,
21
21
  });
22
22
  }
23
- else if (representationData.LABELMAP) {
23
+ else if (representationData.Labelmap) {
24
24
  rawContourData = await computeContourFromLabelmapSegmentation(segmentationId, {
25
25
  segmentIndices,
26
26
  ...options,
@@ -37,7 +37,7 @@ export async function computeContourData(segmentationId, options = {}) {
37
37
  const { viewport, segmentationRepresentationUID } = options;
38
38
  const annotationUIDsMap = createAndAddContourSegmentationsFromClippedSurfaces(rawContourData, viewport, segmentationId);
39
39
  setSegmentationRepresentationConfig(segmentationRepresentationUID, {
40
- CONTOUR: {
40
+ Contour: {
41
41
  fillAlpha: 0,
42
42
  },
43
43
  });
@@ -78,7 +78,7 @@ async function computeContourFromSurfaceSegmentation(segmentationId, options = {
78
78
  const segmentIndexToSurfaceId = new Map();
79
79
  const surfaceIdToSegmentIndex = new Map();
80
80
  const segmentation = getSegmentation(segmentationId);
81
- const representationData = segmentation.representationData.SURFACE;
81
+ const representationData = segmentation.representationData.Surface;
82
82
  const surfacesInfo = [];
83
83
  representationData.geometryIds.forEach((geometryId, segmentIndex) => {
84
84
  if (segmentIndices.includes(segmentIndex)) {
@@ -12,13 +12,13 @@ export async function computeLabelmapData(segmentationId, options = {}) {
12
12
  const segmentation = getSegmentation(segmentationId);
13
13
  const representationData = segmentation.representationData;
14
14
  try {
15
- if (representationData.CONTOUR) {
15
+ if (representationData.Contour) {
16
16
  rawLabelmapData = await computeLabelmapFromContourSegmentation(segmentationId, {
17
17
  segmentIndices,
18
18
  ...options,
19
19
  });
20
20
  }
21
- else if (representationData.SURFACE) {
21
+ else if (representationData.Surface) {
22
22
  rawLabelmapData = await computeLabelmapFromSurfaceSegmentation(segmentation.segmentationId, {
23
23
  segmentIndices,
24
24
  ...options,
@@ -43,7 +43,7 @@ async function computeLabelmapFromContourSegmentation(segmentationId, options =
43
43
  ? options.segmentIndices
44
44
  : getUniqueSegmentIndices(segmentationId);
45
45
  const segmentation = getSegmentation(segmentationId);
46
- const representationData = segmentation.representationData.CONTOUR;
46
+ const representationData = segmentation.representationData.Contour;
47
47
  const convertFunction = isVolume
48
48
  ? convertContourToVolumeLabelmap
49
49
  : convertContourToStackLabelmap;
@@ -62,7 +62,7 @@ async function computeLabelmapFromSurfaceSegmentation(segmentationId, options =
62
62
  : getUniqueSegmentIndices(segmentationId);
63
63
  const segmentation = getSegmentation(segmentationId);
64
64
  const segmentsGeometryIds = new Map();
65
- const representationData = segmentation.representationData.SURFACE;
65
+ const representationData = segmentation.representationData.Surface;
66
66
  representationData.geometryIds.forEach((geometryId, segmentIndex) => {
67
67
  if (segmentIndices.includes(segmentIndex)) {
68
68
  segmentsGeometryIds.set(segmentIndex, geometryId);
@@ -29,7 +29,7 @@ export async function createAndCacheSurfacesFromRaw(segmentationId, rawSurfacesD
29
29
  const geometryId = closedSurface.id;
30
30
  geometryIds.set(segmentIndex, geometryId);
31
31
  return geometryLoader.createAndCacheGeometry(geometryId, {
32
- type: Enums.GeometryType.SURFACE,
32
+ type: Enums.GeometryType.Surface,
33
33
  geometryData: closedSurface,
34
34
  });
35
35
  });
@@ -12,13 +12,13 @@ export async function computeSurfaceData(segmentationId, options = {}) {
12
12
  const segmentation = getSegmentation(segmentationId);
13
13
  const representationData = segmentation.representationData;
14
14
  try {
15
- if (representationData.CONTOUR) {
15
+ if (representationData.Contour) {
16
16
  rawSurfacesData = await computeSurfaceFromContourSegmentation(segmentationId, {
17
17
  segmentIndices,
18
18
  ...options,
19
19
  });
20
20
  }
21
- else if (representationData.LABELMAP) {
21
+ else if (representationData.Labelmap) {
22
22
  rawSurfacesData = await computeSurfaceFromLabelmapSegmentation(segmentation.segmentationId, {
23
23
  segmentIndices,
24
24
  ...options,
@@ -37,12 +37,12 @@ export async function computeSurfaceData(segmentationId, options = {}) {
37
37
  }
38
38
  async function computeSurfaceFromLabelmapSegmentation(segmentationId, options = {}) {
39
39
  const segmentation = getSegmentation(segmentationId);
40
- if (!segmentation?.representationData?.LABELMAP) {
40
+ if (!segmentation?.representationData?.Labelmap) {
41
41
  console.warn('Only support surface update from labelmaps');
42
42
  return;
43
43
  }
44
- const isVolume = isVolumeSegmentation(segmentation.representationData.LABELMAP);
45
- const labelmapRepresentationData = segmentation.representationData.LABELMAP;
44
+ const isVolume = isVolumeSegmentation(segmentation.representationData.Labelmap);
45
+ const labelmapRepresentationData = segmentation.representationData.Labelmap;
46
46
  const segmentIndices = options.segmentIndices || getUniqueSegmentIndices(segmentationId);
47
47
  const promises = segmentIndices.map((index) => {
48
48
  const surface = convertLabelmapToSurface(labelmapRepresentationData, index, isVolume);
@@ -65,7 +65,7 @@ async function computeSurfaceFromLabelmapSegmentation(segmentationId, options =
65
65
  }
66
66
  async function computeSurfaceFromContourSegmentation(segmentationId, options = {}) {
67
67
  const segmentation = getSegmentation(segmentationId);
68
- const contourRepresentationData = segmentation.representationData.CONTOUR;
68
+ const contourRepresentationData = segmentation.representationData.Contour;
69
69
  const segmentIndices = options.segmentIndices || getUniqueSegmentIndices(segmentationId);
70
70
  const promises = segmentIndices.map(async (index) => {
71
71
  const surface = await convertContourToSurface(contourRepresentationData, index);
@@ -13,7 +13,7 @@ export async function updateSurfaceData(segmentationId) {
13
13
  const segmentation = getSegmentation(segmentationId);
14
14
  const indices = getUniqueSegmentIndices(segmentationId);
15
15
  if (!indices.length) {
16
- const geometryIds = segmentation.representationData.SURFACE.geometryIds;
16
+ const geometryIds = segmentation.representationData.Surface.geometryIds;
17
17
  geometryIds.forEach((geometryId) => {
18
18
  const geometry = cache.getGeometry(geometryId);
19
19
  const surface = geometry.data;
@@ -35,7 +35,7 @@ export async function updateSurfaceData(segmentationId) {
35
35
  SegmentationRepresentations.Surface) {
36
36
  return;
37
37
  }
38
- segmentation.representationData.SURFACE.geometryIds.set(segmentIndex, geometryId);
38
+ segmentation.representationData.Surface.geometryIds.set(segmentIndex, geometryId);
39
39
  return createAndCacheSurfacesFromRaw(segmentationId, [{ segmentIndex, data }], {
40
40
  segmentationRepresentationUID: segmentationRepresentation.segmentationRepresentationUID,
41
41
  });
@@ -12,7 +12,6 @@ import { setSegmentationRepresentationConfig } from './setSegmentationRepresenta
12
12
  import { getPerSegmentConfig } from './getPerSegmentConfig';
13
13
  import { setPerSegmentConfig } from './setPerSegmentConfig';
14
14
  import { getSegmentationRepresentations } from './getSegmentationRepresentations';
15
- import { addSegmentationRepresentation } from './addSegmentationRepresentation';
16
15
  import { getSegmentationRepresentationViewportStates } from './getSegmentationRepresentationViewportStates';
17
16
  import { addColorLUT } from './addColorLUT';
18
17
  import { getColorLUT } from './getColorLUT';
@@ -27,4 +26,4 @@ import { setActiveSegmentationRepresentation } from './setActiveSegmentationRepr
27
26
  import { getCurrentLabelmapImageIdForViewport } from './getCurrentLabelmapImageIdForViewport';
28
27
  import { updateLabelmapSegmentationImageReferences } from './updateLabelmapSegmentationImageReferences';
29
28
  import { getStackSegmentationImageIdsForViewport } from './getStackSegmentationImageIdsForViewport';
30
- export { getSegmentation, getSegmentations, addSegmentation, removeSegmentation, getAllSegmentationRepresentations, getSegmentationRepresentation, removeRepresentation, getGlobalConfig, setGlobalConfig, getSegmentationRepresentationConfig, setSegmentationRepresentationConfig, getPerSegmentConfig, setPerSegmentConfig, getSegmentationRepresentations, addSegmentationRepresentation, getSegmentationRepresentationViewportStates, addColorLUT, getColorLUT, getNextColorLUTIndex, removeColorLUT, getSegmentationRepresentationsForSegmentation, getSegmentationRepresentationVisibility, setSegmentationRepresentationVisibility, getViewportIdsWithSegmentation, getActiveSegmentationRepresentation, setActiveSegmentationRepresentation, getCurrentLabelmapImageIdForViewport, updateLabelmapSegmentationImageReferences, getStackSegmentationImageIdsForViewport, };
29
+ export { getSegmentation, getSegmentations, addSegmentation, removeSegmentation, getAllSegmentationRepresentations, getSegmentationRepresentation, removeRepresentation, getGlobalConfig, setGlobalConfig, getSegmentationRepresentationConfig, setSegmentationRepresentationConfig, getPerSegmentConfig, setPerSegmentConfig, getSegmentationRepresentations, getSegmentationRepresentationViewportStates, addColorLUT, getColorLUT, getNextColorLUTIndex, removeColorLUT, getSegmentationRepresentationsForSegmentation, getSegmentationRepresentationVisibility, setSegmentationRepresentationVisibility, getViewportIdsWithSegmentation, getActiveSegmentationRepresentation, setActiveSegmentationRepresentation, getCurrentLabelmapImageIdForViewport, updateLabelmapSegmentationImageReferences, getStackSegmentationImageIdsForViewport, };
@@ -12,7 +12,6 @@ import { setSegmentationRepresentationConfig } from './setSegmentationRepresenta
12
12
  import { getPerSegmentConfig } from './getPerSegmentConfig';
13
13
  import { setPerSegmentConfig } from './setPerSegmentConfig';
14
14
  import { getSegmentationRepresentations } from './getSegmentationRepresentations';
15
- import { addSegmentationRepresentation } from './addSegmentationRepresentation';
16
15
  import { getSegmentationRepresentationViewportStates } from './getSegmentationRepresentationViewportStates';
17
16
  import { addColorLUT } from './addColorLUT';
18
17
  import { getColorLUT } from './getColorLUT';
@@ -27,4 +26,4 @@ import { setActiveSegmentationRepresentation } from './setActiveSegmentationRepr
27
26
  import { getCurrentLabelmapImageIdForViewport } from './getCurrentLabelmapImageIdForViewport';
28
27
  import { updateLabelmapSegmentationImageReferences } from './updateLabelmapSegmentationImageReferences';
29
28
  import { getStackSegmentationImageIdsForViewport } from './getStackSegmentationImageIdsForViewport';
30
- export { getSegmentation, getSegmentations, addSegmentation, removeSegmentation, getAllSegmentationRepresentations, getSegmentationRepresentation, removeRepresentation, getGlobalConfig, setGlobalConfig, getSegmentationRepresentationConfig, setSegmentationRepresentationConfig, getPerSegmentConfig, setPerSegmentConfig, getSegmentationRepresentations, addSegmentationRepresentation, getSegmentationRepresentationViewportStates, addColorLUT, getColorLUT, getNextColorLUTIndex, removeColorLUT, getSegmentationRepresentationsForSegmentation, getSegmentationRepresentationVisibility, setSegmentationRepresentationVisibility, getViewportIdsWithSegmentation, getActiveSegmentationRepresentation, setActiveSegmentationRepresentation, getCurrentLabelmapImageIdForViewport, updateLabelmapSegmentationImageReferences, getStackSegmentationImageIdsForViewport, };
29
+ export { getSegmentation, getSegmentations, addSegmentation, removeSegmentation, getAllSegmentationRepresentations, getSegmentationRepresentation, removeRepresentation, getGlobalConfig, setGlobalConfig, getSegmentationRepresentationConfig, setSegmentationRepresentationConfig, getPerSegmentConfig, setPerSegmentConfig, getSegmentationRepresentations, getSegmentationRepresentationViewportStates, addColorLUT, getColorLUT, getNextColorLUTIndex, removeColorLUT, getSegmentationRepresentationsForSegmentation, getSegmentationRepresentationVisibility, setSegmentationRepresentationVisibility, getViewportIdsWithSegmentation, getActiveSegmentationRepresentation, setActiveSegmentationRepresentation, getCurrentLabelmapImageIdForViewport, updateLabelmapSegmentationImageReferences, getStackSegmentationImageIdsForViewport, };
@@ -1,2 +1,2 @@
1
- import type { SegmentationRepresentationConfig } from '../../types';
2
- export declare function setGlobalConfig(config: SegmentationRepresentationConfig, suppressEvents?: boolean): void;
1
+ import type { GlobalConfig } from '../../types';
2
+ export declare function setGlobalConfig(config: GlobalConfig, suppressEvents?: boolean): void;
@@ -1,2 +1,2 @@
1
- import type { SegmentRepresentationConfig } from '../../types/SegmentationStateTypes';
2
- export declare function setPerSegmentConfig(segmentationRepresentationUID: string, config: SegmentRepresentationConfig, suppressEvents?: boolean): void;
1
+ import type { RepresentationConfig } from '../../types';
2
+ export declare function setPerSegmentConfig(segmentationRepresentationUID: string, config: RepresentationConfig, suppressEvents?: boolean): void;
@@ -2,7 +2,7 @@ import { MouseBindings, ToolModes } from '../../enums';
2
2
  import type { Types } from '@cornerstonejs/core';
3
3
  import type { IToolBinding, IToolGroup, SetToolBindingsType, ToolOptionsType, ToolConfiguration } from '../../types';
4
4
  import { MouseCursor } from '../../cursors';
5
- export default class ToolGroup implements IToolGroup {
5
+ export default class ToolGroup {
6
6
  id: string;
7
7
  viewportsInfo: any[];
8
8
  toolOptions: {};
@@ -562,7 +562,7 @@ class AdvancedMagnifyViewportManager {
562
562
  const { viewportId: sourceViewportId } = evt.detail;
563
563
  this._reset(sourceViewportId);
564
564
  };
565
- element.addEventListener(csEvents.STACK_VIEWPORT_NEW_STACK, newStackHandler);
565
+ element.addEventListener(csEvents.VIEWPORT_NEW_IMAGE_SET, newStackHandler);
566
566
  const newVolumeHandler = (evt) => {
567
567
  const { viewportId: sourceViewportId } = evt.detail;
568
568
  this._reset(sourceViewportId);
@@ -575,7 +575,7 @@ class AdvancedMagnifyViewportManager {
575
575
  _removeSourceElementEventListener(element) {
576
576
  element.removeEventListener(csEvents.STACK_NEW_IMAGE, this._newStackImageCallback);
577
577
  element.removeEventListener(csEvents.VOLUME_NEW_IMAGE, this._newVolumeImageCallback);
578
- element.removeEventListener(csEvents.STACK_VIEWPORT_NEW_STACK, element.newStackHandler);
578
+ element.removeEventListener(csEvents.VIEWPORT_NEW_IMAGE_SET, element.newStackHandler);
579
579
  element.removeEventListener(csEvents.VOLUME_VIEWPORT_NEW_VOLUME, element.newVolumeHandler);
580
580
  delete element.newStackHandler;
581
581
  delete element.newVolumeHandler;