@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
@@ -0,0 +1,3 @@
1
+ import { type Types } from '@cornerstonejs/core';
2
+ export declare function isCPUViewport(viewport?: Types.IViewport): boolean;
3
+ export declare function shouldUseLazyLabelmapEditing(viewport?: Types.IViewport): boolean;
@@ -0,0 +1,42 @@
1
+ import { ActorRenderMode, getShouldUseCPURendering, } from '@cornerstonejs/core';
2
+ import { getConfig } from '../../../config';
3
+ const CPU_RENDER_MODES = new Set([
4
+ ActorRenderMode.CPU_IMAGE,
5
+ ActorRenderMode.CPU_VOLUME,
6
+ ]);
7
+ function getDefaultActor(viewport) {
8
+ try {
9
+ return viewport.getDefaultActor?.();
10
+ }
11
+ catch {
12
+ return;
13
+ }
14
+ }
15
+ export function isCPUViewport(viewport) {
16
+ if (!viewport) {
17
+ return getShouldUseCPURendering();
18
+ }
19
+ const cpuViewport = viewport;
20
+ if (cpuViewport.useCPURendering === true) {
21
+ return true;
22
+ }
23
+ if (cpuViewport._cpuFallbackEnabledElement) {
24
+ return true;
25
+ }
26
+ const defaultActor = getDefaultActor(viewport);
27
+ const renderMode = defaultActor?.actorMapper?.renderMode;
28
+ if (renderMode && CPU_RENDER_MODES.has(renderMode)) {
29
+ return true;
30
+ }
31
+ const actorClassName = typeof defaultActor?.actor?.getClassName === 'function'
32
+ ? defaultActor.actor.getClassName()
33
+ : undefined;
34
+ if (actorClassName === 'CanvasActor') {
35
+ return true;
36
+ }
37
+ return getShouldUseCPURendering();
38
+ }
39
+ export function shouldUseLazyLabelmapEditing(viewport) {
40
+ return (getConfig().segmentation?.overwriteMode !== undefined ||
41
+ isCPUViewport(viewport));
42
+ }
@@ -1,5 +1,6 @@
1
1
  import type { Types } from '@cornerstonejs/core';
2
2
  import type { Synchronizer } from '../store';
3
+ import type { SynchronizerOptions } from '../store/SynchronizerManager/Synchronizer';
3
4
  export default interface ISynchronizerEventHandler {
4
- (synchronizer: Synchronizer, sourceViewport: Types.IViewportId, targetViewport: Types.IViewportId, sourceEvent: any, options?: unknown): Promise<void> | void;
5
+ (synchronizer: Synchronizer, sourceViewport: Types.IViewportId, targetViewport: Types.IViewportId, sourceEvent: Event, options?: SynchronizerOptions): Promise<void> | void;
5
6
  }
@@ -2,9 +2,14 @@ import type { Types } from '@cornerstonejs/core';
2
2
  import type { LabelmapSegmentationDataStack, LabelmapSegmentationDataVolume } from './LabelmapTypes';
3
3
  import type vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
4
4
  import type { LabelmapMemo } from '../utilities/segmentation/createLabelmapMemo';
