@cornerstonejs/tools 2.1.7 → 2.1.8

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.
@@ -16,6 +16,7 @@ declare enum Events {
16
16
  SEGMENTATION_MODIFIED = "CORNERSTONE_TOOLS_SEGMENTATION_MODIFIED",
17
17
  SEGMENTATION_RENDERED = "CORNERSTONE_TOOLS_SEGMENTATION_RENDERED",
18
18
  SEGMENTATION_REPRESENTATION_ADDED = "CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_ADDED",
19
+ SEGMENTATION_ADDED = "CORNERSTONE_TOOLS_SEGMENTATION_ADDED",
19
20
  SEGMENTATION_REPRESENTATION_MODIFIED = "CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_MODIFIED",
20
21
  SEGMENTATION_REMOVED = "CORNERSTONE_TOOLS_SEGMENTATION_REMOVED",
21
22
  SEGMENTATION_REPRESENTATION_REMOVED = "CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_REMOVED",
@@ -17,6 +17,7 @@ var Events;
17
17
  Events["SEGMENTATION_MODIFIED"] = "CORNERSTONE_TOOLS_SEGMENTATION_MODIFIED";
18
18
  Events["SEGMENTATION_RENDERED"] = "CORNERSTONE_TOOLS_SEGMENTATION_RENDERED";
19
19
  Events["SEGMENTATION_REPRESENTATION_ADDED"] = "CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_ADDED";
20
+ Events["SEGMENTATION_ADDED"] = "CORNERSTONE_TOOLS_SEGMENTATION_ADDED";
20
21
  Events["SEGMENTATION_REPRESENTATION_MODIFIED"] = "CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_MODIFIED";
21
22
  Events["SEGMENTATION_REMOVED"] = "CORNERSTONE_TOOLS_SEGMENTATION_REMOVED";
22
23
  Events["SEGMENTATION_REPRESENTATION_REMOVED"] = "CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_REMOVED";
@@ -4,6 +4,7 @@ import vtkColorTransferFunction from '@kitware/vtk.js/Rendering/Core/ColorTransf
4
4
  import vtkPiecewiseFunction from '@kitware/vtk.js/Common/DataModel/PiecewiseFunction';
5
5
  import { triggerSegmentationModified, triggerSegmentationRemoved, triggerSegmentationRepresentationModified, triggerSegmentationRepresentationRemoved, } from './triggerSegmentationEvents';
6
6
  import { segmentationStyle } from './SegmentationStyle';
7
+ import { triggerSegmentationAdded } from './events/triggerSegmentationAdded';
7
8
  const initialDefaultState = {
8
9
  colorLUT: [],
9
10
  segmentations: [],
@@ -62,7 +63,7 @@ export default class SegmentationStateManager {
62
63
  }
63
64
  state.segmentations.push(newSegmentation);
64
65
  });
65
- triggerSegmentationModified(segmentation.segmentationId);
66
+ triggerSegmentationAdded(segmentation.segmentationId);
66
67
  }
