@cornerstonejs/tools 4.0.0-beta.3 → 4.0.0-beta.5

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 (54) hide show
  1. package/dist/esm/enums/Events.d.ts +2 -0
  2. package/dist/esm/enums/Events.js +2 -0
  3. package/dist/esm/eventListeners/segmentation/imageChangeEventListener.js +5 -1
  4. package/dist/esm/index.d.ts +2 -2
  5. package/dist/esm/index.js +2 -2
  6. package/dist/esm/stateManagement/annotation/annotationVisibility.js +2 -0
  7. package/dist/esm/stateManagement/segmentation/SegmentationRenderingEngine.d.ts +1 -0
  8. package/dist/esm/stateManagement/segmentation/SegmentationRenderingEngine.js +11 -0
  9. package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.js +3 -0
  10. package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +13 -0
  11. package/dist/esm/stateManagement/segmentation/internalAddSegmentationRepresentation.js +11 -0
  12. package/dist/esm/store/ToolGroupManager/ToolGroup.js +10 -11
  13. package/dist/esm/tools/CrosshairsTool.d.ts +13 -12
  14. package/dist/esm/tools/CrosshairsTool.js +10 -3
  15. package/dist/esm/tools/OrientationMarkerTool.js +4 -2
  16. package/dist/esm/tools/OverlayGridTool.d.ts +2 -2
  17. package/dist/esm/tools/SegmentationIntersectionTool.d.ts +8 -5
  18. package/dist/esm/tools/SegmentationIntersectionTool.js +1 -1
  19. package/dist/esm/tools/VolumeCroppingControlTool.d.ts +91 -0
  20. package/dist/esm/tools/VolumeCroppingControlTool.js +1208 -0
  21. package/dist/esm/tools/VolumeCroppingTool.d.ts +96 -0
  22. package/dist/esm/tools/VolumeCroppingTool.js +1065 -0
  23. package/dist/esm/tools/WindowLevelTool.js +1 -1
  24. package/dist/esm/tools/annotation/ProbeTool.js +1 -0
  25. package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/utils/generateConvexHullFromContour.js +3 -3
  26. package/dist/esm/tools/annotation/VideoRedactionTool.d.ts +1 -1
  27. package/dist/esm/tools/annotation/VideoRedactionTool.js +1 -1
  28. package/dist/esm/tools/base/AnnotationTool.d.ts +1 -11
  29. package/dist/esm/tools/base/BaseTool.d.ts +2 -0
  30. package/dist/esm/tools/base/BaseTool.js +6 -0
  31. package/dist/esm/tools/index.d.ts +3 -1
  32. package/dist/esm/tools/index.js +3 -1
  33. package/dist/esm/tools/segmentation/CircleROIStartEndThresholdTool.js +30 -16
  34. package/dist/esm/tools/segmentation/LabelmapBaseTool.d.ts +2 -0
  35. package/dist/esm/tools/segmentation/LabelmapBaseTool.js +11 -0
  36. package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js +9 -3
  37. package/dist/esm/tools/segmentation/SegmentLabelTool.js +17 -5
  38. package/dist/esm/tools/segmentation/strategies/BrushStrategy.d.ts +1 -0
  39. package/dist/esm/tools/segmentation/strategies/compositions/preview.js +2 -0
  40. package/dist/esm/tools/segmentation/strategies/fillCircle.d.ts +3 -6
  41. package/dist/esm/tools/segmentation/strategies/fillCircle.js +53 -30
  42. package/dist/esm/tools/segmentation/strategies/fillRectangle.js +26 -24
  43. package/dist/esm/tools/segmentation/strategies/fillSphere.js +14 -12
  44. package/dist/esm/types/AnnotationTypes.d.ts +22 -19
  45. package/dist/esm/types/ContourAnnotation.d.ts +1 -0
  46. package/dist/esm/types/index.d.ts +2 -2
  47. package/dist/esm/utilities/planar/filterAnnotationsWithinSlice.js +17 -5
  48. package/dist/esm/utilities/segmentation/getBrushToolInstances.js +2 -2
  49. package/dist/esm/utilities/stackPrefetch/stackContextPrefetch.d.ts +1 -1
  50. package/dist/esm/utilities/stackPrefetch/stackContextPrefetch.js +20 -10
  51. package/dist/esm/utilities/stackPrefetch/stackPrefetch.js +12 -2
  52. package/dist/esm/version.d.ts +1 -1
  53. package/dist/esm/version.js +1 -1
  54. package/package.json +4 -4