5
+ import type { SegmentLabelmapBindingState } from './LabelmapTypes';
5
6
  type LabelmapToolOperationData = {
6
7
  segmentationId: string;
7
8
  segmentIndex: number;
9
+ labelValue?: number;
10
+ labelmapId?: string;
11
+ overwriteSegmentIndices?: number[];
12
+ crossLayerEraseBindings?: SegmentLabelmapBindingState[];
8
13
  previewColor?: [number, number, number, number];
9
14
  previewSegmentIndex?: number;
10
15
  segmentsLocked: number[];
@@ -14,16 +14,39 @@ export type InactiveLabelmapStyle = {
14
14
  outlineOpacityInactive?: number;
15
15
  };
16
16
  export type LabelmapStyle = BaseLabelmapStyle & InactiveLabelmapStyle;
17
- export type LabelmapSegmentationDataVolume = {
18
- volumeId: string;
17
+ export type LabelmapLayerType = 'volume' | 'stack';
18
+ export type LabelmapLayer = {
19
+ labelmapId: string;
20
+ type: LabelmapLayerType;
21
+ volumeId?: string;
22
+ geometryVolumeId?: string;
19
23
  referencedVolumeId?: string;
24
+ referencedImageIds?: string[];
25
+ imageIds?: string[];
26
+ labelToSegmentIndex?: {
27
+ [labelValue: number]: number;
28
+ };
20
29
  };
21
- export type LabelmapSegmentationDataStack = {
22
- imageIds: string[];
30
+ export type SegmentLabelmapBindingState = {
31
+ labelmapId: string;
32
+ labelValue: number;
23
33
  };
24
- export type LabelmapSegmentationData = LabelmapSegmentationDataVolume | LabelmapSegmentationDataStack | {
34
+ export type LabelmapSegmentationDataShared = {
35
+ referencedImageIds?: string[];
36
+ labelmaps?: {
37
+ [labelmapId: string]: LabelmapLayer;
38
+ };
39
+ segmentBindings?: {
40
+ [segmentIndex: number]: SegmentLabelmapBindingState;
41
+ };
42
+ primaryLabelmapId?: string;
43
+ sourceRepresentationName?: string;
44
+ };
45
+ export type LabelmapSegmentationDataVolume = LabelmapSegmentationDataShared & {
25
46
  volumeId?: string;
26
47
  referencedVolumeId?: string;
27
- referencedImageIds?: string[];
48
+ };
49
+ export type LabelmapSegmentationDataStack = LabelmapSegmentationDataShared & {
28
50
  imageIds?: string[];
29
51
  };
52
+ export type LabelmapSegmentationData = LabelmapSegmentationDataShared & LabelmapSegmentationDataVolume & LabelmapSegmentationDataStack;
@@ -23,9 +23,11 @@ export type Segment = {
23
23
  export type Segmentation = {
24
24
  segmentationId: string;
25
25
  label: string;
26
+ fallbackLabel?: string;
26
27
  segments: {
27
28
  [segmentIndex: number]: Segment;
28
29
  };
30
+ segmentOrder?: number[];
29
31
  representationData: RepresentationsData;
30
32
  cachedStats: {
31
33
  [key: string]: unknown;
@@ -36,6 +38,7 @@ export type LabelmapRenderingConfig = {
36
38
  ofun: vtkPiecewiseFunction;
37
39
  colorLUTIndex: number;
38
40
  blendMode?: coreEnums.BlendModes;
41
+ useSliceRendering?: boolean;
39
42
  };
40
43
  export type ContourRenderingConfig = {};
41
44
  export type SurfaceRenderingConfig = {};
@@ -79,7 +82,9 @@ export type SegmentationPublicInput = {
79
82
  segments?: {
80
83
  [segmentIndex: number]: Partial<Segment>;
81
84
  };
85
+ segmentOrder?: number[];
82
86
  label?: string;
87
+ fallbackLabel?: string;
83
88
  cachedStats?: {
84
89
  [key: string]: unknown;
85
90
  };
@@ -91,6 +96,7 @@ export type RepresentationPublicInput = {
91
96
  config?: {
92
97
  colorLUTOrIndex?: Types.ColorLUT | number;
93
98
  blendMode?: coreEnums.BlendModes;
99
+ useSliceRendering?: boolean;
94
100
  };
95
101
  };
96
102
  export {};
@@ -1,4 +1,5 @@
1
1
  import { utilities, Enums } from '@cornerstonejs/core';
2
+ import { viewportSupportsStackCalibration, viewportSupportsStackCompatibility, } from './viewportCapabilities';
2
3
  const { calibratedPixelSpacingMetadataProvider } = utilities;
3
4
  export default function calibrateImageSpacing(imageId, renderingEngine, calibrationOrScale) {
4
5
  if (typeof calibrationOrScale === 'number') {
@@ -8,11 +9,25 @@ export default function calibrateImageSpacing(imageId, renderingEngine, calibrat
8
9
  };
9
10
  }
10
11
  calibratedPixelSpacingMetadataProvider.add(imageId, calibrationOrScale);
11
- const viewports = renderingEngine.getStackViewports();
12
+ const viewports = renderingEngine.getViewports().filter((viewport) => {
13
+ return (viewportSupportsStackCalibration(viewport) ||
14
+ viewportSupportsStackCompatibility(viewport));
15
+ });
12
16
  viewports.forEach((viewport) => {
13
17
  const imageIds = viewport.getImageIds();
14
18
  if (imageIds.includes(imageId)) {
15
- viewport.calibrateSpacing(imageId);
19
+ if (viewportSupportsStackCalibration(viewport)) {
20
+ viewport.calibrateSpacing(imageId);
21
+ return;
22
+ }
23
+ const currentImageIdIndex = viewport.getCurrentImageIdIndex();
24
+ void Promise.resolve(viewport.setStack(imageIds, currentImageIdIndex))
25
+ .then(() => {
26
+ viewport.render();
27
+ })
28
+ .catch((error) => {
29
+ console.warn('calibrateImageSpacing: failed to refresh stack-compatible viewport', error);
30
+ });
16
31
  }
17
32
  });
18
33
  }
@@ -8,7 +8,6 @@ function validateAnnotation(annotation) {
8
8
  }
9
9
  }
10
10
  class AnnotationToPointData {
11
- static { this.TOOL_NAMES = {}; }
12
11
  constructor() {
13
12
  }
14
13
  static convert(annotation, segment, metadataProvider) {
@@ -36,5 +35,6 @@ class AnnotationToPointData {
36
35
  AnnotationToPointData.TOOL_NAMES[toolClass.toolName] = toolClass;
37
36
  }
38
37
  }
38
+ AnnotationToPointData.TOOL_NAMES = {};
39
39
  AnnotationToPointData.register(RectangleROIStartEndThreshold);
40
40
  export default AnnotationToPointData;
@@ -0,0 +1,7 @@
1
+ import vtkPolyData from '@kitware/vtk.js/Common/DataModel/PolyData';
2
+ import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
3
+ import type { Types } from '@cornerstonejs/core';
4
+ export declare function addLine3DBetweenPoints(viewport: Types.IVolumeViewport, point1: Types.Point3, point2: Types.Point3, color?: [number, number, number], uid?: string, showHandles?: boolean): {
5
+ actor: vtkActor | null;
6
+ source: vtkPolyData | null;
7
+ };
@@ -0,0 +1,34 @@
1
+ import vtkPolyData from '@kitware/vtk.js/Common/DataModel/PolyData';
2
+ import vtkPoints from '@kitware/vtk.js/Common/Core/Points';
3
+ import vtkCellArray from '@kitware/vtk.js/Common/Core/CellArray';
4
+ import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
5
+ import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper';
6
+ export function addLine3DBetweenPoints(viewport, point1, point2, color = [0.7, 0.7, 0.7], uid = '', showHandles = true) {
7
+ if (point1[0] === point2[0] &&
8
+ point1[1] === point2[1] &&
9
+ point1[2] === point2[2]) {
10
+ return { actor: null, source: null };
11
+ }
12
+ const points = vtkPoints.newInstance();
13
+ points.setNumberOfPoints(2);
14
+ points.setPoint(0, point1[0], point1[1], point1[2]);
15
+ points.setPoint(1, point2[0], point2[1], point2[2]);
16
+ const lines = vtkCellArray.newInstance({ values: [2, 0, 1] });
17
+ const polyData = vtkPolyData.newInstance();
18
+ polyData.setPoints(points);
19
+ polyData.setLines(lines);
20
+ const mapper = vtkMapper.newInstance();
21
+ mapper.setInputData(polyData);
22
+ const actor = vtkActor.newInstance();
23
+ actor.setMapper(mapper);
24
+ actor.getProperty().setColor(...color);
25
+ actor.getProperty().setLineWidth(0.5);
26
+ actor.getProperty().setOpacity(1.0);
27
+ actor.getProperty().setInterpolationToFlat();
28
+ actor.getProperty().setAmbient(1.0);
29
+ actor.getProperty().setDiffuse(0.0);
30
+ actor.getProperty().setSpecular(0.0);
31
+ actor.setVisibility(showHandles);
32
+ viewport.addActor({ actor, uid });
33
+ return { actor, source: polyData };
34
+ }
@@ -0,0 +1,6 @@
1
+ export declare function calculateAdaptiveSphereRadius(diagonal: number, config: {
2
+ sphereRadius?: number;
3
+ sphereRadiusScale?: number;
4
+ minSphereRadius?: number;
5
+ maxSphereRadius?: number;
6
+ }): number;
@@ -0,0 +1,7 @@
1
+ export function calculateAdaptiveSphereRadius(diagonal, config) {
2
+ const scaleFactor = config.sphereRadiusScale || 0.01;
3
+ const adaptiveRadius = diagonal * scaleFactor;
4
+ const minRadius = config.minSphereRadius || 2;
5
+ const maxRadius = config.maxSphereRadius || 50;
6
+ return Math.max(minRadius, Math.min(maxRadius, adaptiveRadius));
7
+ }
@@ -0,0 +1,2 @@
1
+ export { addLine3DBetweenPoints } from './addLine3DBetweenPoints';
2
+ export { calculateAdaptiveSphereRadius } from './calculateAdaptiveSphereRadius';
@@ -0,0 +1,2 @@
1
+ export { addLine3DBetweenPoints } from './addLine3DBetweenPoints';
2
+ export { calculateAdaptiveSphereRadius } from './calculateAdaptiveSphereRadius';
@@ -99,28 +99,36 @@ function _findSvgLayer(element) {
99
99
  return internalDiv?.querySelector(':scope > .svg-layer') || null;
100
100
  }
101
101
  function _determineCorners(canvasPoints) {
102
- const p0 = canvasPoints[0];
103
- if (!p0 || canvasPoints.length < 2) {
102
+ const validPoints = canvasPoints.filter(Boolean);
103
+ const p0 = validPoints[0];
104
+ if (!p0 || validPoints.length < 2) {
104
105
  return { left: p0, right: p0, top: p0, bottom: p0 };
105
106
  }
106
- const handlesLeftToRight = [canvasPoints[0], canvasPoints[1]].sort(_compareX);
107
- const handlesTopToBottom = [canvasPoints[0], canvasPoints[1]].sort(_compareY);
108
- const left = handlesLeftToRight[0];
109
- const right = handlesLeftToRight[handlesLeftToRight.length - 1];
110
- const top = handlesTopToBottom[0];
111
- const bottom = handlesTopToBottom[handlesTopToBottom.length - 1];
107
+ let left = p0;
108
+ let right = p0;
109
+ let top = p0;
110
+ let bottom = p0;
111
+ for (let i = 1; i < validPoints.length; i++) {
112
+ const point = validPoints[i];
113
+ if (point[0] < left[0]) {
114
+ left = point;
115
+ }
116
+ if (point[0] > right[0]) {
117
+ right = point;
118
+ }
119
+ if (point[1] < top[1]) {
120
+ top = point;
121
+ }
122
+ if (point[1] > bottom[1]) {
123
+ bottom = point;
124
+ }
125
+ }
112
126
  return {
113
127
  left,
114
128
  top,
115
129
  bottom,
116
130
  right,
117
131
  };
118
- function _compareX(a, b) {
119
- return a[0] < b[0] ? -1 : 1;
120
- }
121
- function _compareY(a, b) {
122
- return a[1] < b[1] ? -1 : 1;
123
- }
124
132
  }
125
133
  function _estimateTextBoxSize(textLines) {
126
134
  const estimatedPadding = 25;
@@ -0,0 +1,6 @@
1
+ import { type Types, type VolumeViewport } from '@cornerstonejs/core';
2
+ export declare function getCenterAndRadiusInCanvas(points: Types.Point3[], viewport: Types.IStackViewport | VolumeViewport): {
3
+ center: Types.Point2;
4
+ radius: number;
5
+ };
6
+ export default getCenterAndRadiusInCanvas;
@@ -0,0 +1,26 @@
1
+ import {} from '@cornerstonejs/core';
2
+ import { vec2, vec3 } from 'gl-matrix';
3
+ const EPSILON = 1e-4;
4
+ export function getCenterAndRadiusInCanvas(points, viewport) {
5
+ const canvasPoints = points.map((p) => viewport.worldToCanvas(p));
6
+ const [cBottom, cTop, cLeft, cRight] = canvasPoints;
7
+ const center = [
8
+ (cBottom[0] + cTop[0]) / 2,
9
+ (cBottom[1] + cTop[1]) / 2,
10
+ ];
11
+ const worldHeight = vec3.distance(points[0], points[1]);
12
+ const worldWidth = vec3.distance(points[2], points[3]);
13
+ const canvasHeight = vec2.distance(cBottom, cTop);
14
+ const canvasWidth = vec2.distance(cLeft, cRight);
15
+ const scaleX = canvasWidth / worldWidth;
16
+ const scaleY = canvasHeight / worldHeight;
17
+ const worldRadius = worldHeight / 2;
18
+ const radius = Math.abs(scaleX - scaleY) > EPSILON
19
+ ? worldRadius * Math.min(scaleX, scaleY)
20
+ : canvasHeight / 2;
21
+ return {
22
+ center: center,
23
+ radius: Math.round(radius),
24
+ };
25
+ }
26
+ export default getCenterAndRadiusInCanvas;
@@ -0,0 +1,2 @@
1
+ import type { VolumeViewport, Types } from '@cornerstonejs/core';
2
+ export default function getEllipseWorldCoordinates(points: [Types.Point3, Types.Point3], viewport: Types.IStackViewport | VolumeViewport): Types.Point3[];
@@ -0,0 +1,26 @@
1
+ import { vec3 } from 'gl-matrix';
2
+ export default function getEllipseWorldCoordinates(points, viewport) {
3
+ const camera = viewport.getCamera();
4
+ const { viewUp, viewPlaneNormal } = camera;
5
+ const viewRight = vec3.create();
6
+ vec3.cross(viewRight, viewUp, viewPlaneNormal);
7
+ const [centerWorld, endWorld] = points;
8
+ const centerToEndDistance = vec3.distance(centerWorld, endWorld);
9
+ const bottomWorld = vec3.create();
10
+ const topWorld = vec3.create();
11
+ const leftWorld = vec3.create();
12
+ const rightWorld = vec3.create();
13
+ for (let i = 0; i <= 2; i++) {
14
+ bottomWorld[i] = centerWorld[i] - viewUp[i] * centerToEndDistance;
15
+ topWorld[i] = centerWorld[i] + viewUp[i] * centerToEndDistance;
16
+ leftWorld[i] = centerWorld[i] - viewRight[i] * centerToEndDistance;
17
+ rightWorld[i] = centerWorld[i] + viewRight[i] * centerToEndDistance;
18
+ }
19
+ const ellipseWorldCoordinates = [
20
+ bottomWorld,
21
+ topWorld,
22
+ leftWorld,
23
+ rightWorld,
24
+ ];
25
+ return ellipseWorldCoordinates;
26
+ }
@@ -1,6 +1,7 @@
1
1
  import { utilities as csUtils } from '@cornerstonejs/core';
2
2
  import { vec3 } from 'gl-matrix';
3
3
  import { getBoundingBoxAroundShapeIJK } from './boundingBox';
4
+ import getViewportICamera from './getViewportICamera';
4
5
  const { transformWorldToIndex } = csUtils;
5
6
  function _getSphereBoundsInfo(circlePoints, imageData, directionVectors) {
6
7
  const [bottom, top] = circlePoints;
@@ -32,7 +33,10 @@ function getSphereBoundsInfoFromViewport(circlePoints, imageData, viewport) {
32
33
  if (!viewport) {
33
34
  throw new Error('viewport is required in order to calculate the sphere bounds');
34
35
  }
35
- const camera = viewport.getCamera();
36
+ const camera = getViewportICamera(viewport);
37
+ if (!camera.viewUp || !camera.viewPlaneNormal) {
38
+ throw new Error('viewport view plane is required in order to calculate the sphere bounds');
39
+ }
36
40
  const viewUp = vec3.fromValues(camera.viewUp[0], camera.viewUp[1], camera.viewUp[2]);
37
41
  const viewPlaneNormal = vec3.fromValues(camera.viewPlaneNormal[0], camera.viewPlaneNormal[1], camera.viewPlaneNormal[2]);
38
42
  const viewRight = vec3.create();
@@ -0,0 +1,4 @@
1
+ import { type Types } from '@cornerstonejs/core';
2
+ type ViewportICamera = Pick<Types.ICamera, 'focalPoint' | 'position' | 'viewPlaneNormal' | 'viewUp'>;
3
+ export default function getViewportICamera(viewport: Types.IViewport, viewReference?: Types.ViewReference): Partial<ViewportICamera>;
4
+ export {};
@@ -0,0 +1,23 @@
1
+ import { utilities } from '@cornerstonejs/core';
2
+ export default function getViewportICamera(viewport, viewReference = viewport.getViewReference()) {
3
+ const genericViewport = viewport;
4
+ const camera = (genericViewport.getResolvedView?.()?.toICamera?.() ||
5
+ viewport.getCamera?.() ||
6
+ {});
7
+ const focalPoint = utilities.clonePoint3(viewReference?.cameraFocalPoint || camera.focalPoint);
8
+ const viewPlaneNormal = utilities.clonePoint3(viewReference?.viewPlaneNormal || camera.viewPlaneNormal);
9
+ const viewUp = utilities.clonePoint3(viewReference?.viewUp || camera.viewUp);
10
+ const position = utilities.clonePoint3(camera.position ||
11
+ (focalPoint &&
12
+ viewPlaneNormal && [
13
+ focalPoint[0] - viewPlaneNormal[0],
14
+ focalPoint[1] - viewPlaneNormal[1],
15
+ focalPoint[2] - viewPlaneNormal[2],
16
+ ]));
17
+ return {
18
+ focalPoint,
19
+ position,
20
+ viewPlaneNormal,
21
+ viewUp,
22
+ };
23
+ }
@@ -1,4 +1,5 @@
1
1
  import { getEnabledElements, utilities as csUtils } from '@cornerstonejs/core';
2
+ import getViewportICamera from './getViewportICamera';
2
3
  const { isEqual } = csUtils;
3
4
  export default function getViewportsForAnnotation(annotation) {
4
5
  const { metadata } = annotation;
@@ -6,7 +7,10 @@ export default function getViewportsForAnnotation(annotation) {
6
7
  .filter((enabledElement) => {
7
8
  if (enabledElement.FrameOfReferenceUID === metadata.FrameOfReferenceUID) {
8
9
  const viewport = enabledElement.viewport;
9
- const { viewPlaneNormal, viewUp } = viewport.getCamera();
10
+ const { viewPlaneNormal, viewUp } = getViewportICamera(viewport);
11
+ if (!viewPlaneNormal) {
12
+ return false;
13
+ }
10
14
  return (isEqual(viewPlaneNormal, metadata.viewPlaneNormal) &&
11
15
  (!metadata.viewUp || isEqual(viewUp, metadata.viewUp)));
12
16
  }
@@ -22,6 +22,7 @@ import * as viewportFilters from './viewportFilters';
22
22
  import * as orientation from './orientation';
23
23
  import * as cine from './cine';
24
24
  import * as boundingBox from './boundingBox';
25
+ import * as draw3D from './draw3D';
25
26
  import * as planarFreehandROITool from './planarFreehandROITool';
26
27
  import * as rectangleROITool from './rectangleROITool';
27
28
  import { stackPrefetch, stackContextPrefetch } from './stackPrefetch';
@@ -42,4 +43,4 @@ import { moveAnnotationToViewPlane } from './moveAnnotationToViewPlane';
42
43
  import { safeStructuredClone } from './safeStructuredClone';
43
44
  import getOrCreateImageVolume from './segmentation/getOrCreateImageVolume';
44
45
  import * as usFanExtraction from '../tools/annotation/UltrasoundPleuraBLineTool/utils/fanExtraction';
45
- export { math, planar, viewportFilters, drawing, debounce, dynamicVolume, throttle, orientation, isObject, touch, triggerEvent, calibrateImageSpacing, getCalibratedLengthUnitsAndScale, getCalibratedProbeUnitsAndValue, getCalibratedAspect, getPixelValueUnits, getPixelValueUnitsImageId, segmentation, contours, triggerAnnotationRenderForViewportIds, triggerAnnotationRenderForToolGroupIds, triggerAnnotationRender, getSphereBoundsInfo, getAnnotationNearPoint, getViewportForAnnotation, getAnnotationNearPointOnEnabledElement, viewport, cine, boundingBox, rectangleROITool, planarFreehandROITool, stackPrefetch, stackContextPrefetch, roundNumber, pointToString, polyDataUtils, voi, AnnotationMultiSlice, contourSegmentation, annotationHydration, getClosestImageIdForStackViewport, pointInSurroundingSphereCallback, normalizeViewportPlane, IslandRemoval, geometricSurfaceUtils, usFanExtraction, setAnnotationLabel, moveAnnotationToViewPlane, safeStructuredClone, getOrCreateImageVolume, };
46
+ export { math, planar, viewportFilters, drawing, debounce, dynamicVolume, throttle, orientation, isObject, touch, triggerEvent, calibrateImageSpacing, getCalibratedLengthUnitsAndScale, getCalibratedProbeUnitsAndValue, getCalibratedAspect, getPixelValueUnits, getPixelValueUnitsImageId, segmentation, contours, triggerAnnotationRenderForViewportIds, triggerAnnotationRenderForToolGroupIds, triggerAnnotationRender, getSphereBoundsInfo, getAnnotationNearPoint, getViewportForAnnotation, getAnnotationNearPointOnEnabledElement, viewport, cine, boundingBox, draw3D, rectangleROITool, planarFreehandROITool, stackPrefetch, stackContextPrefetch, roundNumber, pointToString, polyDataUtils, voi, AnnotationMultiSlice, contourSegmentation, annotationHydration, getClosestImageIdForStackViewport, pointInSurroundingSphereCallback, normalizeViewportPlane, IslandRemoval, geometricSurfaceUtils, usFanExtraction, setAnnotationLabel, moveAnnotationToViewPlane, safeStructuredClone, getOrCreateImageVolume, };
@@ -22,6 +22,7 @@ import * as viewportFilters from './viewportFilters';
22
22
  import * as orientation from './orientation';
23
23
  import * as cine from './cine';
24
24
  import * as boundingBox from './boundingBox';
25
+ import * as draw3D from './draw3D';
25
26
  import * as planarFreehandROITool from './planarFreehandROITool';
26
27
  import * as rectangleROITool from './rectangleROITool';
27
28
  import { stackPrefetch, stackContextPrefetch } from './stackPrefetch';
@@ -42,4 +43,4 @@ import { moveAnnotationToViewPlane } from './moveAnnotationToViewPlane';
42
43
  import { safeStructuredClone } from './safeStructuredClone';
43
44
  import getOrCreateImageVolume from './segmentation/getOrCreateImageVolume';
44
45
  import * as usFanExtraction from '../tools/annotation/UltrasoundPleuraBLineTool/utils/fanExtraction';
45
- export { math, planar, viewportFilters, drawing, debounce, dynamicVolume, throttle, orientation, isObject, touch, triggerEvent, calibrateImageSpacing, getCalibratedLengthUnitsAndScale, getCalibratedProbeUnitsAndValue, getCalibratedAspect, getPixelValueUnits, getPixelValueUnitsImageId, segmentation, contours, triggerAnnotationRenderForViewportIds, triggerAnnotationRenderForToolGroupIds, triggerAnnotationRender, getSphereBoundsInfo, getAnnotationNearPoint, getViewportForAnnotation, getAnnotationNearPointOnEnabledElement, viewport, cine, boundingBox, rectangleROITool, planarFreehandROITool, stackPrefetch, stackContextPrefetch, roundNumber, pointToString, polyDataUtils, voi, AnnotationMultiSlice, contourSegmentation, annotationHydration, getClosestImageIdForStackViewport, pointInSurroundingSphereCallback, normalizeViewportPlane, IslandRemoval, geometricSurfaceUtils, usFanExtraction, setAnnotationLabel, moveAnnotationToViewPlane, safeStructuredClone, getOrCreateImageVolume, };
46
+ export { math, planar, viewportFilters, drawing, debounce, dynamicVolume, throttle, orientation, isObject, touch, triggerEvent, calibrateImageSpacing, getCalibratedLengthUnitsAndScale, getCalibratedProbeUnitsAndValue, getCalibratedAspect, getPixelValueUnits, getPixelValueUnitsImageId, segmentation, contours, triggerAnnotationRenderForViewportIds, triggerAnnotationRenderForToolGroupIds, triggerAnnotationRender, getSphereBoundsInfo, getAnnotationNearPoint, getViewportForAnnotation, getAnnotationNearPointOnEnabledElement, viewport, cine, boundingBox, draw3D, rectangleROITool, planarFreehandROITool, stackPrefetch, stackContextPrefetch, roundNumber, pointToString, polyDataUtils, voi, AnnotationMultiSlice, contourSegmentation, annotationHydration, getClosestImageIdForStackViewport, pointInSurroundingSphereCallback, normalizeViewportPlane, IslandRemoval, geometricSurfaceUtils, usFanExtraction, setAnnotationLabel, moveAnnotationToViewPlane, safeStructuredClone, getOrCreateImageVolume, };
@@ -0,0 +1,5 @@
1
+ type DragOwner = 'orientation-controller';
2
+ export declare function beginOwnedDrag(viewportId: string, owner: DragOwner): boolean;
3
+ export declare function endOwnedDrag(viewportId: string, owner: DragOwner): void;
4
+ export declare function isDragOwnedBy(viewportId: string, owner: DragOwner): boolean;
5
+ export {};
@@ -0,0 +1,16 @@
1
+ const dragOwnerByViewportId = new Map();
2
+ export function beginOwnedDrag(viewportId, owner) {
3
+ if (dragOwnerByViewportId.has(viewportId)) {
4
+ return false;
5
+ }
6
+ dragOwnerByViewportId.set(viewportId, owner);
7
+ return true;
8
+ }
9
+ export function endOwnedDrag(viewportId, owner) {
10
+ if (dragOwnerByViewportId.get(viewportId) === owner) {
11
+ dragOwnerByViewportId.delete(viewportId);
12
+ }
13
+ }
14
+ export function isDragOwnedBy(viewportId, owner) {
15
+ return dragOwnerByViewportId.get(viewportId) === owner;
16
+ }
@@ -1,3 +1,4 @@
1
+ var _a;
1
2
  import { utilities } from '@cornerstonejs/core';
2
3
  import { Calculator, InstanceCalculator } from './Calculator';
3
4
  const { PointsManager } = utilities;
@@ -204,20 +205,21 @@ function basicGetStatistics(state, unit) {
204
205
  return named;
205
206
  }
206
207
  export class BasicStatsCalculator extends Calculator {
207
- static { this.state = createBasicStatsState(true); }
208
208
  static statsInit(options) {
209
209
  if (!options.storePointData) {
210
210
  this.state.pointsInShape = null;
211
211
  }
212
212
  this.state = createBasicStatsState(options.storePointData);
213
213
  }
214
- static { this.statsCallback = ({ value: newValue, pointLPS = null, pointIJK = null, }) => {
215
- basicStatsCallback(this.state, newValue, pointLPS, pointIJK);
216
- }; }
217
- static { this.getStatistics = (options) => {
218
- return basicGetStatistics(this.state, options?.unit);
219
- }; }
220
214
  }
215
+ _a = BasicStatsCalculator;
216
+ BasicStatsCalculator.state = createBasicStatsState(true);
217
+ BasicStatsCalculator.statsCallback = ({ value: newValue, pointLPS = null, pointIJK = null, }) => {
218
+ basicStatsCallback(_a.state, newValue, pointLPS, pointIJK);
219
+ };
220
+ BasicStatsCalculator.getStatistics = (options) => {
221
+ return basicGetStatistics(_a.state, options?.unit);
222
+ };
221
223
  export class InstanceBasicStatsCalculator extends InstanceCalculator {
222
224
  constructor(options) {
223
225
  super(options);
@@ -2,6 +2,7 @@ import { utilities as csUtils } from '@cornerstonejs/core';
2
2
  import { vec3 } from 'gl-matrix';
3
3
  import { pointInSphere } from './math/sphere';
4
4
  import { getBoundingBoxAroundShape } from './boundingBox';
5
+ import getViewportICamera from './getViewportICamera';
5
6
  const { transformWorldToIndex } = csUtils;
6
7
  export function pointInSurroundingSphereCallback(imageData, circlePoints, callback, viewport) {
7
8
  const { boundsIJK, centerWorld, radiusWorld } = _getBounds(circlePoints, imageData, viewport);
@@ -51,7 +52,13 @@ function _getBounds(circlePoints, imageData, viewport) {
51
52
  function _computeBoundsIJKWithCamera(imageData, viewport, circlePoints, centerWorld, radiusWorld) {
52
53
  const [bottom, top] = circlePoints;
53
54
  const dimensions = imageData.getDimensions();
54
- const camera = viewport.getCamera();
55
+ const camera = getViewportICamera(viewport);
56
+ if (!camera.viewUp || !camera.viewPlaneNormal) {
57
+ return getBoundingBoxAroundShape([
58
+ transformWorldToIndex(imageData, top),
59
+ transformWorldToIndex(imageData, bottom),
60
+ ], dimensions);
61
+ }
55
62
  const viewUp = vec3.fromValues(camera.viewUp[0], camera.viewUp[1], camera.viewUp[2]);
56
63
  const viewPlaneNormal = vec3.fromValues(camera.viewPlaneNormal[0], camera.viewPlaneNormal[1], camera.viewPlaneNormal[2]);
57
64
  const viewRight = vec3.create();