@cornerstonejs/tools 1.43.6 → 1.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/dist/cjs/index.d.ts +2 -2
  2. package/dist/cjs/index.js +5 -2
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.d.ts +3 -1
  5. package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.js +7 -2
  6. package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.js.map +1 -1
  7. package/dist/cjs/stateManagement/segmentation/config/segmentationVisibility.d.ts +2 -1
  8. package/dist/cjs/stateManagement/segmentation/config/segmentationVisibility.js +23 -9
  9. package/dist/cjs/stateManagement/segmentation/config/segmentationVisibility.js.map +1 -1
  10. package/dist/cjs/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +14 -1
  11. package/dist/cjs/stateManagement/segmentation/helpers/normalizeSegmentationInput.js.map +1 -1
  12. package/dist/cjs/tools/annotation/AngleTool.js +4 -3
  13. package/dist/cjs/tools/annotation/AngleTool.js.map +1 -1
  14. package/dist/cjs/tools/annotation/ArrowAnnotateTool.js +4 -3
  15. package/dist/cjs/tools/annotation/ArrowAnnotateTool.js.map +1 -1
  16. package/dist/cjs/tools/annotation/BidirectionalTool.js +4 -4
  17. package/dist/cjs/tools/annotation/BidirectionalTool.js.map +1 -1
  18. package/dist/cjs/tools/annotation/CircleROITool.js +4 -3
  19. package/dist/cjs/tools/annotation/CircleROITool.js.map +1 -1
  20. package/dist/cjs/tools/annotation/CobbAngleTool.js +4 -3
  21. package/dist/cjs/tools/annotation/CobbAngleTool.js.map +1 -1
  22. package/dist/cjs/tools/annotation/DragProbeTool.js +4 -1
  23. package/dist/cjs/tools/annotation/DragProbeTool.js.map +1 -1
  24. package/dist/cjs/tools/annotation/EllipticalROITool.js +4 -3
  25. package/dist/cjs/tools/annotation/EllipticalROITool.js.map +1 -1
  26. package/dist/cjs/tools/annotation/KeyImageTool.js +4 -1
  27. package/dist/cjs/tools/annotation/KeyImageTool.js.map +1 -1
  28. package/dist/cjs/tools/annotation/LengthTool.js +4 -4
  29. package/dist/cjs/tools/annotation/LengthTool.js.map +1 -1
  30. package/dist/cjs/tools/annotation/LivewireContourSegmentationTool.d.ts +6 -0
  31. package/dist/cjs/tools/annotation/LivewireContourSegmentationTool.js +14 -0
  32. package/dist/cjs/tools/annotation/LivewireContourSegmentationTool.js.map +1 -0
  33. package/dist/cjs/tools/annotation/LivewireContourTool.d.ts +14 -5
  34. package/dist/cjs/tools/annotation/LivewireContourTool.js +126 -159
  35. package/dist/cjs/tools/annotation/LivewireContourTool.js.map +1 -1
  36. package/dist/cjs/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts +8 -0
  37. package/dist/cjs/tools/annotation/PlanarFreehandContourSegmentationTool.js +24 -0
  38. package/dist/cjs/tools/annotation/PlanarFreehandContourSegmentationTool.js.map +1 -0
  39. package/dist/cjs/tools/annotation/PlanarFreehandROITool.d.ts +16 -6
  40. package/dist/cjs/tools/annotation/PlanarFreehandROITool.js +104 -134
  41. package/dist/cjs/tools/annotation/PlanarFreehandROITool.js.map +1 -1
  42. package/dist/cjs/tools/annotation/ProbeTool.js +1 -1
  43. package/dist/cjs/tools/annotation/ProbeTool.js.map +1 -1
  44. package/dist/cjs/tools/annotation/RectangleROITool.js +4 -3
  45. package/dist/cjs/tools/annotation/RectangleROITool.js.map +1 -1
  46. package/dist/cjs/tools/annotation/SplineContourSegmentationTool.d.ts +8 -0
  47. package/dist/cjs/tools/annotation/SplineContourSegmentationTool.js +23 -0
  48. package/dist/cjs/tools/annotation/SplineContourSegmentationTool.js.map +1 -0
  49. package/dist/cjs/tools/annotation/SplineROITool.d.ts +15 -8
  50. package/dist/cjs/tools/annotation/SplineROITool.js +168 -240
  51. package/dist/cjs/tools/annotation/SplineROITool.js.map +1 -1
  52. package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +5 -5
  53. package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -1
  54. package/dist/cjs/tools/annotation/planarFreehandROITool/drawLoop.js +4 -4
  55. package/dist/cjs/tools/annotation/planarFreehandROITool/drawLoop.js.map +1 -1
  56. package/dist/cjs/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.js +1 -1
  57. package/dist/cjs/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.js.map +1 -1
  58. package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.js +7 -7
  59. package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -1
  60. package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEndEditLoop.js +1 -1
  61. package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEndEditLoop.js.map +1 -1
  62. package/dist/cjs/tools/annotation/planarFreehandROITool/renderMethods.js +19 -15
  63. package/dist/cjs/tools/annotation/planarFreehandROITool/renderMethods.js.map +1 -1
  64. package/dist/cjs/tools/base/AnnotationTool.d.ts +15 -0
  65. package/dist/cjs/tools/base/AnnotationTool.js +24 -0
  66. package/dist/cjs/tools/base/AnnotationTool.js.map +1 -1
  67. package/dist/cjs/tools/base/ContourBaseTool.d.ts +19 -0
  68. package/dist/cjs/tools/base/ContourBaseTool.js +130 -0
  69. package/dist/cjs/tools/base/ContourBaseTool.js.map +1 -0
  70. package/dist/cjs/tools/base/ContourSegmentationBaseTool.d.ts +18 -0
  71. package/dist/cjs/tools/base/ContourSegmentationBaseTool.js +139 -0
  72. package/dist/cjs/tools/base/ContourSegmentationBaseTool.js.map +1 -0
  73. package/dist/cjs/tools/displayTools/Contour/contourDisplay.js +1 -0
  74. package/dist/cjs/tools/displayTools/Contour/contourDisplay.js.map +1 -1
  75. package/dist/cjs/tools/index.d.ts +4 -1
  76. package/dist/cjs/tools/index.js +7 -1
  77. package/dist/cjs/tools/index.js.map +1 -1
  78. package/dist/cjs/types/ContourAnnotation.d.ts +11 -0
  79. package/dist/cjs/types/ContourAnnotation.js +3 -0
  80. package/dist/cjs/types/ContourAnnotation.js.map +1 -0
  81. package/dist/cjs/types/ContourSegmentationAnnotation.d.ts +11 -0
  82. package/dist/cjs/types/ContourSegmentationAnnotation.js +3 -0
  83. package/dist/cjs/types/ContourSegmentationAnnotation.js.map +1 -0
  84. package/dist/cjs/types/ContourTypes.d.ts +4 -1
  85. package/dist/cjs/types/SegmentationStateTypes.d.ts +1 -1
  86. package/dist/cjs/types/ToolSpecificAnnotationTypes.d.ts +11 -52
  87. package/dist/cjs/types/index.d.ts +3 -1
  88. package/dist/cjs/utilities/math/vec2/liangBarksyClip.d.ts +1 -1
  89. package/dist/cjs/utilities/pointInSurroundingSphereCallback.d.ts +4 -0
  90. package/dist/cjs/utilities/pointInSurroundingSphereCallback.js +70 -0
  91. package/dist/cjs/utilities/pointInSurroundingSphereCallback.js.map +1 -0
  92. package/dist/esm/index.js +2 -2
  93. package/dist/esm/index.js.map +1 -1
  94. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +7 -2
  95. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js.map +1 -1
  96. package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.js +20 -7
  97. package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.js.map +1 -1
  98. package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +13 -1
  99. package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js.map +1 -1
  100. package/dist/esm/tools/annotation/AngleTool.js +4 -3
  101. package/dist/esm/tools/annotation/AngleTool.js.map +1 -1
  102. package/dist/esm/tools/annotation/ArrowAnnotateTool.js +4 -3
  103. package/dist/esm/tools/annotation/ArrowAnnotateTool.js.map +1 -1
  104. package/dist/esm/tools/annotation/BidirectionalTool.js +4 -4
  105. package/dist/esm/tools/annotation/BidirectionalTool.js.map +1 -1
  106. package/dist/esm/tools/annotation/CircleROITool.js +4 -3
  107. package/dist/esm/tools/annotation/CircleROITool.js.map +1 -1
  108. package/dist/esm/tools/annotation/CobbAngleTool.js +4 -3
  109. package/dist/esm/tools/annotation/CobbAngleTool.js.map +1 -1
  110. package/dist/esm/tools/annotation/DragProbeTool.js +4 -1
  111. package/dist/esm/tools/annotation/DragProbeTool.js.map +1 -1
  112. package/dist/esm/tools/annotation/EllipticalROITool.js +4 -3
  113. package/dist/esm/tools/annotation/EllipticalROITool.js.map +1 -1
  114. package/dist/esm/tools/annotation/KeyImageTool.js +4 -1
  115. package/dist/esm/tools/annotation/KeyImageTool.js.map +1 -1
  116. package/dist/esm/tools/annotation/LengthTool.js +4 -4
  117. package/dist/esm/tools/annotation/LengthTool.js.map +1 -1
  118. package/dist/esm/tools/annotation/LivewireContourSegmentationTool.js +9 -0
  119. package/dist/esm/tools/annotation/LivewireContourSegmentationTool.js.map +1 -0
  120. package/dist/esm/tools/annotation/LivewireContourTool.js +123 -160
  121. package/dist/esm/tools/annotation/LivewireContourTool.js.map +1 -1
  122. package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js +19 -0
  123. package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js.map +1 -0
  124. package/dist/esm/tools/annotation/PlanarFreehandROITool.js +104 -134
  125. package/dist/esm/tools/annotation/PlanarFreehandROITool.js.map +1 -1
  126. package/dist/esm/tools/annotation/ProbeTool.js +1 -1
  127. package/dist/esm/tools/annotation/ProbeTool.js.map +1 -1
  128. package/dist/esm/tools/annotation/RectangleROITool.js +4 -3
  129. package/dist/esm/tools/annotation/RectangleROITool.js.map +1 -1
  130. package/dist/esm/tools/annotation/SplineContourSegmentationTool.js +18 -0
  131. package/dist/esm/tools/annotation/SplineContourSegmentationTool.js.map +1 -0
  132. package/dist/esm/tools/annotation/SplineROITool.js +153 -227
  133. package/dist/esm/tools/annotation/SplineROITool.js.map +1 -1
  134. package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +5 -5
  135. package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -1
  136. package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js +4 -4
  137. package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js.map +1 -1
  138. package/dist/esm/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.js +1 -1
  139. package/dist/esm/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.js.map +1 -1
  140. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js +7 -7
  141. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -1
  142. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEndEditLoop.js +1 -1
  143. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEndEditLoop.js.map +1 -1
  144. package/dist/esm/tools/annotation/planarFreehandROITool/renderMethods.js +19 -15
  145. package/dist/esm/tools/annotation/planarFreehandROITool/renderMethods.js.map +1 -1
  146. package/dist/esm/tools/base/AnnotationTool.js +24 -0
  147. package/dist/esm/tools/base/AnnotationTool.js.map +1 -1
  148. package/dist/esm/tools/base/ContourBaseTool.js +122 -0
  149. package/dist/esm/tools/base/ContourBaseTool.js.map +1 -0
  150. package/dist/esm/tools/base/ContourSegmentationBaseTool.js +131 -0
  151. package/dist/esm/tools/base/ContourSegmentationBaseTool.js.map +1 -0
  152. package/dist/esm/tools/displayTools/Contour/contourDisplay.js +1 -0
  153. package/dist/esm/tools/displayTools/Contour/contourDisplay.js.map +1 -1
  154. package/dist/esm/tools/index.js +4 -1
  155. package/dist/esm/tools/index.js.map +1 -1
  156. package/dist/esm/types/ContourAnnotation.js +2 -0
  157. package/dist/esm/types/ContourAnnotation.js.map +1 -0
  158. package/dist/esm/types/ContourSegmentationAnnotation.js +2 -0
  159. package/dist/esm/types/ContourSegmentationAnnotation.js.map +1 -0
  160. package/dist/esm/utilities/pointInSurroundingSphereCallback.js +64 -0
  161. package/dist/esm/utilities/pointInSurroundingSphereCallback.js.map +1 -0
  162. package/dist/types/index.d.ts +2 -2
  163. package/dist/types/index.d.ts.map +1 -1
  164. package/dist/types/stateManagement/segmentation/SegmentationStateManager.d.ts +3 -1
  165. package/dist/types/stateManagement/segmentation/SegmentationStateManager.d.ts.map +1 -1
  166. package/dist/types/stateManagement/segmentation/config/segmentationVisibility.d.ts +2 -1
  167. package/dist/types/stateManagement/segmentation/config/segmentationVisibility.d.ts.map +1 -1
  168. package/dist/types/stateManagement/segmentation/helpers/normalizeSegmentationInput.d.ts.map +1 -1
  169. package/dist/types/tools/annotation/AngleTool.d.ts.map +1 -1
  170. package/dist/types/tools/annotation/ArrowAnnotateTool.d.ts.map +1 -1
  171. package/dist/types/tools/annotation/CircleROITool.d.ts.map +1 -1
  172. package/dist/types/tools/annotation/CobbAngleTool.d.ts.map +1 -1
  173. package/dist/types/tools/annotation/DragProbeTool.d.ts.map +1 -1
  174. package/dist/types/tools/annotation/EllipticalROITool.d.ts.map +1 -1
  175. package/dist/types/tools/annotation/KeyImageTool.d.ts.map +1 -1
  176. package/dist/types/tools/annotation/LengthTool.d.ts.map +1 -1
  177. package/dist/types/tools/annotation/LivewireContourSegmentationTool.d.ts +7 -0
  178. package/dist/types/tools/annotation/LivewireContourSegmentationTool.d.ts.map +1 -0
  179. package/dist/types/tools/annotation/LivewireContourTool.d.ts +14 -5
  180. package/dist/types/tools/annotation/LivewireContourTool.d.ts.map +1 -1
  181. package/dist/types/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts +9 -0
  182. package/dist/types/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts.map +1 -0
  183. package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts +16 -6
  184. package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts.map +1 -1
  185. package/dist/types/tools/annotation/RectangleROITool.d.ts.map +1 -1
  186. package/dist/types/tools/annotation/SplineContourSegmentationTool.d.ts +9 -0
  187. package/dist/types/tools/annotation/SplineContourSegmentationTool.d.ts.map +1 -0
  188. package/dist/types/tools/annotation/SplineROITool.d.ts +15 -8
  189. package/dist/types/tools/annotation/SplineROITool.d.ts.map +1 -1
  190. package/dist/types/tools/annotation/planarFreehandROITool/closedContourEditLoop.d.ts.map +1 -1
  191. package/dist/types/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.d.ts.map +1 -1
  192. package/dist/types/tools/annotation/planarFreehandROITool/openContourEditLoop.d.ts.map +1 -1
  193. package/dist/types/tools/annotation/planarFreehandROITool/openContourEndEditLoop.d.ts.map +1 -1
  194. package/dist/types/tools/annotation/planarFreehandROITool/renderMethods.d.ts.map +1 -1
  195. package/dist/types/tools/base/AnnotationTool.d.ts +15 -0
  196. package/dist/types/tools/base/AnnotationTool.d.ts.map +1 -1
  197. package/dist/types/tools/base/ContourBaseTool.d.ts +20 -0
  198. package/dist/types/tools/base/ContourBaseTool.d.ts.map +1 -0
  199. package/dist/types/tools/base/ContourSegmentationBaseTool.d.ts +19 -0
  200. package/dist/types/tools/base/ContourSegmentationBaseTool.d.ts.map +1 -0
  201. package/dist/types/tools/displayTools/Contour/contourDisplay.d.ts.map +1 -1
  202. package/dist/types/tools/index.d.ts +4 -1
  203. package/dist/types/tools/index.d.ts.map +1 -1
  204. package/dist/types/types/ContourAnnotation.d.ts +12 -0
  205. package/dist/types/types/ContourAnnotation.d.ts.map +1 -0
  206. package/dist/types/types/ContourSegmentationAnnotation.d.ts +12 -0
  207. package/dist/types/types/ContourSegmentationAnnotation.d.ts.map +1 -0
  208. package/dist/types/types/ContourTypes.d.ts +4 -1
  209. package/dist/types/types/ContourTypes.d.ts.map +1 -1
  210. package/dist/types/types/SegmentationStateTypes.d.ts +1 -1
  211. package/dist/types/types/SegmentationStateTypes.d.ts.map +1 -1
  212. package/dist/types/types/ToolSpecificAnnotationTypes.d.ts +11 -52
  213. package/dist/types/types/ToolSpecificAnnotationTypes.d.ts.map +1 -1
  214. package/dist/types/types/index.d.ts +3 -1
  215. package/dist/types/types/index.d.ts.map +1 -1
  216. package/dist/types/utilities/math/vec2/liangBarksyClip.d.ts +1 -1
  217. package/dist/types/utilities/pointInSurroundingSphereCallback.d.ts +5 -0
  218. package/dist/types/utilities/pointInSurroundingSphereCallback.d.ts.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/index.ts +6 -0
  223. package/src/stateManagement/segmentation/SegmentationStateManager.ts +11 -2
  224. package/src/stateManagement/segmentation/config/segmentationVisibility.ts +52 -6
  225. package/src/stateManagement/segmentation/helpers/normalizeSegmentationInput.ts +27 -1
  226. package/src/tools/annotation/AngleTool.ts +4 -3
  227. package/src/tools/annotation/ArrowAnnotateTool.ts +4 -3
  228. package/src/tools/annotation/BidirectionalTool.ts +4 -4
  229. package/src/tools/annotation/CircleROITool.ts +4 -3
  230. package/src/tools/annotation/CobbAngleTool.ts +4 -3
  231. package/src/tools/annotation/DragProbeTool.ts +4 -1
  232. package/src/tools/annotation/EllipticalROITool.ts +4 -3
  233. package/src/tools/annotation/KeyImageTool.ts +4 -1
  234. package/src/tools/annotation/LengthTool.ts +4 -5
  235. package/src/tools/annotation/LivewireContourSegmentationTool.ts +13 -0
  236. package/src/tools/annotation/LivewireContourTool.ts +75 -150
  237. package/src/tools/annotation/PlanarFreehandContourSegmentationTool.ts +30 -0
  238. package/src/tools/annotation/PlanarFreehandROITool.ts +153 -187
  239. package/src/tools/annotation/ProbeTool.ts +1 -1
  240. package/src/tools/annotation/RectangleROITool.ts +4 -3
  241. package/src/tools/annotation/SplineContourSegmentationTool.ts +28 -0
  242. package/src/tools/annotation/SplineROITool.ts +172 -282
  243. package/src/tools/annotation/planarFreehandROITool/closedContourEditLoop.ts +7 -5
  244. package/src/tools/annotation/planarFreehandROITool/drawLoop.ts +4 -4
  245. package/src/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.ts +3 -1
  246. package/src/tools/annotation/planarFreehandROITool/openContourEditLoop.ts +12 -9
  247. package/src/tools/annotation/planarFreehandROITool/openContourEndEditLoop.ts +5 -2
  248. package/src/tools/annotation/planarFreehandROITool/renderMethods.ts +19 -14
  249. package/src/tools/base/AnnotationTool.ts +35 -0
  250. package/src/tools/base/ContourBaseTool.ts +226 -0
  251. package/src/tools/base/ContourSegmentationBaseTool.ts +276 -0
  252. package/src/tools/displayTools/Contour/contourDisplay.ts +1 -0
  253. package/src/tools/index.ts +6 -0
  254. package/src/types/ContourAnnotation.ts +13 -0
  255. package/src/types/ContourSegmentationAnnotation.ts +14 -0
  256. package/src/types/ContourTypes.ts +8 -1
  257. package/src/types/SegmentationStateTypes.ts +1 -1
  258. package/src/types/ToolSpecificAnnotationTypes.ts +17 -53
  259. package/src/types/index.ts +12 -0
  260. package/src/utilities/pointInSurroundingSphereCallback.ts +188 -0
