@cornerstonejs/tools 5.0.0-beta.1 → 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 (285) 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/index.d.ts +2 -2
  18. package/dist/esm/index.js +2 -2
  19. package/dist/esm/init.js +2 -0
  20. package/dist/esm/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.js +10 -4
  21. package/dist/esm/stateManagement/segmentation/SegmentationRenderingEngine.js +23 -20
  22. package/dist/esm/stateManagement/segmentation/SegmentationRepresentationDisplayRegistry.d.ts +12 -0
  23. package/dist/esm/stateManagement/segmentation/SegmentationRepresentationDisplayRegistry.js +7 -0
  24. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.d.ts +1 -10
  25. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +28 -149
  26. package/dist/esm/stateManagement/segmentation/addColorLUT.js +7 -1
  27. package/dist/esm/stateManagement/segmentation/getCurrentLabelmapImageIdForViewport.js +16 -1
  28. package/dist/esm/stateManagement/segmentation/helpers/clearSegmentValue.js +9 -7
  29. package/dist/esm/stateManagement/segmentation/helpers/getSegmentationActor.d.ts +1 -1
  30. package/dist/esm/stateManagement/segmentation/helpers/getSegmentationActor.js +3 -2
  31. package/dist/esm/stateManagement/segmentation/helpers/getViewportLabelmapRenderMode.d.ts +5 -0
  32. package/dist/esm/stateManagement/segmentation/helpers/getViewportLabelmapRenderMode.js +58 -0
  33. package/dist/esm/stateManagement/segmentation/helpers/labelmapImageMapperSupport.d.ts +52 -0
  34. package/dist/esm/stateManagement/segmentation/helpers/labelmapImageMapperSupport.js +246 -0
  35. package/dist/esm/stateManagement/segmentation/helpers/labelmapSegmentationState.d.ts +1 -0
  36. package/dist/esm/stateManagement/segmentation/helpers/labelmapSegmentationState.js +1 -0
  37. package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +12 -1
  38. package/dist/esm/stateManagement/segmentation/internalAddSegmentationRepresentation.js +3 -3
  39. package/dist/esm/stateManagement/segmentation/labelmapModel/index.d.ts +9 -0
  40. package/dist/esm/stateManagement/segmentation/labelmapModel/index.js +7 -0
  41. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapEditTransaction.d.ts +54 -0
  42. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapEditTransaction.js +224 -0
  43. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageIdMapping.d.ts +6 -0
  44. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageIdMapping.js +39 -0
  45. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageReferenceResolver.d.ts +23 -0
  46. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageReferenceResolver.js +269 -0
  47. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLayerStore.d.ts +15 -0
  48. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLayerStore.js +160 -0
  49. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLegacyAdapter.d.ts +4 -0
  50. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLegacyAdapter.js +42 -0
  51. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapSegmentBindings.d.ts +11 -0
  52. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapSegmentBindings.js +73 -0
  53. package/dist/esm/stateManagement/segmentation/labelmapModel/normalizeLabelmapSegmentationData.d.ts +17 -0
  54. package/dist/esm/stateManagement/segmentation/labelmapModel/normalizeLabelmapSegmentationData.js +75 -0
  55. package/dist/esm/stateManagement/segmentation/labelmapModel/privateLabelmap.d.ts +5 -0
  56. package/dist/esm/stateManagement/segmentation/labelmapModel/privateLabelmap.js +106 -0
  57. package/dist/esm/stateManagement/segmentation/models/SegmentModel.d.ts +11 -0
  58. package/dist/esm/stateManagement/segmentation/models/SegmentModel.js +19 -0
  59. package/dist/esm/stateManagement/segmentation/models/SegmentationModel.d.ts +12 -0
  60. package/dist/esm/stateManagement/segmentation/models/SegmentationModel.js +23 -0
  61. package/dist/esm/stateManagement/segmentation/removeSegmentationRepresentations.js +6 -10
  62. package/dist/esm/stateManagement/segmentation/segmentIndex.js +24 -0
  63. package/dist/esm/stateManagement/segmentation/segmentationEventManager.js +2 -9
  64. package/dist/esm/stateManagement/segmentation/segmentationState.d.ts +2 -1
  65. package/dist/esm/stateManagement/segmentation/segmentationState.js +4 -1
  66. package/dist/esm/store/SynchronizerManager/Synchronizer.d.ts +3 -1
  67. package/dist/esm/store/state.js +2 -1
  68. package/dist/esm/synchronizers/callbacks/imageSliceSyncCallback.js +12 -3
  69. package/dist/esm/synchronizers/callbacks/presentationViewSyncCallback.js +5 -2
  70. package/dist/esm/synchronizers/callbacks/zoomPanSyncCallback.js +51 -3
  71. package/dist/esm/synchronizers/synchronizers/createPresentationViewSynchronizer.d.ts +1 -1
  72. package/dist/esm/tools/AdvancedMagnifyTool.js +4 -1
  73. package/dist/esm/tools/CrosshairsTool.d.ts +4 -0
  74. package/dist/esm/tools/CrosshairsTool.js +95 -41
  75. package/dist/esm/tools/MagnifyTool.js +3 -1
  76. package/dist/esm/tools/OrientationControllerTool.d.ts +45 -0
  77. package/dist/esm/tools/OrientationControllerTool.js +454 -0
  78. package/dist/esm/tools/OrientationMarkerTool.js +4 -4
  79. package/dist/esm/tools/PanTool.js +26 -3
  80. package/dist/esm/tools/PlanarRotateTool.js +19 -4
  81. package/dist/esm/tools/ReferenceCursors.js +7 -1
  82. package/dist/esm/tools/SculptorTool/CircleSculptCursor.js +1 -1
  83. package/dist/esm/tools/TrackballRotateTool.js +3 -2
  84. package/dist/esm/tools/VolumeCroppingControlTool.d.ts +10 -35
  85. package/dist/esm/tools/VolumeCroppingControlTool.js +179 -699
  86. package/dist/esm/tools/VolumeCroppingTool.d.ts +34 -32
  87. package/dist/esm/tools/VolumeCroppingTool.js +813 -532
  88. package/dist/esm/tools/WindowLevelTool.d.ts +2 -1
  89. package/dist/esm/tools/WindowLevelTool.js +48 -4
  90. package/dist/esm/tools/ZoomTool.d.ts +8 -0
  91. package/dist/esm/tools/ZoomTool.js +92 -11
  92. package/dist/esm/tools/annotation/AngleTool.js +38 -32
  93. package/dist/esm/tools/annotation/ArrowAnnotateTool.js +30 -28
  94. package/dist/esm/tools/annotation/BidirectionalTool.js +51 -49
  95. package/dist/esm/tools/annotation/CircleROITool.d.ts +1 -0
  96. package/dist/esm/tools/annotation/CircleROITool.js +89 -51
  97. package/dist/esm/tools/annotation/CobbAngleTool.js +1 -1
  98. package/dist/esm/tools/annotation/DragProbeTool.js +1 -1
  99. package/dist/esm/tools/annotation/ETDRSGridTool.js +1 -1
  100. package/dist/esm/tools/annotation/EllipticalROITool.js +46 -39
  101. package/dist/esm/tools/annotation/HeightTool.js +1 -1
  102. package/dist/esm/tools/annotation/KeyImageTool.js +11 -11
  103. package/dist/esm/tools/annotation/LabelTool.js +37 -35
  104. package/dist/esm/tools/annotation/LengthTool.js +35 -33
  105. package/dist/esm/tools/annotation/LivewireContourSegmentationTool.js +6 -4
  106. package/dist/esm/tools/annotation/LivewireContourTool.js +4 -8
  107. package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js +6 -4
  108. package/dist/esm/tools/annotation/PlanarFreehandROITool.js +3 -4
  109. package/dist/esm/tools/annotation/ProbeTool.js +66 -56
  110. package/dist/esm/tools/annotation/RectangleROITool.js +48 -37
  111. package/dist/esm/tools/annotation/RegionSegmentPlusTool.js +1 -1
  112. package/dist/esm/tools/annotation/RegionSegmentTool.js +1 -1
  113. package/dist/esm/tools/annotation/SplineContourSegmentationTool.js +1 -1
  114. package/dist/esm/tools/annotation/SplineROITool.js +60 -56
  115. package/dist/esm/tools/annotation/UltrasoundDirectionalTool.js +1 -1
  116. package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/UltrasoundPleuraBLineTool.js +57 -55
  117. package/dist/esm/tools/annotation/VideoRedactionTool.js +1 -1
  118. package/dist/esm/tools/base/AnnotationDisplayTool.js +9 -6
  119. package/dist/esm/tools/base/AnnotationTool.js +2 -1
  120. package/dist/esm/tools/base/BaseTool.js +16 -10
  121. package/dist/esm/tools/base/ContourSegmentationBaseTool.js +1 -1
  122. package/dist/esm/tools/base/GrowCutBaseTool.js +2 -2
  123. package/dist/esm/tools/displayTools/Labelmap/addLabelmapToElement.d.ts +2 -4
  124. package/dist/esm/tools/displayTools/Labelmap/addLabelmapToElement.js +15 -85
  125. package/dist/esm/tools/displayTools/Labelmap/labelmapActorStyle.d.ts +5 -0
  126. package/dist/esm/tools/displayTools/Labelmap/labelmapActorStyle.js +191 -0
  127. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.d.ts +4 -3
  128. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +48 -209
  129. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/createLabelmapRenderPlan.d.ts +3 -0
  130. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/createLabelmapRenderPlan.js +51 -0
  131. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/index.d.ts +4 -0
  132. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/index.js +3 -0
  133. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan.d.ts +14 -0
  134. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan.js +143 -0
  135. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/planarGenericVolumeLabelmap.d.ts +40 -0
  136. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/planarGenericVolumeLabelmap.js +79 -0
  137. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/removeLabelmapRepresentationFromViewport.d.ts +3 -0
  138. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/removeLabelmapRepresentationFromViewport.js +18 -0
  139. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/resolveLabelmapRenderPlan.d.ts +9 -0
  140. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/resolveLabelmapRenderPlan.js +56 -0
  141. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/stackImagePlan.d.ts +11 -0
  142. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/stackImagePlan.js +35 -0
  143. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/types.d.ts +48 -0
  144. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/types.js +0 -0
  145. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/volumeSliceImageMapperPlan.d.ts +13 -0
  146. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/volumeSliceImageMapperPlan.js +34 -0
  147. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan.d.ts +2 -0
  148. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan.js +1 -0
  149. package/dist/esm/tools/displayTools/Labelmap/labelmapRepresentationUID.d.ts +8 -0
  150. package/dist/esm/tools/displayTools/Labelmap/labelmapRepresentationUID.js +18 -0
  151. package/dist/esm/tools/displayTools/Labelmap/removeLabelmapFromElement.js +2 -2
  152. package/dist/esm/tools/displayTools/Labelmap/removeLabelmapRepresentationData.d.ts +3 -0
  153. package/dist/esm/tools/displayTools/Labelmap/removeLabelmapRepresentationData.js +16 -0
  154. package/dist/esm/tools/displayTools/Labelmap/syncStackLabelmapActors.d.ts +2 -0
  155. package/dist/esm/tools/displayTools/Labelmap/syncStackLabelmapActors.js +135 -0
  156. package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapImageMapper.d.ts +16 -0
  157. package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapImageMapper.js +267 -0
  158. package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapSliceData.d.ts +27 -0
  159. package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapSliceData.js +185 -0
  160. package/dist/esm/tools/displayTools/registerBuiltInSegmentationRepresentationDisplays.d.ts +1 -0
  161. package/dist/esm/tools/displayTools/registerBuiltInSegmentationRepresentationDisplays.js +16 -0
  162. package/dist/esm/tools/index.d.ts +2 -1
  163. package/dist/esm/tools/index.js +2 -1
  164. package/dist/esm/tools/segmentation/BrushTool.d.ts +9 -2
  165. package/dist/esm/tools/segmentation/BrushTool.js +123 -26
  166. package/dist/esm/tools/segmentation/CircleScissorsTool.js +19 -36
  167. package/dist/esm/tools/segmentation/LabelmapBaseTool.d.ts +2 -3
  168. package/dist/esm/tools/segmentation/LabelmapBaseTool.js +77 -46
  169. package/dist/esm/tools/segmentation/LabelmapEditWithContour.js +3 -3
  170. package/dist/esm/tools/segmentation/PaintFillTool.js +11 -4
  171. package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.d.ts +2 -0
  172. package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js +16 -8
  173. package/dist/esm/tools/segmentation/RectangleScissorsTool.js +13 -6
  174. package/dist/esm/tools/segmentation/SegmentBidirectionalTool.js +63 -61
  175. package/dist/esm/tools/segmentation/SegmentSelectTool.js +4 -4
  176. package/dist/esm/tools/segmentation/SphereScissorsTool.js +11 -31
  177. package/dist/esm/tools/segmentation/strategies/BrushStrategy.d.ts +7 -0
  178. package/dist/esm/tools/segmentation/strategies/BrushStrategy.js +47 -24
  179. package/dist/esm/tools/segmentation/strategies/compositions/circularCursor.js +49 -21
  180. package/dist/esm/tools/segmentation/strategies/compositions/determineSegmentIndex.js +2 -2
  181. package/dist/esm/tools/segmentation/strategies/compositions/dynamicThreshold.js +5 -1
  182. package/dist/esm/tools/segmentation/strategies/compositions/islandRemovalComposition.js +2 -2
  183. package/dist/esm/tools/segmentation/strategies/compositions/preview.js +2 -2
  184. package/dist/esm/tools/segmentation/strategies/compositions/setValue.js +14 -6
  185. package/dist/esm/tools/segmentation/strategies/fillCircle.d.ts +3 -1
  186. package/dist/esm/tools/segmentation/strategies/fillCircle.js +38 -31
  187. package/dist/esm/tools/segmentation/strategies/fillSphere.js +11 -3
  188. package/dist/esm/tools/segmentation/strategies/utils/crossLayerErase.d.ts +4 -0
  189. package/dist/esm/tools/segmentation/strategies/utils/crossLayerErase.js +23 -0
  190. package/dist/esm/tools/segmentation/strategies/utils/getStrategyData.js +1 -1
  191. package/dist/esm/tools/segmentation/strategies/utils/handleUseSegmentCenterIndex.js +12 -11
  192. package/dist/esm/tools/segmentation/strategies/utils/labelmapOverlap.d.ts +4 -0
  193. package/dist/esm/tools/segmentation/strategies/utils/labelmapOverlap.js +41 -0
  194. package/dist/esm/tools/segmentation/strategies/utils/overwritePolicy.d.ts +3 -0
  195. package/dist/esm/tools/segmentation/strategies/utils/overwritePolicy.js +31 -0
  196. package/dist/esm/tools/segmentation/strategies/utils/segmentSeparation.d.ts +3 -0
  197. package/dist/esm/tools/segmentation/strategies/utils/segmentSeparation.js +38 -0
  198. package/dist/esm/tools/segmentation/utils/LazyBrushEditController.d.ts +19 -0
  199. package/dist/esm/tools/segmentation/utils/LazyBrushEditController.js +55 -0
  200. package/dist/esm/tools/segmentation/utils/lazyBrushPreview.d.ts +3 -0
  201. package/dist/esm/tools/segmentation/utils/lazyBrushPreview.js +34 -0
  202. package/dist/esm/tools/segmentation/utils/shouldUseLazyLabelmapEditing.d.ts +3 -0
  203. package/dist/esm/tools/segmentation/utils/shouldUseLazyLabelmapEditing.js +42 -0
  204. package/dist/esm/types/ISynchronizerEventHandler.d.ts +2 -1
  205. package/dist/esm/types/LabelmapToolOperationData.d.ts +5 -0
  206. package/dist/esm/types/LabelmapTypes.d.ts +29 -6
  207. package/dist/esm/types/SegmentationStateTypes.d.ts +6 -0
  208. package/dist/esm/utilities/calibrateImageSpacing.js +17 -2
  209. package/dist/esm/utilities/contours/AnnotationToPointData.js +1 -1
  210. package/dist/esm/utilities/draw3D/addLine3DBetweenPoints.d.ts +7 -0
  211. package/dist/esm/utilities/draw3D/addLine3DBetweenPoints.js +34 -0
  212. package/dist/esm/utilities/draw3D/calculateAdaptiveSphereRadius.d.ts +6 -0
  213. package/dist/esm/utilities/draw3D/calculateAdaptiveSphereRadius.js +7 -0
  214. package/dist/esm/utilities/draw3D/index.d.ts +2 -0
  215. package/dist/esm/utilities/draw3D/index.js +2 -0
  216. package/dist/esm/utilities/drawing/getTextBoxCoordsCanvas.js +22 -14
  217. package/dist/esm/utilities/getCenterAndRadiusInCanvas.d.ts +6 -0
  218. package/dist/esm/utilities/getCenterAndRadiusInCanvas.js +26 -0
  219. package/dist/esm/utilities/getEllipseWorldCoordinates.d.ts +2 -0
  220. package/dist/esm/utilities/getEllipseWorldCoordinates.js +26 -0
  221. package/dist/esm/utilities/getSphereBoundsInfo.js +5 -1
  222. package/dist/esm/utilities/getViewportICamera.d.ts +4 -0
  223. package/dist/esm/utilities/getViewportICamera.js +23 -0
  224. package/dist/esm/utilities/getViewportsForAnnotation.js +5 -1
  225. package/dist/esm/utilities/index.d.ts +2 -1
  226. package/dist/esm/utilities/index.js +2 -1
  227. package/dist/esm/utilities/interactionDragCoordinator.d.ts +5 -0
  228. package/dist/esm/utilities/interactionDragCoordinator.js +16 -0
  229. package/dist/esm/utilities/math/basic/BasicStatsCalculator.js +9 -7
  230. package/dist/esm/utilities/pointInSurroundingSphereCallback.js +8 -1
  231. package/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js +121 -118
  232. package/dist/esm/utilities/segmentation/SegmentStatsCalculator.js +5 -4
  233. package/dist/esm/utilities/segmentation/VolumetricCalculator.js +1 -1
  234. package/dist/esm/utilities/segmentation/createLabelmapVolumeForViewport.js +1 -1
  235. package/dist/esm/utilities/segmentation/getReferenceVolumeForSegmentation.js +1 -1
  236. package/dist/esm/utilities/segmentation/getReferenceVolumeForSegmentationVolume.js +11 -2
  237. package/dist/esm/utilities/segmentation/getSegmentIndexAtLabelmapBorder.js +36 -17
  238. package/dist/esm/utilities/segmentation/getSegmentIndexAtWorldPoint.js +42 -25
  239. package/dist/esm/utilities/segmentation/getUniqueSegmentIndices.js +3 -30
  240. package/dist/esm/utilities/segmentation/index.d.ts +2 -1
  241. package/dist/esm/utilities/segmentation/index.js +2 -1
  242. package/dist/esm/utilities/segmentation/utilsForWorker.js +6 -2
  243. package/dist/esm/utilities/segmentation/validateLabelmap.js +1 -1
  244. package/dist/esm/utilities/stackPrefetch/stackPrefetch.js +0 -1
  245. package/dist/esm/utilities/touch/index.js +3 -2
  246. package/dist/esm/utilities/viewportCapabilities.d.ts +16 -0
  247. package/dist/esm/utilities/viewportCapabilities.js +18 -0
  248. package/dist/esm/utilities/viewportFilters/filterViewportsWithParallelNormals.d.ts +1 -1
  249. package/dist/esm/utilities/viewportFilters/filterViewportsWithParallelNormals.js +12 -4
  250. package/dist/esm/utilities/viewportFilters/filterViewportsWithSameOrientation.d.ts +1 -1
  251. package/dist/esm/utilities/viewportFilters/filterViewportsWithSameOrientation.js +11 -4
  252. package/dist/esm/utilities/viewportFilters/getViewportIdsWithToolToRender.js +1 -1
  253. package/dist/esm/utilities/viewportPresentation.d.ts +3 -0
  254. package/dist/esm/utilities/viewportPresentation.js +26 -0
  255. package/dist/esm/utilities/volumeCropping/computePlanePlaneIntersection.d.ts +6 -0
  256. package/dist/esm/utilities/volumeCropping/computePlanePlaneIntersection.js +37 -0
  257. package/dist/esm/utilities/volumeCropping/constants.d.ts +31 -0
  258. package/dist/esm/utilities/volumeCropping/constants.js +31 -0
  259. package/dist/esm/utilities/volumeCropping/copyClippingPlanes.d.ts +2 -0
  260. package/dist/esm/utilities/volumeCropping/copyClippingPlanes.js +6 -0
  261. package/dist/esm/utilities/volumeCropping/extractVolumeDirectionVectors.d.ts +9 -0
  262. package/dist/esm/utilities/volumeCropping/extractVolumeDirectionVectors.js +9 -0
  263. package/dist/esm/utilities/volumeCropping/findLineBoundsIntersection.d.ts +5 -0
  264. package/dist/esm/utilities/volumeCropping/findLineBoundsIntersection.js +50 -0
  265. package/dist/esm/utilities/volumeCropping/getColorKeyForPlaneIndex.d.ts +1 -0
  266. package/dist/esm/utilities/volumeCropping/getColorKeyForPlaneIndex.js +13 -0
  267. package/dist/esm/utilities/volumeCropping/getOrientationFromNormal.d.ts +2 -0
  268. package/dist/esm/utilities/volumeCropping/getOrientationFromNormal.js +19 -0
  269. package/dist/esm/utilities/volumeCropping/index.d.ts +9 -0
  270. package/dist/esm/utilities/volumeCropping/index.js +9 -0
  271. package/dist/esm/utilities/volumeCropping/parseCornerKey.d.ts +8 -0
  272. package/dist/esm/utilities/volumeCropping/parseCornerKey.js +11 -0
  273. package/dist/esm/utilities/volumeCropping/types.d.ts +5 -0
  274. package/dist/esm/utilities/volumeCropping/types.js +0 -0
  275. package/dist/esm/utilities/vtkjs/AnnotatedRhombicuboctahedronActor/index.d.ts +31 -0
  276. package/dist/esm/utilities/vtkjs/AnnotatedRhombicuboctahedronActor/index.js +391 -0
  277. package/dist/esm/utilities/vtkjs/OrientationControllerWidget/index.d.ts +69 -0
  278. package/dist/esm/utilities/vtkjs/OrientationControllerWidget/index.js +804 -0
  279. package/dist/esm/utilities/vtkjs/RhombicuboctahedronSource/index.d.ts +7 -0
  280. package/dist/esm/utilities/vtkjs/RhombicuboctahedronSource/index.js +144 -0
  281. package/dist/esm/utilities/vtkjs/index.d.ts +3 -0
  282. package/dist/esm/utilities/vtkjs/index.js +3 -0
  283. package/dist/esm/version.d.ts +1 -1
  284. package/dist/esm/version.js +1 -1
  285. package/package.json +10 -9
