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

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 (265) hide show
  1. package/dist/cjs/drawingSvg/getSvgDrawingHelper.js +1 -1
  2. package/dist/cjs/drawingSvg/getSvgDrawingHelper.js.map +1 -1
  3. package/dist/cjs/enums/Events.d.ts +1 -0
  4. package/dist/cjs/enums/Events.js +1 -0
  5. package/dist/cjs/enums/Events.js.map +1 -1
  6. package/dist/cjs/eventDispatchers/mouseEventHandlers/mouseDown.js +6 -1
  7. package/dist/cjs/eventDispatchers/mouseEventHandlers/mouseDown.js.map +1 -1
  8. package/dist/cjs/eventDispatchers/mouseEventHandlers/mouseDownAnnotationAction.d.ts +2 -0
  9. package/dist/cjs/eventDispatchers/mouseEventHandlers/mouseDownAnnotationAction.js +41 -0
  10. package/dist/cjs/eventDispatchers/mouseEventHandlers/mouseDownAnnotationAction.js.map +1 -0
  11. package/dist/cjs/eventDispatchers/shared/getToolsWithActionsForMouseEvent.d.ts +3 -0
  12. package/dist/cjs/eventDispatchers/shared/getToolsWithActionsForMouseEvent.js +39 -0
  13. package/dist/cjs/eventDispatchers/shared/getToolsWithActionsForMouseEvent.js.map +1 -0
  14. package/dist/cjs/eventListeners/mouse/mouseDownListener.js +5 -1
  15. package/dist/cjs/eventListeners/mouse/mouseDownListener.js.map +1 -1
  16. package/dist/cjs/eventListeners/mouse/mouseMoveListener.js +5 -1
  17. package/dist/cjs/eventListeners/mouse/mouseMoveListener.js.map +1 -1
  18. package/dist/cjs/index.d.ts +2 -2
  19. package/dist/cjs/index.js +5 -2
  20. package/dist/cjs/index.js.map +1 -1
  21. package/dist/cjs/store/ToolGroupManager/ToolGroup.d.ts +2 -0
  22. package/dist/cjs/store/ToolGroupManager/ToolGroup.js +35 -0
  23. package/dist/cjs/store/ToolGroupManager/ToolGroup.js.map +1 -1
  24. package/dist/cjs/synchronizers/callbacks/stackImageSyncCallback.js +1 -1
  25. package/dist/cjs/synchronizers/callbacks/stackImageSyncCallback.js.map +1 -1
  26. package/dist/cjs/tools/AdvancedMagnifyTool.d.ts +36 -0
  27. package/dist/cjs/tools/AdvancedMagnifyTool.js +448 -0
  28. package/dist/cjs/tools/AdvancedMagnifyTool.js.map +1 -0
  29. package/dist/cjs/tools/AdvancedMagnifyViewport.d.ts +76 -0
  30. package/dist/cjs/tools/AdvancedMagnifyViewport.js +352 -0
  31. package/dist/cjs/tools/AdvancedMagnifyViewport.js.map +1 -0
  32. package/dist/cjs/tools/AdvancedMagnifyViewportManager.d.ts +36 -0
  33. package/dist/cjs/tools/AdvancedMagnifyViewportManager.js +133 -0
  34. package/dist/cjs/tools/AdvancedMagnifyViewportManager.js.map +1 -0
  35. package/dist/cjs/tools/MagnifyTool.js +2 -2
  36. package/dist/cjs/tools/MagnifyTool.js.map +1 -1
  37. package/dist/cjs/tools/OrientationMarkerTool.d.ts +88 -0
  38. package/dist/cjs/tools/OrientationMarkerTool.js +193 -0
  39. package/dist/cjs/tools/OrientationMarkerTool.js.map +1 -0
  40. package/dist/cjs/tools/OverlayGridTool.d.ts +31 -0
  41. package/dist/cjs/tools/OverlayGridTool.js +170 -0
  42. package/dist/cjs/tools/OverlayGridTool.js.map +1 -0
  43. package/dist/cjs/tools/ReferenceLinesTool.d.ts +3 -0
  44. package/dist/cjs/tools/ReferenceLinesTool.js +71 -2
  45. package/dist/cjs/tools/ReferenceLinesTool.js.map +1 -1
  46. package/dist/cjs/tools/annotation/AngleTool.js +2 -1
  47. package/dist/cjs/tools/annotation/AngleTool.js.map +1 -1
  48. package/dist/cjs/tools/annotation/BidirectionalTool.js +1 -1
  49. package/dist/cjs/tools/annotation/BidirectionalTool.js.map +1 -1
  50. package/dist/cjs/tools/annotation/CircleROITool.d.ts +1 -2
  51. package/dist/cjs/tools/annotation/CircleROITool.js +8 -8
  52. package/dist/cjs/tools/annotation/CircleROITool.js.map +1 -1
  53. package/dist/cjs/tools/annotation/CobbAngleTool.d.ts +31 -5
  54. package/dist/cjs/tools/annotation/CobbAngleTool.js +268 -71
  55. package/dist/cjs/tools/annotation/CobbAngleTool.js.map +1 -1
  56. package/dist/cjs/tools/annotation/DragProbeTool.js +4 -3
  57. package/dist/cjs/tools/annotation/DragProbeTool.js.map +1 -1
  58. package/dist/cjs/tools/annotation/EllipticalROITool.d.ts +2 -3
  59. package/dist/cjs/tools/annotation/EllipticalROITool.js +20 -16
  60. package/dist/cjs/tools/annotation/EllipticalROITool.js.map +1 -1
  61. package/dist/cjs/tools/annotation/LengthTool.js +1 -1
  62. package/dist/cjs/tools/annotation/LengthTool.js.map +1 -1
  63. package/dist/cjs/tools/annotation/PlanarFreehandROITool.d.ts +1 -2
  64. package/dist/cjs/tools/annotation/PlanarFreehandROITool.js +22 -9
  65. package/dist/cjs/tools/annotation/PlanarFreehandROITool.js.map +1 -1
  66. package/dist/cjs/tools/annotation/ProbeTool.d.ts +1 -2
  67. package/dist/cjs/tools/annotation/ProbeTool.js +10 -9
  68. package/dist/cjs/tools/annotation/ProbeTool.js.map +1 -1
  69. package/dist/cjs/tools/annotation/RectangleROITool.d.ts +1 -1
  70. package/dist/cjs/tools/annotation/RectangleROITool.js +9 -9
  71. package/dist/cjs/tools/annotation/RectangleROITool.js.map +1 -1
  72. package/dist/cjs/tools/base/AnnotationDisplayTool.js +4 -0
  73. package/dist/cjs/tools/base/AnnotationDisplayTool.js.map +1 -1
  74. package/dist/cjs/tools/base/AnnotationTool.d.ts +1 -1
  75. package/dist/cjs/tools/base/AnnotationTool.js.map +1 -1
  76. package/dist/cjs/tools/displayTools/Contour/contourDisplay.js +3 -0
  77. package/dist/cjs/tools/displayTools/Contour/contourDisplay.js.map +1 -1
  78. package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.js +1 -1
  79. package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
  80. package/dist/cjs/tools/index.d.ts +4 -1
  81. package/dist/cjs/tools/index.js +7 -1
  82. package/dist/cjs/tools/index.js.map +1 -1
  83. package/dist/cjs/types/EventTypes.d.ts +9 -1
  84. package/dist/cjs/types/IToolGroup.d.ts +3 -0
  85. package/dist/cjs/types/ToolAction.d.ts +8 -0
  86. package/dist/cjs/types/ToolAction.js +3 -0
  87. package/dist/cjs/types/ToolAction.js.map +1 -0
  88. package/dist/cjs/types/ToolSpecificAnnotationTypes.d.ts +55 -0
  89. package/dist/cjs/types/index.d.ts +2 -1
  90. package/dist/cjs/utilities/getModalityUnit.js +5 -2
  91. package/dist/cjs/utilities/getModalityUnit.js.map +1 -1
  92. package/dist/cjs/utilities/index.d.ts +2 -2
  93. package/dist/cjs/utilities/index.js +4 -3
  94. package/dist/cjs/utilities/index.js.map +1 -1
  95. package/dist/cjs/utilities/math/angle/angleBetweenLines.d.ts +3 -1
  96. package/dist/cjs/utilities/math/angle/angleBetweenLines.js +18 -1
  97. package/dist/cjs/utilities/math/angle/angleBetweenLines.js.map +1 -1
  98. package/dist/cjs/utilities/stackPrefetch/index.d.ts +3 -2
  99. package/dist/cjs/utilities/stackPrefetch/index.js +8 -6
  100. package/dist/cjs/utilities/stackPrefetch/index.js.map +1 -1
  101. package/dist/cjs/utilities/stackPrefetch/stackContextPrefetch.d.ts +16 -0
  102. package/dist/cjs/utilities/stackPrefetch/stackContextPrefetch.js +227 -0
  103. package/dist/cjs/utilities/stackPrefetch/stackContextPrefetch.js.map +1 -0
  104. package/dist/cjs/utilities/stackPrefetch/stackPrefetch.d.ts +7 -1
  105. package/dist/cjs/utilities/stackPrefetch/stackPrefetch.js +23 -93
  106. package/dist/cjs/utilities/stackPrefetch/stackPrefetch.js.map +1 -1
  107. package/dist/cjs/utilities/stackPrefetch/stackPrefetchUtils.d.ts +14 -0
  108. package/dist/cjs/utilities/stackPrefetch/stackPrefetchUtils.js +85 -0
  109. package/dist/cjs/utilities/stackPrefetch/stackPrefetchUtils.js.map +1 -0
  110. package/dist/esm/drawingSvg/getSvgDrawingHelper.js +1 -1
  111. package/dist/esm/drawingSvg/getSvgDrawingHelper.js.map +1 -1
  112. package/dist/esm/enums/Events.d.ts +1 -0
  113. package/dist/esm/enums/Events.js +1 -0
  114. package/dist/esm/enums/Events.js.map +1 -1
  115. package/dist/esm/eventDispatchers/mouseEventHandlers/mouseDown.js +6 -1
  116. package/dist/esm/eventDispatchers/mouseEventHandlers/mouseDown.js.map +1 -1
  117. package/dist/esm/eventDispatchers/mouseEventHandlers/mouseDownAnnotationAction.d.ts +2 -0
  118. package/dist/esm/eventDispatchers/mouseEventHandlers/mouseDownAnnotationAction.js +35 -0
  119. package/dist/esm/eventDispatchers/mouseEventHandlers/mouseDownAnnotationAction.js.map +1 -0
  120. package/dist/esm/eventDispatchers/shared/getToolsWithActionsForMouseEvent.d.ts +3 -0
  121. package/dist/esm/eventDispatchers/shared/getToolsWithActionsForMouseEvent.js +32 -0
  122. package/dist/esm/eventDispatchers/shared/getToolsWithActionsForMouseEvent.js.map +1 -0
  123. package/dist/esm/eventListeners/mouse/mouseDownListener.js +5 -1
  124. package/dist/esm/eventListeners/mouse/mouseDownListener.js.map +1 -1
  125. package/dist/esm/eventListeners/mouse/mouseMoveListener.js +5 -1
  126. package/dist/esm/eventListeners/mouse/mouseMoveListener.js.map +1 -1
  127. package/dist/esm/index.d.ts +2 -2
  128. package/dist/esm/index.js +2 -2
  129. package/dist/esm/index.js.map +1 -1
  130. package/dist/esm/store/ToolGroupManager/ToolGroup.d.ts +2 -0
  131. package/dist/esm/store/ToolGroupManager/ToolGroup.js +35 -1
  132. package/dist/esm/store/ToolGroupManager/ToolGroup.js.map +1 -1
  133. package/dist/esm/synchronizers/callbacks/stackImageSyncCallback.js +1 -1
  134. package/dist/esm/synchronizers/callbacks/stackImageSyncCallback.js.map +1 -1
  135. package/dist/esm/tools/AdvancedMagnifyTool.d.ts +36 -0
  136. package/dist/esm/tools/AdvancedMagnifyTool.js +440 -0
  137. package/dist/esm/tools/AdvancedMagnifyTool.js.map +1 -0
  138. package/dist/esm/tools/AdvancedMagnifyViewport.d.ts +76 -0
  139. package/dist/esm/tools/AdvancedMagnifyViewport.js +346 -0
  140. package/dist/esm/tools/AdvancedMagnifyViewport.js.map +1 -0
  141. package/dist/esm/tools/AdvancedMagnifyViewportManager.d.ts +36 -0
  142. package/dist/esm/tools/AdvancedMagnifyViewportManager.js +128 -0
  143. package/dist/esm/tools/AdvancedMagnifyViewportManager.js.map +1 -0
  144. package/dist/esm/tools/MagnifyTool.js +2 -2
  145. package/dist/esm/tools/MagnifyTool.js.map +1 -1
  146. package/dist/esm/tools/OrientationMarkerTool.d.ts +88 -0
  147. package/dist/esm/tools/OrientationMarkerTool.js +185 -0
  148. package/dist/esm/tools/OrientationMarkerTool.js.map +1 -0
  149. package/dist/esm/tools/OverlayGridTool.d.ts +31 -0
  150. package/dist/esm/tools/OverlayGridTool.js +165 -0
  151. package/dist/esm/tools/OverlayGridTool.js.map +1 -0
  152. package/dist/esm/tools/ReferenceLinesTool.d.ts +3 -0
  153. package/dist/esm/tools/ReferenceLinesTool.js +71 -2
  154. package/dist/esm/tools/ReferenceLinesTool.js.map +1 -1
  155. package/dist/esm/tools/annotation/AngleTool.js +2 -1
  156. package/dist/esm/tools/annotation/AngleTool.js.map +1 -1
  157. package/dist/esm/tools/annotation/BidirectionalTool.js +1 -1
  158. package/dist/esm/tools/annotation/BidirectionalTool.js.map +1 -1
  159. package/dist/esm/tools/annotation/CircleROITool.d.ts +1 -2
  160. package/dist/esm/tools/annotation/CircleROITool.js +8 -8
  161. package/dist/esm/tools/annotation/CircleROITool.js.map +1 -1
  162. package/dist/esm/tools/annotation/CobbAngleTool.d.ts +31 -5
  163. package/dist/esm/tools/annotation/CobbAngleTool.js +275 -72
  164. package/dist/esm/tools/annotation/CobbAngleTool.js.map +1 -1
  165. package/dist/esm/tools/annotation/DragProbeTool.js +4 -3
  166. package/dist/esm/tools/annotation/DragProbeTool.js.map +1 -1
  167. package/dist/esm/tools/annotation/EllipticalROITool.d.ts +2 -3
  168. package/dist/esm/tools/annotation/EllipticalROITool.js +20 -16
  169. package/dist/esm/tools/annotation/EllipticalROITool.js.map +1 -1
  170. package/dist/esm/tools/annotation/LengthTool.js +1 -1
  171. package/dist/esm/tools/annotation/LengthTool.js.map +1 -1
  172. package/dist/esm/tools/annotation/PlanarFreehandROITool.d.ts +1 -2
  173. package/dist/esm/tools/annotation/PlanarFreehandROITool.js +22 -9
  174. package/dist/esm/tools/annotation/PlanarFreehandROITool.js.map +1 -1
  175. package/dist/esm/tools/annotation/ProbeTool.d.ts +1 -2
  176. package/dist/esm/tools/annotation/ProbeTool.js +10 -9
  177. package/dist/esm/tools/annotation/ProbeTool.js.map +1 -1
  178. package/dist/esm/tools/annotation/RectangleROITool.d.ts +1 -1
  179. package/dist/esm/tools/annotation/RectangleROITool.js +9 -9
  180. package/dist/esm/tools/annotation/RectangleROITool.js.map +1 -1
  181. package/dist/esm/tools/base/AnnotationDisplayTool.js +3 -0
  182. package/dist/esm/tools/base/AnnotationDisplayTool.js.map +1 -1
  183. package/dist/esm/tools/base/AnnotationTool.d.ts +1 -1
  184. package/dist/esm/tools/base/AnnotationTool.js.map +1 -1
  185. package/dist/esm/tools/displayTools/Contour/contourDisplay.js +4 -1
  186. package/dist/esm/tools/displayTools/Contour/contourDisplay.js.map +1 -1
  187. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +1 -1
  188. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
  189. package/dist/esm/tools/index.d.ts +4 -1
  190. package/dist/esm/tools/index.js +4 -1
  191. package/dist/esm/tools/index.js.map +1 -1
  192. package/dist/esm/types/EventTypes.d.ts +9 -1
  193. package/dist/esm/types/IToolGroup.d.ts +3 -0
  194. package/dist/esm/types/ToolAction.d.ts +8 -0
  195. package/dist/esm/types/ToolAction.js +2 -0
  196. package/dist/esm/types/ToolAction.js.map +1 -0
  197. package/dist/esm/types/ToolSpecificAnnotationTypes.d.ts +55 -0
  198. package/dist/esm/types/index.d.ts +2 -1
  199. package/dist/esm/utilities/getModalityUnit.js +5 -2
  200. package/dist/esm/utilities/getModalityUnit.js.map +1 -1
  201. package/dist/esm/utilities/index.d.ts +2 -2
  202. package/dist/esm/utilities/index.js +2 -2
  203. package/dist/esm/utilities/index.js.map +1 -1
  204. package/dist/esm/utilities/math/angle/angleBetweenLines.d.ts +3 -1
  205. package/dist/esm/utilities/math/angle/angleBetweenLines.js +19 -2
  206. package/dist/esm/utilities/math/angle/angleBetweenLines.js.map +1 -1
  207. package/dist/esm/utilities/stackPrefetch/index.d.ts +3 -2
  208. package/dist/esm/utilities/stackPrefetch/index.js +3 -2
  209. package/dist/esm/utilities/stackPrefetch/index.js.map +1 -1
  210. package/dist/esm/utilities/stackPrefetch/stackContextPrefetch.d.ts +16 -0
  211. package/dist/esm/utilities/stackPrefetch/stackContextPrefetch.js +220 -0
  212. package/dist/esm/utilities/stackPrefetch/stackContextPrefetch.js.map +1 -0
  213. package/dist/esm/utilities/stackPrefetch/stackPrefetch.d.ts +7 -1
  214. package/dist/esm/utilities/stackPrefetch/stackPrefetch.js +12 -79
  215. package/dist/esm/utilities/stackPrefetch/stackPrefetch.js.map +1 -1
  216. package/dist/esm/utilities/stackPrefetch/stackPrefetchUtils.d.ts +14 -0
  217. package/dist/esm/utilities/stackPrefetch/stackPrefetchUtils.js +77 -0
  218. package/dist/esm/utilities/stackPrefetch/stackPrefetchUtils.js.map +1 -0
  219. package/dist/umd/index.js +1 -1
  220. package/dist/umd/index.js.map +1 -1
  221. package/package.json +3 -3
  222. package/src/drawingSvg/getSvgDrawingHelper.ts +4 -1
  223. package/src/enums/Events.ts +9 -0
  224. package/src/eventDispatchers/mouseEventHandlers/mouseDown.ts +11 -2
  225. package/src/eventDispatchers/mouseEventHandlers/mouseDownAnnotationAction.ts +72 -0
  226. package/src/eventDispatchers/shared/getToolsWithActionsForMouseEvent.ts +66 -0
  227. package/src/eventListeners/mouse/mouseDownListener.ts +7 -1
  228. package/src/eventListeners/mouse/mouseMoveListener.ts +7 -1
  229. package/src/index.ts +6 -0
  230. package/src/store/ToolGroupManager/ToolGroup.ts +79 -2
  231. package/src/synchronizers/callbacks/stackImageSyncCallback.ts +1 -1
  232. package/src/tools/AdvancedMagnifyTool.ts +725 -0
  233. package/src/tools/AdvancedMagnifyViewport.ts +624 -0
  234. package/src/tools/AdvancedMagnifyViewportManager.ts +291 -0
  235. package/src/tools/MagnifyTool.ts +2 -2
  236. package/src/tools/OrientationMarkerTool.ts +235 -0
  237. package/src/tools/OverlayGridTool.ts +357 -0
  238. package/src/tools/ReferenceLinesTool.ts +131 -3
  239. package/src/tools/annotation/AngleTool.ts +4 -1
  240. package/src/tools/annotation/BidirectionalTool.ts +1 -1
  241. package/src/tools/annotation/CircleROITool.ts +13 -20
  242. package/src/tools/annotation/CobbAngleTool.ts +422 -99
  243. package/src/tools/annotation/DragProbeTool.ts +6 -13
  244. package/src/tools/annotation/EllipticalROITool.ts +28 -29
  245. package/src/tools/annotation/LengthTool.ts +1 -1
  246. package/src/tools/annotation/PlanarFreehandROITool.ts +35 -20
  247. package/src/tools/annotation/ProbeTool.ts +17 -30
  248. package/src/tools/annotation/RectangleROITool.ts +15 -19
  249. package/src/tools/base/AnnotationDisplayTool.ts +4 -0
  250. package/src/tools/base/AnnotationTool.ts +2 -1
  251. package/src/tools/displayTools/Contour/contourDisplay.ts +8 -0
  252. package/src/tools/displayTools/Labelmap/labelmapDisplay.ts +1 -1
  253. package/src/tools/index.ts +6 -0
  254. package/src/types/EventTypes.ts +23 -0
  255. package/src/types/IToolGroup.ts +7 -0
  256. package/src/types/ToolAction.ts +54 -0
  257. package/src/types/ToolSpecificAnnotationTypes.ts +58 -0
  258. package/src/types/index.ts +2 -0
  259. package/src/utilities/getModalityUnit.ts +8 -2
  260. package/src/utilities/index.ts +2 -1
  261. package/src/utilities/math/angle/angleBetweenLines.ts +39 -9
  262. package/src/utilities/stackPrefetch/index.ts +3 -7
  263. package/src/utilities/stackPrefetch/stackContextPrefetch.ts +380 -0
  264. package/src/utilities/stackPrefetch/stackPrefetch.ts +29 -151
  265. package/src/utilities/stackPrefetch/stackPrefetchUtils.ts +114 -0
