@cornerstonejs/tools 2.0.0-beta.1 → 2.0.0-beta.2

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 (425) hide show
  1. package/dist/cjs/drawingSvg/drawCircle.js +9 -5
  2. package/dist/cjs/drawingSvg/drawCircle.js.map +1 -1
  3. package/dist/cjs/drawingSvg/drawEllipse.js +4 -4
  4. package/dist/cjs/drawingSvg/drawEllipse.js.map +1 -1
  5. package/dist/cjs/drawingSvg/drawHandles.js +4 -4
  6. package/dist/cjs/drawingSvg/drawHandles.js.map +1 -1
  7. package/dist/cjs/drawingSvg/drawLine.js +4 -4
  8. package/dist/cjs/drawingSvg/drawLine.js.map +1 -1
  9. package/dist/cjs/drawingSvg/drawPolyline.js +4 -4
  10. package/dist/cjs/drawingSvg/drawPolyline.js.map +1 -1
  11. package/dist/cjs/drawingSvg/drawRect.js +4 -4
  12. package/dist/cjs/drawingSvg/drawRect.js.map +1 -1
  13. package/dist/cjs/drawingSvg/drawTextBox.js +4 -4
  14. package/dist/cjs/drawingSvg/drawTextBox.js.map +1 -1
  15. package/dist/cjs/drawingSvg/index.d.ts +3 -1
  16. package/dist/cjs/drawingSvg/index.js +5 -1
  17. package/dist/cjs/drawingSvg/index.js.map +1 -1
  18. package/dist/cjs/drawingSvg/setAttributesIfNecessary.d.ts +2 -0
  19. package/dist/cjs/drawingSvg/{_setAttributesIfNecessary.js → setAttributesIfNecessary.js} +5 -5
  20. package/dist/cjs/drawingSvg/setAttributesIfNecessary.js.map +1 -0
  21. package/dist/cjs/drawingSvg/setNewAttributesIfValid.d.ts +2 -0
  22. package/dist/cjs/drawingSvg/{_setNewAttributesIfValid.js → setNewAttributesIfValid.js} +5 -5
  23. package/dist/cjs/drawingSvg/setNewAttributesIfValid.js.map +1 -0
  24. package/dist/cjs/enums/Events.d.ts +1 -0
  25. package/dist/cjs/enums/Events.js +1 -0
  26. package/dist/cjs/enums/Events.js.map +1 -1
  27. package/dist/cjs/eventDispatchers/shared/getMouseModifier.js +10 -5
  28. package/dist/cjs/eventDispatchers/shared/getMouseModifier.js.map +1 -1
  29. package/dist/cjs/eventListeners/keyboard/keyDownListener.js +8 -0
  30. package/dist/cjs/eventListeners/keyboard/keyDownListener.js.map +1 -1
  31. package/dist/cjs/eventListeners/mouse/mouseDownListener.js +2 -1
  32. package/dist/cjs/eventListeners/mouse/mouseDownListener.js.map +1 -1
  33. package/dist/cjs/eventListeners/touch/touchStartListener.js +10 -5
  34. package/dist/cjs/eventListeners/touch/touchStartListener.js.map +1 -1
  35. package/dist/cjs/index.d.ts +2 -2
  36. package/dist/cjs/index.js +3 -2
  37. package/dist/cjs/index.js.map +1 -1
  38. package/dist/cjs/stateManagement/annotation/config/ToolStyle.js +1 -0
  39. package/dist/cjs/stateManagement/annotation/config/ToolStyle.js.map +1 -1
  40. package/dist/cjs/stateManagement/annotation/config/getState.js +6 -3
  41. package/dist/cjs/stateManagement/annotation/config/getState.js.map +1 -1
  42. package/dist/cjs/stateManagement/annotation/config/helpers.js +4 -2
  43. package/dist/cjs/stateManagement/annotation/config/helpers.js.map +1 -1
  44. package/dist/cjs/store/SynchronizerManager/Synchronizer.js +10 -2
  45. package/dist/cjs/store/SynchronizerManager/Synchronizer.js.map +1 -1
  46. package/dist/cjs/store/ToolGroupManager/ToolGroup.d.ts +3 -3
  47. package/dist/cjs/store/ToolGroupManager/ToolGroup.js +9 -2
  48. package/dist/cjs/store/ToolGroupManager/ToolGroup.js.map +1 -1
  49. package/dist/cjs/store/ToolGroupManager/getToolGroupsWithToolName.js +2 -1
  50. package/dist/cjs/store/ToolGroupManager/getToolGroupsWithToolName.js.map +1 -1
  51. package/dist/cjs/synchronizers/callbacks/stackImageSyncCallback.js +25 -22
  52. package/dist/cjs/synchronizers/callbacks/stackImageSyncCallback.js.map +1 -1
  53. package/dist/cjs/synchronizers/callbacks/voiSyncCallback.js +1 -1
  54. package/dist/cjs/synchronizers/callbacks/voiSyncCallback.js.map +1 -1
  55. package/dist/cjs/tools/MIPJumpToClickTool.js +4 -2
  56. package/dist/cjs/tools/MIPJumpToClickTool.js.map +1 -1
  57. package/dist/cjs/tools/PlanarRotateTool.js +2 -1
  58. package/dist/cjs/tools/PlanarRotateTool.js.map +1 -1
  59. package/dist/cjs/tools/ReferenceCursors.js +58 -29
  60. package/dist/cjs/tools/ReferenceCursors.js.map +1 -1
  61. package/dist/cjs/tools/ScaleOverlayTool.js +2 -1
  62. package/dist/cjs/tools/ScaleOverlayTool.js.map +1 -1
  63. package/dist/cjs/tools/annotation/AngleTool.d.ts +0 -1
  64. package/dist/cjs/tools/annotation/AngleTool.js +31 -14
  65. package/dist/cjs/tools/annotation/AngleTool.js.map +1 -1
  66. package/dist/cjs/tools/annotation/ArrowAnnotateTool.js +15 -1
  67. package/dist/cjs/tools/annotation/ArrowAnnotateTool.js.map +1 -1
  68. package/dist/cjs/tools/annotation/BidirectionalTool.d.ts +0 -1
  69. package/dist/cjs/tools/annotation/BidirectionalTool.js +29 -14
  70. package/dist/cjs/tools/annotation/BidirectionalTool.js.map +1 -1
  71. package/dist/cjs/tools/annotation/CircleROITool.d.ts +0 -1
  72. package/dist/cjs/tools/annotation/CircleROITool.js +56 -53
  73. package/dist/cjs/tools/annotation/CircleROITool.js.map +1 -1
  74. package/dist/cjs/tools/annotation/CobbAngleTool.d.ts +0 -1
  75. package/dist/cjs/tools/annotation/CobbAngleTool.js +26 -11
  76. package/dist/cjs/tools/annotation/CobbAngleTool.js.map +1 -1
  77. package/dist/cjs/tools/annotation/DragProbeTool.js +13 -1
  78. package/dist/cjs/tools/annotation/DragProbeTool.js.map +1 -1
  79. package/dist/cjs/tools/annotation/EllipticalROITool.d.ts +0 -1
  80. package/dist/cjs/tools/annotation/EllipticalROITool.js +48 -46
  81. package/dist/cjs/tools/annotation/EllipticalROITool.js.map +1 -1
  82. package/dist/cjs/tools/annotation/LengthTool.d.ts +0 -1
  83. package/dist/cjs/tools/annotation/LengthTool.js +26 -11
  84. package/dist/cjs/tools/annotation/LengthTool.js.map +1 -1
  85. package/dist/cjs/tools/annotation/PlanarFreehandROITool.d.ts +0 -1
  86. package/dist/cjs/tools/annotation/PlanarFreehandROITool.js +50 -51
  87. package/dist/cjs/tools/annotation/PlanarFreehandROITool.js.map +1 -1
  88. package/dist/cjs/tools/annotation/ProbeTool.d.ts +0 -1
  89. package/dist/cjs/tools/annotation/ProbeTool.js +18 -13
  90. package/dist/cjs/tools/annotation/ProbeTool.js.map +1 -1
  91. package/dist/cjs/tools/annotation/RectangleROITool.d.ts +0 -1
  92. package/dist/cjs/tools/annotation/RectangleROITool.js +46 -48
  93. package/dist/cjs/tools/annotation/RectangleROITool.js.map +1 -1
  94. package/dist/cjs/tools/base/AnnotationTool.d.ts +2 -1
  95. package/dist/cjs/tools/base/AnnotationTool.js +27 -16
  96. package/dist/cjs/tools/base/AnnotationTool.js.map +1 -1
  97. package/dist/cjs/tools/base/index.d.ts +2 -1
  98. package/dist/cjs/tools/base/index.js +3 -1
  99. package/dist/cjs/tools/base/index.js.map +1 -1
  100. package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
  101. package/dist/cjs/tools/displayTools/Labelmap/removeLabelmapFromElement.js +3 -0
  102. package/dist/cjs/tools/displayTools/Labelmap/removeLabelmapFromElement.js.map +1 -1
  103. package/dist/cjs/tools/displayTools/SegmentationDisplayTool.js +5 -6
  104. package/dist/cjs/tools/displayTools/SegmentationDisplayTool.js.map +1 -1
  105. package/dist/cjs/tools/index.d.ts +2 -2
  106. package/dist/cjs/tools/index.js +2 -1
  107. package/dist/cjs/tools/index.js.map +1 -1
  108. package/dist/cjs/tools/segmentation/BrushTool.js +24 -17
  109. package/dist/cjs/tools/segmentation/BrushTool.js.map +1 -1
  110. package/dist/cjs/tools/segmentation/PaintFillTool.js +4 -2
  111. package/dist/cjs/tools/segmentation/PaintFillTool.js.map +1 -1
  112. package/dist/cjs/tools/segmentation/strategies/eraseSphere.d.ts +2 -0
  113. package/dist/cjs/tools/segmentation/strategies/eraseSphere.js.map +1 -1
  114. package/dist/cjs/tools/segmentation/strategies/fillCircle.js +5 -7
  115. package/dist/cjs/tools/segmentation/strategies/fillCircle.js.map +1 -1
  116. package/dist/cjs/tools/segmentation/strategies/fillSphere.d.ts +3 -0
  117. package/dist/cjs/tools/segmentation/strategies/fillSphere.js +38 -10
  118. package/dist/cjs/tools/segmentation/strategies/fillSphere.js.map +1 -1
  119. package/dist/cjs/tools/segmentation/strategies/utils/isWithinThreshold.d.ts +3 -0
  120. package/dist/cjs/tools/segmentation/strategies/utils/isWithinThreshold.js +10 -0
  121. package/dist/cjs/tools/segmentation/strategies/utils/isWithinThreshold.js.map +1 -0
  122. package/dist/cjs/types/CINETypes.d.ts +2 -0
  123. package/dist/cjs/types/CalculatorTypes.d.ts +6 -0
  124. package/dist/cjs/types/CalculatorTypes.js +3 -0
  125. package/dist/cjs/types/CalculatorTypes.js.map +1 -0
  126. package/dist/cjs/types/EventTypes.d.ts +8 -1
  127. package/dist/cjs/types/ISetToolModeOptions.d.ts +2 -2
  128. package/dist/cjs/types/IToolGroup.d.ts +3 -2
  129. package/dist/cjs/types/ToolProps.d.ts +5 -1
  130. package/dist/cjs/types/index.d.ts +3 -2
  131. package/dist/cjs/utilities/cine/playClip.js +13 -3
  132. package/dist/cjs/utilities/cine/playClip.js.map +1 -1
  133. package/dist/cjs/utilities/dynamicVolume/getDataInTime.js +7 -4
  134. package/dist/cjs/utilities/dynamicVolume/getDataInTime.js.map +1 -1
  135. package/dist/cjs/utilities/getCalibratedUnits.js +10 -5
  136. package/dist/cjs/utilities/getCalibratedUnits.js.map +1 -1
  137. package/dist/cjs/utilities/math/basic/BasicStatsCalculator.d.ts +14 -0
  138. package/dist/cjs/utilities/math/basic/BasicStatsCalculator.js +44 -0
  139. package/dist/cjs/utilities/math/basic/BasicStatsCalculator.js.map +1 -0
  140. package/dist/cjs/utilities/math/basic/Calculator.d.ts +8 -0
  141. package/dist/cjs/utilities/math/basic/Calculator.js +6 -0
  142. package/dist/cjs/utilities/math/basic/Calculator.js.map +1 -0
  143. package/dist/cjs/utilities/math/basic/index.d.ts +3 -0
  144. package/dist/cjs/utilities/math/basic/index.js +11 -0
  145. package/dist/cjs/utilities/math/basic/index.js.map +1 -0
  146. package/dist/cjs/utilities/math/index.d.ts +2 -1
  147. package/dist/cjs/utilities/math/index.js +3 -1
  148. package/dist/cjs/utilities/math/index.js.map +1 -1
  149. package/dist/cjs/utilities/math/midPoint.js +2 -1
  150. package/dist/cjs/utilities/math/midPoint.js.map +1 -1
  151. package/dist/cjs/utilities/math/polyline/pointInPolyline.js +2 -1
  152. package/dist/cjs/utilities/math/polyline/pointInPolyline.js.map +1 -1
  153. package/dist/cjs/utilities/math/vec2/liangBarksyClip.d.ts +1 -1
  154. package/dist/cjs/utilities/math/vec2/liangBarksyClip.js +10 -5
  155. package/dist/cjs/utilities/math/vec2/liangBarksyClip.js.map +1 -1
  156. package/dist/cjs/utilities/pointInShapeCallback.d.ts +7 -1
  157. package/dist/cjs/utilities/pointInShapeCallback.js +6 -1
  158. package/dist/cjs/utilities/pointInShapeCallback.js.map +1 -1
  159. package/dist/cjs/utilities/roundNumber.js +4 -2
  160. package/dist/cjs/utilities/roundNumber.js.map +1 -1
  161. package/dist/cjs/utilities/segmentation/brushSizeForToolGroup.d.ts +2 -2
  162. package/dist/cjs/utilities/segmentation/brushSizeForToolGroup.js +4 -4
  163. package/dist/cjs/utilities/segmentation/brushSizeForToolGroup.js.map +1 -1
  164. package/dist/cjs/utilities/segmentation/thresholdVolumeByRange.js +2 -1
  165. package/dist/cjs/utilities/segmentation/thresholdVolumeByRange.js.map +1 -1
  166. package/dist/cjs/utilities/segmentation/utilities.d.ts +1 -2
  167. package/dist/cjs/utilities/segmentation/utilities.js +4 -1
  168. package/dist/cjs/utilities/segmentation/utilities.js.map +1 -1
  169. package/dist/cjs/utilities/stackPrefetch/stackPrefetch.js +4 -4
  170. package/dist/cjs/utilities/stackPrefetch/stackPrefetch.js.map +1 -1
  171. package/dist/esm/drawingSvg/drawCircle.js +9 -5
  172. package/dist/esm/drawingSvg/drawCircle.js.map +1 -1
  173. package/dist/esm/drawingSvg/drawEllipse.js +4 -4
  174. package/dist/esm/drawingSvg/drawEllipse.js.map +1 -1
  175. package/dist/esm/drawingSvg/drawHandles.js +4 -4
  176. package/dist/esm/drawingSvg/drawHandles.js.map +1 -1
  177. package/dist/esm/drawingSvg/drawLine.js +4 -4
  178. package/dist/esm/drawingSvg/drawLine.js.map +1 -1
  179. package/dist/esm/drawingSvg/drawPolyline.js +4 -4
  180. package/dist/esm/drawingSvg/drawPolyline.js.map +1 -1
  181. package/dist/esm/drawingSvg/drawRect.js +4 -4
  182. package/dist/esm/drawingSvg/drawRect.js.map +1 -1
  183. package/dist/esm/drawingSvg/drawTextBox.js +4 -4
  184. package/dist/esm/drawingSvg/drawTextBox.js.map +1 -1
  185. package/dist/esm/drawingSvg/index.d.ts +3 -1
  186. package/dist/esm/drawingSvg/index.js +3 -1
  187. package/dist/esm/drawingSvg/index.js.map +1 -1
  188. package/dist/esm/drawingSvg/setAttributesIfNecessary.d.ts +2 -0
  189. package/dist/esm/drawingSvg/{_setAttributesIfNecessary.js → setAttributesIfNecessary.js} +3 -3
  190. package/dist/esm/drawingSvg/setAttributesIfNecessary.js.map +1 -0
  191. package/dist/esm/drawingSvg/setNewAttributesIfValid.d.ts +2 -0
  192. package/dist/esm/drawingSvg/{_setNewAttributesIfValid.js → setNewAttributesIfValid.js} +3 -3
  193. package/dist/esm/drawingSvg/setNewAttributesIfValid.js.map +1 -0
  194. package/dist/esm/enums/Events.d.ts +1 -0
  195. package/dist/esm/enums/Events.js +1 -0
  196. package/dist/esm/enums/Events.js.map +1 -1
  197. package/dist/esm/eventDispatchers/shared/getMouseModifier.js +10 -5
  198. package/dist/esm/eventDispatchers/shared/getMouseModifier.js.map +1 -1
  199. package/dist/esm/eventListeners/keyboard/keyDownListener.js +8 -0
  200. package/dist/esm/eventListeners/keyboard/keyDownListener.js.map +1 -1
  201. package/dist/esm/eventListeners/mouse/mouseDownListener.js +2 -1
  202. package/dist/esm/eventListeners/mouse/mouseDownListener.js.map +1 -1
  203. package/dist/esm/eventListeners/touch/touchStartListener.js +10 -5
  204. package/dist/esm/eventListeners/touch/touchStartListener.js.map +1 -1
  205. package/dist/esm/index.d.ts +2 -2
  206. package/dist/esm/index.js +2 -2
  207. package/dist/esm/index.js.map +1 -1
  208. package/dist/esm/stateManagement/annotation/config/ToolStyle.js +1 -0
  209. package/dist/esm/stateManagement/annotation/config/ToolStyle.js.map +1 -1
  210. package/dist/esm/stateManagement/annotation/config/getState.js +6 -3
  211. package/dist/esm/stateManagement/annotation/config/getState.js.map +1 -1
  212. package/dist/esm/stateManagement/annotation/config/helpers.js +4 -2
  213. package/dist/esm/stateManagement/annotation/config/helpers.js.map +1 -1
  214. package/dist/esm/store/SynchronizerManager/Synchronizer.js +10 -2
  215. package/dist/esm/store/SynchronizerManager/Synchronizer.js.map +1 -1
  216. package/dist/esm/store/ToolGroupManager/ToolGroup.d.ts +3 -3
  217. package/dist/esm/store/ToolGroupManager/ToolGroup.js +10 -3
  218. package/dist/esm/store/ToolGroupManager/ToolGroup.js.map +1 -1
  219. package/dist/esm/store/ToolGroupManager/getToolGroupsWithToolName.js +2 -1
  220. package/dist/esm/store/ToolGroupManager/getToolGroupsWithToolName.js.map +1 -1
  221. package/dist/esm/synchronizers/callbacks/stackImageSyncCallback.js +26 -23
  222. package/dist/esm/synchronizers/callbacks/stackImageSyncCallback.js.map +1 -1
  223. package/dist/esm/synchronizers/callbacks/voiSyncCallback.js +1 -1
  224. package/dist/esm/synchronizers/callbacks/voiSyncCallback.js.map +1 -1
  225. package/dist/esm/tools/MIPJumpToClickTool.js +4 -2
  226. package/dist/esm/tools/MIPJumpToClickTool.js.map +1 -1
  227. package/dist/esm/tools/PlanarRotateTool.js +2 -1
  228. package/dist/esm/tools/PlanarRotateTool.js.map +1 -1
  229. package/dist/esm/tools/ReferenceCursors.js +58 -29
  230. package/dist/esm/tools/ReferenceCursors.js.map +1 -1
  231. package/dist/esm/tools/ScaleOverlayTool.js +2 -1
  232. package/dist/esm/tools/ScaleOverlayTool.js.map +1 -1
  233. package/dist/esm/tools/annotation/AngleTool.d.ts +0 -1
  234. package/dist/esm/tools/annotation/AngleTool.js +31 -14
  235. package/dist/esm/tools/annotation/AngleTool.js.map +1 -1
  236. package/dist/esm/tools/annotation/ArrowAnnotateTool.js +15 -1
  237. package/dist/esm/tools/annotation/ArrowAnnotateTool.js.map +1 -1
  238. package/dist/esm/tools/annotation/BidirectionalTool.d.ts +0 -1
  239. package/dist/esm/tools/annotation/BidirectionalTool.js +29 -14
  240. package/dist/esm/tools/annotation/BidirectionalTool.js.map +1 -1
  241. package/dist/esm/tools/annotation/CircleROITool.d.ts +0 -1
  242. package/dist/esm/tools/annotation/CircleROITool.js +55 -53
  243. package/dist/esm/tools/annotation/CircleROITool.js.map +1 -1
  244. package/dist/esm/tools/annotation/CobbAngleTool.d.ts +0 -1
  245. package/dist/esm/tools/annotation/CobbAngleTool.js +26 -11
  246. package/dist/esm/tools/annotation/CobbAngleTool.js.map +1 -1
  247. package/dist/esm/tools/annotation/DragProbeTool.js +13 -1
  248. package/dist/esm/tools/annotation/DragProbeTool.js.map +1 -1
  249. package/dist/esm/tools/annotation/EllipticalROITool.d.ts +0 -1
  250. package/dist/esm/tools/annotation/EllipticalROITool.js +47 -46
  251. package/dist/esm/tools/annotation/EllipticalROITool.js.map +1 -1
  252. package/dist/esm/tools/annotation/LengthTool.d.ts +0 -1
  253. package/dist/esm/tools/annotation/LengthTool.js +26 -11
  254. package/dist/esm/tools/annotation/LengthTool.js.map +1 -1
  255. package/dist/esm/tools/annotation/PlanarFreehandROITool.d.ts +0 -1
  256. package/dist/esm/tools/annotation/PlanarFreehandROITool.js +49 -51
  257. package/dist/esm/tools/annotation/PlanarFreehandROITool.js.map +1 -1
  258. package/dist/esm/tools/annotation/ProbeTool.d.ts +0 -1
  259. package/dist/esm/tools/annotation/ProbeTool.js +18 -13
  260. package/dist/esm/tools/annotation/ProbeTool.js.map +1 -1
  261. package/dist/esm/tools/annotation/RectangleROITool.d.ts +0 -1
  262. package/dist/esm/tools/annotation/RectangleROITool.js +45 -48
  263. package/dist/esm/tools/annotation/RectangleROITool.js.map +1 -1
  264. package/dist/esm/tools/base/AnnotationTool.d.ts +2 -1
  265. package/dist/esm/tools/base/AnnotationTool.js +26 -16
  266. package/dist/esm/tools/base/AnnotationTool.js.map +1 -1
  267. package/dist/esm/tools/base/index.d.ts +2 -1
  268. package/dist/esm/tools/base/index.js +2 -1
  269. package/dist/esm/tools/base/index.js.map +1 -1
  270. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
  271. package/dist/esm/tools/displayTools/Labelmap/removeLabelmapFromElement.js +4 -1
  272. package/dist/esm/tools/displayTools/Labelmap/removeLabelmapFromElement.js.map +1 -1
  273. package/dist/esm/tools/displayTools/SegmentationDisplayTool.js +5 -6
  274. package/dist/esm/tools/displayTools/SegmentationDisplayTool.js.map +1 -1
  275. package/dist/esm/tools/index.d.ts +2 -2
  276. package/dist/esm/tools/index.js +2 -2
  277. package/dist/esm/tools/index.js.map +1 -1
  278. package/dist/esm/tools/segmentation/BrushTool.js +25 -18
  279. package/dist/esm/tools/segmentation/BrushTool.js.map +1 -1
  280. package/dist/esm/tools/segmentation/PaintFillTool.js +4 -2
  281. package/dist/esm/tools/segmentation/PaintFillTool.js.map +1 -1
  282. package/dist/esm/tools/segmentation/strategies/eraseSphere.d.ts +2 -0
  283. package/dist/esm/tools/segmentation/strategies/eraseSphere.js.map +1 -1
  284. package/dist/esm/tools/segmentation/strategies/fillCircle.js +1 -6
  285. package/dist/esm/tools/segmentation/strategies/fillCircle.js.map +1 -1
  286. package/dist/esm/tools/segmentation/strategies/fillSphere.d.ts +3 -0
  287. package/dist/esm/tools/segmentation/strategies/fillSphere.js +33 -9
  288. package/dist/esm/tools/segmentation/strategies/fillSphere.js.map +1 -1
  289. package/dist/esm/tools/segmentation/strategies/utils/isWithinThreshold.d.ts +3 -0
  290. package/dist/esm/tools/segmentation/strategies/utils/isWithinThreshold.js +8 -0
  291. package/dist/esm/tools/segmentation/strategies/utils/isWithinThreshold.js.map +1 -0
  292. package/dist/esm/types/CINETypes.d.ts +2 -0
  293. package/dist/esm/types/CalculatorTypes.d.ts +6 -0
  294. package/dist/esm/types/CalculatorTypes.js +2 -0
  295. package/dist/esm/types/CalculatorTypes.js.map +1 -0
  296. package/dist/esm/types/EventTypes.d.ts +8 -1
  297. package/dist/esm/types/ISetToolModeOptions.d.ts +2 -2
  298. package/dist/esm/types/IToolGroup.d.ts +3 -2
  299. package/dist/esm/types/ToolProps.d.ts +5 -1
  300. package/dist/esm/types/index.d.ts +3 -2
  301. package/dist/esm/utilities/cine/playClip.js +13 -4
  302. package/dist/esm/utilities/cine/playClip.js.map +1 -1
  303. package/dist/esm/utilities/dynamicVolume/getDataInTime.js +7 -4
  304. package/dist/esm/utilities/dynamicVolume/getDataInTime.js.map +1 -1
  305. package/dist/esm/utilities/getCalibratedUnits.js +10 -5
  306. package/dist/esm/utilities/getCalibratedUnits.js.map +1 -1
  307. package/dist/esm/utilities/math/basic/BasicStatsCalculator.d.ts +14 -0
  308. package/dist/esm/utilities/math/basic/BasicStatsCalculator.js +36 -0
  309. package/dist/esm/utilities/math/basic/BasicStatsCalculator.js.map +1 -0
  310. package/dist/esm/utilities/math/basic/Calculator.d.ts +8 -0
  311. package/dist/esm/utilities/math/basic/Calculator.js +4 -0
  312. package/dist/esm/utilities/math/basic/Calculator.js.map +1 -0
  313. package/dist/esm/utilities/math/basic/index.d.ts +3 -0
  314. package/dist/esm/utilities/math/basic/index.js +4 -0
  315. package/dist/esm/utilities/math/basic/index.js.map +1 -0
  316. package/dist/esm/utilities/math/index.d.ts +2 -1
  317. package/dist/esm/utilities/math/index.js +2 -1
  318. package/dist/esm/utilities/math/index.js.map +1 -1
  319. package/dist/esm/utilities/math/midPoint.js +2 -1
  320. package/dist/esm/utilities/math/midPoint.js.map +1 -1
  321. package/dist/esm/utilities/math/polyline/pointInPolyline.js +2 -1
  322. package/dist/esm/utilities/math/polyline/pointInPolyline.js.map +1 -1
  323. package/dist/esm/utilities/math/vec2/liangBarksyClip.d.ts +1 -1
  324. package/dist/esm/utilities/math/vec2/liangBarksyClip.js +10 -5
  325. package/dist/esm/utilities/math/vec2/liangBarksyClip.js.map +1 -1
  326. package/dist/esm/utilities/pointInShapeCallback.d.ts +7 -1
  327. package/dist/esm/utilities/pointInShapeCallback.js +6 -1
  328. package/dist/esm/utilities/pointInShapeCallback.js.map +1 -1
  329. package/dist/esm/utilities/roundNumber.js +4 -2
  330. package/dist/esm/utilities/roundNumber.js.map +1 -1
  331. package/dist/esm/utilities/segmentation/brushSizeForToolGroup.d.ts +2 -2
  332. package/dist/esm/utilities/segmentation/brushSizeForToolGroup.js +4 -4
  333. package/dist/esm/utilities/segmentation/brushSizeForToolGroup.js.map +1 -1
  334. package/dist/esm/utilities/segmentation/thresholdVolumeByRange.js +2 -1
  335. package/dist/esm/utilities/segmentation/thresholdVolumeByRange.js.map +1 -1
  336. package/dist/esm/utilities/segmentation/utilities.d.ts +1 -2
  337. package/dist/esm/utilities/segmentation/utilities.js +4 -1
  338. package/dist/esm/utilities/segmentation/utilities.js.map +1 -1
  339. package/dist/esm/utilities/stackPrefetch/stackPrefetch.js +4 -4
  340. package/dist/esm/utilities/stackPrefetch/stackPrefetch.js.map +1 -1
  341. package/dist/umd/index.js +1 -1
  342. package/dist/umd/index.js.map +1 -1
  343. package/package.json +3 -3
  344. package/src/drawingSvg/drawCircle.ts +17 -5
  345. package/src/drawingSvg/drawEllipse.ts +4 -4
  346. package/src/drawingSvg/drawHandles.ts +4 -4
  347. package/src/drawingSvg/drawLine.ts +4 -4
  348. package/src/drawingSvg/drawPolyline.ts +4 -4
  349. package/src/drawingSvg/drawRect.ts +4 -4
  350. package/src/drawingSvg/drawTextBox.ts +4 -4
  351. package/src/drawingSvg/index.ts +4 -0
  352. package/src/drawingSvg/{_setAttributesIfNecessary.ts → setAttributesIfNecessary.ts} +2 -2
  353. package/src/drawingSvg/{_setNewAttributesIfValid.ts → setNewAttributesIfValid.ts} +2 -2
  354. package/src/enums/Events.ts +13 -0
  355. package/src/eventDispatchers/shared/getMouseModifier.ts +15 -5
  356. package/src/eventListeners/keyboard/keyDownListener.ts +13 -0
  357. package/src/eventListeners/mouse/mouseDownListener.ts +3 -1
  358. package/src/eventListeners/touch/touchStartListener.ts +15 -5
  359. package/src/index.ts +2 -0
  360. package/src/stateManagement/annotation/config/ToolStyle.ts +1 -0
  361. package/src/stateManagement/annotation/config/getState.ts +7 -3
  362. package/src/stateManagement/annotation/config/helpers.ts +6 -2
  363. package/src/store/SynchronizerManager/Synchronizer.ts +16 -8
  364. package/src/store/ToolGroupManager/ToolGroup.ts +21 -5
  365. package/src/store/ToolGroupManager/getToolGroupsWithToolName.ts +3 -1
  366. package/src/synchronizers/callbacks/stackImageSyncCallback.ts +63 -68
  367. package/src/synchronizers/callbacks/voiSyncCallback.ts +1 -1
  368. package/src/tools/MIPJumpToClickTool.ts +6 -2
  369. package/src/tools/PlanarRotateTool.ts +3 -1
  370. package/src/tools/ReferenceCursors.ts +85 -29
  371. package/src/tools/ScaleOverlayTool.ts +3 -1
  372. package/src/tools/annotation/AngleTool.ts +38 -19
  373. package/src/tools/annotation/ArrowAnnotateTool.ts +16 -1
  374. package/src/tools/annotation/BidirectionalTool.ts +37 -23
  375. package/src/tools/annotation/CircleROITool.ts +83 -89
  376. package/src/tools/annotation/CobbAngleTool.ts +31 -16
  377. package/src/tools/annotation/DragProbeTool.ts +19 -1
  378. package/src/tools/annotation/EllipticalROITool.ts +63 -71
  379. package/src/tools/annotation/LengthTool.ts +32 -17
  380. package/src/tools/annotation/PlanarFreehandROITool.ts +56 -59
  381. package/src/tools/annotation/ProbeTool.ts +26 -19
  382. package/src/tools/annotation/RectangleROITool.ts +67 -75
  383. package/src/tools/base/AnnotationTool.ts +39 -17
  384. package/src/tools/base/index.ts +2 -1
  385. package/src/tools/displayTools/Labelmap/labelmapDisplay.ts +3 -0
  386. package/src/tools/displayTools/Labelmap/removeLabelmapFromElement.ts +6 -1
  387. package/src/tools/displayTools/SegmentationDisplayTool.ts +12 -18
  388. package/src/tools/index.ts +2 -1
  389. package/src/tools/segmentation/BrushTool.ts +42 -19
  390. package/src/tools/segmentation/PaintFillTool.ts +10 -3
  391. package/src/tools/segmentation/strategies/eraseSphere.ts +2 -0
  392. package/src/tools/segmentation/strategies/fillCircle.ts +1 -13
  393. package/src/tools/segmentation/strategies/fillSphere.ts +56 -8
  394. package/src/tools/segmentation/strategies/utils/isWithinThreshold.ts +16 -0
  395. package/src/types/CINETypes.ts +8 -2
  396. package/src/types/CalculatorTypes.ts +7 -0
  397. package/src/types/EventTypes.ts +20 -0
  398. package/src/types/ISetToolModeOptions.ts +2 -2
  399. package/src/types/IToolGroup.ts +6 -3
  400. package/src/types/ToolProps.ts +7 -1
  401. package/src/types/index.ts +9 -1
  402. package/src/utilities/cine/playClip.ts +20 -3
  403. package/src/utilities/dynamicVolume/getDataInTime.ts +9 -6
  404. package/src/utilities/getCalibratedUnits.ts +15 -5
  405. package/src/utilities/math/basic/BasicStatsCalculator.ts +60 -0
  406. package/src/utilities/math/basic/Calculator.ts +8 -0
  407. package/src/utilities/math/basic/index.ts +4 -0
  408. package/src/utilities/math/index.ts +10 -1
  409. package/src/utilities/math/midPoint.ts +3 -1
  410. package/src/utilities/math/polyline/pointInPolyline.ts +3 -1
  411. package/src/utilities/math/vec2/liangBarksyClip.ts +15 -5
  412. package/src/utilities/pointInShapeCallback.ts +15 -3
  413. package/src/utilities/roundNumber.ts +6 -2
  414. package/src/utilities/segmentation/brushSizeForToolGroup.ts +22 -4
  415. package/src/utilities/segmentation/thresholdVolumeByRange.ts +3 -1
  416. package/src/utilities/segmentation/utilities.ts +8 -1
  417. package/src/utilities/stackPrefetch/stackPrefetch.ts +10 -4
  418. package/dist/cjs/drawingSvg/_setAttributesIfNecessary.d.ts +0 -2
  419. package/dist/cjs/drawingSvg/_setAttributesIfNecessary.js.map +0 -1
  420. package/dist/cjs/drawingSvg/_setNewAttributesIfValid.d.ts +0 -2
  421. package/dist/cjs/drawingSvg/_setNewAttributesIfValid.js.map +0 -1
  422. package/dist/esm/drawingSvg/_setAttributesIfNecessary.d.ts +0 -2
  423. package/dist/esm/drawingSvg/_setAttributesIfNecessary.js.map +0 -1
  424. package/dist/esm/drawingSvg/_setNewAttributesIfValid.d.ts +0 -2
  425. package/dist/esm/drawingSvg/_setNewAttributesIfValid.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { getEnabledElement } from '@cornerstonejs/core';