@@ -1,13 +1,20 @@
1
1
  import { getEnabledElement } from '@cornerstonejs/core';
2
2
  export default function getTouchEventPoints(evt, element) {
3
3
  const elementToUse = element || evt.currentTarget;
4
+ const { viewport } = getEnabledElement(elementToUse) || {};
5
+ if (!viewport) {
6
+ return [];
7
+ }
4
8
  const touches = evt.type === 'touchend' ? evt.changedTouches : evt.touches;
5
- return Object.keys(touches).map((i) => {
9
+ return Object.keys(touches)
10
+ .map((i) => {
6
11
  const clientPoint = _clientToPoint(touches[i]);
7
12
  const pagePoint = _pageToPoint(touches[i]);
8
13
  const canvasPoint = _pagePointsToCanvasPoints(elementToUse, pagePoint);
9
- const { viewport } = getEnabledElement(elementToUse);
10
- const worldPoint = viewport.canvasToWorld(canvasPoint);
14
+ const worldPoint = getWorldPoint(viewport, canvasPoint);
15
+ if (!worldPoint) {
16
+ return;
17
+ }
11
18
  return {
12
19
  page: pagePoint,
13
20
  client: clientPoint,
@@ -21,7 +28,8 @@ export default function getTouchEventPoints(evt, element) {
21
28
  rotationAngle: touches[i].rotationAngle,
22
29
  },
23
30
  };
24
- });
31
+ })
32
+ .filter(Boolean);
25
33
  }