@@ -166,26 +166,19 @@ class DragProbeTool extends ProbeTool {
166
166
  ),
167
167
  };
168
168
 
169
- if (!data.cachedStats[targetId]) {
169
+ if (
170
+ !data.cachedStats[targetId] ||
171
+ data.cachedStats[targetId].value == null
172
+ ) {
170
173
  data.cachedStats[targetId] = {
171
174
  Modality: null,
172
175
  index: null,
173
176
  value: null,
174
177
  };
175
178
 
176
- this._calculateCachedStats(
177
- annotation,
178
- renderingEngine,
179
- enabledElement,
180
- modalityUnitOptions
181
- );
179
+ this._calculateCachedStats(annotation, renderingEngine, enabledElement);
182
180
  } else if (annotation.invalidated) {
183
- this._calculateCachedStats(
184
- annotation,
185
- renderingEngine,
186
- enabledElement,
187
- modalityUnitOptions
188
- );
181
+ this._calculateCachedStats(annotation, renderingEngine, enabledElement);
189
182
  }
190
183
 
191
184
  // If rendering engine has been destroyed while rendering
@@ -47,7 +47,6 @@ import {
47
47
  TextBoxHandle,
48
48
  PublicToolProps,
49
49
  ToolProps,
50
- InteractionTypes,
51
50
  SVGDrawingHelper,
52
51
  } from '../../types';
53
52
  import { EllipticalROIAnnotation } from '../../types/ToolSpecificAnnotationTypes';
@@ -55,8 +54,6 @@ import { EllipticalROIAnnotation } from '../../types/ToolSpecificAnnotationTypes
55
54
  import {
56
55
  AnnotationCompletedEventDetail,
57
56
  AnnotationModifiedEventDetail,
58
- MouseDragEventType,
59
- MouseMoveEventType,
60
57
  } from '../../types/EventTypes';
61
58
  import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
62
59
  import { pointInShapeCallback } from '../../utilities/';
@@ -128,7 +125,7 @@ class EllipticalROITool extends AnnotationTool {
128
125
  viewportIdsToRender: Array<string>;
129
126
  handleIndex?: number;
130
127
  movingTextBox?: boolean;
131
- centerCanvas?: Array<number>;
128
+ centerWorld?: Array<number>;
132
129
  canvasWidth?: number;
133
130
  canvasHeight?: number;
134
131
  originalHandleCanvas?: Array<number>;
@@ -241,7 +238,7 @@ class EllipticalROITool extends AnnotationTool {
241
238
  this.editData = {
242
239
  annotation,
243
240
  viewportIdsToRender,
244
- centerCanvas: canvasPos,
241
+ centerWorld: worldPos,
245
242
  newAnnotation: true,
246
243
  hasMoved: false,
247
244
  };
@@ -368,6 +365,7 @@ class EllipticalROITool extends AnnotationTool {
368
365
  let handleIndex;
369
366
 
370
367
  let centerCanvas;
368
+ let centerWorld;
371
369
  let canvasWidth;
372
370
  let canvasHeight;
373
371
  let originalHandleCanvas;
@@ -376,8 +374,8 @@ class EllipticalROITool extends AnnotationTool {
376
374
  movingTextBox = true;
377
375
  } else {
378
376
  const { points } = data.handles;
379
- const enabledElement = getEnabledElement(element);
380
- const { worldToCanvas } = enabledElement.viewport;
377
+ const { viewport } = getEnabledElement(element);
378
+ const { worldToCanvas, canvasToWorld } = viewport;
381
379
 
382
380
  handleIndex = points.findIndex((p) => p === handle);
383
381
 
@@ -392,6 +390,8 @@ class EllipticalROITool extends AnnotationTool {
392
390
  (pointsCanvas[2][0] + pointsCanvas[3][0]) / 2,
393
391
  (pointsCanvas[0][1] + pointsCanvas[1][1]) / 2,
394
392
  ];
393
+
394
+ centerWorld = canvasToWorld(centerCanvas);
395
395
  }
396
396
 
397
397
  // Find viewports to render on drag.
@@ -406,7 +406,7 @@ class EllipticalROITool extends AnnotationTool {
406
406
  handleIndex,
407
407
  canvasWidth,
408
408
  canvasHeight,
409
- centerCanvas,
409
+ centerWorld,
410
410
  originalHandleCanvas,
411
411
  movingTextBox,
412
412
  };
@@ -483,7 +483,8 @@ class EllipticalROITool extends AnnotationTool {
483
483
  const { canvasToWorld } = viewport;
484
484
 
485
485
  //////
486
- const { annotation, viewportIdsToRender, centerCanvas } = this.editData;
486
+ const { annotation, viewportIdsToRender, centerWorld } = this.editData;
487
+ const centerCanvas = viewport.worldToCanvas(centerWorld as Types.Point3);
487
488
  const { data } = annotation;
488
489
 
489
490
  const dX = Math.abs(currentCanvasPoints[0] - centerCanvas[0]);
@@ -557,17 +558,18 @@ class EllipticalROITool extends AnnotationTool {
557
558
  _dragHandle = (evt: EventTypes.InteractionEventType): void => {
558
559
  const eventDetail = evt.detail;
559
560
  const { element } = eventDetail;
560
- const enabledElement = getEnabledElement(element);
561
- const { canvasToWorld } = enabledElement.viewport;
561
+ const { viewport } = getEnabledElement(element);
562
+ const { canvasToWorld, worldToCanvas } = viewport;
562
563
 
563
564
  const {
564
565
  annotation,
565
566
  canvasWidth,
566
567
  canvasHeight,
567
568
  handleIndex,
568
- centerCanvas,
569
+ centerWorld,
569
570
  originalHandleCanvas,
570
571
  } = this.editData;
572
+ const centerCanvas = viewport.worldToCanvas(centerWorld as Types.Point3);
571
573
  const { data } = annotation;
572
574
  const { points } = data.handles;
573
575
 
@@ -800,21 +802,11 @@ class EllipticalROITool extends AnnotationTool {
800
802
 
801
803
  const { centerPointRadius } = this.configuration;
802
804
 
803
- const modalityUnitOptions = {
804
- isPreScaled: isViewportPreScaled(viewport, targetId),
805
-
806
- isSuvScaled: this.isSuvScaled(
807
- viewport,
808
- targetId,
809
- annotation.metadata.referencedImageId
810
- ),
811
- };
812
-
813
805
  // If cachedStats does not exist, or the unit is missing (as part of import/hydration etc.),
814
806
  // force to recalculate the stats from the points
815
807
  if (
816
808
  !data.cachedStats[targetId] ||
817
- data.cachedStats[targetId].areaUnit === undefined
809
+ data.cachedStats[targetId].areaUnit == null
818
810
  ) {
819
811
  data.cachedStats[targetId] = {
820
812
  Modality: null,
@@ -829,16 +821,14 @@ class EllipticalROITool extends AnnotationTool {
829
821
  annotation,
830
822
  viewport,
831
823
  renderingEngine,
832
- enabledElement,
833
- modalityUnitOptions
824
+ enabledElement
834
825
  );
835
826
  } else if (annotation.invalidated) {
836
827
  this._throttledCalculateCachedStats(
837
828
  annotation,
838
829
  viewport,
839
830
  renderingEngine,
840
- enabledElement,
841
- modalityUnitOptions
831
+ enabledElement
842
832
  );
843
833
  // If the invalidated data is as a result of volumeViewport manipulation
844
834
  // of the tools, we need to invalidate the related viewports data, so that
@@ -1013,8 +1003,7 @@ class EllipticalROITool extends AnnotationTool {
1013
1003
  annotation,
1014
1004
  viewport,
1015
1005
  renderingEngine,
1016
- enabledElement,
1017
- modalityUnitOptions: ModalityUnitOptions
1006
+ enabledElement
1018
1007
  ) => {
1019
1008
  const data = annotation.data;
1020
1009
  const { viewportId, renderingEngineId } = enabledElement;
@@ -1107,6 +1096,16 @@ class EllipticalROITool extends AnnotationTool {
1107
1096
  scale /
1108
1097
  scale;
1109
1098
 
1099
+ const modalityUnitOptions = {
1100
+ isPreScaled: isViewportPreScaled(viewport, targetId),
1101
+
1102
+ isSuvScaled: this.isSuvScaled(
1103
+ viewport,
1104
+ targetId,
1105
+ annotation.metadata.referencedImageId
1106
+ ),
1107
+ };
1108
+
1110
1109
  const modalityUnit = getModalityUnit(
1111
1110
  metadata.Modality,
1112
1111
  annotation.metadata.referencedImageId,
@@ -662,7 +662,7 @@ class LengthTool extends AnnotationTool {
662
662
  // force to recalculate the stats from the points
663
663
  if (
664
664
  !data.cachedStats[targetId] ||
665
- data.cachedStats[targetId].unit === undefined
665
+ data.cachedStats[targetId].unit == null
666
666
  ) {
667
667
  data.cachedStats[targetId] = {
668
668
  length: null,
@@ -44,14 +44,13 @@ import {
44
44
  AnnotationStyle,
45
45
  PublicToolProps,
46
46
  ToolProps,
47
- InteractionTypes,
48
47
  SVGDrawingHelper,
49
48
  } from '../../types';
50
- import { drawLine, drawCircle, drawLinkedTextBox } from '../../drawingSvg';
49
+ import { drawLinkedTextBox } from '../../drawingSvg';
51
50
  import { PlanarFreehandROIAnnotation } from '../../types/ToolSpecificAnnotationTypes';
52
51
  import { getTextBoxCoordsCanvas } from '../../utilities/drawing';
53
52
  import { PlanarFreehandROICommonData } from '../../utilities/math/polyline/planarFreehandROIInternalTypes';
54
- import pointInPolyline from '../../utilities/math/polyline/pointInPolyline';
53
+
55
54
  import { getIntersectionCoordinatesWithPolyline } from '../../utilities/math/polyline/getIntersectionWithPolyline';
56
55
  import pointInShapeCallback from '../../utilities/pointInShapeCallback';
57
56
  import { isViewportPreScaled } from '../../utilities/viewport/isViewportPreScaled';
@@ -679,20 +678,11 @@ class PlanarFreehandROITool extends AnnotationTool {
679
678
  return;
680
679
  }
681
680
 
682
- const modalityUnitOptions = {
683
- isPreScaled: isViewportPreScaled(viewport, targetId),
684
- isSuvScaled: this.isSuvScaled(
685
- viewport,
686
- targetId,
687
- annotation.metadata.referencedImageId
688
- ),
689
- };
690
-
691
681
  if (!this.commonData?.movingTextBox) {
692
682
  const { data } = annotation;
693
683
  if (
694
684
  !data.cachedStats[targetId] ||
695
- data.cachedStats[targetId].areaUnit === undefined
685
+ data.cachedStats[targetId].areaUnit == null
696
686
  ) {
697
687
  data.cachedStats[targetId] = {
698
688
  Modality: null,
@@ -707,16 +697,14 @@ class PlanarFreehandROITool extends AnnotationTool {
707
697
  annotation,
708
698
  viewport,
709
699
  renderingEngine,
710
- enabledElement,
711
- modalityUnitOptions
700
+ enabledElement
712
701
  );
713
702
  } else if (annotation.invalidated) {
714
703
  this._throttledCalculateCachedStats(
715
704
  annotation,
716
705
  viewport,
717
706
  renderingEngine,
718
- enabledElement,
719
- modalityUnitOptions
707
+ enabledElement
720
708
  );
721
709
  }
722
710
  }
@@ -731,8 +719,7 @@ class PlanarFreehandROITool extends AnnotationTool {
731
719
  annotation,
732
720
  viewport,
733
721
  renderingEngine,
734
- enabledElement,
735
- modalityUnitOptions: ModalityUnitOptions
722
+ enabledElement
736
723
  ) => {
737
724
  const data = annotation.data;
738
725
  const { cachedStats, polyline: points } = data;
@@ -752,9 +739,28 @@ class PlanarFreehandROITool extends AnnotationTool {
752
739
 
753
740
  const { imageData, metadata } = image;
754
741
  const canvasCoordinates = points.map((p) => viewport.worldToCanvas(p));
742
+
743
+ // Using an arbitrary start point (canvasPoint), calculate the
744
+ // mm spacing for the canvas in the X and Y directions.
745
+ const canvasPoint = canvasCoordinates[0];
746
+ const originalWorldPoint = viewport.canvasToWorld(canvasPoint);
747
+ const deltaXPoint = viewport.canvasToWorld([
748
+ canvasPoint[0] + 1,
749
+ canvasPoint[1],
750
+ ]);
751
+ const deltaYPoint = viewport.canvasToWorld([
752
+ canvasPoint[0],
753
+ canvasPoint[1] + 1,
754
+ ]);
755
+
756
+ const deltaInX = vec3.distance(originalWorldPoint, deltaXPoint);
757
+ const deltaInY = vec3.distance(originalWorldPoint, deltaYPoint);
758
+
755
759
  const scale = getCalibratedScale(image);
756
- const area =
760
+ let area =
757
761
  polyline.calculateAreaOfPoints(canvasCoordinates) / scale / scale;
762
+ // Convert from canvas_pixels ^2 to mm^2
763
+ area *= deltaInX * deltaInY;
758
764
 
759
765
  const worldPosIndex = csUtils.transformWorldToIndex(imageData, points[0]);
760
766
  worldPosIndex[0] = Math.floor(worldPosIndex[0]);
@@ -850,6 +856,15 @@ class PlanarFreehandROITool extends AnnotationTool {
850
856
  boundsIJK
851
857
  );
852
858
 
859
+ const modalityUnitOptions = {
860
+ isPreScaled: isViewportPreScaled(viewport, targetId),
861
+ isSuvScaled: this.isSuvScaled(
862
+ viewport,
863
+ targetId,
864
+ annotation.metadata.referencedImageId
865
+ ),
866
+ };
867
+
853
868
  const modalityUnit = getModalityUnit(
854
869
  metadata.Modality,
855
870
  annotation.metadata.referencedImageId,
@@ -442,36 +442,19 @@ class ProbeTool extends AnnotationTool {
442
442
 
443
443
  const color = this.getStyle('color', styleSpecifier, annotation);
444
444
 
445
- const modalityUnitOptions = {
446
- isPreScaled: isViewportPreScaled(viewport, targetId),
447
-
448
- isSuvScaled: this.isSuvScaled(
449
- viewport,
450
- targetId,
451
- annotation.metadata.referencedImageId
452
- ),
453
- };
454
-
455
- if (!data.cachedStats[targetId]) {
445
+ if (
446
+ !data.cachedStats[targetId] ||
447
+ data.cachedStats[targetId].value == null
448
+ ) {
456
449
  data.cachedStats[targetId] = {
457
450
  Modality: null,
458
451
  index: null,
459
452
  value: null,
460
453
  };
461
454
 
462
- this._calculateCachedStats(
463
- annotation,
464
- renderingEngine,
465
- enabledElement,
466
- modalityUnitOptions
467
- );
455
+ this._calculateCachedStats(annotation, renderingEngine, enabledElement);
468
456
  } else if (annotation.invalidated) {
469
- this._calculateCachedStats(
470
- annotation,
471
- renderingEngine,
472
- enabledElement,
473
- modalityUnitOptions
474
- );
457
+ this._calculateCachedStats(annotation, renderingEngine, enabledElement);
475
458
 
476
459
  // If the invalidated data is as a result of volumeViewport manipulation
477
460
  // of the tools, we need to invalidate the related stackViewports data if
@@ -554,14 +537,9 @@ class ProbeTool extends AnnotationTool {
554
537
  return renderStatus;
555
538
  };
556
539
 
557
- _calculateCachedStats(
558
- annotation,
559
- renderingEngine,
560
- enabledElement,
561
- modalityUnitOptions: ModalityUnitOptions
562
- ) {
540
+ _calculateCachedStats(annotation, renderingEngine, enabledElement) {
563
541
  const data = annotation.data;
564
- const { viewportId, renderingEngineId } = enabledElement;
542
+ const { viewportId, renderingEngineId, viewport } = enabledElement;
565
543
 
566
544
  const worldPos = data.handles.points[0];
567
545
  const { cachedStats } = data;
@@ -571,6 +549,15 @@ class ProbeTool extends AnnotationTool {
571
549
  for (let i = 0; i < targetIds.length; i++) {
572
550
  const targetId = targetIds[i];
573
551
 
552
+ const modalityUnitOptions = {
553
+ isPreScaled: isViewportPreScaled(viewport, targetId),
554
+ isSuvScaled: this.isSuvScaled(
555
+ viewport,
556
+ targetId,
557
+ annotation.metadata.referencedImageId
558
+ ),
559
+ };
560
+
574
561
  const image = this.getTargetIdImage(targetId, renderingEngine);
575
562
 
576
563
  // If image does not exists for the targetId, skip. This can be due
@@ -45,7 +45,6 @@ import {
45
45
  TextBoxHandle,
46
46
  ToolProps,
47
47
  PublicToolProps,
48
- InteractionTypes,
49
48
  SVGDrawingHelper,
50
49
  } from '../../types';
51
50
  import { RectangleROIAnnotation } from '../../types/ToolSpecificAnnotationTypes';
@@ -659,21 +658,11 @@ class RectangleROITool extends AnnotationTool {
659
658
 
660
659
  const { viewPlaneNormal, viewUp } = viewport.getCamera();
661
660
 
662
- const modalityUnitOptions = {
663
- isPreScaled: isViewportPreScaled(viewport, targetId),
664
-
665
- isSuvScaled: this.isSuvScaled(
666
- viewport,
667
- targetId,
668
- annotation.metadata.referencedImageId
669
- ),
670
- };
671
-
672
661
  // If cachedStats does not exist, or the unit is missing (as part of import/hydration etc.),
673
662
  // force to recalculate the stats from the points
674
663
  if (
675
664
  !data.cachedStats[targetId] ||
676
- data.cachedStats[targetId].areaUnit === undefined
665
+ data.cachedStats[targetId].areaUnit == null
677
666
  ) {
678
667
  data.cachedStats[targetId] = {
679
668
  Modality: null,
@@ -689,8 +678,7 @@ class RectangleROITool extends AnnotationTool {
689
678
  viewPlaneNormal,
690
679
  viewUp,
691
680
  renderingEngine,
692
- enabledElement,
693
- modalityUnitOptions
681
+ enabledElement
694
682
  );
695
683
  } else if (annotation.invalidated) {
696
684
  this._throttledCalculateCachedStats(
@@ -698,8 +686,7 @@ class RectangleROITool extends AnnotationTool {
698
686
  viewPlaneNormal,
699
687
  viewUp,
700
688
  renderingEngine,
701
- enabledElement,
702
- modalityUnitOptions
689
+ enabledElement
703
690
  );
704
691
 
705
692
  // If the invalidated data is as a result of volumeViewport manipulation
@@ -881,11 +868,10 @@ class RectangleROITool extends AnnotationTool {
881
868
  viewPlaneNormal,
882
869
  viewUp,
883
870
  renderingEngine,
884
- enabledElement,
885
- modalityUnitOptions
871
+ enabledElement
886
872
  ) => {
887
873
  const { data } = annotation;
888
- const { viewportId, renderingEngineId } = enabledElement;
874
+ const { viewportId, renderingEngineId, viewport } = enabledElement;
889
875
 
890
876
  const worldPos1 = data.handles.points[0];
891
877
  const worldPos2 = data.handles.points[3];
@@ -954,6 +940,16 @@ class RectangleROITool extends AnnotationTool {
954
940
 
955
941
  const area = Math.abs(worldWidth * worldHeight) / (scale * scale);
956
942
 
943
+ const modalityUnitOptions = {
944
+ isPreScaled: isViewportPreScaled(viewport, targetId),
945
+
946
+ isSuvScaled: this.isSuvScaled(
947
+ viewport,
948
+ targetId,
949
+ annotation.metadata.referencedImageId
950
+ ),
951
+ };
952
+
957
953
  const modalityUnit = getModalityUnit(
958
954
  metadata.Modality,
959
955
  annotation.metadata.referencedImageId,
@@ -102,6 +102,10 @@ abstract class AnnotationDisplayTool extends BaseTool {
102
102
 
103
103
  // for this specific tool
104
104
  toolSpecificAnnotations.forEach((annotation) => {
105
+ if (!annotation.metadata?.referencedImageId) {
106
+ return;
107
+ }
108
+
105
109
  // if the annotation is drawn on the same imageId
106
110
  const referencedImageURI = utilities.imageIdToURI(
107
111
  annotation.metadata.referencedImageId
@@ -94,7 +94,8 @@ abstract class AnnotationTool extends AnnotationDisplayTool {
94
94
  abstract toolSelectedCallback(
95
95
  evt: EventTypes.InteractionEventType,
96
96
  annotation: Annotation,
97
- interactionType: InteractionTypes
97
+ interactionType: InteractionTypes,
98
+ canvasCoords?: Types.Point2
98
99
  ): void;
99
100
 
100
101
  /**
@@ -2,6 +2,7 @@ import {
2
2
  getEnabledElementByIds,
3
3
  Types,
4
4
  utilities as csUtils,
5
+ StackViewport,
5
6
  } from '@cornerstonejs/core';
6
7
 
7
8
  import Representations from '../../../enums/SegmentationRepresentations';
@@ -128,6 +129,13 @@ async function render(
128
129
  const contourData = segmentation.representationData[Representations.Contour];
129
130
  const { geometryIds } = contourData;
130
131
 
132
+
133
+ // We don't have a good way to handle stack viewports for contours at the moment.
134
+ // Plus, if we add a segmentation to one viewport, it gets added to all the viewports in the toolGroup too.
135
+ if (viewport instanceof StackViewport) {
136
+ return;
137
+ }
138
+
131
139
  if (!geometryIds?.length) {
132
140
  console.warn(
133
141
  `No contours found for segmentationId ${segmentationId}. Skipping render.`
@@ -416,7 +416,7 @@ function _needsTransferFunctionUpdate(
416
416
  renderFill,
417
417
  renderOutline,
418
418
  outlineWidth,
419
- segmentColor,
419
+ segmentColor: segmentColor.slice(), // Create a copy
420
420
  segmentsHidden: new Set(segmentsHidden), // Create a copy
421
421
  });
422
422
 
@@ -10,7 +10,9 @@ import VolumeRotateMouseWheelTool from './VolumeRotateMouseWheelTool';
10
10
  import MIPJumpToClickTool from './MIPJumpToClickTool';
11
11
  import CrosshairsTool from './CrosshairsTool';
12
12
  import MagnifyTool from './MagnifyTool';
13
+ import AdvancedMagnifyTool from './AdvancedMagnifyTool';
13
14
  import ReferenceLinesTool from './ReferenceLinesTool';
15
+ import OverlayGridTool from './OverlayGridTool';
14
16
  //
15
17
  import BidirectionalTool from './annotation/BidirectionalTool';
16
18
  import LengthTool from './annotation/LengthTool';
@@ -38,6 +40,7 @@ import RectangleROIThresholdTool from './segmentation/RectangleROIThresholdTool'
38
40
  import RectangleROIStartEndThresholdTool from './segmentation/RectangleROIStartEndThresholdTool';
39
41
  import BrushTool from './segmentation/BrushTool';
40
42
  import PaintFillTool from './segmentation/PaintFillTool';
43
+ import OrientationMarkerTool from './OrientationMarkerTool';
41
44
 
42
45
  export {
43
46
  // ~~ BASE
@@ -58,6 +61,7 @@ export {
58
61
  // Annotation Tools
59
62
  CrosshairsTool,
60
63
  ReferenceLinesTool,
64
+ OverlayGridTool,
61
65
  BidirectionalTool,
62
66
  LengthTool,
63
67
  ProbeTool,
@@ -79,7 +83,9 @@ export {
79
83
  RectangleROIStartEndThresholdTool,
80
84
  BrushTool,
81
85
  MagnifyTool,
86
+ AdvancedMagnifyTool,
82
87
  ReferenceLines,
83
88
  PaintFillTool,
84
89
  ScaleOverlayTool,
90
+ OrientationMarkerTool,
85
91
  };
@@ -5,6 +5,7 @@ import ITouchPoints from './ITouchPoints';
5
5
  import IDistance from './IDistance';
6
6
  import { SetToolBindingsType } from './ISetToolModeOptions';
7
7
  import { Swipe } from '../enums/Touch';
8
+ import { ToolModes } from '../enums';
8
9
 
9
10
  /**
10
11
  * The normalized interaction event detail
@@ -71,6 +72,20 @@ type InteractionStartEventDetail = InteractionEventDetail;
71
72
 
72
73
  type InteractionEndEventDetail = InteractionEventDetail;
73
74
 
75
+ /**
76
+ * The data that is passed to the event handler when tool mode changes
77
+ */
78
+ type ToolModeChangedEventDetail = {
79
+ /** unique id of the toolGroup */
80
+ toolGroupId: string;
81
+ /** Tool name */
82
+ toolName: string;
83
+ /** Tool mode */
84
+ mode: ToolModes;
85
+ /** Tool binding options */
86
+ toolBindingsOptions?: SetToolBindingsType;
87
+ };
88
+
74
89
  /**
75
90
  * The data that is passed to the event handler when a tool is activated.
76
91
  */
@@ -424,6 +439,12 @@ type NormalizedMouseEventType = Types.CustomEventType<MouseCustomEventDetail>;
424
439
  */
425
440
  type NormalizedTouchEventType = Types.CustomEventType<TouchCustomEventDetail>;
426
441
 
442
+ /**
443
+ * The ToolModeChanged event type
444
+ */
445
+ type ToolModeChangedEventType =
446
+ Types.CustomEventType<ToolModeChangedEventDetail>;
447
+
427
448
  /**
428
449
  * The ToolActivated event type
429
450
  */
@@ -629,6 +650,8 @@ export {
629
650
  NormalizedInteractionEventDetail,
630
651
  NormalizedMouseEventType,
631
652
  NormalizedTouchEventType,
653
+ ToolModeChangedEventDetail,
654
+ ToolModeChangedEventType,
632
655
  ToolActivatedEventDetail,
633
656
  ToolActivatedEventType,
634
657
  AnnotationAddedEventDetail,
@@ -75,4 +75,11 @@ export default interface IToolGroup {
75
75
  getDefaultMousePrimary: {
76
76
  (): MouseBindings;
77
77
  };
78
+
79
+ clone: {
80
+ (
81
+ newToolGroupId: string,
82
+ fnToolFilter: (toolName: string) => boolean
83
+ ): IToolGroup;
84
+ };
78
85
  }
@@ -0,0 +1,54 @@
1
+ import type { Annotation } from './AnnotationTypes';
2
+ import type { InteractionEventType } from './EventTypes';
3
+ import type { SetToolBindingsType } from './ISetToolModeOptions';
4
+
5
+ /**
6
+ * An action that may be defined at the tool configuration level
7
+ *
8
+ * Annotations can have actions that run a specific task (ex: showing a dropdown
9
+ * containing a list of all predefined zoom levels - advanced magnifier glass).
10
+ * Each action must have at least one binding option (mouse button + [modifier(s)])
11
+ * and a action runs if and only if no other tool is using that same binding options
12
+ * to draw an annotation because action has lower priority.
13
+ *
14
+ * Actions are defined in the following way in a annotation tool constructor:
15
+ *
16
+ * class MyAnnotationTool extends AnnotationTool {
17
+ * constructor(
18
+ * toolProps: PublicToolProps = {},
19
+ * defaultToolProps: ToolProps = {
20
+ * configuration: {
21
+ * actions: [
22
+ * {
23
+ * method: 'myAction',
24
+ * bindings: [
25
+ * {
26
+ * mouseButton: MouseBindings.Secondary,
27
+ * modifierKey: KeyboardBindings.Shift,
28
+ * }
29
+ * ]
30
+ * }
31
+ * ]
32
+ * }
33
+ * }
34
+ * ) {
35
+ * super(toolProps, defaultToolProps);
36
+ * }
37
+ *
38
+ * public myAction(evt: EventTypes.InteractionEventType, annotation: MyAnnotation) {
39
+ * // action code
40
+ * }
41
+ * }
42
+ *
43
+ * The "method" property may be a string or a javascript function. In case it is
44
+ * a string a function with same name must exists in the tool class. In both ways
45
+ * (string or function) the function is called in the tool's context (`this`)
46
+ */
47
+ type ToolAction = {
48
+ method:
49
+ | string
50
+ | ((evt: InteractionEventType, annotation: Annotation) => void);
51
+ bindings: SetToolBindingsType[];
52
+ };
53
+
54
+ export default ToolAction;