@cornerstonejs/tools 4.15.27 → 4.15.29

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.
@@ -1 +1,3 @@
1
- export declare function clearSegmentValue(segmentationId: string, segmentIndex: number): void;
1
+ export declare function clearSegmentValue(segmentationId: string, segmentIndex: number, options?: {
2
+ recordHistory?: boolean;
3
+ }): void;
@@ -1,7 +1,9 @@
1
- import { cache } from '@cornerstonejs/core';
1
+ import { cache, utilities } from '@cornerstonejs/core';
2
2
  import { getSegmentation } from '../getSegmentation';
3
3
  import { triggerSegmentationDataModified } from '../triggerSegmentationEvents';
4
- export function clearSegmentValue(segmentationId, segmentIndex) {
4
+ import { createLabelmapMemo } from '../../../utilities/segmentation/createLabelmapMemo';
5
+ const { DefaultHistoryMemo } = utilities.HistoryMemo;
6
+ export function clearSegmentValue(segmentationId, segmentIndex, options) {
5
7
  const segmentation = getSegmentation(segmentationId);
6
8
  if (segmentation.representationData.Labelmap) {
7
9
  const { representationData } = segmentation;
@@ -15,11 +17,18 @@ export function clearSegmentValue(segmentationId, segmentIndex) {
15
17
  return;
16
18
  }
17
19
  const { voxelManager } = item;
20
+ const memo = options?.recordHistory
21
+ ? createLabelmapMemo(segmentationId, voxelManager)
22
+ : null;
23
+ const useVoxelManager = memo?.voxelManager ?? voxelManager;
18
24
  voxelManager.forEach(({ value, index }) => {
19
25
  if (value === segmentIndex) {
20
- voxelManager.setAtIndex(index, 0);
26
+ useVoxelManager.setAtIndex(index, 0);
21
27
  }
22
28
  });
29
+ if (memo?.commitMemo()) {
30
+ DefaultHistoryMemo.push(memo);
31
+ }
23
32
  });
24
33
  }
25
34
  triggerSegmentationDataModified(segmentationId);
@@ -1 +1,3 @@
1
- export declare function removeContourSegmentAnnotations(segmentationId: string, segmentIndex: number): void;
1
+ export declare function removeContourSegmentAnnotations(segmentationId: string, segmentIndex: number, options?: {
2
+ recordHistory?: boolean;
3
+ }): void;
@@ -1,19 +1,36 @@
1
1
  import { getAnnotation } from '../../annotation/annotationState';
2
+ import AnnotationTool from '../../../tools/base/AnnotationTool';
2
3
  import { getAnnotationsUIDMapFromSegmentation, removeCompleteContourAnnotation, } from '../utilities';
3
4
  import { isContourSegmentationAnnotation } from '../../../utilities/contourSegmentation';