26
34
  function _pagePointsToCanvasPoints(element, pagePoint) {
27
35
  const rect = element.getBoundingClientRect();
@@ -36,3 +44,18 @@ function _pageToPoint(touch) {
36
44
  function _clientToPoint(touch) {
37
45
  return [touch.clientX, touch.clientY];
38
46
  }
47
+ function getWorldPoint(viewport, canvasPoint) {
48
+ try {
49
+ return viewport.canvasToWorld(canvasPoint);
50
+ }
51
+ catch (error) {
52
+ if (isNoMountedDataError(error)) {
53
+ return;
54
+ }
55
+ throw error;
56
+ }
57
+ }
58
+ function isNoMountedDataError(error) {
59
+ return (error instanceof Error &&
60
+ error.message.includes('because no data is mounted'));
61
+ }
@@ -1,4 +1,4 @@
1
- import { getEnabledElement, triggerEvent } from '@cornerstonejs/core';
1
+ import { getEnabledElement, triggerEvent, utilities, } from '@cornerstonejs/core';
2
2
  import Events from '../../enums/Events';
3
3
  import { Swipe } from '../../enums/Touch';
4
4
  import getTouchEventPoints from './getTouchEventPoints';
@@ -59,8 +59,8 @@ const defaultTapState = {
59
59
  tapMaxDistance: 24,
60
60
  tapToleranceMs: 300,
61
61
  };
62
- let state = JSON.parse(JSON.stringify(defaultState));
63
- let tapState = JSON.parse(JSON.stringify(defaultTapState));
62
+ let state = utilities.deepClone(defaultState);
63
+ let tapState = utilities.deepClone(defaultTapState);
64
64
  function triggerEventCallback(ele, name, eventDetail) {
65
65
  return triggerEvent(ele, name, eventDetail);
66
66
  }
@@ -194,7 +194,7 @@ function _onTouchEnd(evt) {
194
194
  };
195
195
  triggerEventCallback(eventDetail.element, TOUCH_END, eventDetail);
196
196
  _checkTouchTap(evt);
197
- state = JSON.parse(JSON.stringify(defaultState));
197
+ state = utilities.deepClone(defaultState);
198
198
  document.removeEventListener('touchmove', _onTouchDrag);
199
199
  document.removeEventListener('touchend', _onTouchEnd);
200
200
  }
@@ -236,7 +236,7 @@ function _checkTouchTap(evt) {
236
236
  taps: tapState.taps,
237
237
  };
238
238
  triggerEventCallback(eventDetail.element, TOUCH_TAP, eventDetail);
239
- tapState = JSON.parse(JSON.stringify(defaultTapState));
239
+ tapState = utilities.deepClone(defaultTapState);
240
240
  }, tapState.tapToleranceMs);
