@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
@@ -3,24 +3,23 @@ import type * as Enums from '../enums';
3
3
  import type { ContourConfig, ContourRenderingConfig, ContourSegmentationData } from './ContourTypes';
4
4
  import type { LabelmapConfig, LabelmapRenderingConfig, LabelmapSegmentationData } from './LabelmapTypes';
5
5
  import type { SurfaceSegmentationData, SurfaceRenderingConfig } from './SurfaceTypes';
6
- export type SegmentRepresentationConfig = {
7
- [key: number | string]: RepresentationConfig;
8
- };
9
6
  export type SurfaceConfig = {};
10
- export type RepresentationConfig = {
11
- LABELMAP?: LabelmapConfig;
12
- CONTOUR?: ContourConfig;
13
- SURFACE?: SurfaceConfig;
7
+ export type RepresentationsConfig = {
8
+ [Enums.SegmentationRepresentations.Labelmap]?: LabelmapConfig;
9
+ [Enums.SegmentationRepresentations.Contour]?: ContourConfig;
10
+ [Enums.SegmentationRepresentations.Surface]?: SurfaceConfig;
14
11
  };
15
- export type SegmentationRepresentationConfig = {
12
+ export type RepresentationConfig = LabelmapConfig | ContourConfig | SurfaceConfig;
13
+ export type GlobalConfig = {
16
14
  renderInactiveRepresentations: boolean;
17
- representations: RepresentationConfig;
15
+ representations: RepresentationsConfig;
18
16
  };
19
- export type SegmentationRepresentationData = {
20
- LABELMAP?: LabelmapSegmentationData;
21
- CONTOUR?: ContourSegmentationData;
22
- SURFACE?: SurfaceSegmentationData;
17
+ export type RepresentationsData = {
18
+ [Enums.SegmentationRepresentations.Labelmap]?: LabelmapSegmentationData;
19
+ [Enums.SegmentationRepresentations.Contour]?: ContourSegmentationData;
20
+ [Enums.SegmentationRepresentations.Surface]?: SurfaceSegmentationData;
23
21
  };
22
+ export type RepresentationData = LabelmapSegmentationData | ContourSegmentationData | SurfaceSegmentationData;
24
23
  export type Segmentation = {
25
24
  segmentationId: string;
26
25
  type: Enums.SegmentationRepresentations;
@@ -33,7 +32,7 @@ export type Segmentation = {
33
32
  segmentLabels: {
34
33
  [key: string]: string;
35
34
  };
36
- representationData: SegmentationRepresentationData;
35
+ representationData: RepresentationsData;
37
36
  };
38
37
  export type BaseSegmentationRepresentation = {
39
38
  segmentationRepresentationUID: string;
@@ -46,7 +45,7 @@ export type BaseSegmentationRepresentation = {
46
45
  };
47
46
  config: {
48
47
  allSegments?: RepresentationConfig;
49
- perSegment?: SegmentRepresentationConfig;
48
+ perSegment?: RepresentationConfig;
50
49
  };
51
50
  };
52
51
  export type LabelmapRepresentation = BaseSegmentationRepresentation & {
@@ -62,7 +61,7 @@ export type SegmentationRepresentation = LabelmapRepresentation | ContourReprese
62
61
  export type SegmentationState = {
63
62
  colorLUT: Types.ColorLUT[];
64
63
  segmentations: Segmentation[];
65
- globalConfig: SegmentationRepresentationConfig;
64
+ globalConfig: GlobalConfig;
66
65
  representations: {
67
66
  [key: string]: SegmentationRepresentation;
68
67
  };
@@ -80,14 +79,9 @@ export type SegmentationPublicInput = {
80
79
  segmentationId: string;
81
80
  representation: {
82
81
  type: Enums.SegmentationRepresentations;
83
- data?: LabelmapSegmentationData | ContourSegmentationData | SurfaceSegmentationData;
82
+ data?: RepresentationData;
84
83
  };
85
84
  };
86
- export type RepresentationPublicInput = {
87
- segmentationId: string;
88
- type: Enums.SegmentationRepresentations;
89
- options?: RepresentationPublicInputOptions;
90
- };
91
85
  export type RepresentationPublicInputOptions = {
92
86
  segmentationRepresentationUID?: string;
93
87
  colorLUTOrIndex?: Types.ColorLUT | number;
@@ -96,3 +90,9 @@ export type RepresentationPublicInputOptions = {
96
90
  options?: unknown;
97
91
  };
98
92
  };
93
+ export type RepresentationPublicInput = {
94
+ segmentationId: string;
95
+ type: Enums.SegmentationRepresentations;
96
+ options?: RepresentationPublicInputOptions;
97
+ config?: RepresentationConfig;
98
+ };
@@ -22,7 +22,7 @@ import type ScrollOptions from './ScrollOptions';
22
22
  import type BoundsIJK from './BoundsIJK';
23
23
  import type SVGDrawingHelper from './SVGDrawingHelper';
24
24
  import type * as CINETypes from './CINETypes';
25
- import type { RepresentationConfig, SegmentationRepresentationConfig, SegmentationRepresentationData, Segmentation, SegmentationState, RepresentationPublicInput } from './SegmentationStateTypes';
25
+ import type { RepresentationConfig, RepresentationData, RepresentationsData, GlobalConfig, Segmentation, SegmentationState, RepresentationPublicInput } from './SegmentationStateTypes';
26
26
  import type { ISculptToolShape } from './ISculptToolShape';
27
27
  import type ISynchronizerEventHandler from './ISynchronizerEventHandler';
28
28
  import type { FloodFillGetter, FloodFillOptions, FloodFillResult } from './FloodFillTypes';
@@ -46,4 +46,5 @@ import type { SplineLineSegment } from './SplineLineSegment';
46
46
  import type { SplineProps } from './SplineProps';
47
47
  import type { BidirectionalData } from '../utilities/segmentation/createBidirectionalToolData';
48
48
  import type { PolySegConversionOptions } from './PolySeg';
49
- export type { Annotation, Annotations, ContourAnnotationData, ContourAnnotation, ContourSegmentationAnnotationData, ContourSegmentationAnnotation, BidirectionalData, CanvasCoordinates, IAnnotationManager, InterpolationViewportData, ImageInterpolationData, GroupSpecificAnnotations, AnnotationState, AnnotationStyle, ToolSpecificAnnotationTypes, JumpToSliceOptions, AnnotationGroupSelector, AnnotationRenderContext, PlanarBoundingBox, ToolProps, PublicToolProps, ToolConfiguration, EventTypes, IPoints, ITouchPoints, IDistance, IToolBinding, SetToolBindingsType, ToolOptionsType, InteractionTypes, ToolAction, IToolGroup, IToolClassReference, ISynchronizerEventHandler, ToolHandle, AnnotationHandle, TextBoxHandle, Segmentation, SegmentationState, SegmentationRepresentationData, SegmentationRepresentationConfig, RepresentationConfig, RepresentationPublicInput, LabelmapTypes, SVGCursorDescriptor, SVGPoint, ScrollOptions, CINETypes, BoundsIJK, SVGDrawingHelper, FloodFillResult, FloodFillGetter, FloodFillOptions, ContourSegmentationData, ISculptToolShape, Statistics, NamedStatistics, LabelmapToolOperationData, LabelmapToolOperationDataStack, LabelmapToolOperationDataVolume, CardinalSplineProps, ClosestControlPoint, ClosestPoint, ClosestSplinePoint, ControlPointInfo, ISpline, SplineCurveSegment, SplineLineSegment, SplineProps, PolySegConversionOptions, };
49
+ import type { IBaseTool } from './IBaseTool';
50
+ export type { Annotation, Annotations, ContourAnnotationData, ContourAnnotation, ContourSegmentationAnnotationData, ContourSegmentationAnnotation, BidirectionalData, CanvasCoordinates, IAnnotationManager, InterpolationViewportData, ImageInterpolationData, GroupSpecificAnnotations, AnnotationState, AnnotationStyle, ToolSpecificAnnotationTypes, JumpToSliceOptions, AnnotationGroupSelector, AnnotationRenderContext, PlanarBoundingBox, ToolProps, PublicToolProps, ToolConfiguration, EventTypes, IPoints, ITouchPoints, IDistance, IToolBinding, SetToolBindingsType, ToolOptionsType, InteractionTypes, ToolAction, IToolGroup, IToolClassReference, ISynchronizerEventHandler, ToolHandle, AnnotationHandle, TextBoxHandle, Segmentation, SegmentationState, RepresentationData, RepresentationsData, RepresentationConfig, RepresentationPublicInput, LabelmapTypes, SVGCursorDescriptor, SVGPoint, ScrollOptions, CINETypes, BoundsIJK, SVGDrawingHelper, FloodFillResult, FloodFillGetter, FloodFillOptions, ContourSegmentationData, ISculptToolShape, Statistics, NamedStatistics, LabelmapToolOperationData, LabelmapToolOperationDataStack, LabelmapToolOperationDataVolume, CardinalSplineProps, ClosestControlPoint, ClosestPoint, ClosestSplinePoint, ControlPointInfo, ISpline, SplineCurveSegment, SplineLineSegment, SplineProps, PolySegConversionOptions, IBaseTool, GlobalConfig, };
@@ -8,10 +8,10 @@ export function addContourSegmentationAnnotation(annotation) {
8
8
  }
9
9
  const { segmentationId, segmentIndex } = annotation.data.segmentation;
10
10
  const segmentation = getSegmentation(segmentationId);
11
- if (!segmentation.representationData.CONTOUR) {
12
- segmentation.representationData.CONTOUR = { annotationUIDsMap: new Map() };
11
+ if (!segmentation.representationData.Contour) {
12
+ segmentation.representationData.Contour = { annotationUIDsMap: new Map() };
13
13
  }
14
- const { annotationUIDsMap } = segmentation.representationData.CONTOUR;
14
+ const { annotationUIDsMap } = segmentation.representationData.Contour;
15
15
  let annotationsUIDsSet = annotationUIDsMap.get(segmentIndex);
16
16
  if (!annotationsUIDsSet) {
17
17
  annotationsUIDsSet = new Set();
@@ -5,7 +5,7 @@ export function removeContourSegmentationAnnotation(annotation) {
5
5
  }
6
6
  const { segmentationId, segmentIndex } = annotation.data.segmentation;
7
7
  const segmentation = getSegmentation(segmentationId);
8
- const { annotationUIDsMap } = segmentation?.representationData.CONTOUR || {};
8
+ const { annotationUIDsMap } = segmentation?.representationData.Contour || {};
9
9
  const annotationsUIDsSet = annotationUIDsMap?.get(segmentIndex);
10
10
  if (!annotationsUIDsSet) {
11
11
  return;
@@ -2,7 +2,7 @@ import { getAnnotation } from '../../stateManagement';
2
2
  import { getSegmentation } from '../../stateManagement/segmentation/segmentationState';
3
3
  export function getHoveredContourSegmentationAnnotation(segmentationId) {
4
4
  const segmentation = getSegmentation(segmentationId);
5
- const { annotationUIDsMap } = segmentation.representationData.CONTOUR;
5
+ const { annotationUIDsMap } = segmentation.representationData.Contour;
6
6
  for (const [segmentIndex, annotationUIDs] of annotationUIDsMap.entries()) {
7
7
  const highlightedAnnotationUID = Array.from(annotationUIDs).find((annotationUID) => getAnnotation(annotationUID).highlighted);
8
8
  if (highlightedAnnotationUID) {
@@ -3,7 +3,7 @@ import { getSegmentation, getSegmentationRepresentationsForSegmentation, getCurr
3
3
  import { isVolumeSegmentation } from '../../tools/segmentation/strategies/utils/stackVolumeCheck';
4
4
  export function getSegmentIndexAtLabelmapBorder(segmentationId, worldPoint, { viewport, searchRadius }) {
5
5
  const segmentation = getSegmentation(segmentationId);
6
- const labelmapData = segmentation.representationData.LABELMAP;
6
+ const labelmapData = segmentation.representationData.Labelmap;
7
7
  if (isVolumeSegmentation(labelmapData, viewport)) {
8
8
  const { volumeId } = labelmapData;
9
9
  const segmentationVolume = cache.getVolume(volumeId);
@@ -21,7 +21,7 @@ export function getSegmentIndexAtWorldPoint(segmentationId, worldPoint, options
21
21
  }
22
22
  }
23
23
  export function getSegmentIndexAtWorldForLabelmap(segmentation, worldPoint, { viewport }) {
24
- const labelmapData = segmentation.representationData.LABELMAP;
24
+ const labelmapData = segmentation.representationData.Labelmap;
25
25
  if (isVolumeSegmentation(labelmapData)) {
26
26
  const { volumeId } = labelmapData;
27
27
  const segmentationVolume = cache.getVolume(volumeId);
@@ -51,7 +51,7 @@ export function getSegmentIndexAtWorldForLabelmap(segmentation, worldPoint, { vi
51
51
  return segmentIndex;
52
52
  }
53
53
  export function getSegmentIndexAtWorldForContour(segmentation, worldPoint, { viewport }) {
54
- const contourData = segmentation.representationData.CONTOUR;
54
+ const contourData = segmentation.representationData.Contour;
55
55
  const segmentIndices = Array.from(contourData.annotationUIDsMap.keys());
56
56
  const { viewPlaneNormal } = viewport.getCamera();
57
57
  for (const segmentIndex of segmentIndices) {
@@ -62,7 +62,7 @@ function addImageSegmentIndices(keySet, imageIds) {
62
62
  });
63
63
  }
64
64
  function handleContourSegmentation(segmentation) {
65
- const { annotationUIDsMap, geometryIds } = segmentation.representationData.CONTOUR || {};
65
+ const { annotationUIDsMap, geometryIds } = segmentation.representationData.Contour || {};
66
66
  if (!geometryIds) {
67
67
  throw new Error(`No geometryIds found for segmentationId ${segmentation.segmentationId}`);
68
68
  }
@@ -74,7 +74,7 @@ function handleContourSegmentation(segmentation) {
74
74
  return Array.from(indices).sort((a, b) => a - b);
75
75
  }
76
76
  function handleSurfaceSegmentation(segmentation) {
77
- const geometryIds = segmentation.representationData.SURFACE?.geometryIds ?? [];
77
+ const geometryIds = segmentation.representationData.Surface?.geometryIds ?? [];
78
78
  return Array.from(geometryIds.keys())
79
79
  .map(Number)
80
80
  .sort((a, b) => a - b);