@cornerstonejs/tools 4.22.13 → 5.0.0

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 (225) hide show
  1. package/dist/esm/config.d.ts +4 -0
  2. package/dist/esm/drawingSvg/drawPath.d.ts +3 -0
  3. package/dist/esm/drawingSvg/drawPath.js +4 -1
  4. package/dist/esm/eventListeners/keyboard/keyDownListener.js +2 -2
  5. package/dist/esm/eventListeners/mouse/getMouseEventPoints.d.ts +1 -1
  6. package/dist/esm/eventListeners/mouse/getMouseEventPoints.js +19 -1
  7. package/dist/esm/eventListeners/mouse/mouseDoubleClickListener.js +8 -1
  8. package/dist/esm/eventListeners/mouse/mouseDownListener.js +37 -5
  9. package/dist/esm/eventListeners/mouse/mouseMoveListener.js +3 -0
  10. package/dist/esm/eventListeners/segmentation/imageChangeEventListener.js +60 -92
  11. package/dist/esm/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.js +49 -21
  12. package/dist/esm/eventListeners/segmentation/labelmap/performStackLabelmapUpdate.js +7 -13
  13. package/dist/esm/eventListeners/segmentation/labelmap/performVolumeLabelmapUpdate.js +44 -18
  14. package/dist/esm/eventListeners/touch/getTouchEventPoints.js +27 -4
  15. package/dist/esm/eventListeners/touch/touchStartListener.js +27 -9
  16. package/dist/esm/eventListeners/wheel/wheelListener.js +5 -1
  17. package/dist/esm/init.js +2 -0
  18. package/dist/esm/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.js +10 -4
  19. package/dist/esm/stateManagement/segmentation/SegmentationRenderingEngine.js +23 -20
  20. package/dist/esm/stateManagement/segmentation/SegmentationRepresentationDisplayRegistry.d.ts +12 -0
  21. package/dist/esm/stateManagement/segmentation/SegmentationRepresentationDisplayRegistry.js +7 -0
  22. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.d.ts +1 -11
  23. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +28 -166
  24. package/dist/esm/stateManagement/segmentation/addColorLUT.js +7 -1
  25. package/dist/esm/stateManagement/segmentation/getCurrentLabelmapImageIdForViewport.js +16 -1
  26. package/dist/esm/stateManagement/segmentation/helpers/clearSegmentValue.js +9 -7
  27. package/dist/esm/stateManagement/segmentation/helpers/getSegmentationActor.d.ts +1 -1
  28. package/dist/esm/stateManagement/segmentation/helpers/getSegmentationActor.js +3 -2
  29. package/dist/esm/stateManagement/segmentation/helpers/getViewportLabelmapRenderMode.d.ts +5 -0
  30. package/dist/esm/stateManagement/segmentation/helpers/getViewportLabelmapRenderMode.js +58 -0
  31. package/dist/esm/stateManagement/segmentation/helpers/labelmapImageMapperSupport.d.ts +52 -0
  32. package/dist/esm/stateManagement/segmentation/helpers/labelmapImageMapperSupport.js +246 -0
  33. package/dist/esm/stateManagement/segmentation/helpers/labelmapSegmentationState.d.ts +1 -0
  34. package/dist/esm/stateManagement/segmentation/helpers/labelmapSegmentationState.js +1 -0
  35. package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +11 -1
  36. package/dist/esm/stateManagement/segmentation/internalAddSegmentationRepresentation.js +3 -3
  37. package/dist/esm/stateManagement/segmentation/labelmapModel/index.d.ts +9 -0
  38. package/dist/esm/stateManagement/segmentation/labelmapModel/index.js +7 -0
  39. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapEditTransaction.d.ts +54 -0
  40. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapEditTransaction.js +224 -0
  41. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageIdMapping.d.ts +6 -0
  42. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageIdMapping.js +39 -0
  43. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageReferenceResolver.d.ts +23 -0
  44. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageReferenceResolver.js +269 -0
  45. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLayerStore.d.ts +15 -0
  46. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLayerStore.js +160 -0
  47. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLegacyAdapter.d.ts +4 -0
  48. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLegacyAdapter.js +42 -0
  49. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapSegmentBindings.d.ts +11 -0
  50. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapSegmentBindings.js +73 -0
  51. package/dist/esm/stateManagement/segmentation/labelmapModel/normalizeLabelmapSegmentationData.d.ts +17 -0
  52. package/dist/esm/stateManagement/segmentation/labelmapModel/normalizeLabelmapSegmentationData.js +75 -0
  53. package/dist/esm/stateManagement/segmentation/labelmapModel/privateLabelmap.d.ts +5 -0
  54. package/dist/esm/stateManagement/segmentation/labelmapModel/privateLabelmap.js +106 -0
  55. package/dist/esm/stateManagement/segmentation/models/SegmentModel.d.ts +11 -0
  56. package/dist/esm/stateManagement/segmentation/models/SegmentModel.js +19 -0
  57. package/dist/esm/stateManagement/segmentation/models/SegmentationModel.d.ts +12 -0
  58. package/dist/esm/stateManagement/segmentation/models/SegmentationModel.js +23 -0
  59. package/dist/esm/stateManagement/segmentation/removeSegmentationRepresentations.js +6 -10
  60. package/dist/esm/stateManagement/segmentation/segmentIndex.js +24 -0
  61. package/dist/esm/stateManagement/segmentation/segmentationEventManager.js +2 -9
  62. package/dist/esm/stateManagement/segmentation/segmentationState.d.ts +2 -1
  63. package/dist/esm/stateManagement/segmentation/segmentationState.js +4 -1
  64. package/dist/esm/store/state.js +2 -1
  65. package/dist/esm/synchronizers/callbacks/imageSliceSyncCallback.js +12 -3
  66. package/dist/esm/synchronizers/callbacks/presentationViewSyncCallback.js +5 -2
  67. package/dist/esm/synchronizers/callbacks/zoomPanSyncCallback.js +51 -3
  68. package/dist/esm/tools/AdvancedMagnifyTool.js +1 -1
  69. package/dist/esm/tools/CrosshairsTool.js +5 -5
  70. package/dist/esm/tools/OrientationControllerTool.js +1 -1
  71. package/dist/esm/tools/OrientationMarkerTool.js +4 -4
  72. package/dist/esm/tools/PanTool.js +26 -3
  73. package/dist/esm/tools/PlanarRotateTool.js +19 -4
  74. package/dist/esm/tools/ReferenceCursors.js +7 -1
  75. package/dist/esm/tools/SculptorTool/CircleSculptCursor.js +1 -1
  76. package/dist/esm/tools/TrackballRotateTool.js +3 -2
  77. package/dist/esm/tools/VolumeCroppingTool.js +3 -2
  78. package/dist/esm/tools/WindowLevelTool.d.ts +2 -1
  79. package/dist/esm/tools/WindowLevelTool.js +48 -4
  80. package/dist/esm/tools/ZoomTool.d.ts +8 -0
  81. package/dist/esm/tools/ZoomTool.js +92 -11
  82. package/dist/esm/tools/annotation/AngleTool.js +33 -31
  83. package/dist/esm/tools/annotation/ArrowAnnotateTool.js +30 -28
  84. package/dist/esm/tools/annotation/BidirectionalTool.js +51 -49
  85. package/dist/esm/tools/annotation/CircleROITool.js +49 -44
  86. package/dist/esm/tools/annotation/CobbAngleTool.js +1 -1
  87. package/dist/esm/tools/annotation/DragProbeTool.js +1 -1
  88. package/dist/esm/tools/annotation/ETDRSGridTool.js +1 -1
  89. package/dist/esm/tools/annotation/EllipticalROITool.js +42 -37
  90. package/dist/esm/tools/annotation/HeightTool.js +1 -1
  91. package/dist/esm/tools/annotation/KeyImageTool.js +11 -11
  92. package/dist/esm/tools/annotation/LabelTool.js +37 -35
  93. package/dist/esm/tools/annotation/LengthTool.js +35 -33
  94. package/dist/esm/tools/annotation/LivewireContourSegmentationTool.js +6 -4
  95. package/dist/esm/tools/annotation/LivewireContourTool.js +1 -1
  96. package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js +6 -4
  97. package/dist/esm/tools/annotation/PlanarFreehandROITool.js +1 -1
  98. package/dist/esm/tools/annotation/ProbeTool.js +51 -46
  99. package/dist/esm/tools/annotation/RectangleROITool.js +42 -37
  100. package/dist/esm/tools/annotation/RegionSegmentPlusTool.js +1 -1
  101. package/dist/esm/tools/annotation/RegionSegmentTool.js +1 -1
  102. package/dist/esm/tools/annotation/SplineContourSegmentationTool.js +1 -1
  103. package/dist/esm/tools/annotation/SplineROITool.js +51 -49
  104. package/dist/esm/tools/annotation/UltrasoundDirectionalTool.js +1 -1
  105. package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/UltrasoundPleuraBLineTool.js +57 -55
  106. package/dist/esm/tools/annotation/VideoRedactionTool.js +1 -1
  107. package/dist/esm/tools/base/AnnotationDisplayTool.js +9 -6
  108. package/dist/esm/tools/base/AnnotationTool.js +2 -1
  109. package/dist/esm/tools/base/BaseTool.js +16 -10
  110. package/dist/esm/tools/base/ContourSegmentationBaseTool.js +1 -1
  111. package/dist/esm/tools/base/GrowCutBaseTool.js +2 -2
  112. package/dist/esm/tools/displayTools/Labelmap/addLabelmapToElement.d.ts +2 -4
  113. package/dist/esm/tools/displayTools/Labelmap/addLabelmapToElement.js +15 -85
  114. package/dist/esm/tools/displayTools/Labelmap/labelmapActorStyle.d.ts +5 -0
  115. package/dist/esm/tools/displayTools/Labelmap/labelmapActorStyle.js +191 -0
  116. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.d.ts +4 -3
  117. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +48 -209
  118. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/createLabelmapRenderPlan.d.ts +3 -0
  119. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/createLabelmapRenderPlan.js +51 -0
  120. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/index.d.ts +4 -0
  121. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/index.js +3 -0
  122. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan.d.ts +14 -0
  123. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan.js +143 -0
  124. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/planarGenericVolumeLabelmap.d.ts +40 -0
  125. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/planarGenericVolumeLabelmap.js +79 -0
  126. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/removeLabelmapRepresentationFromViewport.d.ts +3 -0
  127. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/removeLabelmapRepresentationFromViewport.js +18 -0
  128. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/resolveLabelmapRenderPlan.d.ts +9 -0
  129. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/resolveLabelmapRenderPlan.js +56 -0
  130. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/stackImagePlan.d.ts +11 -0
  131. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/stackImagePlan.js +35 -0
  132. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/types.d.ts +48 -0
  133. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/types.js +0 -0
  134. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/volumeSliceImageMapperPlan.d.ts +13 -0
  135. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/volumeSliceImageMapperPlan.js +34 -0
  136. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan.d.ts +2 -0
  137. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan.js +1 -0
  138. package/dist/esm/tools/displayTools/Labelmap/labelmapRepresentationUID.d.ts +8 -0
  139. package/dist/esm/tools/displayTools/Labelmap/labelmapRepresentationUID.js +18 -0
  140. package/dist/esm/tools/displayTools/Labelmap/removeLabelmapFromElement.js +2 -5
  141. package/dist/esm/tools/displayTools/Labelmap/removeLabelmapRepresentationData.d.ts +3 -0
  142. package/dist/esm/tools/displayTools/Labelmap/removeLabelmapRepresentationData.js +16 -0
  143. package/dist/esm/tools/displayTools/Labelmap/syncStackLabelmapActors.d.ts +2 -0
  144. package/dist/esm/tools/displayTools/Labelmap/syncStackLabelmapActors.js +135 -0
  145. package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapImageMapper.d.ts +16 -0
  146. package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapImageMapper.js +267 -0
  147. package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapSliceData.d.ts +27 -0
  148. package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapSliceData.js +185 -0
  149. package/dist/esm/tools/displayTools/registerBuiltInSegmentationRepresentationDisplays.d.ts +1 -0
  150. package/dist/esm/tools/displayTools/registerBuiltInSegmentationRepresentationDisplays.js +16 -0
  151. package/dist/esm/tools/segmentation/BrushTool.d.ts +9 -2
  152. package/dist/esm/tools/segmentation/BrushTool.js +109 -25
  153. package/dist/esm/tools/segmentation/CircleScissorsTool.js +13 -6
  154. package/dist/esm/tools/segmentation/LabelmapBaseTool.d.ts +2 -3
  155. package/dist/esm/tools/segmentation/LabelmapBaseTool.js +77 -38
  156. package/dist/esm/tools/segmentation/LabelmapEditWithContour.js +3 -3
  157. package/dist/esm/tools/segmentation/PaintFillTool.js +11 -4
  158. package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.d.ts +2 -0
  159. package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js +16 -8
  160. package/dist/esm/tools/segmentation/RectangleScissorsTool.js +13 -6
  161. package/dist/esm/tools/segmentation/SegmentBidirectionalTool.js +63 -61
  162. package/dist/esm/tools/segmentation/SegmentSelectTool.js +4 -4
  163. package/dist/esm/tools/segmentation/SphereScissorsTool.js +5 -1
  164. package/dist/esm/tools/segmentation/strategies/BrushStrategy.d.ts +7 -0
  165. package/dist/esm/tools/segmentation/strategies/BrushStrategy.js +47 -24
  166. package/dist/esm/tools/segmentation/strategies/compositions/circularCursor.js +49 -15
  167. package/dist/esm/tools/segmentation/strategies/compositions/determineSegmentIndex.js +2 -2
  168. package/dist/esm/tools/segmentation/strategies/compositions/dynamicThreshold.js +5 -1
  169. package/dist/esm/tools/segmentation/strategies/compositions/islandRemovalComposition.js +2 -2
  170. package/dist/esm/tools/segmentation/strategies/compositions/preview.js +2 -2
  171. package/dist/esm/tools/segmentation/strategies/compositions/setValue.js +14 -6
  172. package/dist/esm/tools/segmentation/strategies/utils/crossLayerErase.d.ts +4 -0
  173. package/dist/esm/tools/segmentation/strategies/utils/crossLayerErase.js +23 -0
  174. package/dist/esm/tools/segmentation/strategies/utils/getStrategyData.js +1 -1
  175. package/dist/esm/tools/segmentation/strategies/utils/handleUseSegmentCenterIndex.js +12 -11
  176. package/dist/esm/tools/segmentation/strategies/utils/labelmapOverlap.d.ts +4 -0
  177. package/dist/esm/tools/segmentation/strategies/utils/labelmapOverlap.js +41 -0
  178. package/dist/esm/tools/segmentation/strategies/utils/overwritePolicy.d.ts +3 -0
  179. package/dist/esm/tools/segmentation/strategies/utils/overwritePolicy.js +31 -0
  180. package/dist/esm/tools/segmentation/strategies/utils/segmentSeparation.d.ts +3 -0
  181. package/dist/esm/tools/segmentation/strategies/utils/segmentSeparation.js +38 -0
  182. package/dist/esm/tools/segmentation/utils/LazyBrushEditController.d.ts +19 -0
  183. package/dist/esm/tools/segmentation/utils/LazyBrushEditController.js +55 -0
  184. package/dist/esm/tools/segmentation/utils/lazyBrushPreview.d.ts +3 -0
  185. package/dist/esm/tools/segmentation/utils/lazyBrushPreview.js +34 -0
  186. package/dist/esm/tools/segmentation/utils/shouldUseLazyLabelmapEditing.d.ts +3 -0
  187. package/dist/esm/tools/segmentation/utils/shouldUseLazyLabelmapEditing.js +42 -0
  188. package/dist/esm/types/LabelmapToolOperationData.d.ts +5 -0
  189. package/dist/esm/types/LabelmapTypes.d.ts +29 -6
  190. package/dist/esm/types/SegmentationStateTypes.d.ts +4 -0
  191. package/dist/esm/utilities/calibrateImageSpacing.js +17 -2
  192. package/dist/esm/utilities/contours/AnnotationToPointData.js +1 -1
  193. package/dist/esm/utilities/getSphereBoundsInfo.js +5 -1
  194. package/dist/esm/utilities/getViewportICamera.d.ts +4 -0
  195. package/dist/esm/utilities/getViewportICamera.js +23 -0
  196. package/dist/esm/utilities/getViewportsForAnnotation.js +5 -1
  197. package/dist/esm/utilities/math/basic/BasicStatsCalculator.js +9 -7
  198. package/dist/esm/utilities/pointInSurroundingSphereCallback.js +8 -1
  199. package/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js +121 -118
  200. package/dist/esm/utilities/segmentation/SegmentStatsCalculator.js +5 -4
  201. package/dist/esm/utilities/segmentation/VolumetricCalculator.js +1 -1
  202. package/dist/esm/utilities/segmentation/createLabelmapVolumeForViewport.js +1 -1
  203. package/dist/esm/utilities/segmentation/getReferenceVolumeForSegmentation.js +1 -1
  204. package/dist/esm/utilities/segmentation/getReferenceVolumeForSegmentationVolume.js +11 -2
  205. package/dist/esm/utilities/segmentation/getSegmentIndexAtLabelmapBorder.js +36 -17
  206. package/dist/esm/utilities/segmentation/getSegmentIndexAtWorldPoint.js +42 -25
  207. package/dist/esm/utilities/segmentation/getUniqueSegmentIndices.js +3 -30
  208. package/dist/esm/utilities/segmentation/index.d.ts +2 -1
  209. package/dist/esm/utilities/segmentation/index.js +2 -1
  210. package/dist/esm/utilities/segmentation/utilsForWorker.js +2 -2
  211. package/dist/esm/utilities/segmentation/validateLabelmap.js +1 -1
  212. package/dist/esm/utilities/stackPrefetch/stackPrefetch.js +0 -1
  213. package/dist/esm/utilities/touch/index.js +3 -2
  214. package/dist/esm/utilities/viewportCapabilities.d.ts +16 -0
  215. package/dist/esm/utilities/viewportCapabilities.js +18 -0
  216. package/dist/esm/utilities/viewportFilters/filterViewportsWithParallelNormals.d.ts +1 -1
  217. package/dist/esm/utilities/viewportFilters/filterViewportsWithParallelNormals.js +12 -4
  218. package/dist/esm/utilities/viewportFilters/filterViewportsWithSameOrientation.d.ts +1 -1
  219. package/dist/esm/utilities/viewportFilters/filterViewportsWithSameOrientation.js +11 -4
  220. package/dist/esm/utilities/viewportFilters/getViewportIdsWithToolToRender.js +1 -1
  221. package/dist/esm/utilities/viewportPresentation.d.ts +3 -0
  222. package/dist/esm/utilities/viewportPresentation.js +26 -0
  223. package/dist/esm/version.d.ts +1 -1
  224. package/dist/esm/version.js +1 -1
  225. package/package.json +10 -10