241
241
  }
242
242
  function _checkTouchSwipe(evt, deltaPoints) {
@@ -267,9 +267,22 @@ function _checkTouchSwipe(evt, deltaPoints) {
267
267
  }
268
268
  }
269
269
  function _updateTouchEventsLastPoints(element, lastPoints) {
270
- const { viewport } = getEnabledElement(element);
271
- return lastPoints.map((lp) => {
272
- const world = viewport.canvasToWorld(lp.canvas);
270
+ const { viewport } = getEnabledElement(element) || {};
271
+ if (!viewport) {
272
+ return lastPoints;
273
+ }
274
+ return lastPoints
275
+ .map((lp) => {
276
+ let world;
277
+ try {
278
+ world = viewport.canvasToWorld(lp.canvas);
279
+ }
280
+ catch (error) {
281
+ if (isNoMountedDataError(error)) {
282
+ return;
283
+ }
284
+ throw error;
285
+ }
273
286
  return {
274
287
  page: lp.page,
275
288
  client: lp.client,
@@ -277,6 +290,11 @@ function _updateTouchEventsLastPoints(element, lastPoints) {
277
290
  world,
278
291
  touch: lp.touch,
279
292
  };
280
- });
293
+ })
294
+ .filter(Boolean);
295
+ }
296
+ function isNoMountedDataError(error) {
297
+ return (error instanceof Error &&
298
+ error.message.includes('because no data is mounted'));
281
299
  }
282
300
  export default touchStartListener;
@@ -9,6 +9,10 @@ function wheelListener(evt) {
9
9
  if (evt.deltaY > -1 && evt.deltaY < 1) {
10
10
  return;
11
11
  }
12
+ const points = getMouseEventPoints(evt);
13
+ if (!points) {
14
+ return;
15
+ }
12
16
  evt.preventDefault();
13
17
  const { spinX, spinY, pixelX, pixelY } = normalizeWheel(evt);
14
18
  const direction = spinY < 0 ? -1 : 1;
@@ -27,7 +31,7 @@ function wheelListener(evt) {
27
31
  pixelY,
28
32
  direction,
29
33
  },
30
- points: getMouseEventPoints(evt),
34
+ points,
31
35
  };
32
36
  triggerEvent(element, Events.MOUSE_WHEEL, eventDetail);
33
37
  }
