@cornerstonejs/tools 1.43.7 → 1.44.1

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 (252) 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/esm/index.js +2 -2
  90. package/dist/esm/index.js.map +1 -1
  91. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +7 -2
  92. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js.map +1 -1
  93. package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.js +20 -7
  94. package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.js.map +1 -1
  95. package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +13 -1
  96. package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js.map +1 -1
  97. package/dist/esm/tools/annotation/AngleTool.js +4 -3
  98. package/dist/esm/tools/annotation/AngleTool.js.map +1 -1
  99. package/dist/esm/tools/annotation/ArrowAnnotateTool.js +4 -3
  100. package/dist/esm/tools/annotation/ArrowAnnotateTool.js.map +1 -1
  101. package/dist/esm/tools/annotation/BidirectionalTool.js +4 -4
  102. package/dist/esm/tools/annotation/BidirectionalTool.js.map +1 -1
  103. package/dist/esm/tools/annotation/CircleROITool.js +4 -3
  104. package/dist/esm/tools/annotation/CircleROITool.js.map +1 -1
  105. package/dist/esm/tools/annotation/CobbAngleTool.js +4 -3
  106. package/dist/esm/tools/annotation/CobbAngleTool.js.map +1 -1
  107. package/dist/esm/tools/annotation/DragProbeTool.js +4 -1
  108. package/dist/esm/tools/annotation/DragProbeTool.js.map +1 -1
  109. package/dist/esm/tools/annotation/EllipticalROITool.js +4 -3
  110. package/dist/esm/tools/annotation/EllipticalROITool.js.map +1 -1
  111. package/dist/esm/tools/annotation/KeyImageTool.js +4 -1
  112. package/dist/esm/tools/annotation/KeyImageTool.js.map +1 -1
  113. package/dist/esm/tools/annotation/LengthTool.js +4 -4
  114. package/dist/esm/tools/annotation/LengthTool.js.map +1 -1
  115. package/dist/esm/tools/annotation/LivewireContourSegmentationTool.js +9 -0
  116. package/dist/esm/tools/annotation/LivewireContourSegmentationTool.js.map +1 -0
  117. package/dist/esm/tools/annotation/LivewireContourTool.js +123 -160
  118. package/dist/esm/tools/annotation/LivewireContourTool.js.map +1 -1
  119. package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js +19 -0
  120. package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js.map +1 -0
  121. package/dist/esm/tools/annotation/PlanarFreehandROITool.js +104 -134
  122. package/dist/esm/tools/annotation/PlanarFreehandROITool.js.map +1 -1
  123. package/dist/esm/tools/annotation/ProbeTool.js +1 -1
  124. package/dist/esm/tools/annotation/ProbeTool.js.map +1 -1
  125. package/dist/esm/tools/annotation/RectangleROITool.js +4 -3
  126. package/dist/esm/tools/annotation/RectangleROITool.js.map +1 -1
  127. package/dist/esm/tools/annotation/SplineContourSegmentationTool.js +18 -0
  128. package/dist/esm/tools/annotation/SplineContourSegmentationTool.js.map +1 -0
  129. package/dist/esm/tools/annotation/SplineROITool.js +153 -227
  130. package/dist/esm/tools/annotation/SplineROITool.js.map +1 -1
  131. package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +5 -5
  132. package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -1
  133. package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js +4 -4
  134. package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js.map +1 -1
  135. package/dist/esm/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.js +1 -1
  136. package/dist/esm/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.js.map +1 -1
  137. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js +7 -7
  138. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -1
  139. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEndEditLoop.js +1 -1
  140. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEndEditLoop.js.map +1 -1
  141. package/dist/esm/tools/annotation/planarFreehandROITool/renderMethods.js +19 -15
  142. package/dist/esm/tools/annotation/planarFreehandROITool/renderMethods.js.map +1 -1
  143. package/dist/esm/tools/base/AnnotationTool.js +24 -0
  144. package/dist/esm/tools/base/AnnotationTool.js.map +1 -1
  145. package/dist/esm/tools/base/ContourBaseTool.js +122 -0
  146. package/dist/esm/tools/base/ContourBaseTool.js.map +1 -0
  147. package/dist/esm/tools/base/ContourSegmentationBaseTool.js +131 -0
  148. package/dist/esm/tools/base/ContourSegmentationBaseTool.js.map +1 -0
  149. package/dist/esm/tools/displayTools/Contour/contourDisplay.js +1 -0
  150. package/dist/esm/tools/displayTools/Contour/contourDisplay.js.map +1 -1
  151. package/dist/esm/tools/index.js +4 -1
  152. package/dist/esm/tools/index.js.map +1 -1
  153. package/dist/esm/types/ContourAnnotation.js +2 -0
  154. package/dist/esm/types/ContourAnnotation.js.map +1 -0
  155. package/dist/esm/types/ContourSegmentationAnnotation.js +2 -0
  156. package/dist/esm/types/ContourSegmentationAnnotation.js.map +1 -0
  157. package/dist/types/index.d.ts +2 -2
  158. package/dist/types/index.d.ts.map +1 -1
  159. package/dist/types/stateManagement/segmentation/SegmentationStateManager.d.ts +3 -1
  160. package/dist/types/stateManagement/segmentation/SegmentationStateManager.d.ts.map +1 -1
  161. package/dist/types/stateManagement/segmentation/config/segmentationVisibility.d.ts +2 -1
  162. package/dist/types/stateManagement/segmentation/config/segmentationVisibility.d.ts.map +1 -1
  163. package/dist/types/stateManagement/segmentation/helpers/normalizeSegmentationInput.d.ts.map +1 -1
  164. package/dist/types/tools/annotation/AngleTool.d.ts.map +1 -1
  165. package/dist/types/tools/annotation/ArrowAnnotateTool.d.ts.map +1 -1
  166. package/dist/types/tools/annotation/CircleROITool.d.ts.map +1 -1
  167. package/dist/types/tools/annotation/CobbAngleTool.d.ts.map +1 -1
  168. package/dist/types/tools/annotation/DragProbeTool.d.ts.map +1 -1
  169. package/dist/types/tools/annotation/EllipticalROITool.d.ts.map +1 -1
  170. package/dist/types/tools/annotation/KeyImageTool.d.ts.map +1 -1
  171. package/dist/types/tools/annotation/LengthTool.d.ts.map +1 -1
  172. package/dist/types/tools/annotation/LivewireContourSegmentationTool.d.ts +7 -0
  173. package/dist/types/tools/annotation/LivewireContourSegmentationTool.d.ts.map +1 -0
  174. package/dist/types/tools/annotation/LivewireContourTool.d.ts +14 -5
  175. package/dist/types/tools/annotation/LivewireContourTool.d.ts.map +1 -1
  176. package/dist/types/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts +9 -0
  177. package/dist/types/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts.map +1 -0
  178. package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts +16 -6
  179. package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts.map +1 -1
  180. package/dist/types/tools/annotation/RectangleROITool.d.ts.map +1 -1
  181. package/dist/types/tools/annotation/SplineContourSegmentationTool.d.ts +9 -0
  182. package/dist/types/tools/annotation/SplineContourSegmentationTool.d.ts.map +1 -0
  183. package/dist/types/tools/annotation/SplineROITool.d.ts +15 -8
  184. package/dist/types/tools/annotation/SplineROITool.d.ts.map +1 -1
  185. package/dist/types/tools/annotation/planarFreehandROITool/closedContourEditLoop.d.ts.map +1 -1
  186. package/dist/types/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.d.ts.map +1 -1
  187. package/dist/types/tools/annotation/planarFreehandROITool/openContourEditLoop.d.ts.map +1 -1
  188. package/dist/types/tools/annotation/planarFreehandROITool/openContourEndEditLoop.d.ts.map +1 -1
  189. package/dist/types/tools/annotation/planarFreehandROITool/renderMethods.d.ts.map +1 -1
  190. package/dist/types/tools/base/AnnotationTool.d.ts +15 -0
  191. package/dist/types/tools/base/AnnotationTool.d.ts.map +1 -1
  192. package/dist/types/tools/base/ContourBaseTool.d.ts +20 -0
  193. package/dist/types/tools/base/ContourBaseTool.d.ts.map +1 -0
  194. package/dist/types/tools/base/ContourSegmentationBaseTool.d.ts +19 -0
  195. package/dist/types/tools/base/ContourSegmentationBaseTool.d.ts.map +1 -0
  196. package/dist/types/tools/displayTools/Contour/contourDisplay.d.ts.map +1 -1
  197. package/dist/types/tools/index.d.ts +4 -1
  198. package/dist/types/tools/index.d.ts.map +1 -1
  199. package/dist/types/types/ContourAnnotation.d.ts +12 -0
  200. package/dist/types/types/ContourAnnotation.d.ts.map +1 -0
  201. package/dist/types/types/ContourSegmentationAnnotation.d.ts +12 -0
  202. package/dist/types/types/ContourSegmentationAnnotation.d.ts.map +1 -0
  203. package/dist/types/types/ContourTypes.d.ts +4 -1
  204. package/dist/types/types/ContourTypes.d.ts.map +1 -1
  205. package/dist/types/types/SegmentationStateTypes.d.ts +1 -1
  206. package/dist/types/types/SegmentationStateTypes.d.ts.map +1 -1
  207. package/dist/types/types/ToolSpecificAnnotationTypes.d.ts +11 -52
  208. package/dist/types/types/ToolSpecificAnnotationTypes.d.ts.map +1 -1
  209. package/dist/types/types/index.d.ts +3 -1
  210. package/dist/types/types/index.d.ts.map +1 -1
  211. package/dist/types/utilities/math/vec2/liangBarksyClip.d.ts +1 -1
  212. package/dist/umd/index.js +1 -1
  213. package/dist/umd/index.js.map +1 -1
  214. package/package.json +3 -3
  215. package/src/index.ts +6 -0
  216. package/src/stateManagement/segmentation/SegmentationStateManager.ts +11 -2
  217. package/src/stateManagement/segmentation/config/segmentationVisibility.ts +52 -6
  218. package/src/stateManagement/segmentation/helpers/normalizeSegmentationInput.ts +27 -1
  219. package/src/tools/annotation/AngleTool.ts +4 -3
  220. package/src/tools/annotation/ArrowAnnotateTool.ts +4 -3
  221. package/src/tools/annotation/BidirectionalTool.ts +4 -4
  222. package/src/tools/annotation/CircleROITool.ts +4 -3
  223. package/src/tools/annotation/CobbAngleTool.ts +4 -3
  224. package/src/tools/annotation/DragProbeTool.ts +4 -1
  225. package/src/tools/annotation/EllipticalROITool.ts +4 -3
  226. package/src/tools/annotation/KeyImageTool.ts +4 -1
  227. package/src/tools/annotation/LengthTool.ts +4 -5
  228. package/src/tools/annotation/LivewireContourSegmentationTool.ts +13 -0
  229. package/src/tools/annotation/LivewireContourTool.ts +75 -150
  230. package/src/tools/annotation/PlanarFreehandContourSegmentationTool.ts +30 -0
  231. package/src/tools/annotation/PlanarFreehandROITool.ts +153 -187
  232. package/src/tools/annotation/ProbeTool.ts +1 -1
  233. package/src/tools/annotation/RectangleROITool.ts +4 -3
  234. package/src/tools/annotation/SplineContourSegmentationTool.ts +28 -0
  235. package/src/tools/annotation/SplineROITool.ts +172 -282
  236. package/src/tools/annotation/planarFreehandROITool/closedContourEditLoop.ts +7 -5
  237. package/src/tools/annotation/planarFreehandROITool/drawLoop.ts +4 -4
  238. package/src/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.ts +3 -1
  239. package/src/tools/annotation/planarFreehandROITool/openContourEditLoop.ts +12 -9
  240. package/src/tools/annotation/planarFreehandROITool/openContourEndEditLoop.ts +5 -2
  241. package/src/tools/annotation/planarFreehandROITool/renderMethods.ts +19 -14
  242. package/src/tools/base/AnnotationTool.ts +35 -0
  243. package/src/tools/base/ContourBaseTool.ts +226 -0
  244. package/src/tools/base/ContourSegmentationBaseTool.ts +276 -0
  245. package/src/tools/displayTools/Contour/contourDisplay.ts +1 -0
  246. package/src/tools/index.ts +6 -0
  247. package/src/types/ContourAnnotation.ts +13 -0
  248. package/src/types/ContourSegmentationAnnotation.ts +14 -0
  249. package/src/types/ContourTypes.ts +8 -1
  250. package/src/types/SegmentationStateTypes.ts +1 -1
  251. package/src/types/ToolSpecificAnnotationTypes.ts +17 -53
  252. package/src/types/index.ts +12 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "1.43.7",