@@ -4,6 +4,8 @@ declare enum Events {
4
4
  TOOLGROUP_VIEWPORT_REMOVED = "CORNERSTONE_TOOLS_TOOLGROUP_VIEWPORT_REMOVED",
5
5
  TOOL_MODE_CHANGED = "CORNERSTONE_TOOLS_TOOL_MODE_CHANGED",
6
6
  CROSSHAIR_TOOL_CENTER_CHANGED = "CORNERSTONE_TOOLS_CROSSHAIR_TOOL_CENTER_CHANGED",
7
+ VOLUMECROPPINGCONTROL_TOOL_CHANGED = "CORNERSTONE_TOOLS_VOLUMECROPPINGCONTROL_TOOL_CHANGED",
8
+ VOLUMECROPPING_TOOL_CHANGED = "CORNERSTONE_TOOLS_VOLUMECROPPING_TOOL_CHANGED",
7
9
  ANNOTATION_ADDED = "CORNERSTONE_TOOLS_ANNOTATION_ADDED",
8
10
  ANNOTATION_COMPLETED = "CORNERSTONE_TOOLS_ANNOTATION_COMPLETED",
9
11
  ANNOTATION_MODIFIED = "CORNERSTONE_TOOLS_ANNOTATION_MODIFIED",
@@ -5,6 +5,8 @@ var Events;
5
5
  Events["TOOLGROUP_VIEWPORT_REMOVED"] = "CORNERSTONE_TOOLS_TOOLGROUP_VIEWPORT_REMOVED";
6
6
  Events["TOOL_MODE_CHANGED"] = "CORNERSTONE_TOOLS_TOOL_MODE_CHANGED";
7
7
  Events["CROSSHAIR_TOOL_CENTER_CHANGED"] = "CORNERSTONE_TOOLS_CROSSHAIR_TOOL_CENTER_CHANGED";
8
+ Events["VOLUMECROPPINGCONTROL_TOOL_CHANGED"] = "CORNERSTONE_TOOLS_VOLUMECROPPINGCONTROL_TOOL_CHANGED";
9
+ Events["VOLUMECROPPING_TOOL_CHANGED"] = "CORNERSTONE_TOOLS_VOLUMECROPPING_TOOL_CHANGED";
8
10
  Events["ANNOTATION_ADDED"] = "CORNERSTONE_TOOLS_ANNOTATION_ADDED";
9
11
  Events["ANNOTATION_COMPLETED"] = "CORNERSTONE_TOOLS_ANNOTATION_COMPLETED";
10
12
  Events["ANNOTATION_MODIFIED"] = "CORNERSTONE_TOOLS_ANNOTATION_MODIFIED";
@@ -65,6 +65,7 @@ function _imageChangeEventListener(evt) {
65
65
  if (!derivedImageIds) {
66
66
  return;
67
67
  }
68
+ let shouldTriggerSegmentationRender = false;
68
69
  const updateSegmentationActor = (derivedImageId) => {
69
70
  const derivedImage = cache.getImage(derivedImageId);
70
71
  if (!derivedImage) {
@@ -103,7 +104,7 @@ function _imageChangeEventListener(evt) {
103
104
  },
104
105
  },
105
106
  ]);
106
- triggerSegmentationRender(viewportId);
107
+ shouldTriggerSegmentationRender = true;
107
108
  return;
108
109
  }
109
110
  else {
@@ -119,6 +120,9 @@ function _imageChangeEventListener(evt) {
119
120
  }
120
121
  };
121
122
  derivedImageIds.forEach(updateSegmentationActor);
123
+ if (shouldTriggerSegmentationRender) {
124
+ triggerSegmentationRender(viewportId);
125
+ }
122
126
  viewport.render();