@@ -1,3 +1,4 @@
1
+ var _a;
1
2
  import { AnnotationTool } from '../base';
2
3
  import { getEnabledElement, VolumeViewport, utilities as csUtils, getEnabledElementByViewportId, } from '@cornerstonejs/core';
3
4
  import { vec3 } from 'gl-matrix';
@@ -15,12 +16,12 @@ import * as rectangle from '../../utilities/math/rectangle';
15
16
  import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCursor';
16
17
  import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
17
18
  import { getPixelValueUnits } from '../../utilities/getPixelValueUnits';
19
+ import { viewportSupportsImageSlices } from '../../utilities/viewportCapabilities';
18
20
  import { isViewportPreScaled } from '../../utilities/viewport/isViewportPreScaled';
19
21
  import { BasicStatsCalculator } from '../../utilities/math/basic';
20
22
  import { getStyleProperty } from '../../stateManagement/annotation/config/helpers';
21
23
  const { transformWorldToIndex } = csUtils;
22
24
  class RectangleROITool extends AnnotationTool {
23
- static { this.toolName = 'RectangleROI'; }
24
25
  constructor(toolProps = {}, defaultToolProps = {
25
26
  supportedInteractionTypes: ['Mouse', 'Touch'],
26
27
  configuration: {
@@ -352,7 +353,9 @@ class RectangleROITool extends AnnotationTool {
352
353
  const { referencedImageId } = annotation.metadata;
353
354
  for (const targetId in data.cachedStats) {
354
355
  if (targetId.startsWith('imageId')) {
355
- const viewports = renderingEngine.getStackViewports();
356
+ const viewports = renderingEngine
357
+ .getViewports()
358
+ .filter(viewportSupportsImageSlices);
356
359
  const invalidatedStack = viewports.find((vp) => {
357
360
  const referencedImageURI = csUtils.imageIdToURI(referencedImageId);
358
361
  const hasImageURI = vp.hasImageURI(referencedImageURI);
@@ -456,11 +459,11 @@ class RectangleROITool extends AnnotationTool {
456
459
  ];
457
460
  const handles = [pos1Index, pos2Index];
458
461
  const calibrate = getCalibratedLengthUnitsAndScale(image, handles);
459
- const width = RectangleROITool.calculateLengthInIndex(calibrate, [
462
+ const width = _a.calculateLengthInIndex(calibrate, [
460
463
  indexHandles[0],
461
464
  indexHandles[1],
462
465
  ]);
463
- const height = RectangleROITool.calculateLengthInIndex(calibrate, [
466
+ const height = _a.calculateLengthInIndex(calibrate, [
464
467
  indexHandles[0],
465
468
  indexHandles[2],
466
469
  ]);
@@ -513,40 +516,42 @@ class RectangleROITool extends AnnotationTool {
513
516
  };
514
517
  this._throttledCalculateCachedStats = throttle(this._calculateCachedStats, 100, { trailing: true });
515
518
  }
516
- static { this.hydrate = (viewportId, points, options) => {
517
- const enabledElement = getEnabledElementByViewportId(viewportId);
518
- if (!enabledElement) {
519
- return;
520
- }
521
- const { FrameOfReferenceUID, referencedImageId, viewPlaneNormal, instance, viewport, } = this.hydrateBase(RectangleROITool, enabledElement, points, options);
522
- const { toolInstance, ...serializableOptions } = options || {};
523
- const annotation = {
524
- annotationUID: options?.annotationUID || csUtils.uuidv4(),
525
- data: {
526
- handles: {
527
- points,
528
- activeHandleIndex: null,
529
- },
530
- label: '',
531
- cachedStats: {},
532
- },
533
- highlighted: false,
534
- autoGenerated: false,
535
- invalidated: false,
536
- isLocked: false,
537
- isVisible: true,
538
- metadata: {
539
- toolName: instance.getToolName(),
540
- viewPlaneNormal,
541
- FrameOfReferenceUID,
542
- referencedImageId,
543
- ...serializableOptions,
544
- },
545
- };
546
- addAnnotation(annotation, viewport.element);
547
- triggerAnnotationRenderForViewportIds([viewport.id]);
548
- }; }
549
519
  }
520
+ _a = RectangleROITool;
521
+ RectangleROITool.toolName = 'RectangleROI';
522
+ RectangleROITool.hydrate = (viewportId, points, options) => {
523
+ const enabledElement = getEnabledElementByViewportId(viewportId);
524
+ if (!enabledElement) {
525
+ return;
526
+ }
527
+ const { FrameOfReferenceUID, referencedImageId, viewPlaneNormal, instance, viewport, } = _a.hydrateBase(_a, enabledElement, points, options);
528
+ const { toolInstance, ...serializableOptions } = options || {};
529
+ const annotation = {
530
+ annotationUID: options?.annotationUID || csUtils.uuidv4(),
531
+ data: {
532
+ handles: {
533
+ points,
534
+ activeHandleIndex: null,
535
+ },
536
+ label: '',
537
+ cachedStats: {},
538
+ },
539
+ highlighted: false,
540
+ autoGenerated: false,
541
+ invalidated: false,
542
+ isLocked: false,
543
+ isVisible: true,
544
+ metadata: {
545
+ toolName: instance.getToolName(),
546
+ viewPlaneNormal,
547
+ FrameOfReferenceUID,
548
+ referencedImageId,
549
+ ...serializableOptions,
550
+ },
551
+ };
552
+ addAnnotation(annotation, viewport.element);
553
+ triggerAnnotationRenderForViewportIds([viewport.id]);
554
+ };
550
555
  function defaultGetTextLines(data, targetId) {
551
556
  const cachedVolumeStats = data.cachedStats[targetId];
552
557
  const { area, mean, max, stdDev, areaUnit, modalityUnit, min } = cachedVolumeStats;
@@ -4,7 +4,6 @@ import GrowCutBaseTool from '../base/GrowCutBaseTool';
4
4
  import { calculateGrowCutSeeds } from '../../utilities/segmentation/growCut/runOneClickGrowCut';
5
5
  import { ToolModes } from '../../enums';
6
6
  class RegionSegmentPlusTool extends GrowCutBaseTool {
7
- static { this.toolName = 'RegionSegmentPlus'; }
8
7
  constructor(toolProps = {}, defaultToolProps = {
9
8
  supportedInteractionTypes: ['Mouse', 'Touch'],
10
9
  configuration: {
@@ -125,4 +124,5 @@ class RegionSegmentPlusTool extends GrowCutBaseTool {
125
124
  });
126
125
  }
127
126
  }
127
+ RegionSegmentPlusTool.toolName = 'RegionSegmentPlus';
128
128
  export default RegionSegmentPlusTool;
@@ -7,7 +7,6 @@ import triggerAnnotationRenderForViewportUIDs from '../../utilities/triggerAnnot
7
7
  import { growCut } from '../../utilities/segmentation';
8
8
  import GrowCutBaseTool from '../base/GrowCutBaseTool';
9
9
  class RegionSegmentTool extends GrowCutBaseTool {
10
- static { this.toolName = 'RegionSegment'; }
11
10
  constructor(toolProps = {}, defaultToolProps = {
12
11
  supportedInteractionTypes: ['Mouse', 'Touch'],
13
12
  configuration: {
@@ -111,4 +110,5 @@ class RegionSegmentTool extends GrowCutBaseTool {
111
110
  });
112
111
  }
113
112
  }
113
+ RegionSegmentTool.toolName = 'RegionSegment';
114
114
  export default RegionSegmentTool;
@@ -3,7 +3,6 @@ import SplineROITool from './SplineROITool';
3
3
  import { Events } from '../../enums';
4
4
  import { convertContourSegmentationAnnotation } from '../../utilities/contourSegmentation';
5
5
  class SplineContourSegmentationTool extends SplineROITool {
6
- static { this.toolName = 'SplineContourSegmentationTool'; }
7
6
  constructor(toolProps) {
8
7
  const initialProps = utilities.deepMerge({
9
8
  configuration: {
@@ -33,4 +32,5 @@ class SplineContourSegmentationTool extends SplineROITool {
33
32
  convertContourSegmentationAnnotation(annotation);
34
33
  }
35
34
  }
35
+ SplineContourSegmentationTool.toolName = 'SplineContourSegmentationTool';
36
36
  export default SplineContourSegmentationTool;
@@ -1,3 +1,4 @@
1
+ var _a;
1
2
  import { getEnabledElement, eventTarget, triggerEvent, utilities, getEnabledElementByViewportId, } from '@cornerstonejs/core';
2
3
  import { vec3 } from 'gl-matrix';
3
4
  import { addAnnotation, getChildAnnotations, removeAnnotation, } from '../../stateManagement/annotation/annotationState';
@@ -46,9 +47,6 @@ const splineToolNames = [
46
47
  'CardinalSplineROI',
47
48
  ];
48
49
  class SplineROITool extends ContourSegmentationBaseTool {
49
- static { this.toolName = 'SplineROI'; }
50
- static { this.SplineTypes = SplineTypesEnum; }
51
- static { this.Actions = SplineToolActions; }
52
50
  constructor(toolProps = {}, defaultToolProps = {
53
51
  supportedInteractionTypes: ['Mouse', 'Touch'],
54
52
  configuration: {
@@ -782,54 +780,58 @@ class SplineROITool extends ContourSegmentationBaseTool {
782
780
  }
783
781
  return spline;
784
782
  }
785
- static { this.hydrate = (viewportId, points, options) => {
786
- const enabledElement = getEnabledElementByViewportId(viewportId);
787
- if (!enabledElement) {
788
- return;
789
- }
790
- if (points.length < SPLINE_MIN_POINTS) {
791
- console.warn('Spline requires at least 3 control points');
792
- return;
793
- }
794
- const { FrameOfReferenceUID, referencedImageId, viewPlaneNormal, viewUp, instance, viewport, } = this.hydrateBase(SplineROITool, enabledElement, points, options);
795
- const splineType = options?.splineType || SplineTypesEnum.CatmullRom;
796
- const splineConfig = instance._getSplineConfig(splineType);
797
- const SplineClass = splineConfig.Class;
798
- const splineInstance = new SplineClass();
799
- const { toolInstance, ...serializableOptions } = options || {};
800
- const annotation = {
801
- annotationUID: options?.annotationUID || utilities.uuidv4(),
802
- data: {
803
- handles: {
804
- points,
805
- },
806
- label: '',
807
- cachedStats: {},
808
- spline: {
809
- type: splineType,
810
- instance: splineInstance,
811
- },
812
- contour: {
813
- closed: true,
814
- },
783
+ }
784
+ _a = SplineROITool;
785
+ SplineROITool.toolName = 'SplineROI';
786
+ SplineROITool.SplineTypes = SplineTypesEnum;
787
+ SplineROITool.Actions = SplineToolActions;
788
+ SplineROITool.hydrate = (viewportId, points, options) => {
789
+ const enabledElement = getEnabledElementByViewportId(viewportId);
790
+ if (!enabledElement) {
791
+ return;
792
+ }
793
+ if (points.length < SPLINE_MIN_POINTS) {
794
+ console.warn('Spline requires at least 3 control points');
795
+ return;
796
+ }
797
+ const { FrameOfReferenceUID, referencedImageId, viewPlaneNormal, viewUp, instance, viewport, } = _a.hydrateBase(_a, enabledElement, points, options);
798
+ const splineType = options?.splineType || SplineTypesEnum.CatmullRom;
799
+ const splineConfig = instance._getSplineConfig(splineType);
800
+ const SplineClass = splineConfig.Class;
801
+ const splineInstance = new SplineClass();
802
+ const { toolInstance, ...serializableOptions } = options || {};
803
+ const annotation = {
804
+ annotationUID: options?.annotationUID || utilities.uuidv4(),
805
+ data: {
806
+ handles: {
807
+ points,
815
808
  },
816
- highlighted: false,
817
- autoGenerated: false,
818
- invalidated: true,
819
- isLocked: false,
820
- isVisible: true,
821
- metadata: {
822
- toolName: instance.getToolName(),
823
- viewPlaneNormal,
824
- FrameOfReferenceUID,
825
- referencedImageId,
826
- ...serializableOptions,
809
+ label: '',
810
+ cachedStats: {},
811
+ spline: {
812
+ type: splineType,
813
+ instance: splineInstance,
827
814
  },
828
- };
829
- addAnnotation(annotation, viewport.element);
830
- triggerAnnotationRenderForViewportIds([viewport.id]);
831
- }; }
832
- }
815
+ contour: {
816
+ closed: true,
817
+ },
818
+ },
819
+ highlighted: false,
820
+ autoGenerated: false,
821
+ invalidated: true,
822
+ isLocked: false,
823
+ isVisible: true,
824
+ metadata: {
825
+ toolName: instance.getToolName(),
826
+ viewPlaneNormal,
827
+ FrameOfReferenceUID,
828
+ referencedImageId,
829
+ ...serializableOptions,
830
+ },
831
+ };
832
+ addAnnotation(annotation, viewport.element);
833
+ triggerAnnotationRenderForViewportIds([viewport.id]);
834
+ };
833
835
  function defaultGetTextLines(data, targetId) {
834
836
  const cachedVolumeStats = data.cachedStats[targetId];
835
837
  const { area, isEmptyArea, areaUnit } = cachedVolumeStats;
@@ -14,7 +14,6 @@ import { getCalibratedProbeUnitsAndValue } from '../../utilities/getCalibratedUn
14
14
  import { lineSegment } from '../../utilities/math';
15
15
  const { transformWorldToIndex } = csUtils;
16
16
  class UltrasoundDirectionalTool extends AnnotationTool {
17
- static { this.toolName = 'UltrasoundDirectionalTool'; }
18
17
  constructor(toolProps = {}, defaultToolProps = {
19
18
  supportedInteractionTypes: ['Mouse', 'Touch'],
20
19
  configuration: {
@@ -417,6 +416,7 @@ class UltrasoundDirectionalTool extends AnnotationTool {
417
416
  return cachedStats;
418
417
  }
419
418
  }
419
+ UltrasoundDirectionalTool.toolName = 'UltrasoundDirectionalTool';
420
420
  function defaultGetTextLines(data, targetId, configuration) {
421
421
  const cachedStats = data.cachedStats[targetId];
422
422
  const { xValues, yValues, units, isUnitless, isHorizontal } = cachedStats;
@@ -1,3 +1,4 @@
1
+ var _a;
1
2
  import { Events, ChangeTypes } from '../../../enums';
2
3
  import { getEnabledElement, utilities, metaData, getEnabledElementByViewportId, } from '@cornerstonejs/core';
3
4
  import { AnnotationTool } from '../../base';
@@ -15,11 +16,6 @@ import { angleFromCenter, calculateInnerFanPercentage, clipInterval, intervalFro
15
16
  import { calculateFanGeometry } from './utils/fanExtraction';
16
17
  const { transformIndexToWorld } = utilities;
17
18
  class UltrasoundPleuraBLineTool extends AnnotationTool {
18
- static { this.toolName = 'UltrasoundPleuraBLineTool'; }
19
- static { this.USPleuraBLineAnnotationType = {
20
- BLINE: 'bLine',
21
- PLEURA: 'pleura',
22
- }; }
23
19
  constructor(toolProps = {}, defaultToolProps = {
24
20
  supportedInteractionTypes: ['Mouse', 'Touch'],
25
21
  configuration: {
@@ -311,7 +307,7 @@ class UltrasoundPleuraBLineTool extends AnnotationTool {
311
307
  const currentImageId = viewport.getCurrentImageId();
312
308
  const unMergedPleuraIntervals = annotations
313
309
  .filter((annotation) => annotation.data.annotationType ===
314
- UltrasoundPleuraBLineTool.USPleuraBLineAnnotationType.PLEURA &&
310
+ _a.USPleuraBLineAnnotationType.PLEURA &&
315
311
  annotation.metadata.referencedImageId === currentImageId)
316
312
  .map((annotation) => {
317
313
  const canvasCoordinates = annotation.data.handles.points.map((p) => viewport.worldToCanvas(p));
@@ -364,7 +360,7 @@ class UltrasoundPleuraBLineTool extends AnnotationTool {
364
360
  const lineInterval = intervalFromPoints(fanCenter, canvasCoordinates);
365
361
  let fanNumber = 0;
366
362
  if (annotation.data.annotationType ===
367
- UltrasoundPleuraBLineTool.USPleuraBLineAnnotationType.BLINE) {
363
+ _a.USPleuraBLineAnnotationType.BLINE) {
368
364
  const uncoveredIntervals = subtractIntervals(bLineIntervalsDisplayed, lineInterval);
369
365
  uncoveredIntervals.forEach((interval) => {
370
366
  const clippedIntervals = clipInterval(interval, mergedPleuraIntervals);
@@ -386,7 +382,7 @@ class UltrasoundPleuraBLineTool extends AnnotationTool {
386
382
  });
387
383
  }
388
384
  else if (annotation.data.annotationType ===
389
- UltrasoundPleuraBLineTool.USPleuraBLineAnnotationType.PLEURA) {
385
+ _a.USPleuraBLineAnnotationType.PLEURA) {
390
386
  const uncoveredIntervals = subtractIntervals(pleuraIntervalsDisplayed, lineInterval);
391
387
  uncoveredIntervals.forEach((interval, index) => {
392
388
  fanNumber++;
@@ -407,7 +403,7 @@ class UltrasoundPleuraBLineTool extends AnnotationTool {
407
403
  }
408
404
  };
409
405
  const pleuraAnnotationsToDraw = annotations.filter((annotation) => annotation.data.annotationType ===
410
- UltrasoundPleuraBLineTool.USPleuraBLineAnnotationType.PLEURA &&
406
+ _a.USPleuraBLineAnnotationType.PLEURA &&
411
407
  annotation.metadata.referencedImageId === currentImageId);
412
408
  pleuraAnnotationsToDraw.forEach((annotation) => {
413
409
  if (!viewport.getRenderingEngine()) {
@@ -417,7 +413,7 @@ class UltrasoundPleuraBLineTool extends AnnotationTool {
417
413
  drawAnnotation(annotation);
418
414
  });
419
415
  const bLineAnnotationsToDraw = annotations.filter((annotation) => annotation.data.annotationType ===
420
- UltrasoundPleuraBLineTool.USPleuraBLineAnnotationType.BLINE &&
416
+ _a.USPleuraBLineAnnotationType.BLINE &&
421
417
  annotation.metadata.referencedImageId === currentImageId);
422
418
  bLineAnnotationsToDraw.forEach((annotation) => {
423
419
  if (!viewport.getRenderingEngine()) {
@@ -433,10 +429,10 @@ class UltrasoundPleuraBLineTool extends AnnotationTool {
433
429
  return renderStatus;
434
430
  };
435
431
  this.activeAnnotationType =
436
- UltrasoundPleuraBLineTool.USPleuraBLineAnnotationType.BLINE;
432
+ _a.USPleuraBLineAnnotationType.BLINE;
437
433
  }
438
434
  static filterAnnotations(element, filterFunction = () => true) {
439
- const annotations = getAnnotations(UltrasoundPleuraBLineTool.toolName, element);
435
+ const annotations = getAnnotations(_a.toolName, element);
440
436
  if (!annotations?.length) {
441
437
  return [];
442
438
  }
@@ -447,7 +443,7 @@ class UltrasoundPleuraBLineTool extends AnnotationTool {
447
443
  return filteredAnnotations;
448
444
  }
449
445
  static countAnnotations(element, filterFunction = () => true) {
450
- const annotations = getAnnotations(UltrasoundPleuraBLineTool.toolName, element);
446
+ const annotations = getAnnotations(_a.toolName, element);
451
447
  const { viewport } = getEnabledElement(element);
452
448
  const imageIds = viewport.getImageIds();
453
449
  const getImageIdIndex = (imageId) => {
@@ -479,11 +475,11 @@ class UltrasoundPleuraBLineTool extends AnnotationTool {
479
475
  };
480
476
  }
481
477
  if (annotationType ===
482
- UltrasoundPleuraBLineTool.USPleuraBLineAnnotationType.PLEURA) {
478
+ _a.USPleuraBLineAnnotationType.PLEURA) {
483
479
  counts.pleura++;
484
480
  }
485
481
  else if (annotationType ===
486
- UltrasoundPleuraBLineTool.USPleuraBLineAnnotationType.BLINE) {
482
+ _a.USPleuraBLineAnnotationType.BLINE) {
487
483
  counts.bLine++;
488
484
  }
489
485
  annotationMapping.set(currentImageId, counts);
@@ -491,7 +487,7 @@ class UltrasoundPleuraBLineTool extends AnnotationTool {
491
487
  return annotationMapping;
492
488
  }
493
489
  static deleteAnnotations(element, filterFunction = () => false) {
494
- const annotations = getAnnotations(UltrasoundPleuraBLineTool.toolName, element);
490
+ const annotations = getAnnotations(_a.toolName, element);
495
491
  if (!annotations?.length) {
496
492
  return;
497
493
  }
@@ -510,50 +506,20 @@ class UltrasoundPleuraBLineTool extends AnnotationTool {
510
506
  }
511
507
  deleteLastAnnotationType(element, type) {
512
508
  let annotationList;
513
- const annotations = getAnnotations(UltrasoundPleuraBLineTool.toolName, element);
514
- if (type === UltrasoundPleuraBLineTool.USPleuraBLineAnnotationType.PLEURA) {
509
+ const annotations = getAnnotations(_a.toolName, element);
510
+ if (type === _a.USPleuraBLineAnnotationType.PLEURA) {
515
511
  annotationList = annotations.filter((annotation) => annotation.data.annotationType ===
516
- UltrasoundPleuraBLineTool.USPleuraBLineAnnotationType.PLEURA);
512
+ _a.USPleuraBLineAnnotationType.PLEURA);
517
513
  }
518
- else if (type === UltrasoundPleuraBLineTool.USPleuraBLineAnnotationType.BLINE) {
514
+ else if (type === _a.USPleuraBLineAnnotationType.BLINE) {
519
515
  annotationList = annotations.filter((annotation) => annotation.data.annotationType ===
520
- UltrasoundPleuraBLineTool.USPleuraBLineAnnotationType.BLINE);
516
+ _a.USPleuraBLineAnnotationType.BLINE);
521
517
  }
522
518
  if (annotationList?.length > 0) {
523
519
  const annotation = annotationList.pop();
524
520
  removeAnnotation(annotation.annotationUID);
525
521
  }
526
522
  }
527
- static { this.hydrate = (viewportId, points, options) => {
528
- const enabledElement = getEnabledElementByViewportId(viewportId);
529
- if (!enabledElement) {
530
- return;
531
- }
532
- const { FrameOfReferenceUID, referencedImageId, viewPlaneNormal, instance, viewport, } = this.hydrateBase(UltrasoundPleuraBLineTool, enabledElement, points, options);
533
- const { toolInstance, ...serializableOptions } = options || {};
534
- const annotation = {
535
- annotationUID: options?.annotationUID || utilities.uuidv4(),
536
- data: {
537
- handles: {
538
- points,
539
- },
540
- },
541
- highlighted: false,
542
- autoGenerated: false,
543
- invalidated: false,
544
- isLocked: false,
545
- isVisible: true,
546
- metadata: {
547
- toolName: instance.getToolName(),
548
- viewPlaneNormal,
549
- FrameOfReferenceUID,
550
- referencedImageId,
551
- ...serializableOptions,
552
- },
553
- };
554
- addAnnotation(annotation, viewport.element);
555
- triggerAnnotationRenderForViewportIds([viewport.id]);
556
- }; }
557
523
  handleSelectedCallback(evt, annotation, handle) {
558
524
  const eventDetail = evt.detail;
559
525
  const { element } = eventDetail;
@@ -655,7 +621,7 @@ class UltrasoundPleuraBLineTool extends AnnotationTool {
655
621
  const annotations = getAnnotations(this.getToolName(), element) || [];
656
622
  const pleuraIntervals = annotations
657
623
  .filter((annotation) => annotation.data.annotationType ===
658
- UltrasoundPleuraBLineTool.USPleuraBLineAnnotationType.PLEURA &&
624
+ _a.USPleuraBLineAnnotationType.PLEURA &&
659
625
  annotation.metadata.referencedImageId === currentImageId)
660
626
  .map((annotation) => {
661
627
  const canvasCoordinates = annotation.data.handles.points.map((p) => viewport.worldToCanvas(p));
@@ -663,7 +629,7 @@ class UltrasoundPleuraBLineTool extends AnnotationTool {
663
629
  });
664
630
  const bLineIntervals = annotations
665
631
  .filter((annotation) => annotation.data.annotationType ===
666
- UltrasoundPleuraBLineTool.USPleuraBLineAnnotationType.BLINE &&
632
+ _a.USPleuraBLineAnnotationType.BLINE &&
667
633
  annotation.metadata.referencedImageId === currentImageId)
668
634
  .map((annotation) => {
669
635
  const canvasCoordinates = annotation.data.handles.points.map((p) => viewport.worldToCanvas(p));
@@ -675,11 +641,11 @@ class UltrasoundPleuraBLineTool extends AnnotationTool {
675
641
  const { annotationType } = annotation.data;
676
642
  const { bLineColor, pleuraColor } = this.configuration;
677
643
  if (annotationType ===
678
- UltrasoundPleuraBLineTool.USPleuraBLineAnnotationType.BLINE) {
644
+ _a.USPleuraBLineAnnotationType.BLINE) {
679
645
  return bLineColor;
680
646
  }
681
647
  if (annotationType ===
682
- UltrasoundPleuraBLineTool.USPleuraBLineAnnotationType.PLEURA) {
648
+ _a.USPleuraBLineAnnotationType.PLEURA) {
683
649
  return pleuraColor;
684
650
  }
685
651
  return bLineColor;
@@ -746,6 +712,42 @@ class UltrasoundPleuraBLineTool extends AnnotationTool {
746
712
  utilities.indexWithinDimensions(index2, dimensions));
747
713
  }
748
714
  }
715
+ _a = UltrasoundPleuraBLineTool;
716
+ UltrasoundPleuraBLineTool.toolName = 'UltrasoundPleuraBLineTool';
717
+ UltrasoundPleuraBLineTool.USPleuraBLineAnnotationType = {
718
+ BLINE: 'bLine',
719
+ PLEURA: 'pleura',
720
+ };
721
+ UltrasoundPleuraBLineTool.hydrate = (viewportId, points, options) => {
722
+ const enabledElement = getEnabledElementByViewportId(viewportId);
723
+ if (!enabledElement) {
724
+ return;
725
+ }
726
+ const { FrameOfReferenceUID, referencedImageId, viewPlaneNormal, instance, viewport, } = _a.hydrateBase(_a, enabledElement, points, options);
727
+ const { toolInstance, ...serializableOptions } = options || {};
728
+ const annotation = {
729
+ annotationUID: options?.annotationUID || utilities.uuidv4(),
730
+ data: {
731
+ handles: {
732
+ points,
733
+ },
734
+ },
735
+ highlighted: false,
736
+ autoGenerated: false,
737
+ invalidated: false,
738
+ isLocked: false,
739
+ isVisible: true,
740
+ metadata: {
741
+ toolName: instance.getToolName(),
742
+ viewPlaneNormal,
743
+ FrameOfReferenceUID,
744
+ referencedImageId,
745
+ ...serializableOptions,
746
+ },
747
+ };
748
+ addAnnotation(annotation, viewport.element);
749
+ triggerAnnotationRenderForViewportIds([viewport.id]);
750
+ };
749
751
  function defaultGetTextLines(data, targetId) {
750
752
  return [''];
751
753
  }
@@ -12,7 +12,6 @@ import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCur
12
12
  import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
13
13
  import getWorldWidthAndHeightFromTwoPoints from '../../utilities/planar/getWorldWidthAndHeightFromTwoPoints';
14
14
  class VideoRedactionTool extends AnnotationTool {
15
- static { this.toolName = 'VideoRedaction'; }
16
15
  constructor(toolConfiguration = {}) {
17
16
  super(toolConfiguration, {
18
17
  supportedInteractionTypes: ['Mouse', 'Touch'],
@@ -443,4 +442,5 @@ class VideoRedactionTool extends AnnotationTool {
443
442
  return `stackTarget:${viewport.uid}`;
444
443
  }
445
444
  }
445
+ VideoRedactionTool.toolName = 'VideoRedaction';
446
446
  export default VideoRedactionTool;
@@ -3,6 +3,7 @@ import BaseTool from './BaseTool';
3
3
  import { getAnnotationManager } from '../../stateManagement/annotation/annotationState';
4
4
  import triggerAnnotationRender from '../../utilities/triggerAnnotationRender';
5
5
  import filterAnnotationsForDisplay from '../../utilities/planar/filterAnnotationsForDisplay';
6
+ import getViewportICamera from '../../utilities/getViewportICamera';
6
7
  import { getStyleProperty } from '../../stateManagement/annotation/config/helpers';
7
8
  import { getState } from '../../stateManagement/annotation/config';
8
9
  class AnnotationDisplayTool extends BaseTool {
@@ -81,17 +82,19 @@ class AnnotationDisplayTool extends BaseTool {
81
82
  const { world: worldPos } = currentPoints;
82
83
  const enabledElement = getEnabledElement(element);
83
84
  const { viewport } = enabledElement;
84
- const camera = viewport.getCamera();
85
- const { viewPlaneNormal, viewUp, position: cameraPosition } = camera;
86
- const referencedImageId = this.getReferencedImageId(viewport, worldPos, viewPlaneNormal, viewUp);
87
85
  const viewReference = viewport.getViewReference({ points: [worldPos] });
86
+ const { viewPlaneNormal, viewUp, position: cameraPosition, } = getViewportICamera(viewport, viewReference);
87
+ const referencedImageId = viewReference.referencedImageId ||
88
+ (viewPlaneNormal
89
+ ? this.getReferencedImageId(viewport, worldPos, viewPlaneNormal, viewUp)
90
+ : undefined);
88
91
  const annotation = AnnotationDisplayTool.createAnnotation({
89
92
  metadata: {
90
93
  toolName: this.getToolName(),
91
94
  ...viewReference,
92
- referencedImageId,
93
- viewUp,
94
- cameraPosition,
95
+ ...(referencedImageId ? { referencedImageId } : {}),
96
+ ...(viewUp ? { viewUp } : {}),
97
+ ...(cameraPosition ? { cameraPosition } : {}),
95
98
  },
96
99
  data: {
97
100
  handles: {
@@ -11,6 +11,7 @@ import ChangeTypes from '../../enums/ChangeTypes';
11
11
  import { setAnnotationSelected } from '../../stateManagement/annotation/annotationSelection';
12
12
  import { addContourSegmentationAnnotation } from '../../utilities/contourSegmentation';
13
13
  import { safeStructuredClone } from '../../utilities/safeStructuredClone';
14
+ import getViewportICamera from '../../utilities/getViewportICamera';
14
15
  const { DefaultHistoryMemo } = csUtils.HistoryMemo;
15
16
  class AnnotationTool extends AnnotationDisplayTool {
16
17
  static createAnnotationForViewport(viewport, ...annotationBaseData) {
@@ -291,7 +292,7 @@ class AnnotationTool extends AnnotationDisplayTool {
291
292
  }
292
293
  const { viewport } = enabledElement;
293
294
  const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
294
- const camera = viewport.getCamera();
295
+ const camera = getViewportICamera(viewport);
295
296
  const viewPlaneNormal = options.viewplaneNormal ?? camera.viewPlaneNormal;
296
297
  const viewUp = options.viewUp ?? camera.viewUp;
297
298
  const instance = options.toolInstance || new ToolClass();
@@ -1,18 +1,10 @@
1
- import { utilities as csUtils } from '@cornerstonejs/core';
1
+ import { utilities as csUtils, viewportHasPan, viewportHasZoom, } from '@cornerstonejs/core';
2
2
  import ToolModes from '../../enums/ToolModes';
3
3
  const { DefaultHistoryMemo } = csUtils.HistoryMemo;
4
4
  class BaseTool {
5
5
  get configurationTyped() {
6
6
  return this.configuration;
7
7
  }
8
- static { this.defaults = {
9
- configuration: {
10
- strategies: {},
11
- defaultStrategy: undefined,
12
- activeStrategy: undefined,
13
- strategyOptions: {},
14
- },
15
- }; }
16
8
  constructor(toolProps, defaultToolProps) {
17
9
  this.isPrimary = false;
18
10
  const mergedDefaults = BaseTool.mergeDefaultProps(BaseTool.defaults, defaultToolProps);
@@ -116,6 +108,9 @@ class BaseTool {
116
108
  DefaultHistoryMemo.redo();
117
109
  }
118
110
  static createZoomPanMemo(viewport) {
111
+ if (!viewportHasPan(viewport) || !viewportHasZoom(viewport)) {
112
+ return;
113
+ }
119
114
  const state = {
120
115
  pan: viewport.getPan(),
121
116
  zoom: viewport.getZoom(),
@@ -124,9 +119,12 @@ class BaseTool {
124
119
  restoreMemo: () => {
125
120
  const currentPan = viewport.getPan();
126
121
  const currentZoom = viewport.getZoom();
122
+ const renderableViewport = viewport;
127
123
  viewport.setZoom(state.zoom);
128
124
  viewport.setPan(state.pan);
129
- viewport.render();
125
+ if (typeof renderableViewport.render === 'function') {
126
+ renderableViewport.render();
127
+ }
130
128
  state.pan = currentPan;
131
129
  state.zoom = currentZoom;
132
130
  },
@@ -174,5 +172,13 @@ class BaseTool {
174
172
  return true;
175
173
  }
176
174
  }
175
+ BaseTool.defaults = {
176
+ configuration: {
177
+ strategies: {},
178
+ defaultStrategy: undefined,
179
+ activeStrategy: undefined,
180
+ strategyOptions: {},
181
+ },
182
+ };
177
183
  BaseTool.toolName = 'BaseTool';
178
184
  export default BaseTool;