1
+ import { StackViewport, getEnabledElement } from '@cornerstonejs/core';
2
2
  import type { Types } from '@cornerstonejs/core';
3
3
 
4
4
  /**
@@ -19,6 +19,11 @@ function removeLabelmapFromElement(
19
19
  const enabledElement = getEnabledElement(element);
20
20
  const { viewport } = enabledElement;
21
21
 
22
+ if (viewport instanceof StackViewport) {
23
+ // Todo: we don't have stack segmentation yet
24
+ return;
25
+ }
26
+
22
27
  (viewport as Types.IVolumeViewport).removeVolumeActors([
23
28
  segmentationRepresentationUID,
24
29
  ]);
@@ -143,26 +143,20 @@ class SegmentationDisplayTool extends BaseTool {
143
143
  const config = this._getMergedRepresentationsConfig(toolGroupId);
144
144
 
145
145
  const viewportsRenderList = [];
146
+ const display =
147
+ representation.type === Representations.Labelmap
148
+ ? labelmapDisplay
149
+ : contourDisplay;
150
+
146
151
  for (const viewport of toolGroupViewports) {
147
- if (representation.type == Representations.Labelmap) {
148
- viewportsRenderList.push(
149
- labelmapDisplay.render(
150
- viewport as Types.IVolumeViewport,
151
- representation,
152
- config
153
- )
154
- );
155
- } else if (representation.type == Representations.Contour) {
156
- viewportsRenderList.push(
157
- contourDisplay.render(
158
- viewport as Types.IVolumeViewport,
159
- representation,
160
- config
161
- )
162
- );
163
- }
164
- }
152
+ const renderedViewport = display.render(
153
+ viewport as Types.IVolumeViewport,
154
+ representation,
155
+ config
156
+ );
165
157
 
158
+ viewportsRenderList.push(renderedViewport);
159
+ }
166
160
  return viewportsRenderList;
167
161
  }
168
162
  );
@@ -1,4 +1,4 @@
1
- import { BaseTool, AnnotationTool } from './base';
1
+ import { BaseTool, AnnotationTool, AnnotationDisplayTool } from './base';
2
2
  import PanTool from './PanTool';
3
3
  import TrackballRotateTool from './TrackballRotateTool';
4
4
  import WindowLevelTool from './WindowLevelTool';
@@ -43,6 +43,7 @@ export {
43
43
  // ~~ BASE
44
44
  BaseTool,
45
45
  AnnotationTool,
46
+ AnnotationDisplayTool,
46
47
  // Manipulation Tools
47
48
  PanTool,
48
49
  TrackballRotateTool,
@@ -1,4 +1,5 @@
1
1
  import { cache, getEnabledElement, StackViewport } from '@cornerstonejs/core';
2
+ import { vec3 } from 'gl-matrix';
2
3
 
3
4
  import type { Types } from '@cornerstonejs/core';
4
5
  import type {
@@ -8,7 +9,10 @@ import type {
8
9
  SVGDrawingHelper,
9
10
  } from '../../types';
10
11
  import { BaseTool } from '../base';
11
- import { fillInsideSphere } from './strategies/fillSphere';
12
+ import {
13
+ fillInsideSphere,
14
+ thresholdInsideSphere,
15
+ } from './strategies/fillSphere';
12
16
  import { eraseInsideSphere } from './strategies/eraseSphere';
13
17
  import {
14
18
  thresholdInsideCircle,
@@ -59,10 +63,11 @@ class BrushTool extends BaseTool {
59
63
  configuration: {
60
64
  strategies: {
61
65
  FILL_INSIDE_CIRCLE: fillInsideCircle,
62
- THRESHOLD_INSIDE_CIRCLE: thresholdInsideCircle,
63
66
  ERASE_INSIDE_CIRCLE: eraseInsideCircle,
64
67
  FILL_INSIDE_SPHERE: fillInsideSphere,
65
68
  ERASE_INSIDE_SPHERE: eraseInsideSphere,
69
+ THRESHOLD_INSIDE_CIRCLE: thresholdInsideCircle,
70
+ THRESHOLD_INSIDE_SPHERE: thresholdInsideSphere,
66
71
  },
67
72
  strategySpecificConfiguration: {
68
73
  THRESHOLD_INSIDE_CIRCLE: {
@@ -277,24 +282,42 @@ class BrushTool extends BaseTool {
277
282
  const enabledElement = getEnabledElement(element);
278
283
  const { viewport } = enabledElement;
279
284
  const { canvasToWorld } = viewport;
285
+ const camera = viewport.getCamera();
280
286
  const { brushSize } = this.configuration;
281
- // Center of circle in canvas Coordinates
282
287
 
283
- const radius = brushSize;
288
+ const viewUp = vec3.fromValues(
289
+ camera.viewUp[0],
290
+ camera.viewUp[1],
291
+ camera.viewUp[2]
292
+ );
293
+ const viewPlaneNormal = vec3.fromValues(
294
+ camera.viewPlaneNormal[0],
295
+ camera.viewPlaneNormal[1],
296
+ camera.viewPlaneNormal[2]
297
+ );
298
+ const viewRight = vec3.create();
284
299
 
285
- const bottomCanvas: Types.Point2 = [
300
+ vec3.cross(viewRight, viewUp, viewPlaneNormal);
301
+
302
+ // in the world coordinate system, the brushSize is the radius of the circle
303
+ // in mm
304
+ const centerCursorInWorld: Types.Point3 = canvasToWorld([
286
305
  centerCanvas[0],
287
- centerCanvas[1] + radius,
288
- ];
289
- const topCanvas: Types.Point2 = [centerCanvas[0], centerCanvas[1] - radius];
290
- const leftCanvas: Types.Point2 = [
291
- centerCanvas[0] - radius,
292
- centerCanvas[1],
293
- ];
294
- const rightCanvas: Types.Point2 = [
295
- centerCanvas[0] + radius,
296
306
  centerCanvas[1],
297
- ];
307
+ ]);
308
+
309
+ const bottomCursorInWorld = vec3.create();
310
+ const topCursorInWorld = vec3.create();
311
+ const leftCursorInWorld = vec3.create();
312
+ const rightCursorInWorld = vec3.create();
313
+
314
+ // Calculate the bottom and top points of the circle in world coordinates
315
+ for (let i = 0; i <= 2; i++) {
316
+ bottomCursorInWorld[i] = centerCursorInWorld[i] - viewUp[i] * brushSize;
317
+ topCursorInWorld[i] = centerCursorInWorld[i] + viewUp[i] * brushSize;
318
+ leftCursorInWorld[i] = centerCursorInWorld[i] - viewRight[i] * brushSize;
319
+ rightCursorInWorld[i] = centerCursorInWorld[i] + viewRight[i] * brushSize;
320
+ }
298
321
 
299
322
  const { brushCursor } = this._hoverData;
300
323
  const { data } = brushCursor;
@@ -304,10 +327,10 @@ class BrushTool extends BaseTool {
304
327
  }
305
328
 
306
329
  data.handles.points = [
307
- canvasToWorld(bottomCanvas),
308
- canvasToWorld(topCanvas),
309
- canvasToWorld(leftCanvas),
310
- canvasToWorld(rightCanvas),
330
+ bottomCursorInWorld,
331
+ topCursorInWorld,
332
+ leftCursorInWorld,
333
+ rightCursorInWorld,
311
334
  ];
312
335
 
313
336
  data.invalidated = false;
@@ -90,7 +90,10 @@ class PaintFillTool extends BaseTool {
90
90
 
91
91
  const index = transformWorldToIndex(segmentation.imageData, worldPos);
92
92
 
93
- const fixedDimension = this.getFixedDimension(viewPlaneNormal, direction);
93
+ const fixedDimension = this.getFixedDimension(
94
+ viewPlaneNormal,
95
+ direction as number[]
96
+ );
94
97
 
95
98
  if (fixedDimension === undefined) {
96
99
  console.warn('Oblique paint fill not yet supported');
@@ -169,8 +172,12 @@ class PaintFillTool extends BaseTool {
169
172
  for (let b = 0; b < boundaries.length; b++) {
170
173
  const j = boundaries[b][1];
171
174
 
172
- if (j < minJ) minJ = j;
173
- if (j > maxJ) maxJ = j;
175
+ if (j < minJ) {
176
+ minJ = j;
177
+ }
178
+ if (j > maxJ) {
179
+ maxJ = j;
180
+ }
174
181
  }
175
182
 
176
183
  const framesModified = [];
@@ -4,6 +4,7 @@ import { fillInsideSphere } from './fillSphere';
4
4
 
5
5
  type OperationData = {
6
6
  points: [Types.Point3, Types.Point3, Types.Point3, Types.Point3];
7
+ imageVolume: Types.IImageVolume;
7
8
  volume: Types.IImageVolume;
8
9
  segmentIndex: number;
9
10
  segmentationId: string;
@@ -11,6 +12,7 @@ type OperationData = {
11
12
  viewPlaneNormal: Types.Point3;
12
13
  viewUp: Types.Point3;
13
14
  constraintFn: () => boolean;
15
+ strategySpecificConfiguration: any;
14
16
  };
15
17
 
16
18
  export function eraseInsideSphere(
@@ -9,6 +9,7 @@ import {
9
9
  import { getBoundingBoxAroundShape } from '../../../utilities/boundingBox';
10
10
  import { triggerSegmentationDataModified } from '../../../stateManagement/segmentation/triggerSegmentationEvents';
11
11
  import { pointInShapeCallback } from '../../../utilities';
12
+ import isWithinThreshold from './utils/isWithinThreshold';
12
13
 
13
14
  const { transformWorldToIndex } = csUtils;
14
15
 
@@ -117,19 +118,6 @@ function fillCircle(
117
118
  triggerSegmentationDataModified(segmentationId, arrayOfSlices);
118
119
  }
119
120
 
120
- function isWithinThreshold(
121
- index: number,
122
- imageVolume: Types.IImageVolume,
123
- strategySpecificConfiguration: any
124
- ) {
125
- const { THRESHOLD_INSIDE_CIRCLE } = strategySpecificConfiguration;
126
-
127
- const voxelValue = imageVolume.getScalarData()[index];
128
- const { threshold } = THRESHOLD_INSIDE_CIRCLE;
129
-
130
- return threshold[0] <= voxelValue && voxelValue <= threshold[1];
131
- }
132
-
133
121
  /**
134
122
  * Fill inside the circular region segment inside the segmentation defined by the operationData.
135
123
  * It fills the segmentation pixels inside the defined circle.
@@ -1,29 +1,36 @@
1
1
  import type { Types } from '@cornerstonejs/core';
2
+ import { utilities as csUtils } from '@cornerstonejs/core';
2
3
 
3
4
  import { triggerSegmentationDataModified } from '../../../stateManagement/segmentation/triggerSegmentationEvents';
4
5
  import { pointInSurroundingSphereCallback } from '../../../utilities';
6
+ import isWithinThreshold from './utils/isWithinThreshold';
5
7
 
6
8
  type OperationData = {
7
9
  points: [Types.Point3, Types.Point3, Types.Point3, Types.Point3];
8
10
  volume: Types.IImageVolume;
11
+ imageVolume: Types.IImageVolume;
9
12
  segmentIndex: number;
10
13
  segmentationId: string;
11
14
  segmentsLocked: number[];
12
15
  viewPlaneNormal: Types.Point3;
13
16
  viewUp: Types.Point3;
17
+ strategySpecificConfiguration: any;
14
18
  constraintFn: () => boolean;
15
19
  };
16
20
 
17
21
  function fillSphere(
18
22
  enabledElement: Types.IEnabledElement,
19
23
  operationData: OperationData,
20
- _inside = true
24
+ _inside = true,
25
+ threshold = false
21
26
  ): void {
22
27
  const { viewport } = enabledElement;
23
28
  const {
24
29
  volume: segmentation,
25
30
  segmentsLocked,
26
31
  segmentIndex,
32
+ imageVolume,
33
+ strategySpecificConfiguration,
27
34
  segmentationId,
28
35
  points,
29
36
  } = operationData;
@@ -32,13 +39,30 @@ function fillSphere(
32
39
  const scalarData = segmentation.getScalarData();
33
40
  const scalarIndex = [];
34
41
 
35
- const callback = ({ index, value }) => {
36
- if (segmentsLocked.includes(value)) {
37
- return;
38
- }
39
- scalarData[index] = segmentIndex;
40
- scalarIndex.push(index);
41
- };
42
+ let callback;
43
+
44
+ if (threshold) {
45
+ callback = ({ value, index, pointIJK }) => {
46
+ if (segmentsLocked.includes(value)) {
47
+ return;
48
+ }
49
+
50
+ if (
51
+ isWithinThreshold(index, imageVolume, strategySpecificConfiguration)
52
+ ) {
53
+ scalarData[index] = segmentIndex;
54
+ scalarIndex.push(index);
55
+ }
56
+ };
57
+ } else {
58
+ callback = ({ index, value }) => {
59
+ if (segmentsLocked.includes(value)) {
60
+ return;
61
+ }
62
+ scalarData[index] = segmentIndex;
63
+ scalarIndex.push(index);
64
+ };
65
+ }
42
66
 
43
67
  pointInSurroundingSphereCallback(
44
68
  imageData,
@@ -74,6 +98,30 @@ export function fillInsideSphere(
74
98
  fillSphere(enabledElement, operationData, true);
75
99
  }
76
100
 
101
+ /**
102
+ * Fill inside the circular region segment inside the segmentation defined by the operationData.
103
+ * It fills the segmentation pixels inside the defined circle.
104
+ * @param enabledElement - The element for which the segment is being filled.
105
+ * @param operationData - EraseOperationData
106
+ */
107
+ export function thresholdInsideSphere(
108
+ enabledElement: Types.IEnabledElement,
109
+ operationData: OperationData
110
+ ): void {
111
+ const { volume, imageVolume } = operationData;
112
+
113
+ if (
114
+ !csUtils.isEqual(volume.dimensions, imageVolume.dimensions) ||
115
+ !csUtils.isEqual(volume.direction, imageVolume.direction)
116
+ ) {
117
+ throw new Error(
118
+ 'Only source data the same dimensions/size/orientation as the segmentation currently supported.'
119
+ );
120
+ }
121
+
122
+ fillSphere(enabledElement, operationData, true, true);
123
+ }
124
+
77
125
  /**
78
126
  * Fill outside a sphere with the given segment index in the given operation data. The
79
127
  * operation data contains the sphere required points.
@@ -0,0 +1,16 @@
1
+ import { Types } from '@cornerstonejs/core';
2
+
3
+ function isWithinThreshold(
4
+ index: number,
5
+ imageVolume: Types.IImageVolume,
6
+ strategySpecificConfiguration: any
7
+ ) {
8
+ const { THRESHOLD_INSIDE_CIRCLE } = strategySpecificConfiguration;
9
+
10
+ const voxelValue = imageVolume.getScalarData()[index];
11
+ const { threshold } = THRESHOLD_INSIDE_CIRCLE;
12
+
13
+ return threshold[0] <= voxelValue && voxelValue <= threshold[1];
14
+ }
15
+
16
+ export default isWithinThreshold;
@@ -1,5 +1,3 @@
1
- import { Types } from '@cornerstonejs/core';
2
-
3
1
  type PlayClipOptions = {
4
2
  framesPerSecond?: number;
5
3
  frameTimeVector?: number[];
@@ -7,6 +5,11 @@ type PlayClipOptions = {
7
5
  loop?: boolean;
8
6
  dynamicCineEnabled?: boolean;
9
7
  frameTimeVectorSpeedMultiplier?: number;
8
+ // How many CINE frames to wait for a rendered event to occur before
9
+ // trying to display the image after the next one
10
+ // A CINE frame is attempted every 1 / fps seconds
11
+ // The default is 30 tries, or 1.25 seconds at 24 fps
12
+ waitForRendered?: number;
10
13
  };
11
14
 
12
15
  interface ToolData {
@@ -26,6 +29,9 @@ type CinePlayContext = {
26
29
  get numScrollSteps(): number;
27
30
  get currentStepIndex(): number;
28
31
  get frameTimeVectorEnabled(): boolean;
32
+ // How many times has the wait for rendered been tried without showing
33
+ // the next image.
34
+ waitForRenderedCount?: number;
29
35
  scroll(delta: number): void;
30
36
  };
31
37
 
@@ -0,0 +1,7 @@
1
+ type Statistics = {
2
+ name: string;
3
+ value: number;
4
+ unit: null | string;
5
+ };
6
+
7
+ export type { Statistics };
@@ -3,6 +3,7 @@ import { Annotation } from './AnnotationTypes';
3
3
  import IPoints from './IPoints';
4
4
  import ITouchPoints from './ITouchPoints';
5
5
  import IDistance from './IDistance';
6
+ import { SetToolBindingsType } from './ISetToolModeOptions';
6
7
  import { Swipe } from '../enums/Touch';
7
8
 
8
9
  /**
@@ -70,6 +71,18 @@ type InteractionStartEventDetail = InteractionEventDetail;
70
71
 
71
72
  type InteractionEndEventDetail = InteractionEventDetail;
72
73
 
74
+ /**
75
+ * The data that is passed to the event handler when a tool is activated.
76
+ */
77
+ type ToolActivatedEventDetail = {
78
+ /** unique id of the toolGroup */
79
+ toolGroupId: string;
80
+ /** Tool name */
81
+ toolName: string;
82
+ /** Tool binding options */
83
+ toolBindingsOptions: SetToolBindingsType;
84
+ };
85
+
73
86
  /**
74
87
  * The data that is passed to the event handler when a new annotation is added
75
88
  * to the annotations.
@@ -411,6 +424,11 @@ type NormalizedMouseEventType = Types.CustomEventType<MouseCustomEventDetail>;
411
424
  */