4
- export function removeContourSegmentAnnotations(segmentationId, segmentIndex) {
5
+ export function removeContourSegmentAnnotations(segmentationId, segmentIndex, options) {
5
6
  const annotationUIDsMap = getAnnotationsUIDMapFromSegmentation(segmentationId);
6
7
  if (!annotationUIDsMap) {
7
8
  return;
8
9
  }
9
- const annotationUIDs = annotationUIDsMap.get(segmentIndex);
10
- if (!annotationUIDs) {
10
+ const annotationUIDsSet = annotationUIDsMap.get(segmentIndex);
11
+ if (!annotationUIDsSet) {
11
12
  return;
12
13
  }
13
- annotationUIDs.forEach((annotationUID) => {
14
+ const annotationUIDs = Array.from(annotationUIDsSet);
15
+ const annotations = [];
16
+ for (const annotationUID of annotationUIDs) {
14
17
  const annotation = getAnnotation(annotationUID);
15
18
  if (isContourSegmentationAnnotation(annotation)) {
16
- removeCompleteContourAnnotation(annotation);
19
+ annotations.push(annotation);
17
20
  }
18
- });
21
+ }
22
+ if (annotations.length === 0) {
23
+ return;
24
+ }
25
+ for (const annotation of annotations) {
26
+ if (annotation.parentAnnotationUID) {
27
+ continue;
28
+ }
29
+ if (options?.recordHistory) {
30
+ AnnotationTool.createAnnotationMemo(null, annotation, {
31
+ deleting: true,
32
+ });
33
+ }
34
+ removeCompleteContourAnnotation(annotation);
35
+ }
19
36
  }
@@ -1,3 +1,4 @@
1
1
  export declare function removeSegment(segmentationId: string, segmentIndex: number, options?: {
2
- setNextSegmentAsActive: boolean;
2
+ setNextSegmentAsActive?: boolean;
3
+ recordHistory?: boolean;
3
4
  }): void;
@@ -11,10 +11,14 @@ export function removeSegment(segmentationId, segmentIndex, options = {
11
11
  }) {
12
12
  const segmentation = getSegmentation(segmentationId);
13
13
  if (segmentation?.representationData.Contour) {
14
- removeContourSegmentAnnotations(segmentationId, segmentIndex);
14
+ removeContourSegmentAnnotations(segmentationId, segmentIndex, {
15
+ recordHistory: options.recordHistory,
16
+ });
15
17
  }
16
18
  else if (segmentation?.representationData.Labelmap) {
17
- clearSegmentValue(segmentationId, segmentIndex);
19
+ clearSegmentValue(segmentationId, segmentIndex, {
20
+ recordHistory: options.recordHistory,
21
+ });
18
22
  }
19
23
  else {
20
24
  throw new Error('Invalid segmentation type');
@@ -33,7 +37,7 @@ export function removeSegment(segmentationId, segmentIndex, options = {
33
37
  },
34
38
  },
35
39
  ]);
36
- if (isThisSegmentActive && options.setNextSegmentAsActive) {
40
+ if (isThisSegmentActive && options.setNextSegmentAsActive !== false) {
37
41
  const segmentIndices = Object.keys(segments)
38
42
  .map(Number)
39
43
  .sort((a, b) => a - b);
@@ -42,7 +42,7 @@ declare abstract class AnnotationTool extends AnnotationDisplayTool {
42
42
  data: import("../../types").AnnotationData;
43
43
  deleting: boolean;
44
44
  };
45
- static createAnnotationMemo(element: any, annotation: Annotation, options?: {
45
+ static createAnnotationMemo(element: HTMLDivElement | null | undefined, annotation: Annotation, options?: {
46
46
  newAnnotation?: boolean;
47
47
  deleting?: boolean;
48
48
  }): {
@@ -216,7 +216,9 @@ class AnnotationTool extends AnnotationDisplayTool {
216
216
  }
217
217
  state.data = newState.data;
218
218
  currentAnnotation.invalidated = true;
219
- triggerAnnotationModified(currentAnnotation, element, ChangeTypes.History);
219
+ if (element) {
220
+ triggerAnnotationModified(currentAnnotation, element, ChangeTypes.History);
221
+ }
220
222
  },
221
223
  id: annotationUID,
222
224
  operationType: 'annotation',
@@ -1,6 +1,5 @@
1
- import { utilities, eventTarget } from '@cornerstonejs/core';
1
+ import { utilities } from '@cornerstonejs/core';
2
2
  import { triggerSegmentationDataModified } from '../../stateManagement/segmentation/triggerSegmentationEvents';
3
- import Events from '../../enums/Events';
4
3
  const { VoxelManager, RLEVoxelMap } = utilities;
5
4
  export function createLabelmapMemo(segmentationId, segmentationVoxelManager) {
6
5
  return createRleMemo(segmentationId, segmentationVoxelManager);
@@ -13,7 +13,10 @@ export function getReferenceVolumeForSegmentationVolume(segmentationVolumeId) {
13
13
  const imageIds = segmentationVolume.imageIds;
14
14
  const image = cache.getImage(imageIds[0]);
15
15
  const referencedImageId = image.referencedImageId;
16
- const volumeInfo = cache.getVolumeContainingImageId(referencedImageId);
16
+ let volumeInfo = cache.getVolumeContainingImageId(referencedImageId);
17
+ if (!volumeInfo?.volume) {
18
+ volumeInfo = cache.getVolumeContainingImageId(image.imageId);
19
+ }
17
20
  imageVolume = volumeInfo?.volume;
18
21
  }
19
22
  return imageVolume;
@@ -1 +1 @@
1
- export declare const version = "4.15.27";
1
+ export declare const version = "4.15.29";
@@ -1 +1 @@
1
- export const version = '4.15.27';
1
+ export const version = '4.15.29';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "4.15.27",
3
+ "version": "4.15.29",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "types": "./dist/esm/index.d.ts",
6
6
  "module": "./dist/esm/index.js",
@@ -108,7 +108,7 @@
108
108
  "canvas": "3.2.0"
109
109
  },
110
110
  "peerDependencies": {
111
- "@cornerstonejs/core": "4.15.27",
111
+ "@cornerstonejs/core": "4.15.29",
112
112
  "@kitware/vtk.js": "34.15.1",
113
113
  "@types/d3-array": "3.2.1",
114
114
  "@types/d3-interpolate": "3.0.4",
@@ -127,5 +127,5 @@
127
127
  "type": "individual",
128
128
  "url": "https://ohif.org/donate"
129
129
  },
130
- "gitHead": "af3578dd13210050d2f9c309f69483deb1f67168"
130
+ "gitHead": "ff9cdf1e59a849b7ba2be95578dee05b311800d0"
131
131
  }