@@ -1,5 +1,4 @@
1
- import { AnnotationTool } from '../base';
2
-
1
+ import { utilities } from '@cornerstonejs/core';
3
2
  import {
4
3
  getEnabledElement,
5
4
  eventTarget,
@@ -7,13 +6,7 @@ import {
7
6
  } from '@cornerstonejs/core';
8
7
  import type { Types } from '@cornerstonejs/core';
9
8
  import { vec3 } from 'gl-matrix';
10
- import {
11
- addAnnotation,
12
- getAnnotations,
13
- removeAnnotation,
14
- } from '../../stateManagement/annotation/annotationState';
15
- import { isAnnotationLocked } from '../../stateManagement/annotation/annotationLocking';
16
- import { isAnnotationVisible } from '../../stateManagement/annotation/annotationVisibility';
9
+ import { removeAnnotation } from '../../stateManagement/annotation/annotationState';
17
10
  import {
18
11
  drawHandles as drawHandlesSvg,
19
12
  drawPolyline as drawPolylineSvg,
@@ -23,6 +16,7 @@ import { state } from '../../store';
23
16
  import { Events, MouseBindings, KeyboardBindings } from '../../enums';
24
17
  import { resetElementCursor } from '../../cursors/elementCursor';
25
18
  import {
19
+ Annotation,
26
20
  EventTypes,
27
21
  ToolHandle,
28
22
  TextBoxHandle,
@@ -46,12 +40,12 @@ import {
46
40
  AnnotationCompletedEventDetail,
47
41
  AnnotationModifiedEventDetail,
48
42
  } from '../../types/EventTypes';
49
- import { StyleSpecifier } from '../../types/AnnotationStyle';
50
43
  import { ISpline } from '../../types/ISpline';
51
44
  import { CardinalSpline } from './splines/CardinalSpline';
52
45
  import { LinearSpline } from './splines/LinearSpline';
53
46
  import { CatmullRomSpline } from './splines/CatmullRomSpline';
54
47
  import { BSpline } from './splines/BSpline';
48
+ import ContourSegmentationBaseTool from '../base/ContourSegmentationBaseTool';
55
49
 
56
50
  const SPLINE_MIN_POINTS = 3;
57
51
  const SPLINE_CLICK_CLOSE_CURVE_DIST = 10;
@@ -77,7 +71,7 @@ enum SplineToolActions {
77
71
  DeleteControlPoint = 'deleteControlPoint',
78
72
  }
79
73
 
80
- class SplineROITool extends AnnotationTool {
74
+ class SplineROITool extends ContourSegmentationBaseTool {
81
75
  static toolName;
82
76
  static SplineTypes = SplineTypesEnum;
83
77
  static Actions = SplineToolActions;
@@ -168,71 +162,17 @@ class SplineROITool extends AnnotationTool {
168
162
  * @returns The annotation object.
169
163
  *
170
164
  */
171
- addNewAnnotation = (
172
- evt: EventTypes.InteractionEventType
173
- ): SplineROIAnnotation => {
165
+ addNewAnnotation(evt: EventTypes.InteractionEventType): SplineROIAnnotation {
174
166
  const eventDetail = evt.detail;
175
167
  const { currentPoints, element } = eventDetail;
176
- const { world: worldPos, canvas: canvasPos } = currentPoints;
168
+ const { canvas: canvasPos } = currentPoints;
177
169
 
178
170
  const enabledElement = getEnabledElement(element);
179
- const { viewport, renderingEngine } = enabledElement;
171
+ const { renderingEngine } = enabledElement;
172
+ const annotation = this.createAnnotation(evt) as SplineROIAnnotation;
180
173
 
181
174
  this.isDrawing = true;
182
-
183
- const camera = viewport.getCamera();
184
- const { viewPlaneNormal, viewUp } = camera;
185
-
186
- const { type: splineType } = this.configuration.spline;
187
- const splineConfig = this._getSplineConfig(splineType);
188
- const spline = new splineConfig.Class();
189
-
190
- const referencedImageId = this.getReferencedImageId(
191
- viewport,
192
- worldPos,
193
- viewPlaneNormal,
194
- viewUp
195
- );
196
-
197
- const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
198
-
199
- const annotation: SplineROIAnnotation = {
200
- highlighted: true,
201
- invalidated: true,
202
- metadata: {
203
- toolName: this.getToolName(),
204
- viewPlaneNormal: <Types.Point3>[...viewPlaneNormal],
205
- viewUp: <Types.Point3>[...viewUp],
206
- FrameOfReferenceUID,
207
- referencedImageId,
208
- },
209
- data: {
210
- handles: {
211
- textBox: {
212
- hasMoved: false,
213
- worldPosition: <Types.Point3>[0, 0, 0],
214
- worldBoundingBox: {
215
- topLeft: <Types.Point3>[0, 0, 0],
216
- topRight: <Types.Point3>[0, 0, 0],
217
- bottomLeft: <Types.Point3>[0, 0, 0],
218
- bottomRight: <Types.Point3>[0, 0, 0],
219
- },
220
- },
221
- points: [[...worldPos]],
222
- activeHandleIndex: null,
223
- },
224
- spline: {
225
- type: splineConfig.type,
226
- instance: spline,
227
- resolution: splineConfig.resolution,
228
- closed: false,
229
- polyline: [],
230
- },
231
- cachedStats: {},
232
- },
233
- };
234
-
235
- addAnnotation(annotation, element);
175
+ this.addAnnotation(annotation, element);
236
176
 
237
177
  const viewportIdsToRender = getViewportIdsWithToolToRender(
238
178
  element,
@@ -253,7 +193,7 @@ class SplineROITool extends AnnotationTool {
253
193
  triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
254
194
 
255
195
  return annotation;
256
- };
196
+ }
257
197
 
258
198
  /**
259
199
  * It returns if the canvas point is near the provided annotation in the provided
@@ -438,7 +378,7 @@ class SplineROITool extends AnnotationTool {
438
378
  const { annotation, viewportIdsToRender } = this.editData;
439
379
  const { data } = annotation;
440
380
 
441
- if (data.spline.closed) {
381
+ if (data.contour.closed) {
442
382
  return;
443
383
  }
444
384
 
@@ -448,7 +388,7 @@ class SplineROITool extends AnnotationTool {
448
388
  const { canvas: canvasPoint, world: worldPoint } = currentPoints;
449
389
  const enabledElement = getEnabledElement(element);
450
390
  const { renderingEngine } = enabledElement;
451
- let closeSpline = data.handles.points.length >= 2 && doubleClick;
391
+ let closeContour = data.handles.points.length >= 2 && doubleClick;
452
392
  let addNewPoint = true;
453
393
 
454
394
  // Check if user clicked on the first point to close the curve
@@ -461,7 +401,7 @@ class SplineROITool extends AnnotationTool {
461
401
 
462
402
  if (closestControlPoint?.index === 0) {
463
403
  addNewPoint = false;
464
- closeSpline = true;
404
+ closeContour = true;
465
405
  }
466
406
  }
467
407
 
@@ -469,11 +409,11 @@ class SplineROITool extends AnnotationTool {
469
409
  data.handles.points.push(worldPoint);
470
410
  }
471
411
 
472
- data.spline.closed = data.spline.closed || closeSpline;
412
+ data.contour.closed = data.contour.closed || closeContour;
473
413
  annotation.invalidated = true;
474
414
  triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
475
415
 
476
- if (data.spline.closed) {
416
+ if (data.contour.closed) {
477
417
  this._endCallback(evt);
478
418
  }
479
419
 
@@ -532,7 +472,7 @@ class SplineROITool extends AnnotationTool {
532
472
  triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
533
473
  };
534
474
 
535
- cancel = (element: HTMLDivElement) => {
475
+ cancel(element: HTMLDivElement) {
536
476
  // If it is not in mid-draw or mid-modify
537
477
  if (!this.isDrawing) {
538
478
  return;
@@ -549,6 +489,8 @@ class SplineROITool extends AnnotationTool {
549
489
  removeAnnotation(annotation.annotationUID);
550
490
  }
551
491
 
492
+ super.cancelAnnotation(annotation);
493
+
552
494
  const enabledElement = getEnabledElement(element);
553
495
  const { renderingEngine } = enabledElement;
554
496
 
@@ -556,7 +498,7 @@ class SplineROITool extends AnnotationTool {
556
498
 
557
499
  this.editData = null;
558
500
  return annotation.annotationUID;
559
- };
501
+ }
560
502
 
561
503
  /**
562
504
  * Triggers an annotation modified event.
@@ -629,226 +571,191 @@ class SplineROITool extends AnnotationTool {
629
571
  element.removeEventListener(Events.TOUCH_TAP, this._mouseDownCallback);
630
572
  };
631
573
 
574
+ protected isContourSegmentationTool(): boolean {
575
+ // Disable contour segmenatation behavior because it shall be activated only
576
+ // for SplineContourSegmentationTool
577
+ return false;
578
+ }
579
+
632
580
  /**
633
- * it is used to draw the circleROI annotation in each
634
- * request animation frame. It calculates the updated cached statistics if
635
- * data is invalidated and cache it.
636
- *
637
- * @param enabledElement - The Cornerstone's enabledElement.
638
- * @param svgDrawingHelper - The svgDrawingHelper providing the context for drawing.
581
+ * Render an annotation instance
582
+ * @param renderContext - Render context that contains the annotation, enabledElement, etc.
583
+ * @returns True if the annotation is rendered or false otherwise
639
584
  */
640
- renderAnnotation = (
641
- enabledElement: Types.IEnabledElement,
642
- svgDrawingHelper: SVGDrawingHelper
643
- ): boolean => {
644
- let renderStatus = false;
585
+ protected renderAnnotationInstance(renderContext: {
586
+ enabledElement: Types.IEnabledElement;
587
+ targetId: string;
588
+ annotation: Annotation;
589
+ annotationStyle: Record<string, any>;
590
+ svgDrawingHelper: SVGDrawingHelper;
591
+ }): boolean {
592
+ const { enabledElement, targetId, svgDrawingHelper, annotationStyle } =
593
+ renderContext;
645
594
  const { viewport } = enabledElement;
646
595
  const { worldToCanvas } = viewport;
647
596
  const { element } = viewport;
597
+ const annotation = renderContext.annotation as SplineROIAnnotation;
598
+ const { annotationUID, data, highlighted } = annotation;
599
+ const { handles } = data;
600
+ const { points: controlPoints, activeHandleIndex } = handles;
601
+ const newAnnotation = this.editData?.newAnnotation;
648
602
 
649
- // If rendering engine has been destroyed while rendering
650
- if (!viewport.getRenderingEngine()) {
651
- console.warn('Rendering Engine has been destroyed');
652
- return renderStatus;
653
- }
654
-
655
- let annotations = getAnnotations(this.getToolName(), element);
603
+ const {
604
+ lineWidth,
605
+ lineDash,
606
+ color,
607
+ locked: annotationLocked,
608
+ } = annotationStyle;
656
609
 
657
- if (!annotations?.length) {
658
- return renderStatus;
659
- }
610
+ const canvasCoordinates = controlPoints.map((p) =>
611
+ worldToCanvas(p)
612
+ ) as Types.Point2[];
660
613
 
661
- annotations = this.filterInteractableAnnotationsForElement(
662
- element,
663
- annotations
664
- );
614
+ const { drawPreviewEnabled } = this.configuration.spline;
615
+ const splineType = annotation.data.spline.type;
616
+ const splineConfig = this._getSplineConfig(splineType);
617
+ const spline = this._updateSplineInstance(element, annotation);
618
+ const splinePolylineCanvas = spline.getPolylinePoints();
619
+ const splinePolylineWorld = [];
665
620
 
666
- if (!annotations?.length) {
667
- return renderStatus;
621
+ for (let i = 0, len = splinePolylineCanvas.length; i < len; i++) {
622
+ splinePolylineWorld.push(viewport.canvasToWorld(splinePolylineCanvas[i]));
668
623
  }
669
624
 
670
- const targetId = this.getTargetId(viewport);
671
- const newAnnotation = this.editData?.newAnnotation;
672
- const styleSpecifier: StyleSpecifier = {
673
- toolGroupId: this.toolGroupId,
674
- toolName: this.getToolName(),
675
- viewportId: enabledElement.viewport.id,
676
- };
625
+ data.contour.polyline = splinePolylineWorld;
677
626
 
678
- for (let i = 0; i < annotations.length; i++) {
679
- const annotation = annotations[i] as SplineROIAnnotation;
680
- const { annotationUID, data, highlighted } = annotation;
681
- const { handles } = data;
682
- const { points: controlPoints, activeHandleIndex } = handles;
683
-
684
- styleSpecifier.annotationUID = annotationUID;
685
-
686
- const lineWidth = this.getStyle(
687
- 'lineWidth',
688
- styleSpecifier,
689
- annotation
690
- ) as number;
691
- const lineDash = this.getStyle(
692
- 'lineDash',
693
- styleSpecifier,
694
- annotation
695
- ) as string;
696
- const color = this.getStyle(
697
- 'color',
698
- styleSpecifier,
699
- annotation
700
- ) as string;
701
-
702
- const canvasCoordinates = controlPoints.map((p) =>
703
- worldToCanvas(p)
704
- ) as Types.Point2[];
705
-
706
- const { drawPreviewEnabled } = this.configuration.spline;
707
- const splineType = annotation.data.spline.type;
708
- const splineConfig = this._getSplineConfig(splineType);
709
- const spline = this._updateSplineInstance(element, annotation);
710
- const splinePolylineCanvas = spline.getPolylinePoints();
711
- const splinePolylineWorld = [];
712
-
713
- for (let i = 0, len = splinePolylineCanvas.length; i < len; i++) {
714
- splinePolylineWorld.push(
715
- viewport.canvasToWorld(splinePolylineCanvas[i])
716
- );
717
- }
627
+ // Let the base class render the contour
628
+ super.renderAnnotationInstance(renderContext);
718
629
 
719
- data.spline.polyline = splinePolylineWorld;
720
-
721
- // If cachedStats does not exist, or the areaUnit is missing (as part of
722
- // import/hydration etc.), force to recalculate the stats from the points
723
- if (
724
- !data.cachedStats[targetId] ||
725
- data.cachedStats[targetId].areaUnit == null
726
- ) {
727
- data.cachedStats[targetId] = {
728
- Modality: null,
729
- area: null,
730
- areaUnit: null,
731
- };
732
-
733
- this._calculateCachedStats(annotation, element);
734
- } else if (annotation.invalidated) {
735
- this._throttledCalculateCachedStats(annotation, element);
736
- }
630
+ // If cachedStats does not exist, or the areaUnit is missing (as part of
631
+ // import/hydration etc.), force to recalculate the stats from the points
632
+ if (
633
+ !data.cachedStats[targetId] ||
634
+ data.cachedStats[targetId].areaUnit == null
635
+ ) {
636
+ data.cachedStats[targetId] = {
637
+ Modality: null,
638
+ area: null,
639
+ areaUnit: null,
640
+ };
737
641
 
738
- let activeHandleCanvasCoords;
642
+ this._calculateCachedStats(annotation, element);
643
+ } else if (annotation.invalidated) {
644
+ this._throttledCalculateCachedStats(annotation, element);
645
+ }
739
646
 
740
- if (!isAnnotationVisible(annotationUID)) {
741
- continue;
742
- }
647
+ let activeHandleCanvasCoords;
743
648
 
744
- if (
745
- !isAnnotationLocked(annotation) &&
746
- !this.editData &&
747
- activeHandleIndex !== null
748
- ) {
749
- // Not locked or creating and hovering over handle, so render handle.
750
- activeHandleCanvasCoords = [canvasCoordinates[activeHandleIndex]];
751
- }
649
+ if (!annotationLocked && !this.editData && activeHandleIndex !== null) {
650
+ // Not locked or creating and hovering over handle, so render handle.
651
+ activeHandleCanvasCoords = [canvasCoordinates[activeHandleIndex]];
652
+ }
752
653
 
753
- if (activeHandleCanvasCoords || newAnnotation || highlighted) {
754
- const handleGroupUID = '0';
755
- drawHandlesSvg(
756
- svgDrawingHelper,
757
- annotationUID,
758
- handleGroupUID,
759
- canvasCoordinates,
760
- {
761
- color,
762
- lineDash,
763
- lineWidth,
764
- handleRadius: '3',
765
- }
766
- );
767
- }
654
+ if (activeHandleCanvasCoords || newAnnotation || highlighted) {
655
+ const handleGroupUID = '0';
768
656
 
769
- if (
770
- drawPreviewEnabled &&
771
- spline.numControlPoints > 1 &&
772
- this.editData?.lastCanvasPoint &&
773
- !spline.closed
774
- ) {
775
- const { lastCanvasPoint } = this.editData;
776
- const previewPolylinePoints = spline.getPreviewPolylinePoints(
777
- lastCanvasPoint,
778
- SPLINE_CLICK_CLOSE_CURVE_DIST
779
- );
780
-
781
- drawPolylineSvg(
782
- svgDrawingHelper,
783
- annotationUID,
784
- 'previewSplineChange',
785
- previewPolylinePoints,
786
- {
787
- color: '#9EA0CA',
788
- lineDash,
789
- lineWidth,
790
- }
791
- );
792
- }
657
+ // Move this call to the base class (contour seg) in the near future
658
+ drawHandlesSvg(
659
+ svgDrawingHelper,
660
+ annotationUID,
661
+ handleGroupUID,
662
+ canvasCoordinates,
663
+ {
664
+ color,
665
+ lineWidth: Math.max(1, lineWidth),
666
+ handleRadius: '3',
667
+ }
668
+ );
669
+ }
793
670
 
794
- if (splineConfig.showControlPointsConnectors) {
795
- const controlPointsConnectors = [...canvasCoordinates];
671
+ if (
672
+ drawPreviewEnabled &&
673
+ spline.numControlPoints > 1 &&
674
+ this.editData?.lastCanvasPoint &&
675
+ !spline.closed
676
+ ) {
677
+ const { lastCanvasPoint } = this.editData;
678
+ const previewPolylinePoints = spline.getPreviewPolylinePoints(
679
+ lastCanvasPoint,
680
+ SPLINE_CLICK_CLOSE_CURVE_DIST
681
+ );
796
682
 
797
- // Connect the last point to the first one when the spline is closed
798
- if (spline.closed) {
799
- controlPointsConnectors.push(canvasCoordinates[0]);
683
+ drawPolylineSvg(
684
+ svgDrawingHelper,
685
+ annotationUID,
686
+ 'previewSplineChange',
687
+ previewPolylinePoints,
688
+ {
689
+ color: '#9EA0CA',
690
+ lineDash,
691
+ lineWidth: 1,
800
692
  }
693
+ );
694
+ }
801
695
 
802
- drawPolylineSvg(
803
- svgDrawingHelper,
804
- annotationUID,
805
- 'controlPointsConnectors',
806
- controlPointsConnectors,
807
- {
808
- color: 'rgba(255, 255, 255, 0.5)',
809
- lineDash,
810
- lineWidth,
811
- }
812
- );
696
+ if (splineConfig.showControlPointsConnectors) {
697
+ const controlPointsConnectors = [...canvasCoordinates];
698
+
699
+ // Connect the last point to the first one when the spline is closed
700
+ if (spline.closed) {
701
+ controlPointsConnectors.push(canvasCoordinates[0]);
813
702
  }
814
703
 
815
704
  drawPolylineSvg(
816
705
  svgDrawingHelper,
817
706
  annotationUID,
818
- 'lineSegments',
819
- splinePolylineCanvas,
707
+ 'controlPointsConnectors',
708
+ controlPointsConnectors,
820
709
  {
821
- color,
822
- lineDash,
823
- lineWidth,
710
+ color: 'rgba(255, 255, 255, 0.5)',
711
+ lineWidth: 1,
824
712
  }
825
713
  );
714
+ }
826
715
 
827
- this._renderStats(annotation, viewport, enabledElement, svgDrawingHelper);
716
+ this._renderStats(
717
+ annotation,
718
+ viewport,
719
+ svgDrawingHelper,
720
+ annotationStyle.textbox
721
+ );
828
722
 
829
- renderStatus = true;
830
- annotation.invalidated = false;
831
- }
723
+ annotation.invalidated = false;
724
+ return true;
725
+ }
832
726
 
833
- return renderStatus;
834
- };
727
+ protected createAnnotation(evt: EventTypes.InteractionEventType): Annotation {
728
+ const contourAnnotation = super.createAnnotation(evt);
729
+ const { world: worldPos } = evt.detail.currentPoints;
730
+ const { type: splineType } = this.configuration.spline;
731
+ const splineConfig = this._getSplineConfig(splineType);
732
+ const spline = new splineConfig.Class();
733
+
734
+ return <SplineROIAnnotation>utilities.deepMerge(contourAnnotation, {
735
+ data: {
736
+ handles: {
737
+ points: [[...worldPos]],
738
+ },
739
+ spline: {
740
+ type: splineConfig.type,
741
+ instance: spline,
742
+ resolution: splineConfig.resolution,
743
+ },
744
+ cachedStats: {},
745
+ },
746
+ });
747
+ }
835
748
 
836
- _renderStats = (annotation, viewport, enabledElement, svgDrawingHelper) => {
749
+ private _renderStats = (
750
+ annotation,
751
+ viewport,
752
+ svgDrawingHelper,
753
+ textboxStyle
754
+ ) => {
837
755
  const data = annotation.data;
838
756
  const targetId = this.getTargetId(viewport);
839
757
 
840
- if (!data.spline.closed) {
841
- return;
842
- }
843
-
844
- const styleSpecifier: StyleSpecifier = {
845
- toolGroupId: this.toolGroupId,
846
- toolName: this.getToolName(),
847
- viewportId: enabledElement.viewport.id,
848
- };
849
-
850
- const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
851
- if (!options.visibility) {
758
+ if (!data.spline.closed || !textboxStyle.visibility) {
852
759
  return;
853
760
  }
854
761
 
@@ -880,7 +787,7 @@ class SplineROITool extends AnnotationTool {
880
787
  textBoxPosition,
881
788
  canvasCoordinates,
882
789
  {},
883
- options
790
+ textboxStyle
884
791
  );
885
792
 
886
793
  const { x: left, y: top, width, height } = boundingBox;
@@ -1007,23 +914,6 @@ class SplineROITool extends AnnotationTool {
1007
914
  return Object.assign({ type }, DEFAULT_SPLINE_CONFIG, splineConfigs[type]);
1008
915
  }
1009
916
 
1010
- private _updateSplineScale(spline: ISpline, annotation: SplineROIAnnotation) {
1011
- const splineType = annotation.data.spline.type;
1012
- const splineConfig = this._getSplineConfig(splineType);
1013
-
1014
- if (
1015
- !(spline instanceof CardinalSpline) ||
1016
- spline.fixedScale ||
1017
- splineConfig.scale === undefined ||
1018
- spline.scale === splineConfig.scale
1019
- ) {
1020
- return;
1021
- }
1022
-
1023
- spline.scale = splineConfig.scale;
1024
- annotation.invalidated = true;
1025
- }
1026
-
1027
917
  private _updateSplineInstance(
1028
918
  element: HTMLDivElement,
1029
919
  annotation: SplineROIAnnotation
@@ -1038,7 +928,7 @@ class SplineROITool extends AnnotationTool {
1038
928
  const canvasPoints = worldPoints.map(worldToCanvas);
1039
929
 
1040
930
  spline.setControlPoints(canvasPoints);
1041
- spline.closed = !!data.spline?.closed;
931
+ spline.closed = !!data.contour.closed;
1042
932
 
1043
933
  // Update spline resolution in case it has changed
1044
934
  if (spline.resolution !== splineConfig.resolution) {
@@ -1069,14 +959,14 @@ class SplineROITool extends AnnotationTool {
1069
959
  }
1070
960
  const data = annotation.data;
1071
961
 
1072
- if (!data.spline.closed) {
962
+ if (!data.contour.closed) {
1073
963
  return;
1074
964
  }
1075
965
 
1076
966
  const enabledElement = getEnabledElement(element);
1077
967
  const { viewport, renderingEngine } = enabledElement;
1078
968
  const { cachedStats } = data;
1079
- const { polyline: points } = data.spline;
969
+ const { polyline: points } = data.contour;
1080
970
  const targetIds = Object.keys(cachedStats);
1081
971
 
1082
972
  for (let i = 0; i < targetIds.length; i++) {
@@ -38,7 +38,9 @@ function activateClosedContourEdit(
38
38
  const enabledElement = getEnabledElement(element);
39
39
  const { viewport } = enabledElement;
40
40
 
41
- const prevCanvasPoints = annotation.data.polyline.map(viewport.worldToCanvas);
41
+ const prevCanvasPoints = annotation.data.contour.polyline.map(
42
+ viewport.worldToCanvas
43
+ );
42
44
 
43
45
  const { spacing, xDir, yDir } = getSubPixelSpacingAndXYDirections(
44
46
  viewport,
@@ -223,8 +225,8 @@ function finishEditAndStartNewEdit(evt: EventTypes.InteractionEventType): void {
223
225
  viewport.canvasToWorld(canvasPoint)
224
226
  );
225
227
 
226
- annotation.data.polyline = worldPoints;
227
- annotation.data.isOpenContour = false;
228
+ annotation.data.contour.polyline = worldPoints;
229
+ annotation.data.contour.closed = true;
228
230
 
229
231
  this.triggerAnnotationModified(annotation, enabledElement);
230
232
 
@@ -441,8 +443,8 @@ function completeClosedContourEdit(element: HTMLDivElement) {
441
443
  const worldPoints = updatedPoints.map((canvasPoint) =>
442
444
  viewport.canvasToWorld(canvasPoint)
443
445
  );
444
- annotation.data.polyline = worldPoints;
445
- annotation.data.isOpenContour = false;
446
+ annotation.data.contour.polyline = worldPoints;
447
+ annotation.data.contour.closed = true;
446
448
 
447
449
  annotation.invalidated = true;
448
450
 
@@ -227,8 +227,8 @@ function completeDrawClosedContour(element: HTMLDivElement): boolean {
227
227
  viewport.canvasToWorld(canvasPoint)
228
228
  );
229
229
 
230
- annotation.data.polyline = worldPoints;
231
- annotation.data.isOpenContour = false;
230
+ annotation.data.contour.polyline = worldPoints;
231
+ annotation.data.contour.closed = true;
232
232
  const { textBox } = annotation.data.handles;
233
233
 
234
234
  if (!textBox.hasMoved) {
@@ -297,8 +297,8 @@ function completeDrawOpenContour(element: HTMLDivElement): boolean {
297
297
  viewport.canvasToWorld(canvasPoint)
298
298
  );
299
299
 
300
- annotation.data.polyline = worldPoints;
301
- annotation.data.isOpenContour = true;
300
+ annotation.data.contour.polyline = worldPoints;
301
+ annotation.data.contour.closed = false;
302
302
  const { textBox } = annotation.data.handles;
303
303
 
304
304
  // Add the first and last points to the list of handles. These means they