123
127
  if (evt.type === Enums.Events.IMAGE_RENDERED) {
124
128
  viewport.element.removeEventListener(Enums.Events.IMAGE_RENDERED, _imageChangeEventListener);
@@ -12,7 +12,7 @@ import * as Types from './types';
12
12
  import * as annotation from './stateManagement/annotation';
13
13
  import * as segmentation from './stateManagement/segmentation';
14
14
  import * as splines from './tools/annotation/splines';
15
- import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, SegmentBidirectionalTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, UltrasoundPleuraBLineTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentLabelTool, LabelMapEditWithContourTool } from './tools';
15
+ import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, VolumeCroppingTool, VolumeCroppingControlTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, SegmentBidirectionalTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, UltrasoundPleuraBLineTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentLabelTool, LabelMapEditWithContourTool } from './tools';
16
16
  import VideoRedactionTool from './tools/annotation/VideoRedactionTool';
17
17
  import * as Enums from './enums';
18
- export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, SegmentBidirectionalTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, UltrasoundPleuraBLineTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, SegmentLabelTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, store, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, LabelMapEditWithContourTool, splines, version, };
18
+ export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, SegmentBidirectionalTool, TrackballRotateTool, VolumeCroppingTool, VolumeCroppingControlTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, UltrasoundPleuraBLineTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, SegmentLabelTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, store, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, LabelMapEditWithContourTool, splines, version, };
package/dist/esm/index.js CHANGED
@@ -12,7 +12,7 @@ import * as Types from './types';
12
12
  import * as annotation from './stateManagement/annotation';
13
13
  import * as segmentation from './stateManagement/segmentation';
14
14
  import * as splines from './tools/annotation/splines';
15
- import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, SegmentBidirectionalTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, UltrasoundPleuraBLineTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentLabelTool, LabelMapEditWithContourTool, } from './tools';
15
+ import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, VolumeCroppingTool, VolumeCroppingControlTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, SegmentBidirectionalTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, UltrasoundPleuraBLineTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentLabelTool, LabelMapEditWithContourTool, } from './tools';
16
16
  import VideoRedactionTool from './tools/annotation/VideoRedactionTool';
17
17
  import * as Enums from './enums';
18
- export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, SegmentBidirectionalTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, UltrasoundPleuraBLineTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, SegmentLabelTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, store, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, LabelMapEditWithContourTool, splines, version, };
18
+ export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, SegmentBidirectionalTool, TrackballRotateTool, VolumeCroppingTool, VolumeCroppingControlTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, UltrasoundPleuraBLineTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, SegmentLabelTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, store, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, LabelMapEditWithContourTool, splines, version, };
@@ -49,6 +49,8 @@ function hide(annotationUID, annotationUIDsSet, detail) {
49
49
  deselectAnnotation(annotationUID);
50
50
  }
51
51
  detail.lastHidden.push(annotationUID);
52
+ const annotation = getAnnotation(annotationUID);
53
+ annotation.isVisible = false;
52
54
  }
53
55
  }