67
68
  removeSegmentation(segmentationId) {
68
69
  this.updateState((state) => {
@@ -25,8 +25,8 @@ function getSegmentIndexColor(viewportId, segmentationId, segmentIndex) {
25
25
  const representations = getSegmentationRepresentations(viewportId, {
26
26
  segmentationId,
27
27
  });
28
- if (!representations) {
29
- throw new Error(`segmentation representation with segmentationId ${segmentationId} does not exist`);
28
+ if (!representations || representations.length === 0) {
29
+ return null;
30
30
  }
31
31
  const representation = representations[0];
32
32
  const { colorLUTIndex } = representation;
@@ -0,0 +1 @@
1
+ export declare function triggerSegmentationAdded(segmentationId: string): void;
@@ -0,0 +1,8 @@
1
+ import { triggerEvent, eventTarget } from '@cornerstonejs/core';
2
+ import { Events } from '../../../enums';
3
+ export function triggerSegmentationAdded(segmentationId) {
4
+ const eventDetail = {
5
+ segmentationId,
6
+ };
7
+ triggerEvent(eventTarget, Events.SEGMENTATION_ADDED, eventDetail);
8
+ }
@@ -11,6 +11,7 @@ function normalizeSegmentationInput(segmentationInput) {
11
11
  normalizeContourData(data);
12
12
  }
13
13
  const normalizedSegments = normalizeSegments(config?.segments, type, data);
14
+ delete config?.segments;
14
15
  return {
15
16
  segmentationId,
16
17
  label: config?.label ?? null,
@@ -130,6 +130,9 @@ type SegmentationRepresentationRemovedEventDetail = {
130
130
  type SegmentationModifiedEventDetail = {
131
131
  segmentationId: string;
132
132
  };
133
+ type SegmentationAddedEventDetail = {
134
+ segmentationId: string;
135
+ };
133
136
  type KeyDownEventDetail = {
134
137
  element: HTMLDivElement;
135
138
  viewportId: string;
@@ -206,6 +209,7 @@ type SegmentationRemovedEventType = Types.CustomEventType<SegmentationRemovedEve
206
209
  type SegmentationRepresentationRemovedEventType = Types.CustomEventType<SegmentationRepresentationRemovedEventDetail>;
207
210
  type SegmentationRenderedEventType = Types.CustomEventType<SegmentationRenderedEventDetail>;
208
211
  type SegmentationModifiedEventType = Types.CustomEventType<SegmentationModifiedEventDetail>;
212
+ type SegmentationAddedEventType = Types.CustomEventType<SegmentationAddedEventDetail>;
209
213
  type KeyDownEventType = Types.CustomEventType<KeyDownEventDetail>;
210
214
  type KeyUpEventType = Types.CustomEventType<KeyUpEventDetail>;
211
215
  type MouseDownEventType = Types.CustomEventType<MouseDownEventDetail>;
@@ -226,4 +230,4 @@ type MouseClickEventType = Types.CustomEventType<MouseClickEventDetail>;
226
230
  type MouseMoveEventType = Types.CustomEventType<MouseMoveEventDetail>;
227
231
  type MouseDoubleClickEventType = Types.CustomEventType<MouseDoubleClickEventDetail>;
228
232
  type MouseWheelEventType = Types.CustomEventType<MouseWheelEventDetail>;
229
- export type { InteractionStartType, InteractionEndType, InteractionEventType, NormalizedInteractionEventDetail, NormalizedMouseEventType, NormalizedTouchEventType, ToolModeChangedEventDetail, ToolModeChangedEventType, ToolActivatedEventDetail, ToolActivatedEventType, AnnotationAddedEventDetail, AnnotationAddedEventType, AnnotationCompletedEventDetail, AnnotationCompletedEventType, AnnotationModifiedEventDetail, AnnotationModifiedEventType, AnnotationRemovedEventDetail, AnnotationRemovedEventType, AnnotationSelectionChangeEventDetail, AnnotationSelectionChangeEventType, AnnotationRenderedEventDetail, AnnotationRenderedEventType, AnnotationLockChangeEventDetail, AnnotationVisibilityChangeEventDetail, AnnotationLockChangeEventType, AnnotationVisibilityChangeEventType, AnnotationInterpolationCompletedEventDetail, AnnotationInterpolationCompletedEventType, AnnotationInterpolationRemovedEventDetail, AnnotationInterpolationRemovedEventType, ContourAnnotationCompletedEventDetail, SegmentationDataModifiedEventType, SegmentationRepresentationModifiedEventDetail, SegmentationRepresentationModifiedEventType, SegmentationRepresentationRemovedEventDetail, SegmentationRepresentationRemovedEventType, SegmentationRemovedEventType, SegmentationRemovedEventDetail, SegmentationDataModifiedEventDetail, SegmentationRenderedEventType, SegmentationRenderedEventDetail, SegmentationModifiedEventType, SegmentationModifiedEventDetail, KeyDownEventDetail, KeyDownEventType, KeyUpEventDetail, KeyUpEventType, MouseDownEventDetail, TouchStartEventDetail, MouseDownEventType, TouchStartEventType, MouseDownActivateEventDetail, TouchStartActivateEventDetail, MouseDownActivateEventType, TouchStartActivateEventType, MouseDragEventDetail, TouchDragEventDetail, MouseDragEventType, TouchDragEventType, MouseUpEventDetail, TouchEndEventDetail, MouseUpEventType, TouchEndEventType, MouseClickEventDetail, MouseClickEventType, TouchTapEventDetail, TouchTapEventType, TouchSwipeEventDetail, TouchSwipeEventType, TouchPressEventDetail, TouchPressEventType, MouseMoveEventDetail, MouseMoveEventType, MouseDoubleClickEventDetail, MouseDoubleClickEventType, MouseWheelEventDetail, MouseWheelEventType, };
233
+ export type { InteractionStartType, InteractionEndType, InteractionEventType, NormalizedInteractionEventDetail, NormalizedMouseEventType, NormalizedTouchEventType, ToolModeChangedEventDetail, ToolModeChangedEventType, ToolActivatedEventDetail, ToolActivatedEventType, AnnotationAddedEventDetail, AnnotationAddedEventType, AnnotationCompletedEventDetail, AnnotationCompletedEventType, AnnotationModifiedEventDetail, AnnotationModifiedEventType, AnnotationRemovedEventDetail, AnnotationRemovedEventType, AnnotationSelectionChangeEventDetail, AnnotationSelectionChangeEventType, AnnotationRenderedEventDetail, AnnotationRenderedEventType, AnnotationLockChangeEventDetail, AnnotationVisibilityChangeEventDetail, AnnotationLockChangeEventType, AnnotationVisibilityChangeEventType, AnnotationInterpolationCompletedEventDetail, AnnotationInterpolationCompletedEventType, AnnotationInterpolationRemovedEventDetail, AnnotationInterpolationRemovedEventType, ContourAnnotationCompletedEventDetail, SegmentationDataModifiedEventType, SegmentationRepresentationModifiedEventDetail, SegmentationRepresentationModifiedEventType, SegmentationRepresentationRemovedEventDetail, SegmentationRepresentationRemovedEventType, SegmentationRemovedEventType, SegmentationRemovedEventDetail, SegmentationDataModifiedEventDetail, SegmentationRenderedEventType, SegmentationRenderedEventDetail, SegmentationModifiedEventType, SegmentationModifiedEventDetail, KeyDownEventDetail, KeyDownEventType, KeyUpEventDetail, KeyUpEventType, MouseDownEventDetail, TouchStartEventDetail, MouseDownEventType, TouchStartEventType, MouseDownActivateEventDetail, TouchStartActivateEventDetail, MouseDownActivateEventType, TouchStartActivateEventType, MouseDragEventDetail, TouchDragEventDetail, MouseDragEventType, TouchDragEventType, MouseUpEventDetail, TouchEndEventDetail, MouseUpEventType, TouchEndEventType, MouseClickEventDetail, MouseClickEventType, TouchTapEventDetail, TouchTapEventType, TouchSwipeEventDetail, TouchSwipeEventType, TouchPressEventDetail, TouchPressEventType, MouseMoveEventDetail, MouseMoveEventType, MouseDoubleClickEventDetail, MouseDoubleClickEventType, MouseWheelEventDetail, MouseWheelEventType, SegmentationAddedEventDetail, SegmentationAddedEventType, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "2.1.7",
3
+ "version": "2.1.8",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "main": "./dist/esm/index.js",
6
6
  "types": "./dist/esm/index.d.ts",
@@ -105,7 +105,7 @@
105
105
  "canvas": "^2.11.2"
106
106
  },
107
107
  "peerDependencies": {
108
- "@cornerstonejs/core": "^2.1.7",
108
+ "@cornerstonejs/core": "^2.1.8",
109
109
  "@kitware/vtk.js": "32.1.0",
110
110
  "@types/d3-array": "^3.0.4",
111
111
  "@types/d3-interpolate": "^3.0.1",
@@ -124,5 +124,5 @@
124
124
  "type": "individual",
125
125
  "url": "https://ohif.org/donate"
126
126
  },
127
- "gitHead": "079eb63faace4c72556559fc1ce272c2a9a910ca"
127
+ "gitHead": "5addc676c0202a1ac03d89be5d727c4d88de3bca"
128
128
  }