@@ -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, 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';
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, OrientationControllerTool, 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, 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, };
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, OrientationControllerTool, 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, 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';
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, OrientationControllerTool, 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, 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, };
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, OrientationControllerTool, 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/init.js CHANGED
@@ -10,11 +10,13 @@ import { defaultSegmentationStateManager } from './stateManagement/segmentation/
10
10
  import segmentationRepresentationModifiedListener from './eventListeners/segmentation/segmentationRepresentationModifiedListener';
11
11
  import { setConfig } from './config';
12
12
  import segmentationRemovedListener from './eventListeners/segmentation/segmentationRemovedEventListener';
13
+ import { registerBuiltInSegmentationRepresentationDisplays } from './tools/displayTools/registerBuiltInSegmentationRepresentationDisplays';
13
14
  let csToolsInitialized = false;
14
15
  export function init(defaultConfiguration = {}) {
15
16
  if (csToolsInitialized) {
16
17
  return;
17
18
  }
19
+ registerBuiltInSegmentationRepresentationDisplays();
18
20
  setConfig(defaultConfiguration);
19
21
  _addCornerstoneEventListeners();
20
22
  _addCornerstoneToolsEventListeners();
@@ -1,4 +1,7 @@
1
1
  import { Enums, eventTarget, getEnabledElement, utilities, } from '@cornerstonejs/core';
2
+ function isUnsafeKey(key) {
3
+ return key === '__proto__' || key === 'constructor' || key === 'prototype';
4
+ }
2
5
  class FrameOfReferenceSpecificAnnotationManager {
3
6
  constructor(uid) {
4
7
  this.getGroupKey = (annotationGroupSelector) => {
@@ -77,6 +80,9 @@ class FrameOfReferenceSpecificAnnotationManager {
77
80
  const { metadata } = annotation;
78
81
  const { FrameOfReferenceUID, toolName } = metadata;
79
82
  groupKey = groupKey || FrameOfReferenceUID;
83
+ if (isUnsafeKey(groupKey) || isUnsafeKey(toolName)) {
84
+ return;
85
+ }
80
86
  const annotations = this.annotations;
81
87
  let frameOfReferenceSpecificAnnotations = annotations[groupKey];
82
88
  if (!frameOfReferenceSpecificAnnotations) {
@@ -146,13 +152,13 @@ class FrameOfReferenceSpecificAnnotationManager {
146
152
  return;
147
153
  }
148
154
  const toolSpecificAnnotations = frameOfReferenceSpecificAnnotations[toolName];
149
- return structuredClone(toolSpecificAnnotations);
155
+ return utilities.deepClone(toolSpecificAnnotations);
150
156
  }
151
157
  else if (groupKey) {
152
158
  const frameOfReferenceSpecificAnnotations = annotations[groupKey];
153
- return structuredClone(frameOfReferenceSpecificAnnotations);
159
+ return utilities.deepClone(frameOfReferenceSpecificAnnotations);
154
160
  }
155
- return structuredClone(annotations);
161
+ return utilities.deepClone(annotations);
156
162
  };
157
163
  this.restoreAnnotations = (state, groupKey, toolName) => {
158
164
  const annotations = this.annotations;
@@ -168,7 +174,7 @@ class FrameOfReferenceSpecificAnnotationManager {
168
174
  annotations[groupKey] = state;
169
175
  }
170
176
  else {
171
- this.annotations = structuredClone(state);
177
+ this.annotations = utilities.deepClone(state);
172
178
  }
173
179
  };
174
180
  this.getAllAnnotations = () => {
@@ -1,21 +1,13 @@
1
1
  import { triggerEvent, eventTarget, Enums, getRenderingEngines, getEnabledElementByViewportId, } from '@cornerstonejs/core';
2
2
  import { SegmentationRepresentations, Events as csToolsEvents, } from '../../enums';
3
- import Representations from '../../enums/SegmentationRepresentations';
4
3
  import { getSegmentation } from './getSegmentation';
5
4
  import { getSegmentationRepresentations } from './getSegmentationRepresentation';
6
- import surfaceDisplay from '../../tools/displayTools/Surface/surfaceDisplay';
7
- import contourDisplay from '../../tools/displayTools/Contour/contourDisplay';
8
- import labelmapDisplay from '../../tools/displayTools/Labelmap/labelmapDisplay';
9
5
  import { addTool } from '../../store/addTool';
10
6
  import { state } from '../../store/state';
11
7
  import PlanarFreehandContourSegmentationTool from '../../tools/annotation/PlanarFreehandContourSegmentationTool';
12
8
  import { getToolGroupForViewport } from '../../store/ToolGroupManager';
13
9
  import { addDefaultSegmentationListener } from './segmentationEventManager';
14
- const renderers = {
15
- [Representations.Labelmap]: labelmapDisplay,
16
- [Representations.Contour]: contourDisplay,
17
- [Representations.Surface]: surfaceDisplay,
18
- };
10
+ import { getSegmentationRepresentationDisplay } from './SegmentationRepresentationDisplayRegistry';
19
11
  const planarContourToolName = PlanarFreehandContourSegmentationTool.toolName;
20
12
  class SegmentationRenderingEngine {
21
13
  constructor() {
@@ -108,22 +100,33 @@ class SegmentationRenderingEngine {
108
100
  if (representation.type === SegmentationRepresentations.Contour) {
109
101
  this._addPlanarFreeHandToolIfAbsent(viewport);
110
102
  }
111
- const display = renderers[representation.type];
103
+ const display = getSegmentationRepresentationDisplay(representation.type);
112
104
  const segmentation = getSegmentation(representation.segmentationId);
113
105
  const existingRepresentation = segmentation.representationData[representation.type] !== undefined;
114
- try {
115
- display.render(viewport, representation).then(() => {
116
- if (!existingRepresentation) {
117
- addDefaultSegmentationListener(viewport, representation.segmentationId, representation.type);
118
- }
106
+ if (!display) {
107
+ console.warn(`No display registered for segmentation representation type ${representation.type}.`);
108
+ return Promise.resolve({
109
+ segmentationId: representation.segmentationId,
110
+ type: representation.type,
119
111
  });
120
112
  }
121
- catch (error) {
113
+ return display
114
+ .render(viewport, representation)
115
+ .then(() => {
116
+ if (!existingRepresentation) {
117
+ addDefaultSegmentationListener(viewport, representation.segmentationId, representation.type);
118
+ }
119
+ return {
120
+ segmentationId: representation.segmentationId,
121
+ type: representation.type,
122
+ };
123
+ })
124
+ .catch((error) => {
122
125
  console.error(error);
123
- }
124
- return Promise.resolve({
125
- segmentationId: representation.segmentationId,
126
- type: representation.type,
126
+ return {
127
+ segmentationId: representation.segmentationId,
128
+ type: representation.type,
129
+ };
127
130
  });
128
131
  });
129
132
  Promise.allSettled(segmentationRenderList).then((results) => {
@@ -0,0 +1,12 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ import type SegmentationRepresentations from '../../enums/SegmentationRepresentations';
3
+ import type { SegmentationRepresentation } from '../../types/SegmentationStateTypes';
4
+ type SegmentationRepresentationUpdateFunction = (segmentationId: string) => Promise<void>;
5
+ export type SegmentationRepresentationDisplay = {
6
+ getUpdateFunction: (viewport: Types.IVolumeViewport | Types.IStackViewport) => SegmentationRepresentationUpdateFunction | void | null;
7
+ render: (viewport: Types.IVolumeViewport | Types.IStackViewport, representation: SegmentationRepresentation) => Promise<void>;
8
+ removeRepresentation: (viewportId: string, segmentationId: string, renderImmediate?: boolean) => void;
9
+ };
10
+ export declare function registerSegmentationRepresentationDisplay(representationType: SegmentationRepresentations, display: SegmentationRepresentationDisplay): void;
11
+ export declare function getSegmentationRepresentationDisplay(representationType: SegmentationRepresentations): SegmentationRepresentationDisplay | undefined;
12
+ export {};
@@ -0,0 +1,7 @@
1
+ const segmentationRepresentationDisplays = new Map();
2
+ export function registerSegmentationRepresentationDisplay(representationType, display) {
3
+ segmentationRepresentationDisplays.set(representationType, display);
4
+ }
5
+ export function getSegmentationRepresentationDisplay(representationType) {
6
+ return segmentationRepresentationDisplays.get(representationType);
7
+ }
@@ -4,8 +4,7 @@ import type { RenderingConfig, RepresentationsData, Segmentation, SegmentationRe
4
4
  export default class SegmentationStateManager {
5
5
  private state;
6
6
  readonly uid: string;
7
- private _stackLabelmapImageIdReferenceMap;
8
- private _labelmapImageIdReferenceMap;
7
+ private readonly labelmapImageReferenceResolver;
9
8
  constructor(uid?: string);
10
9
  getState(): Readonly<SegmentationState>;
11
10
  private updateState;
@@ -20,9 +19,7 @@ export default class SegmentationStateManager {
20
19
  private addDefaultSegmentationRepresentation;
21
20
  addLabelmapRepresentation(state: SegmentationState, viewportId: string, segmentationId: string, renderingConfig?: RenderingConfig): void;
22
21
  processLabelmapRepresentationAddition(viewportId: string, segmentationId: string): Promise<void>;
23
- _updateLabelmapSegmentationReferences(segmentationId: any, viewport: any, labelmapImageIds: any, updateCallback: any): string | undefined;
24
22
  updateLabelmapSegmentationImageReferences(viewportId: any, segmentationId: any): string;
25
- _updateAllLabelmapSegmentationImageReferences(viewportId: any, segmentationId: any): void;
26
23
  getLabelmapImageIds(representationData: RepresentationsData): any;
27
24
  getLabelmapImageIdsForImageId(imageId: string, segmentationId: string): string[];
28
25
  getCurrentLabelmapImageIdsForViewport(viewportId: string, segmentationId: string): string[] | undefined;
@@ -43,11 +40,6 @@ export default class SegmentationStateManager {
43
40
  segmentationId: string;
44
41
  type: SegmentationRepresentations;
45
42
  }>;
46
- _updateLabelmapImageIdReferenceMap({ segmentationId, referenceImageId, labelmapImageId, }: {
47
- segmentationId: any;
48
- referenceImageId: any;
49
- labelmapImageId: any;
50
- }): void;
51
43
  _setActiveSegmentation(state: SegmentationState, viewportId: string, segmentationId: string): void;
52
44
  setActiveSegmentation(viewportId: string, segmentationId: string): void;
53
45
  getActiveSegmentation(viewportId: string): Segmentation | undefined;
@@ -78,7 +70,6 @@ export default class SegmentationStateManager {
78
70
  viewportId: string;
79
71
  representations: SegmentationRepresentation[];
80
72
  }[];
81
- private _generateMapKey;
82
73
  }
83
74
  declare function internalComputeVolumeLabelmapFromStack({ imageIds, options, }: {
84
75
  imageIds: string[];