412
425
  type NormalizedTouchEventType = Types.CustomEventType<TouchCustomEventDetail>;
413
426
 
427
+ /**
428
+ * The ToolActivated event type
429
+ */
430
+ type ToolActivatedEventType = Types.CustomEventType<ToolActivatedEventDetail>;
431
+
414
432
  /**
415
433
  * The AnnotationAdded event type
416
434
  */
@@ -611,6 +629,8 @@ export {
611
629
  NormalizedInteractionEventDetail,
612
630
  NormalizedMouseEventType,
613
631
  NormalizedTouchEventType,
632
+ ToolActivatedEventDetail,
633
+ ToolActivatedEventType,
614
634
  AnnotationAddedEventDetail,
615
635
  AnnotationAddedEventType,
616
636
  AnnotationCompletedEventDetail,
@@ -1,9 +1,9 @@
1
1
  import { ToolModes, MouseBindings, KeyboardBindings } from '../enums';
2
2
 
3
- type ToolBindingMouseType = typeof MouseBindings[keyof typeof MouseBindings];
3
+ type ToolBindingMouseType = (typeof MouseBindings)[keyof typeof MouseBindings];
4
4
 
5
5
  type ToolBindingKeyboardType =
6
- typeof KeyboardBindings[keyof typeof KeyboardBindings];
6
+ (typeof KeyboardBindings)[keyof typeof KeyboardBindings];
7
7
 
8
8
  type IToolBinding = {
9
9
  /** Mouse button bindings e.g., MouseBindings.Primary/Secondary etc. */
@@ -1,6 +1,7 @@
1
1
  import type { Types } from '@cornerstonejs/core';
2
2
  import { SetToolBindingsType, ToolOptionsType } from './ISetToolModeOptions';
3
3
  import { MouseBindings } from '../enums';
4
+ import { ToolConfiguration } from '../types';
4
5
  /**
5
6
  * ToolGroup interface
6
7
  */
@@ -19,8 +20,10 @@ export default interface IToolGroup {
19
20
  getViewportsInfo: () => Array<Types.IViewportId>;
20
21
  /** Get the toolInstance of the toolName */
21
22
  getToolInstance: { (toolName: string): any };
22
- /** Add a tool to toolGroup with its configuration */
23
- addTool: { (toolName: string, toolConfiguration?: any): void };
23
+ /** Add a tool to toolGroup with its configuration and custom calculator if wanted */
24
+ addTool: {
25
+ (toolName: string, toolConfiguration?: ToolConfiguration): void;
26
+ };
24
27
  /** Add tool instance, if you want to create more than one instance from the same tool e.g., brush/eraser tool */
25
28
  addToolInstance: {
26
29
  (ttoolName: string, parentClassName: string, configuration?: any): void;
@@ -62,7 +65,7 @@ export default interface IToolGroup {
62
65
  setToolConfiguration: {
63
66
  (
64
67
  toolName: string,
65
- configuration: Record<any, any>,
68
+ configuration: ToolConfiguration,
66
69
  overwrite?: boolean
67
70
  ): void;
68
71
  };
@@ -1,8 +1,14 @@
1
+ import { Calculator } from '../utilities/math/basic';
2
+
1
3
  type SharedToolProp = {
2
4
  /** supported interactions for the tool */
3
5
  supportedInteractionTypes?: Array<string>;
4
6
  /** tool specific tool configuration */
5
- configuration?: Record<string, any>;
7
+ configuration?: ToolConfiguration;
8
+ };
9
+
10
+ export type ToolConfiguration = Record<string, any> & {
11
+ statsCalculator?: Calculator;
6
12
  };
7
13
 
8
14
  export type ToolProps = SharedToolProp;
@@ -21,7 +21,11 @@ import type * as AnnotationStyle from './AnnotationStyle';
21
21
  import type ToolHandle from './ToolHandle';
22
22
  import type { AnnotationHandle, TextBoxHandle } from './ToolHandle';
23
23
  import type InteractionTypes from './InteractionTypes';
24
- import type { ToolProps, PublicToolProps } from './ToolProps';
24
+ import type {
25
+ ToolProps,
26
+ PublicToolProps,
27
+ ToolConfiguration,
28
+ } from './ToolProps';
25
29
  import type { SVGCursorDescriptor, SVGPoint } from './CursorTypes';
26
30
  import type JumpToSliceOptions from './JumpToSliceOptions';
27
31
  import type ScrollOptions from './ScrollOptions';
@@ -52,6 +56,7 @@ import IToolClassReference from './IToolClassReference';
52
56
  import { ContourSegmentationData } from './ContourTypes';
53
57
  import IAnnotationManager from './IAnnotationManager';
54
58
  import AnnotationGroupSelector from './AnnotationGroupSelector';
59
+ import { Statistics } from './CalculatorTypes';
55
60
 
56
61
  export type {
57
62
  // AnnotationState
@@ -68,6 +73,7 @@ export type {
68
73
  PlanarBoundingBox,
69
74
  ToolProps,
70
75
  PublicToolProps,
76
+ ToolConfiguration,
71
77
  // Event data
72
78
  EventTypes,
73
79
  IPoints,
@@ -114,4 +120,6 @@ export type {
114
120
  FloodFillOptions,
115
121
  // Contour
116
122
  ContourSegmentationData,
123
+ //Statistics
124
+ Statistics,
117
125
  };
@@ -6,6 +6,7 @@ import {
6
6
  VolumeViewport,
7
7
  cache,
8
8
  BaseVolumeViewport,
9
+ Enums,
9
10
  } from '@cornerstonejs/core';
10
11
 
11
12
  import { Types } from '@cornerstonejs/core';
@@ -14,6 +15,7 @@ import { addToolState, getToolState } from './state';
14
15
  import { CINETypes } from '../../types';
15
16
  import scroll from '../scroll';
16
17
 
18
+ const { ViewportStatus } = Enums;
17
19
  const { triggerEvent } = csUtils;
18
20
 
19
21
  const debounced = true;
@@ -193,7 +195,9 @@ function stopClip(element: HTMLDivElement): void {
193
195
 
194
196
  function _stopClip(element: HTMLDivElement, stopDynamicCine: boolean): void {
195
197
  const enabledElement = getEnabledElement(element);
196
- if (!enabledElement) return;
198
+ if (!enabledElement) {
199
+ return;
200
+ }
197
201
  const { viewport } = enabledElement;
198
202
  const cineToolData = getToolState(viewport.element);
199
203
 
@@ -313,7 +317,8 @@ function _getVolumeFromViewport(viewport): Types.IImageVolume {
313
317
  }
314
318
 
315
319
  function _createStackViewportCinePlayContext(
316
- viewport: StackViewport
320
+ viewport: StackViewport,
321
+ waitForRendered: number
317
322
  ): CINETypes.CinePlayContext {
318
323
  const imageIds = viewport.getImageIds();
319
324
 
@@ -328,7 +333,16 @@ function _createStackViewportCinePlayContext(
328
333
  // It is always in acquired orientation
329
334
  return true;
330
335
  },
336
+ waitForRenderedCount: 0,
331
337
  scroll(delta: number): void {
338
+ if (
339
+ this.waitForRenderedCount <= waitForRendered &&
340
+ viewport.viewportStatus !== ViewportStatus.RENDERED
341
+ ) {
342
+ this.waitForRenderedCount++;
343
+ return;
344
+ }
345
+ this.waitForRenderedCount = 0;
332
346
  scroll(viewport, { delta, debounceLoading: debounced });
333
347
  },
334
348
  };
@@ -417,7 +431,10 @@ function _createCinePlayContext(
417
431
  playClipOptions: CINETypes.PlayClipOptions
418
432
  ): CINETypes.CinePlayContext {
419
433
  if (viewport instanceof StackViewport) {
420
- return _createStackViewportCinePlayContext(viewport);
434
+ return _createStackViewportCinePlayContext(
435
+ viewport,
436
+ playClipOptions.waitForRendered ?? 30
437
+ );
421
438
  }
422
439
 
423
440
  if (viewport instanceof VolumeViewport) {
@@ -40,13 +40,16 @@ function getDataInTime(
40
40
 
41
41
  if (options.maskVolumeId) {
42
42
  const segmentationVolume = cache.getVolume(options.maskVolumeId);
43
+ const segScalarData = segmentationVolume.getScalarData();
44
+ const indexArray = [];
45
+
46
+ // Get the index of every non-zero voxel in mask
47
+ for (let i = 0, len = segScalarData.length; i < len; i++) {
48
+ if (segScalarData[i] !== 0) {
49
+ indexArray.push(i);
50
+ }
51
+ }
43
52
 
44
- // Get the index of every non-zero voxel in mask by mapping indexes to
45
- // new array, then using the array to filter
46
- const indexArray = segmentationVolume
47
- .getScalarData()
48
- .map((_, i) => i)
49
- .filter((i) => segmentationVolume.getScalarData()[i] !== 0);
50
53
  const dataInTime = _getTimePointDataMask(frames, indexArray, dynamicVolume);
51
54
 
52
55
  return dataInTime;
@@ -23,10 +23,16 @@ const getCalibratedLengthUnits = (handles, image): string => {
23
23
  const { calibration, hasPixelSpacing } = image;
24
24
  // Anachronistic - moving to using calibration consistently, but not completed yet
25
25
  const units = hasPixelSpacing ? 'mm' : PIXEL_UNITS;
26
- if (!calibration || !calibration.type) return units;
27
- if (calibration.type === CalibrationTypes.UNCALIBRATED) return PIXEL_UNITS;
26
+ if (!calibration || !calibration.type) {
27
+ return units;
28
+ }
29
+ if (calibration.type === CalibrationTypes.UNCALIBRATED) {
30
+ return PIXEL_UNITS;
31
+ }
28
32
  // TODO - handle US regions properly
29
- if (calibration.SequenceOfUltrasoundRegions) return 'US Region';
33
+ if (calibration.SequenceOfUltrasoundRegions) {
34
+ return 'US Region';
35
+ }
30
36
  return `${units} ${calibration.type}`;
31
37
  };
32
38
 
@@ -37,8 +43,12 @@ const SQUARE = '\xb2';
37
43
  const getCalibratedAreaUnits = (handles, image): string => {
38
44
  const { calibration, hasPixelSpacing } = image;
39
45
  const units = (hasPixelSpacing ? 'mm' : PIXEL_UNITS) + SQUARE;
40
- if (!calibration || !calibration.type) return units;
41
- if (calibration.SequenceOfUltrasoundRegions) return 'US Region';
46
+ if (!calibration || !calibration.type) {
47
+ return units;
48
+ }
49
+ if (calibration.SequenceOfUltrasoundRegions) {
50
+ return 'US Region';
51
+ }
42
52
  return `${units} ${calibration.type}`;
43
53
  };
44
54