3
+ "version": "1.44.1",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "main": "src/index.ts",
6
6
  "types": "dist/types/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  "webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
30
30
  },
31
31
  "dependencies": {
32
- "@cornerstonejs/core": "^1.43.7",
32
+ "@cornerstonejs/core": "^1.44.1",
33
33
  "comlink": "^4.4.1",
34
34
  "lodash.clonedeep": "4.5.0",
35
35
  "lodash.get": "^4.4.2"
@@ -53,5 +53,5 @@
53
53
  "type": "individual",
54
54
  "url": "https://ohif.org/donate"
55
55
  },
56
- "gitHead": "2d0c559929aa0524bf303922230ded50ac0ef1df"
56
+ "gitHead": "0cc7cbccd489e63dbea1a855fbb72d87792b6f89"
57
57
  }
package/src/index.ts CHANGED
@@ -40,9 +40,12 @@ import {
40
40
  EllipticalROITool,
41
41
  CircleROITool,
42
42
  SplineROITool,
43
+ SplineContourSegmentationTool,
43
44
  BidirectionalTool,
44
45
  PlanarFreehandROITool,
46
+ PlanarFreehandContourSegmentationTool,
45
47
  LivewireContourTool,
48
+ LivewireContourSegmentationTool,
46
49
  ArrowAnnotateTool,
47
50
  KeyImageTool,
48
51
  CrosshairsTool,
@@ -107,9 +110,12 @@ export {
107
110
  EllipticalROITool,
108
111
  CircleROITool,
109
112
  SplineROITool,
113
+ SplineContourSegmentationTool,
110
114
  BidirectionalTool,
111
115
  PlanarFreehandROITool,
116
+ PlanarFreehandContourSegmentationTool,
112
117
  LivewireContourTool,
118
+ LivewireContourSegmentationTool,
113
119
  ArrowAnnotateTool,
114
120
  AngleTool,
115
121
  CobbAngleTool,
@@ -382,7 +382,10 @@ export default class SegmentationStateManager {
382
382
  setSegmentSpecificConfig(
383
383
  toolGroupId: string,
384
384
  segmentationRepresentationUID: string,
385
- config: SegmentSpecificRepresentationConfig
385
+ config: SegmentSpecificRepresentationConfig,
386
+ options?: {
387
+ clear: false;
388
+ }
386
389
  ): void {
387
390
  const segmentationRepresentation = this.getSegmentationRepresentationByUID(
388
391
  toolGroupId,
@@ -393,7 +396,13 @@ export default class SegmentationStateManager {
393
396
  return;
394
397
  }
395
398
 
396
- segmentationRepresentation.segmentSpecificConfig = config;
399
+ if (!segmentationRepresentation.segmentSpecificConfig || options?.clear) {
400
+ segmentationRepresentation.segmentSpecificConfig = {};
401
+ }
402
+
403
+ Object.keys(config).forEach((key) => {
404
+ segmentationRepresentation.segmentSpecificConfig[key] = config[key];
405
+ });
397
406
  }
398
407
 
399
408
  /**
@@ -5,7 +5,7 @@ import { ToolGroupSpecificRepresentation } from '../../../types/SegmentationStat
5
5
  import { triggerSegmentationRepresentationModified } from '../triggerSegmentationEvents';
6
6
  import SegmentationRepresentations from '../../../enums/SegmentationRepresentations';
7
7
 
8
- function getSegmentationIndices(segmentationId) {
8
+ function getUniqueSegmentIndices(segmentationId) {
9
9
  const segmentation = SegmentationState.getSegmentation(segmentationId);
10
10
 
11
11
  if (segmentation.type === SegmentationRepresentations.Labelmap) {
@@ -21,6 +21,10 @@ function getSegmentationIndices(segmentationId) {
21
21
  }
22
22
  return Object.keys(keySet).map((it) => parseInt(it, 10));
23
23
  } else if (segmentation.type === SegmentationRepresentations.Contour) {
24
+ const annotationUIDsMap =
25
+ segmentation.representationData.CONTOUR?.annotationUIDsMap;
26
+
27
+ const indices = new Set(annotationUIDsMap.keys());
24
28
  const geometryIds = segmentation.representationData.CONTOUR?.geometryIds;
25
29
 
26
30
  if (!geometryIds) {
@@ -29,10 +33,12 @@ function getSegmentationIndices(segmentationId) {
29
33
  );
30
34
  }
31
35
 
32
- return geometryIds.map((geometryId) => {
36
+ geometryIds.forEach((geometryId) => {
33
37
  const geometry = cache.getGeometry(geometryId) as Types.IGeometry;
34
- return (geometry.data as Types.IContourSet).getSegmentIndex();
38
+ indices.add((geometry.data as Types.IContourSet).getSegmentIndex());
35
39
  });
40
+
41
+ return Array.from(indices.values()).sort();
36
42
  }
37
43
  }
38
44
 
@@ -70,7 +76,7 @@ function setSegmentationVisibility(
70
76
 
71
77
  const { segmentsHidden, segmentationId } = representation;
72
78
 
73
- const indices = getSegmentationIndices(segmentationId);
79
+ const indices = getUniqueSegmentIndices(segmentationId);
74
80
 
75
81
  // if visibility is set to be true, we need to remove all the segments
76
82
  // from the segmentsHidden set, otherwise we need to add all the segments
@@ -115,9 +121,17 @@ function getSegmentationVisibility(
115
121
  return;
116
122
  }
117
123
 
118
- const { segmentsHidden } = representation;
124
+ const { segmentsHidden, segmentationId } = representation;
125
+ const indices = getUniqueSegmentIndices(segmentationId);
126
+
127
+ // Create a set that contains all segments indices
128
+ const indicesSet = new Set(indices);
129
+
130
+ // Remove a indices that are hidden
131
+ segmentsHidden.forEach((segmentIndex) => indicesSet.delete(segmentIndex));
119
132
 
120
- return segmentsHidden.size === 0;
133
+ // Check if there is at least one segment visible
134
+ return !!indicesSet.size;
121
135
  }
122
136
 
123
137
  /**
@@ -160,6 +174,13 @@ function setSegmentsVisibility(
160
174
  );
161
175
  }
162
176
 
177
+ /**
178
+ * @param toolGroupId - The Id of the tool group that contains the segmentation
179
+ * @param segmentationRepresentationUID - The id of the segmentation representation that contains the segment
180
+ * @param segmentIndex - Index of the segment that will be updated
181
+ * @param visibility - True to show the segment or false to hide it
182
+ * @returns True if the segment is visible or false otherwise
183
+ */
163
184
  function setSegmentVisibility(
164
185
  toolGroupId: string,
165
186
  segmentationRepresentationUID: string,
@@ -186,9 +207,34 @@ function setSegmentVisibility(
186
207
  );
187
208
  }
188
209
 
210
+ /**
211
+ * @param toolGroupId - The Id of the tool group that contains the segmentation.
212
+ * @param segmentationRepresentationUID - The id of the segmentation representation to modify its visibility.
213
+ * @param segmentIndex - Index of the segment
214
+ * @returns True if the segment is visible or false otherwise
215
+ */
216
+ function getSegmentVisibility(
217
+ toolGroupId: string,
218
+ segmentationRepresentationUID: string,
219
+ segmentIndex: number
220
+ ): boolean {
221
+ const segRepresentation =
222
+ SegmentationState.getSegmentationRepresentationByUID(
223
+ toolGroupId,
224
+ segmentationRepresentationUID
225
+ );
226
+
227
+ if (!segRepresentation) {
228
+ return false;
229
+ }
230
+
231
+ return !segRepresentation.segmentsHidden.has(segmentIndex);
232
+ }
233
+
189
234
  export {
190
235
  setSegmentationVisibility,
191
236
  getSegmentationVisibility,
192
237
  setSegmentVisibility,
193
238
  setSegmentsVisibility,
239
+ getSegmentVisibility,
194
240
  };
@@ -1,7 +1,9 @@
1
+ import { SegmentationRepresentations } from '../../../enums';
1
2
  import {
2
3
  SegmentationPublicInput,
3
4
  Segmentation,
4
5
  } from '../../../types/SegmentationStateTypes';
6
+ import type { ContourSegmentationData } from '../../../types/ContourTypes';
5
7
 
6
8
  /**
7
9
  * It takes in a segmentation input and returns a segmentation with default values
@@ -13,6 +15,30 @@ function normalizeSegmentationInput(
13
15
  segmentationInput: SegmentationPublicInput
14
16
  ): Segmentation {
15
17
  const { segmentationId, representation } = segmentationInput;
18
+ const isContourRepresentation =
19
+ representation.type === SegmentationRepresentations.Contour;
20
+ let data = representation.data ? { ...representation.data } : null;
21
+
22
+ // Contour representation data is defined internally
23
+ data = !data && isContourRepresentation ? {} : data;
24
+
25
+ // Data cannot be undefined for labelmap and surface
26
+ if (!data) {
27
+ throw new Error('Segmentation representation data may not be undefined');
28
+ }
29
+
30
+ if (isContourRepresentation) {
31
+ const contourData = <ContourSegmentationData>data;
32
+
33
+ // geometryIds will be removed in a near future. It still exist in the
34
+ // code for compatibility only but it is optional from now on.
35
+ contourData.geometryIds = contourData.geometryIds ?? [];
36
+
37
+ // Make sure annotationUIDsMap is defined because an empty contour is
38
+ // created before adding contour annotations to the map. Also it prevents
39
+ // breaking legacy code after moving from geometryIds to annotationUIDsMap.
40
+ contourData.annotationUIDsMap = contourData.annotationUIDsMap ?? new Map();
41
+ }
16
42
 
17
43
  // Todo: we should be able to let the user pass in non-default values for
18
44
  // cachedStats, label, activeSegmentIndex, etc.
@@ -26,7 +52,7 @@ function normalizeSegmentationInput(
26
52
  activeSegmentIndex: 1,
27
53
  representationData: {
28
54
  [representation.type]: {
29
- ...representation.data,
55
+ ...data,
30
56
  },
31
57
  },
32
58
  };
@@ -649,9 +649,10 @@ class AngleTool extends AnnotationTool {
649
649
 
650
650
  styleSpecifier.annotationUID = annotationUID;
651
651
 
652
- const lineWidth = this.getStyle('lineWidth', styleSpecifier, annotation);
653
- const lineDash = this.getStyle('lineDash', styleSpecifier, annotation);
654
- const color = this.getStyle('color', styleSpecifier, annotation);
652
+ const { color, lineWidth, lineDash } = this.getAnnotationStyle({
653
+ annotation,
654
+ styleSpecifier,
655
+ });
655
656
 
656
657
  const canvasCoordinates = points.map((p) => viewport.worldToCanvas(p));
657
658
 
@@ -703,9 +703,10 @@ class ArrowAnnotateTool extends AnnotationTool {
703
703
 
704
704
  styleSpecifier.annotationUID = annotationUID;
705
705
 
706
- const lineWidth = this.getStyle('lineWidth', styleSpecifier, annotation);
707
- const lineDash = this.getStyle('lineDash', styleSpecifier, annotation);
708
- const color = this.getStyle('color', styleSpecifier, annotation);
706
+ const { color, lineWidth, lineDash } = this.getAnnotationStyle({
707
+ annotation,
708
+ styleSpecifier,
709
+ });
709
710
 
710
711
  const canvasCoordinates = points.map((p) => viewport.worldToCanvas(p));
711
712
 
@@ -1064,10 +1064,10 @@ class BidirectionalTool extends AnnotationTool {
1064
1064
 
1065
1065
  styleSpecifier.annotationUID = annotationUID;
1066
1066
 
1067
- const lineWidth = this.getStyle('lineWidth', styleSpecifier, annotation);
1068
- const lineDash = this.getStyle('lineDash', styleSpecifier, annotation);
1069
- const color = this.getStyle('color', styleSpecifier, annotation);
1070
- const shadow = this.getStyle('shadow', styleSpecifier, annotation);
1067
+ const { color, lineWidth, lineDash, shadow } = this.getAnnotationStyle({
1068
+ annotation,
1069
+ styleSpecifier,
1070
+ });
1071
1071
 
1072
1072
  // If cachedStats does not exist, or the unit is missing (as part of import/hydration etc.),
1073
1073
  // force to recalculate the stats from the points
@@ -659,9 +659,10 @@ class CircleROITool extends AnnotationTool {
659
659
 
660
660
  styleSpecifier.annotationUID = annotationUID;
661
661
 
662
- const lineWidth = this.getStyle('lineWidth', styleSpecifier, annotation);
663
- const lineDash = this.getStyle('lineDash', styleSpecifier, annotation);
664
- const color = this.getStyle('color', styleSpecifier, annotation);
662
+ const { color, lineWidth, lineDash } = this.getAnnotationStyle({
663
+ annotation,
664
+ styleSpecifier,
665
+ });
665
666
 
666
667
  const canvasCoordinates = points.map((p) =>
667
668
  viewport.worldToCanvas(p)
@@ -673,9 +673,10 @@ class CobbAngleTool extends AnnotationTool {
673
673
 
674
674
  styleSpecifier.annotationUID = annotationUID;
675
675
 
676
- const lineWidth = this.getStyle('lineWidth', styleSpecifier, annotation);
677
- const lineDash = this.getStyle('lineDash', styleSpecifier, annotation);
678
- const color = this.getStyle('color', styleSpecifier, annotation);
676
+ const { color, lineWidth, lineDash } = this.getAnnotationStyle({
677
+ annotation,
678
+ styleSpecifier,
679
+ });
679
680
 
680
681
  const canvasCoordinates = points.map((p) => viewport.worldToCanvas(p));
681
682
 
@@ -154,7 +154,10 @@ class DragProbeTool extends ProbeTool {
154
154
 
155
155
  styleSpecifier.annotationUID = annotationUID;
156
156
 
157
- const color = this.getStyle('color', styleSpecifier, annotation);
157
+ const { color } = this.getAnnotationStyle({
158
+ annotation,
159
+ styleSpecifier,
160
+ });
158
161
 
159
162
  const modalityUnitOptions = {
160
163
  isPreScaled: isViewportPreScaled(viewport, targetId),
@@ -774,9 +774,10 @@ class EllipticalROITool extends AnnotationTool {
774
774
 
775
775
  styleSpecifier.annotationUID = annotationUID;
776
776
 
777
- const lineWidth = this.getStyle('lineWidth', styleSpecifier, annotation);
778
- const lineDash = this.getStyle('lineDash', styleSpecifier, annotation);
779
- const color = this.getStyle('color', styleSpecifier, annotation);
777
+ const { color, lineWidth, lineDash } = this.getAnnotationStyle({
778
+ annotation,
779
+ styleSpecifier,
780
+ });
780
781
 
781
782
  const canvasCoordinates = points.map((p) =>
782
783
  viewport.worldToCanvas(p)
@@ -384,7 +384,10 @@ class KeyImageTool extends AnnotationTool {
384
384
 
385
385
  styleSpecifier.annotationUID = annotationUID;
386
386
 
387
- const color = this.getStyle('color', styleSpecifier, annotation);
387
+ const { color } = this.getAnnotationStyle({
388
+ annotation,
389
+ styleSpecifier,
390
+ });
388
391
 
389
392
  const { canvasPosition, canvasSize } = this.configuration;
390
393
  if (canvasPosition?.length) {
@@ -645,11 +645,10 @@ class LengthTool extends AnnotationTool {
645
645
 
646
646
  styleSpecifier.annotationUID = annotationUID;
647
647
 
648
- // Todo: move these into annotationTool class
649
- const lineWidth = this.getStyle('lineWidth', styleSpecifier, annotation);
650
- const lineDash = this.getStyle('lineDash', styleSpecifier, annotation);
651
- const color = this.getStyle('color', styleSpecifier, annotation);
652
- const shadow = this.getStyle('shadow', styleSpecifier, annotation);
648
+ const { color, lineWidth, lineDash, shadow } = this.getAnnotationStyle({
649
+ annotation,
650
+ styleSpecifier,
651
+ });
653
652
 
654
653
  const canvasCoordinates = points.map((p) => viewport.worldToCanvas(p));
655
654
 
@@ -0,0 +1,13 @@
1
+ import LivewireContourTool from './LivewireContourTool';
2
+
3
+ class LivewireContourSegmentationTool extends LivewireContourTool {
4
+ static toolName;
5
+
6
+ protected isContourSegmentationTool(): boolean {
7
+ // Re-enable contour segmentation behavior disabled by LivewireContourTool
8
+ return true;
9
+ }
10
+ }
11
+
12
+ LivewireContourSegmentationTool.toolName = 'LivewireContourSegmentationTool';
13
+ export default LivewireContourSegmentationTool;