@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 { vec3 } from 'gl-matrix';
1
+ import { vec3, mat4 } from 'gl-matrix';
2
2
  import {
3
3
  getRenderingEngine,
4
4
  Types,
@@ -8,28 +8,27 @@ import {
8
8
  import { Synchronizer } from '../../store';
9
9
  import { jumpToSlice } from '../../utilities';
10
10
  import areViewportsCoplanar from './areViewportsCoplanar ';
11
+
12
+ const getSpatialRegistration = (targetId, sourceId) =>
13
+ utilities.spatialRegistrationMetadataProvider.get(
14
+ 'spatialRegistrationModule',
15
+ [targetId, sourceId]
16
+ );
17
+
11
18
  /**
12
19
  * Synchronizer callback to synchronize the source viewport image to the
13
- * target viewports closest image in its stack. There are two scenarios
20
+ * target viewports closest image in its stack.
14
21
  *
15
- * 1) viewports are in the same frameOfReferenceUID then we can use the
16
- * absolute imagePositionPatient for the source viewport's current image
17
- * and set the target viewport's image to the closest image in its stack
18
- * (which might have different slice thickness so cannot use slice number)
22
+ * This synchronizer does a setup (which can already be predefined as required)
23
+ * to register the target and soruce viewports. The registration will default
24
+ * to the identity registration if the same FOR is present in both viewports,
25
+ * unless the option `useInitialPosition` is set in the target viewport.
19
26
  *
20
- * 2) viewports have different frameOfReferenceUIDs then we look inside the
21
- * registrationMetadataProvider to check if there is a corresponding matrix
22
- * for mapping between the source and target viewport if so it is used to
23
- * and is applied to the imagePositionPatient of the source viewport's to
24
- * get the imagePositionPatient of the target viewport's closest image in
25
- * its stack.
26
- * Note for 2) The consuming apps using Cornerstone3D (OHIF, etc) are responsible
27
- * to provide such data in the registrationMetadataProvider. This can be done
27
+ * The consuming apps using Cornerstone3D (OHIF, etc) MAY provide such data in
28
+ * the registrationMetadataProvider to override the data here. This can be done
28
29
  * by various methods 1) Using spatialRegistrationModule inside dicom 2) assuming
29
30
  * the user has actually manually scrolled the target viewport to the correct
30
31
  * slice before initiating the synchronization 3) using some other method
31
- * But overall, the consuming app is responsible for providing the data.
32
- *
33
32
  *
34
33
  * @param synchronizerInstance - The Instance of the Synchronizer
35
34
  * @param sourceViewport - The list of IDs defining the source viewport.
@@ -53,13 +52,16 @@ export default async function stackImageSyncCallback(
53
52
  sourceViewport.viewportId
54
53
  ) as Types.IStackViewport;
55
54
 
55
+ const options = synchronizerInstance.getOptions(targetViewport.viewportId);
56
+
57
+ if (options?.disabled) {
58
+ return;
59
+ }
60
+
56
61
  const tViewport = renderingEngine.getViewport(
57
62
  targetViewport.viewportId
58
63
  ) as Types.IStackViewport;
59
64
 
60
- const frameOfReferenceUID1 = sViewport.getFrameOfReferenceUID();
61
- const frameOfReferenceUID2 = tViewport.getFrameOfReferenceUID();
62
-
63
65
  const imageId1 = sViewport.getCurrentImageId();
64
66
  const imagePlaneModule1 = metaData.get('imagePlaneModule', imageId1);
65
67
  const sourceImagePositionPatient = imagePlaneModule1.imagePositionPatient;
@@ -70,69 +72,62 @@ export default async function stackImageSyncCallback(
70
72
  return;
71
73
  }
72
74
 
73
- if (frameOfReferenceUID1 === frameOfReferenceUID2) {
74
- // if frames of references are the same we can use the absolute
75
- // imagePositionPatient to find the closest image in the target viewport's stack
76
- const closestImageIdIndex = _getClosestImageIdIndex(
77
- sourceImagePositionPatient,
78
- targetImageIds
79
- );
75
+ // if the frame of reference is different we need to use the registrationMetadataProvider
76
+ // and add that to the imagePositionPatient of the source viewport to get the
77
+ // imagePositionPatient of the target viewport's closest image in its stack
78
+ let registrationMatrixMat4 = getSpatialRegistration(
79
+ targetViewport.viewportId,
80
+ sourceViewport.viewportId
81
+ );
80
82
 
83
+ if (!registrationMatrixMat4) {
84
+ const frameOfReferenceUID1 = sViewport.getFrameOfReferenceUID();
85
+ const frameOfReferenceUID2 = tViewport.getFrameOfReferenceUID();
81
86
  if (
82
- closestImageIdIndex.index !== -1 &&
83
- tViewport.getCurrentImageIdIndex() !== closestImageIdIndex.index
87
+ frameOfReferenceUID1 === frameOfReferenceUID2 &&
88
+ options.useInitialPosition !== false
84
89
  ) {
85
- // await tViewport.setImageIdIndex(closestImageIdIndex.index);
86
- await jumpToSlice(tViewport.element, {
87
- imageIndex: closestImageIdIndex.index,
88
- });
89
-
90
- return;
91
- }
92
- } else {
93
- // if the frame of reference is different we need to use the registrationMetadataProvider
94
- // and add that to the imagePositionPatient of the source viewport to get the
95
- // imagePositionPatient of the target viewport's closest image in its stack
96
- const registrationMatrixMat4 =
97
- utilities.spatialRegistrationMetadataProvider.get(
98
- 'spatialRegistrationModule',
99
- [targetViewport.viewportId, sourceViewport.viewportId]
90
+ registrationMatrixMat4 = mat4.identity(mat4.create());
91
+ } else {
92
+ utilities.calculateViewportsSpatialRegistration(sViewport, tViewport);
93
+ registrationMatrixMat4 = getSpatialRegistration(
94
+ targetViewport.viewportId,
95
+ sourceViewport.viewportId
100
96
  );
101
-
97
+ }
102
98
  if (!registrationMatrixMat4) {
103
- throw new Error(
104
- `No registration matrix found for sourceViewport: ${sourceViewport.viewportId} and targetViewport: ${targetViewport.viewportId}, viewports with different frameOfReferenceUIDs must have a registration matrix in the registrationMetadataProvider. Use calculateViewportsRegistrationMatrix to calculate the matrix.`
105
- );
99
+ return;
106
100
  }
101
+ }
107
102
 
108
- // apply the registration matrix to the source viewport's imagePositionPatient
109
- // to get the target viewport's imagePositionPatient
110
- const targetImagePositionPatientWithRegistrationMatrix = vec3.transformMat4(
111
- vec3.create(),
112
- sourceImagePositionPatient,
113
- registrationMatrixMat4
114
- );
103
+ // apply the registration matrix to the source viewport's imagePositionPatient
104
+ // to get the target viewport's imagePositionPatient
105
+ const targetImagePositionPatientWithRegistrationMatrix = vec3.transformMat4(
106
+ vec3.create(),
107
+ sourceImagePositionPatient,
108
+ registrationMatrixMat4
109
+ );
115
110
 
116
- // find the closest image in the target viewport's stack to the
117
- // targetImagePositionPatientWithRegistrationMatrix
118
- const closestImageIdIndex2 = _getClosestImageIdIndex(
119
- targetImagePositionPatientWithRegistrationMatrix,
120
- targetImageIds
121
- );
111
+ // find the closest image in the target viewport's stack to the
112
+ // targetImagePositionPatientWithRegistrationMatrix
113
+ const closestImageIdIndex2 = _getClosestImageIdIndex(
114
+ targetImagePositionPatientWithRegistrationMatrix,
115
+ targetImageIds
116
+ );
122
117
 
123
- if (
124
- closestImageIdIndex2.index !== -1 &&
125
- tViewport.getCurrentImageIdIndex() !== closestImageIdIndex2.index
126
- ) {
127
- await jumpToSlice(tViewport.element, {
128
- imageIndex: closestImageIdIndex2.index,
129
- });
130
- }
118
+ if (
119
+ closestImageIdIndex2.index !== -1 &&
120
+ tViewport.getCurrentImageIdIndex() !== closestImageIdIndex2.index
121
+ ) {
122
+ await jumpToSlice(tViewport.element, {
123
+ imageIndex: closestImageIdIndex2.index,
124
+ });
131
125
  }
132
126
  }
133
127
 
134
128
  function _getClosestImageIdIndex(targetPoint, imageIds) {
135
129
  // todo: this does not assume orientation yet, but that can be added later
130
+ // todo: handle multiframe images
136
131
  return imageIds.reduce(
137
132
  (closestImageIdIndex, imageId, index) => {
138
133
  const { imagePositionPatient } = metaData.get(
@@ -39,7 +39,7 @@ export default function voiSyncCallback(
39
39
  voiRange: range,
40
40
  };
41
41
 
42
- if (options.syncInvertState && invertStateChanged) {
42
+ if (options?.syncInvertState && invertStateChanged) {
43
43
  tProperties.invert = invert;
44
44
  }
45
45
 
@@ -80,9 +80,13 @@ class MIPJumpToClickTool extends BaseTool {
80
80
  const { targetViewportIds, toolGroupId } = this.configuration;
81
81
  // TODO - consider making this a utility
82
82
  const viewports = renderingEngine.getViewports().filter((vp) => {
83
- if (targetViewportIds?.indexOf(vp.id) >= 0) return true;
83
+ if (targetViewportIds?.indexOf(vp.id) >= 0) {
84
+ return true;
85
+ }
84
86
  const foundToolGroup = getToolGroupForViewport(vp.id, renderingEngine.id);
85
- if (toolGroupId && toolGroupId === foundToolGroup?.id) return true;
87
+ if (toolGroupId && toolGroupId === foundToolGroup?.id) {
88
+ return true;
89
+ }
86
90
  return false;
87
91
  });
88
92
 
@@ -56,7 +56,9 @@ class PlanarRotateTool extends BaseTool {
56
56
  angle = -angle;
57
57
  }
58
58
 
59
- if (Number.isNaN(angle)) return;
59
+ if (Number.isNaN(angle)) {
60
+ return;
61
+ }
60
62
 
61
63
  if (viewport instanceof BaseVolumeViewport) {
62
64
  const rotAngle = (angle * Math.PI) / 180;
@@ -104,26 +104,38 @@ class ReferenceCursors extends AnnotationDisplayTool {
104
104
 
105
105
  onSetToolActive(): void {
106
106
  this._disableCursorEnabled = this.configuration.disableCursor;
107
- if (!this._disableCursorEnabled) return;
107
+ if (!this._disableCursorEnabled) {
108
+ return;
109
+ }
108
110
  const viewportIds = getToolGroup(this.toolGroupId).viewportsInfo;
109
- if (!viewportIds) return;
111
+ if (!viewportIds) {
112
+ return;
113
+ }
110
114
  const enabledElements = viewportIds.map((e) =>
111
115
  getEnabledElementByIds(e.viewportId, e.renderingEngineId)
112
116
  );
113
117
 
114
118
  enabledElements.forEach((element) => {
115
- if (element) hideElementCursor(element.viewport.element);
119
+ if (element) {
120
+ hideElementCursor(element.viewport.element);
121
+ }
116
122
  });
117
123
  }
118
124
  onSetToolDisabled(): void {
119
- if (!this._disableCursorEnabled) return;
125
+ if (!this._disableCursorEnabled) {
126
+ return;
127
+ }
120
128
  const viewportIds = getToolGroup(this.toolGroupId).viewportsInfo;
121
- if (!viewportIds) return;
129
+ if (!viewportIds) {
130
+ return;
131
+ }
122
132
  const enabledElements = viewportIds.map((e) =>
123
133
  getEnabledElementByIds(e.viewportId, e.renderingEngineId)
124
134
  );
125
135
  enabledElements.forEach((element) => {
126
- if (element) resetElementCursor(element.viewport.element);
136
+ if (element) {
137
+ resetElementCursor(element.viewport.element);
138
+ }
127
139
  });
128
140
  }
129
141
 
@@ -132,14 +144,18 @@ class ReferenceCursors extends AnnotationDisplayTool {
132
144
  element: HTMLDivElement
133
145
  ): void => {
134
146
  const enabledElement = getEnabledElement(element);
135
- if (!enabledElement) throw new Error('No enabled element found');
147
+ if (!enabledElement) {
148
+ throw new Error('No enabled element found');
149
+ }
136
150
  const { viewport, renderingEngine } = enabledElement;
137
151
 
138
152
  this.isDrawing = true;
139
153
 
140
154
  const camera = viewport.getCamera();
141
155
  const { viewPlaneNormal, viewUp } = camera;
142
- if (!viewPlaneNormal || !viewUp) throw new Error('Camera not found');
156
+ if (!viewPlaneNormal || !viewUp) {
157
+ throw new Error('Camera not found');
158
+ }
143
159
 
144
160
  const referencedImageId = this.getReferencedImageId(
145
161
  viewport,
@@ -181,10 +197,14 @@ class ReferenceCursors extends AnnotationDisplayTool {
181
197
 
182
198
  const annotations = getAnnotations(this.getToolName(), element);
183
199
 
184
- if (annotations.length > 0) return null;
200
+ if (annotations.length > 0) {
201
+ return null;
202
+ }
185
203
  const annotationId = addAnnotation(annotation, element);
186
204
 
187
- if (annotationId === null) return;
205
+ if (annotationId === null) {
206
+ return;
207
+ }
188
208
 
189
209
  const viewportIdsToRender = getViewportIdsWithToolToRender(
190
210
  element,
@@ -212,8 +232,12 @@ class ReferenceCursors extends AnnotationDisplayTool {
212
232
  annotation: Annotation
213
233
  ): void {
214
234
  const worldPos = this._currentCursorWorldPosition;
215
- if (!worldPos) return;
216
- if (!annotation.data?.handles?.points) return;
235
+ if (!worldPos) {
236
+ return;
237
+ }
238
+ if (!annotation.data?.handles?.points) {
239
+ return;
240
+ }
217
241
  annotation.data.handles.points = [[...worldPos]];
218
242
  annotation.invalidated = true;
219
243
 
@@ -223,7 +247,9 @@ class ReferenceCursors extends AnnotationDisplayTool {
223
247
  false
224
248
  );
225
249
  const enabledElement = getEnabledElement(element);
226
- if (!enabledElement) return;
250
+ if (!enabledElement) {
251
+ return;
252
+ }
227
253
  const { renderingEngine } = enabledElement;
228
254
  triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
229
255
  }
@@ -238,7 +264,9 @@ class ReferenceCursors extends AnnotationDisplayTool {
238
264
  | Types.IStackViewport;
239
265
 
240
266
  //only react to changes for element with cursor, otherwise would cause infinite loop
241
- if (element !== this._elementWithCursor) return;
267
+ if (element !== this._elementWithCursor) {
268
+ return;
269
+ }
242
270
  //check if camera moved along its normal
243
271
  const oldFocalPoint = previousCamera.focalPoint;
244
272
  const cameraNormal = camera.viewPlaneNormal;
@@ -247,14 +275,20 @@ class ReferenceCursors extends AnnotationDisplayTool {
247
275
  const deltaCameraFocalPoint: Types.Point3 = [0, 0, 0];
248
276
  vtkMath.subtract(newFocalPoint, oldFocalPoint, deltaCameraFocalPoint);
249
277
  //check if focal point changed
250
- if (deltaCameraFocalPoint.reduce((a, b) => a + b, 0) === 0) return;
278
+ if (deltaCameraFocalPoint.reduce((a, b) => a + b, 0) === 0) {
279
+ return;
280
+ }
251
281
  //if nomrmal is perpendicular to focal point change, then we are not moving along the normal
252
282
  const dotProduct = vtkMath.dot(deltaCameraFocalPoint, cameraNormal);
253
283
  //dot product is 0 -> perpendicular
254
- if (Math.abs(dotProduct) < 1e-2) return;
284
+ if (Math.abs(dotProduct) < 1e-2) {
285
+ return;
286
+ }
255
287
 
256
288
  //need to update the position of the annotation since camera changed
257
- if (!this._currentCanvasPosition) return;
289
+ if (!this._currentCanvasPosition) {
290
+ return;
291
+ }
258
292
 
259
293
  const newWorldPos = viewport.canvasToWorld(this._currentCanvasPosition);
260
294
  this._currentCursorWorldPosition = newWorldPos;
@@ -267,15 +301,23 @@ class ReferenceCursors extends AnnotationDisplayTool {
267
301
  annotations: Annotations
268
302
  ): Annotations {
269
303
  //calculate distance of current viewport to annotation
270
- if (!(annotations instanceof Array) || annotations.length === 0) return [];
304
+ if (!(annotations instanceof Array) || annotations.length === 0) {
305
+ return [];
306
+ }
271
307
  const annotation = annotations[0];
272
308
  const viewport = getEnabledElement(element)?.viewport;
273
- if (!viewport) return [];
309
+ if (!viewport) {
310
+ return [];
311
+ }
274
312
  const camera = viewport.getCamera();
275
313
  const { viewPlaneNormal, focalPoint } = camera;
276
- if (!viewPlaneNormal || !focalPoint) return [];
314
+ if (!viewPlaneNormal || !focalPoint) {
315
+ return [];
316
+ }
277
317
  const points = annotation.data?.handles?.points;
278
- if (!(points instanceof Array) || points.length !== 1) return [];
318
+ if (!(points instanceof Array) || points.length !== 1) {
319
+ return [];
320
+ }
279
321
  const worldPos = points[0];
280
322
  const plane = utilities.planar.planeEquation(viewPlaneNormal, focalPoint);
281
323
  const distance = utilities.planar.planeDistanceToPoint(plane, worldPos);
@@ -333,7 +375,9 @@ class ReferenceCursors extends AnnotationDisplayTool {
333
375
  const { handles } = data;
334
376
  const { points } = handles;
335
377
 
336
- if (!annotationUID) return renderStatus;
378
+ if (!annotationUID) {
379
+ return renderStatus;
380
+ }
337
381
  styleSpecifier.annotationUID = annotationUID;
338
382
 
339
383
  const lineWidthBase = parseFloat(
@@ -347,7 +391,9 @@ class ReferenceCursors extends AnnotationDisplayTool {
347
391
  const lineDash = this.getStyle('lineDash', styleSpecifier, annotation);
348
392
  const color = this.getStyle('color', styleSpecifier, annotation);
349
393
 
350
- if (points[0].some((e) => isNaN(e))) return renderStatus;
394
+ if (points[0].some((e) => isNaN(e))) {
395
+ return renderStatus;
396
+ }
351
397
  const canvasCoordinates = points.map((p) =>
352
398
  viewport.worldToCanvas(p)
353
399
  ) as [Types.Point2];
@@ -414,8 +460,9 @@ class ReferenceCursors extends AnnotationDisplayTool {
414
460
  ): void {
415
461
  const currentMousePosition = this._currentCursorWorldPosition;
416
462
 
417
- if (!currentMousePosition || currentMousePosition.some((e) => isNaN(e)))
463
+ if (!currentMousePosition || currentMousePosition.some((e) => isNaN(e))) {
418
464
  return;
465
+ }
419
466
 
420
467
  if (viewport instanceof StackViewport) {
421
468
  const closestIndex = utilities.getClosestStackImageIndexForPoint(
@@ -423,12 +470,17 @@ class ReferenceCursors extends AnnotationDisplayTool {
423
470
  viewport
424
471
  );
425
472
 
426
- if (closestIndex === null) return;
427
- if (closestIndex !== viewport.getCurrentImageIdIndex())
473
+ if (closestIndex === null) {
474
+ return;
475
+ }
476
+ if (closestIndex !== viewport.getCurrentImageIdIndex()) {
428
477
  viewport.setImageIdIndex(closestIndex);
478
+ }
429
479
  } else if (viewport instanceof VolumeViewport) {
430
480
  const { focalPoint, viewPlaneNormal } = viewport.getCamera();
431
- if (!focalPoint || !viewPlaneNormal) return;
481
+ if (!focalPoint || !viewPlaneNormal) {
482
+ return;
483
+ }
432
484
  const plane = utilities.planar.planeEquation(viewPlaneNormal, focalPoint);
433
485
  const currentDistance = utilities.planar.planeDistanceToPoint(
434
486
  plane,
@@ -436,7 +488,9 @@ class ReferenceCursors extends AnnotationDisplayTool {
436
488
  true
437
489
  );
438
490
 
439
- if (Math.abs(currentDistance) < 0.5) return;
491
+ if (Math.abs(currentDistance) < 0.5) {
492
+ return;
493
+ }
440
494
  const normalizedViewPlane = vec3.normalize(
441
495
  vec3.create(),
442
496
  vec3.fromValues(...viewPlaneNormal)
@@ -456,7 +510,9 @@ class ReferenceCursors extends AnnotationDisplayTool {
456
510
  if (isInBounds) {
457
511
  viewport.setCamera({ focalPoint: newFocalPoint });
458
512
  const renderingEngine = viewport.getRenderingEngine();
459
- if (renderingEngine) renderingEngine.renderViewport(viewport.id);
513
+ if (renderingEngine) {
514
+ renderingEngine.renderViewport(viewport.id);
515
+ }
460
516
  }
461
517
  }
462
518
  }
@@ -72,7 +72,9 @@ class ScaleOverlayTool extends AnnotationDisplayTool {
72
72
  // get viewports with tool enabled
73
73
  const viewportIds = getToolGroup(this.toolGroupId).viewportsInfo;
74
74
 
75
- if (!viewportIds) return;
75
+ if (!viewportIds) {
76
+ return;
77
+ }
76
78
 
77
79
  // get enabled elements
78
80
  const enabledElements = viewportIds.map((e) =>
@@ -74,6 +74,7 @@ class AngleTool extends AnnotationTool {
74
74
  configuration: {
75
75
  shadow: true,
76
76
  preventHandleOutsideImage: false,
77
+ getTextLines: defaultGetTextLines,
77
78
  },
78
79
  }
79
80
  ) {
@@ -219,8 +220,12 @@ class AngleTool extends AnnotationTool {
219
220
  [canvasCoords[0], canvasCoords[1]]
220
221
  );
221
222
 
222
- if (distanceToPoint <= proximity) return true;
223
- if (!point3) return false;
223
+ if (distanceToPoint <= proximity) {
224
+ return true;
225
+ }
226
+ if (!point3) {
227
+ return false;
228
+ }
224
229
 
225
230
  const canvasPoint3 = viewport.worldToCanvas(point3);
226
231
 
@@ -740,7 +745,22 @@ class AngleTool extends AnnotationTool {
740
745
  continue;
741
746
  }
742
747
 
743
- const textLines = this._getTextLines(data, targetId);
748
+ const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
749
+ if (!options.visibility) {
750
+ data.handles.textBox = {
751
+ hasMoved: false,
752
+ worldPosition: <Types.Point3>[0, 0, 0],
753
+ worldBoundingBox: {
754
+ topLeft: <Types.Point3>[0, 0, 0],
755
+ topRight: <Types.Point3>[0, 0, 0],
756
+ bottomLeft: <Types.Point3>[0, 0, 0],
757
+ bottomRight: <Types.Point3>[0, 0, 0],
758
+ },
759
+ };
760
+ continue;
761
+ }
762
+
763
+ const textLines = this.configuration.getTextLines(data, targetId);
744
764
 
745
765
  if (!data.handles.textBox.hasMoved) {
746
766
  // linked to the vertex by default
@@ -763,7 +783,7 @@ class AngleTool extends AnnotationTool {
763
783
  textBoxPosition,
764
784
  canvasCoordinates,
765
785
  {},
766
- this.getLinkedTextBoxStyle(styleSpecifier, annotation)
786
+ options
767
787
  );
768
788
 
769
789
  const { x: left, y: top, width, height } = boundingBox;
@@ -779,20 +799,6 @@ class AngleTool extends AnnotationTool {
779
799
  return renderStatus;
780
800
  };
781
801
 
782
- // text line for the current active angle annotation
783
- _getTextLines(data, targetId) {
784
- const cachedVolumeStats = data.cachedStats[targetId];
785
- const { angle } = cachedVolumeStats;
786
-
787
- if (angle === undefined) {
788
- return;
789
- }
790
-
791
- const textLines = [`${roundNumber(angle)} ${String.fromCharCode(176)}`];
792
-
793
- return textLines;
794
- }
795
-
796
802
  _calculateCachedStats(annotation, renderingEngine, enabledElement) {
797
803
  const data = annotation.data;
798
804
  const { viewportId, renderingEngineId } = enabledElement;
@@ -817,7 +823,7 @@ class AngleTool extends AnnotationTool {
817
823
  );
818
824
 
819
825
  cachedStats[targetId] = {
820
- angle,
826
+ angle: isNaN(angle) ? 'Incomplete Angle' : angle,
821
827
  };
822
828
  }
823
829
 
@@ -837,5 +843,18 @@ class AngleTool extends AnnotationTool {
837
843
  }
838
844
  }
839
845
 
846
+ function defaultGetTextLines(data, targetId): string[] {
847
+ const cachedVolumeStats = data.cachedStats[targetId];
848
+ const { angle } = cachedVolumeStats;
849
+
850
+ if (angle === undefined) {
851
+ return;
852
+ }
853
+
854
+ const textLines = [`${roundNumber(angle)} ${String.fromCharCode(176)}`];
855
+
856
+ return textLines;
857
+ }
858
+
840
859
  AngleTool.toolName = 'Angle';
841
860
  export default AngleTool;
@@ -776,6 +776,21 @@ class ArrowAnnotateTool extends AnnotationTool {
776
776
  continue;
777
777
  }
778
778
 
779
+ const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
780
+ if (!options.visibility) {
781
+ data.handles.textBox = {
782
+ hasMoved: false,
783
+ worldPosition: <Types.Point3>[0, 0, 0],
784
+ worldBoundingBox: {
785
+ topLeft: <Types.Point3>[0, 0, 0],
786
+ topRight: <Types.Point3>[0, 0, 0],
787
+ bottomLeft: <Types.Point3>[0, 0, 0],
788
+ bottomRight: <Types.Point3>[0, 0, 0],
789
+ },
790
+ };
791
+ continue;
792
+ }
793
+
779
794
  // Need to update to sync w/ annotation while unlinked/not moved
780
795
  if (!data.handles.textBox.hasMoved) {
781
796
  // linked to the point that doesn't have the arrowhead by default
@@ -798,7 +813,7 @@ class ArrowAnnotateTool extends AnnotationTool {
798
813
  textBoxPosition,
799
814
  canvasCoordinates,
800
815
  {},
801
- this.getLinkedTextBoxStyle(styleSpecifier, annotation)
816
+ options
802
817
  );
803
818
 
804
819
  const { x: left, y: top, width, height } = boundingBox;