54
56
  function publish(detail) {
@@ -1,5 +1,6 @@
1
1
  declare class SegmentationRenderingEngine {
2
2
  private _needsRender;
3
+ private _pendingRenderQueue;
3
4
  private _animationFrameSet;
4
5
  private _animationFrameHandle;
5
6
  hasBeenDestroyed: boolean;
@@ -18,6 +18,7 @@ const planarContourToolName = PlanarFreehandContourSegmentationTool.toolName;
18
18
  class SegmentationRenderingEngine {
19
19
  constructor() {
20
20
  this._needsRender = new Set();
21
+ this._pendingRenderQueue = [];
21
22
  this._animationFrameSet = false;
22
23
  this._animationFrameHandle = null;
23
24
  this._getAllViewports = () => {
@@ -33,6 +34,12 @@ class SegmentationRenderingEngine {
33
34
  this._needsRender.clear();
34
35
  this._animationFrameSet = false;
35
36
  this._animationFrameHandle = null;
37
+ if (this._pendingRenderQueue.length > 0) {
38
+ const nextViewportIds = this._pendingRenderQueue.shift();
39
+ if (nextViewportIds && nextViewportIds.length > 0) {
40
+ this._setViewportsToBeRenderedNextFrame(nextViewportIds);
41
+ }
42
+ }
36
43
  };
37
44
  }
38
45
  renderSegmentationsForViewport(viewportId) {
@@ -71,6 +78,10 @@ class SegmentationRenderingEngine {
71
78
  }
72
79
  }
73
80
  _setViewportsToBeRenderedNextFrame(viewportIds) {
81
+ if (this._animationFrameSet) {
82
+ this._pendingRenderQueue.push(viewportIds);
83
+ return;
84
+ }
74
85
  viewportIds.forEach((viewportId) => {
75
86
  this._needsRender.add(viewportId);
76
87
  });
@@ -24,6 +24,9 @@ function setSegmentIndexVisibility(viewportId, specifier, segmentIndex, visibili
24
24
  return;
25
25
  }
26
26
  representations.forEach((representation) => {
27
+ if (!representation.segments || !representation.segments[segmentIndex]) {
28
+ return;
29
+ }
27
30
  representation.segments[segmentIndex].visible = visibility;
28
31
  });
29
32
  triggerSegmentationRenderBySegmentationId(specifier.segmentationId);
@@ -44,6 +44,9 @@ function normalizeSegments(segmentsConfig, type, data) {
44
44
  normalizedSegments[segmentIndex] = normalizedSegment;
45
45
  });
46
46
  }
47
+ else if (type === SegmentationRepresentations.Contour) {
48
+ normalizeContourSegments(normalizedSegments, data);
49
+ }
47
50
  else if (type === SegmentationRepresentations.Surface) {
48
51
  normalizeSurfaceSegments(normalizedSegments, data);
49
52
  }
@@ -52,6 +55,16 @@ function normalizeSegments(segmentsConfig, type, data) {
52
55
  }
53
56
  return normalizedSegments;
54
57
  }
58
+ function normalizeContourSegments(normalizedSegments, contourData) {
59
+ const { geometryIds } = contourData;
60
+ geometryIds?.forEach((geometryId) => {
61
+ const geometry = cache.getGeometry(geometryId);
62
+ if (geometry?.data) {
63
+ const { segmentIndex } = geometry.data;
64
+ normalizedSegments[segmentIndex] = { segmentIndex };
65
+ }
66
+ });
67
+ }
55
68
  function normalizeSurfaceSegments(normalizedSegments, surfaceData) {
56
69
  const { geometryIds } = surfaceData;
57
70
  geometryIds?.forEach((geometryId) => {
@@ -4,6 +4,7 @@ import { SegmentationRepresentations } from '../../enums';
4
4
  import { triggerSegmentationModified } from './triggerSegmentationEvents';
5
5
  import { addColorLUT } from './addColorLUT';
6
6
  import { defaultSegmentationStateManager } from './SegmentationStateManager';
7
+ import { getActiveSegmentIndex, setActiveSegmentIndex } from './segmentIndex';
7
8
  function internalAddSegmentationRepresentation(viewportId, representationInput) {
8
9
  const { segmentationId, config } = representationInput;
9
10
  const renderingConfig = {
@@ -11,6 +12,16 @@ function internalAddSegmentationRepresentation(viewportId, representationInput)
11
12
  ...config,
12
13
  };
13
14
  defaultSegmentationStateManager.addSegmentationRepresentation(viewportId, segmentationId, representationInput.type, renderingConfig);
15
+ if (!getActiveSegmentIndex(segmentationId)) {
16
+ const segmentation = defaultSegmentationStateManager.getSegmentation(segmentationId);
17
+ if (segmentation) {
18
+ const segmentKeys = Object.keys(segmentation.segments);
19
+ if (segmentKeys.length > 0) {
20
+ const firstSegmentIndex = segmentKeys.map((k) => Number(k)).sort()[0];
21
+ setActiveSegmentIndex(segmentationId, firstSegmentIndex);
22
+ }
23
+ }
24
+ }
14
25
  if (representationInput.type === SegmentationRepresentations.Contour) {
15
26
  triggerAnnotationRenderForViewportIds([viewportId]);
16
27
  }
@@ -91,10 +91,7 @@ export default class ToolGroup {
91
91
  });
92
92
  }
93
93
  const toolName = this.getActivePrimaryMouseButtonTool();
94
- const runtimeSettings = Settings.getRuntimeSettings();
95
- if (runtimeSettings.get('useCursors')) {
96
- this.setViewportsCursorByToolName(toolName);
97
- }
94
+ this.setViewportsCursorByToolName(toolName);
98
95
  const eventDetail = {
99
96
  toolGroupId: this.id,
100
97
  viewportId,
@@ -190,18 +187,16 @@ export default class ToolGroup {
190
187
  };
191
188
  this.toolOptions[toolName] = toolOptions;
192
189
  this._toolInstances[toolName].mode = Active;
193
- const runtimeSettings = Settings.getRuntimeSettings();
194
- const useCursor = runtimeSettings.get('useCursors');
195
- if (this._hasMousePrimaryButtonBinding(toolBindingsOptions) && useCursor) {
196
- this.setViewportsCursorByToolName(toolName);
197
- }
198
- else {
190
+ if (!this._hasMousePrimaryButtonBinding(toolBindingsOptions)) {
199
191
  const activeToolIdentifier = this.getActivePrimaryMouseButtonTool();
200
- if (!activeToolIdentifier && useCursor) {
192
+ if (!activeToolIdentifier) {
201
193
  const cursor = MouseCursor.getDefinedCursor('default');
202
194
  this._setCursorForViewports(cursor);
203
195
  }
204
196
  }
197
+ else {
198
+ this.setViewportsCursorByToolName(toolName);
199
+ }
205
200
  if (this._hasMousePrimaryButtonBinding(toolBindingsOptions)) {
206
201
  if (this.prevActivePrimaryToolName === null) {
207
202
  this.prevActivePrimaryToolName = toolName;
@@ -331,6 +326,10 @@ export default class ToolGroup {
331
326
  return MouseCursor.getDefinedCursor('default');
332
327
  }
333
328
  _setCursorForViewports(cursor) {
329
+ const runtimeSettings = Settings.getRuntimeSettings();
330
+ if (!runtimeSettings.get('useCursors')) {
331
+ return;
332
+ }
334
333
  this.viewportsInfo.forEach(({ renderingEngineId, viewportId }) => {
335
334
  const enabledElement = getEnabledElementByIds(viewportId, renderingEngineId);
336
335
  if (!enabledElement) {
@@ -1,18 +1,19 @@
1
1
  import { AnnotationTool } from './base';
2
2
  import type { Types } from '@cornerstonejs/core';
3
- import type { Annotation, Annotations, EventTypes, ToolHandle, PublicToolProps, ToolProps, InteractionTypes, SVGDrawingHelper } from '../types';
4
- interface CrosshairsAnnotation extends Annotation {
5
- data: {
6
- handles: {
7
- rotationPoints: Types.Point3[];
8
- slabThicknessPoints: Types.Point3[];
9
- activeOperation: number | null;
10
- toolCenter: Types.Point3;
11
- };
12
- activeViewportIds: string[];
13
- viewportId: string;
3
+ import type { Annotation, AnnotationData, Annotations, EventTypes, ToolHandle, PublicToolProps, ToolProps, InteractionTypes, SVGDrawingHelper } from '../types';
4
+ export type CrosshairsAnnotationData = AnnotationData & {
5
+ handles: {
6
+ rotationPoints: Types.Point3[];
7
+ slabThicknessPoints: Types.Point3[];
8
+ activeOperation: number | null;
9
+ toolCenter: Types.Point3;
14
10
  };
15
- }
11
+ activeViewportIds: string[];
12
+ viewportId: string;
13
+ };
14
+ export type CrosshairsAnnotation = Annotation & {
15
+ data: CrosshairsAnnotationData;
16
+ };
16
17
  declare class CrosshairsTool extends AnnotationTool {
17
18
  static toolName: any;
18
19
  toolCenter: Types.Point3;
@@ -32,7 +32,6 @@ const OPERATION = {
32
32
  ROTATE: 2,
33
33
  SLAB: 3,
34
34
  };
35
- const EPSILON = 1e-3;
36
35
  class CrosshairsTool extends AnnotationTool {
37
36
  constructor(toolProps = {}, defaultToolProps = {
38
37
  supportedInteractionTypes: ['Mouse'],
@@ -51,12 +50,14 @@ class CrosshairsTool extends AnnotationTool {
51
50
  handleRadius: 3,
52
51
  enableHDPIHandles: false,
53
52
  referenceLinesCenterGapRadius: 20,
53
+ referenceLinesCenterGapRatio: null,
54
54
  filterActorUIDsToSetSlabThickness: [],
55
55
  slabThicknessBlendMode: Enums.BlendModes.MAXIMUM_INTENSITY_BLEND,
56
56
  mobile: {
57
57
  enabled: false,
58
58
  opacity: 0.8,
59
59
  handleRadius: 9,
60
+ referenceLinesCenterGapRatio: 0.05,
60
61
  },
61
62
  },
62
63
  }) {
@@ -384,7 +385,13 @@ class CrosshairsTool extends AnnotationTool {
384
385
  const canvasVectorFromCenterShort = vec2.create();
385
386
  vec2.scale(canvasVectorFromCenterShort, canvasUnitVectorFromCenter, canvasMinDimensionLength * 0.2);
386
387
  const canvasVectorFromCenterStart = vec2.create();
387
- const centerGap = this.configuration.referenceLinesCenterGapRadius;
388
+ const mobileConfig = this.configuration.mobile;
389
+ const { referenceLinesCenterGapRatio } = mobileConfig?.enabled
390
+ ? mobileConfig
391
+ : this.configuration;
392
+ const centerGap = referenceLinesCenterGapRatio > 0
393
+ ? canvasMinDimensionLength * referenceLinesCenterGapRatio
394
+ : this.configuration.referenceLinesCenterGapRadius;
388
395
  vec2.scale(canvasVectorFromCenterStart, canvasUnitVectorFromCenter, otherViewportAnnotations.length === 2 ? centerGap : 0);
389
396
  const refLinePointOne = vec2.create();
390
397
  const refLinePointTwo = vec2.create();
@@ -1044,7 +1051,7 @@ class CrosshairsTool extends AnnotationTool {
1044
1051
  ];
1045
1052
  const viewportDraggableRotatable = this._getReferenceLineDraggableRotatable(otherViewport.id);
1046
1053
  if (!viewportDraggableRotatable) {
1047
- const { rotationPoints } = this.editData.annotation.data.handles;
1054
+ const { rotationPoints } = (this.editData.annotation.data).handles;
1048
1055
  const otherViewportRotationPoints = rotationPoints.filter((point) => point[1].uid === otherViewport.id);
1049
1056
  if (otherViewportRotationPoints.length === 2) {
1050
1057
  const point1 = viewport.canvasToWorld(otherViewportRotationPoints[0][3]);
@@ -159,7 +159,8 @@ class OrientationMarkerTool extends BaseTool {
159
159
  actor?.delete();
160
160
  const renderWindow = viewport
161
161
  .getRenderingEngine()
162
- .offscreenMultiRenderWindow.getRenderWindow();
162
+ .getOffscreenMultiRenderWindow(viewport.id)
163
+ .getRenderWindow();
163
164
  renderWindow.render();
164
165
  viewport.getRenderingEngine().render();
165
166
  delete this.orientationMarkers[viewport.id];
@@ -204,7 +205,8 @@ class OrientationMarkerTool extends BaseTool {
204
205
  const renderer = viewport.getRenderer();
205
206
  const renderWindow = viewport
206
207
  .getRenderingEngine()
207
- .offscreenMultiRenderWindow.getRenderWindow();
208
+ .getOffscreenMultiRenderWindow(viewportId)
209
+ .getRenderWindow();
208
210
  const { enabled, viewportCorner, viewportSize, minPixelSize, maxPixelSize, } = this.configuration.orientationWidget;
209
211
  const orientationWidget = vtkOrientationMarkerWidget.newInstance({
210
212
  actor,
@@ -1,12 +1,12 @@
1
1
  import type { Types } from '@cornerstonejs/core';
2
2
  import type { PublicToolProps, ToolProps, SVGDrawingHelper, Annotation } from '../types';
3
3
  import AnnotationDisplayTool from './base/AnnotationDisplayTool';
4
- export interface OverlayGridAnnotation extends Annotation {
4
+ export type OverlayGridAnnotation = Annotation & {
5
5
  data: {
6
6
  viewportData: Map<string, object>;
7
7
  pointSets: Array<object>;
8
8
  };
9
- }
9
+ };
10
10
  declare class OverlayGridTool extends AnnotationDisplayTool {
11
11
  static toolName: any;
12
12
  _throttledCalculateCachedStats: Function;
@@ -1,12 +1,15 @@
1
1
  import type { Types } from '@cornerstonejs/core';
2
- import type { PublicToolProps, ToolProps, SVGDrawingHelper } from '../types';
2
+ import type { PublicToolProps, ToolProps, SVGDrawingHelper, Annotation } from '../types';
3
3
  import AnnotationDisplayTool from './base/AnnotationDisplayTool';
4
- import type { Annotation } from '../types';
5
- export interface SegmentationIntersectionAnnotation extends Annotation {
4
+ export type WorldPointSet = {
5
+ worldPointsSet: any;
6
+ color: any;
7
+ };
8
+ export type SegmentationIntersectionAnnotation = Annotation & {
6
9
  data: {
7
- actorsWorldPointsMap: Map<string, Map<string, object>>;
10
+ actorsWorldPointsMap: Map<string, Map<string, WorldPointSet>>;
8
11
  };
9
- }
12
+ };
10
13
  declare class SegmentationIntersectionTool extends AnnotationDisplayTool {
11
14
  static toolName: any;
12
15
  constructor(toolProps?: PublicToolProps, defaultToolProps?: ToolProps);
@@ -60,7 +60,7 @@ class SegmentationIntersectionTool extends AnnotationDisplayTool {
60
60
  }
61
61
  const annotation = annotations[0];
62
62
  const { annotationUID } = annotation;
63
- const actorsWorldPointsMap = annotation.data.actorsWorldPointsMap;
63
+ const actorsWorldPointsMap = (annotation).data.actorsWorldPointsMap;
64
64
  calculateSurfaceSegmentationIntersectionsForViewport(actorsWorldPointsMap, viewport);
65
65
  const actorEntries = viewport.getActors();
66
66
  const cacheId = getCacheId(viewport);
@@ -0,0 +1,91 @@
1
+ import type vtkPlane from '@kitware/vtk.js/Common/DataModel/Plane';
2
+ import { AnnotationTool } from './base';
3
+ import type { Types } from '@cornerstonejs/core';
4
+ import type { Annotation, Annotations, EventTypes, ToolHandle, PublicToolProps, ToolProps, InteractionTypes, SVGDrawingHelper } from '../types';
5
+ type ReferenceLine = [
6
+ viewport: {
7
+ id: string;
8
+ canvas?: HTMLCanvasElement;
9
+ canvasToWorld?: (...args: unknown[]) => Types.Point3;
10
+ },
11
+ startPoint: Types.Point2,
12
+ endPoint: Types.Point2,
13
+ type: 'min' | 'max'
14
+ ];
15
+ interface VolumeCroppingAnnotation extends Annotation {
16
+ data: {
17
+ handles: {
18
+ activeOperation: number | null;
19
+ toolCenter: Types.Point3;
20
+ toolCenterMin: Types.Point3;
21
+ toolCenterMax: Types.Point3;
22
+ };
23
+ activeViewportIds: string[];
24
+ viewportId: string;
25
+ referenceLines: ReferenceLine[];
26
+ clippingPlanes?: vtkPlane[];
27
+ clippingPlaneReferenceLines?: ReferenceLine[];
28
+ orientation?: string;
29
+ };
30
+ isVirtual?: boolean;
31
+ virtualNormal?: Types.Point3;
32
+ }
33
+ declare class VolumeCroppingControlTool extends AnnotationTool {
34
+ _virtualAnnotations: VolumeCroppingAnnotation[];
35
+ static toolName: any;
36
+ seriesInstanceUID?: string;
37
+ sphereStates: {
38
+ point: Types.Point3;
39
+ axis: string;
40
+ uid: string;
41
+ sphereSource: any;
42
+ sphereActor: any;
43
+ }[];
44
+ draggingSphereIndex: number | null;
45
+ toolCenter: Types.Point3;
46
+ toolCenterMin: Types.Point3;
47
+ toolCenterMax: Types.Point3;
48
+ _getReferenceLineColor?: (viewportId: string) => string;
49
+ _getReferenceLineControllable?: (viewportId: string) => boolean;
50
+ constructor(toolProps?: PublicToolProps, defaultToolProps?: ToolProps);
51
+ _updateToolCentersFromViewport(viewport: any): void;
52
+ initializeViewport: ({ renderingEngineId, viewportId, }: Types.IViewportId) => {
53
+ normal: Types.Point3;
54
+ point: Types.Point3;
55
+ };
56
+ _getViewportsInfo: () => any[];
57
+ onSetToolInactive(): void;
58
+ onSetToolActive(): void;
59
+ onSetToolEnabled(): void;
60
+ onSetToolDisabled(): void;
61
+ resetCroppingSpheres: () => void;
62
+ computeToolCenter: () => void;
63
+ _computeToolCenter: (viewportsInfo: any) => void;
64
+ _getOrientationFromNormal(normal: Types.Point3): string | null;
65
+ _syncWithVolumeCroppingTool(originalClippingPlanes: any): void;
66
+ setToolCenter(toolCenter: Types.Point3, handleType: any): void;
67
+ addNewAnnotation(evt: EventTypes.InteractionEventType): VolumeCroppingAnnotation;
68
+ cancel: () => void;
69
+ isPointNearTool: (element: HTMLDivElement, annotation: VolumeCroppingAnnotation, canvasCoords: Types.Point2, proximity: number) => boolean;
70
+ toolSelectedCallback: (evt: EventTypes.InteractionEventType, annotation: Annotation, interactionType: InteractionTypes) => void;
71
+ handleSelectedCallback(evt: EventTypes.InteractionEventType, annotation: Annotation, handle: ToolHandle, interactionType: InteractionTypes): void;
72
+ onResetCamera: (evt: any) => void;
73
+ mouseMoveCallback: (evt: EventTypes.MouseMoveEventType, filteredToolAnnotations: Annotations) => boolean;
74
+ filterInteractableAnnotationsForElement: (element: any, annotations: any) => any;
75
+ renderAnnotation: (enabledElement: Types.IEnabledElement, svgDrawingHelper: SVGDrawingHelper) => boolean;
76
+ _getAnnotations: (enabledElement: Types.IEnabledElement) => Annotation[];
77
+ _onSphereMoved: (evt: any) => void;
78
+ _onNewVolume: () => void;
79
+ _unsubscribeToViewportNewVolumeSet(viewportsInfo: any): void;
80
+ _subscribeToViewportNewVolumeSet(viewports: any): void;
81
+ _getAnnotationsForViewportsWithDifferentCameras: (enabledElement: any, annotations: any) => any;
82
+ _filterViewportWithSameOrientation: (enabledElement: any, referenceAnnotation: any, annotations: any) => any;
83
+ _activateModify: (element: any) => void;
84
+ _deactivateModify: (element: any) => void;
85
+ _endCallback: (evt: EventTypes.InteractionEventType) => void;
86
+ _dragCallback: (evt: EventTypes.InteractionEventType) => void;
87
+ _applyDeltaShiftToSelectedViewportCameras(renderingEngine: any, viewportsAnnotationsToUpdate: any, delta: any): void;
88
+ _applyDeltaShiftToViewportCamera(renderingEngine: Types.IRenderingEngine, annotation: any, delta: any): void;
89
+ _pointNearTool(element: any, annotation: any, canvasCoords: any, proximity: any): boolean;
90
+ }
91
+ export default VolumeCroppingControlTool;