@jax-data-science/sci-image-visualizer 0.1.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 (311) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +404 -0
  3. package/esm2022/index.mjs +52 -0
  4. package/esm2022/jax-data-science-sci-image-visualizer.mjs +5 -0
  5. package/esm2022/lib/channel-histogram/channel-histogram.component.mjs +398 -0
  6. package/esm2022/lib/contracts/capabilities.contract.mjs +32 -0
  7. package/esm2022/lib/contracts/cell-segmenter.contract.mjs +12 -0
  8. package/esm2022/lib/contracts/channel-histogram-api.contract.mjs +14 -0
  9. package/esm2022/lib/contracts/colormap-lut.mjs +95 -0
  10. package/esm2022/lib/contracts/coordinate-transform.contract.mjs +2 -0
  11. package/esm2022/lib/contracts/display-types.mjs +8 -0
  12. package/esm2022/lib/contracts/image.contract.mjs +11 -0
  13. package/esm2022/lib/contracts/intensity.mjs +28 -0
  14. package/esm2022/lib/contracts/plot-type.mjs +112 -0
  15. package/esm2022/lib/contracts/ports/image-state.port.mjs +3 -0
  16. package/esm2022/lib/contracts/ports/preferences.port.mjs +3 -0
  17. package/esm2022/lib/contracts/ports/region-io.port.mjs +3 -0
  18. package/esm2022/lib/contracts/ports/tile-access.port.mjs +3 -0
  19. package/esm2022/lib/contracts/region-editor-api.contract.mjs +4 -0
  20. package/esm2022/lib/contracts/region-overlay.contract.mjs +2 -0
  21. package/esm2022/lib/contracts/region-store.contract.mjs +2 -0
  22. package/esm2022/lib/contracts/sam.contract.mjs +12 -0
  23. package/esm2022/lib/contracts/toolbar-config.mjs +8 -0
  24. package/esm2022/lib/contracts/visualizer.contract.mjs +10 -0
  25. package/esm2022/lib/contracts/viz-config.mjs +3 -0
  26. package/esm2022/lib/hex-color-picker/hex-color-picker.component.mjs +260 -0
  27. package/esm2022/lib/implementations/base-store-visualizer.mjs +76 -0
  28. package/esm2022/lib/implementations/napari-js/napari-axes-labels.mjs +106 -0
  29. package/esm2022/lib/implementations/napari-js/napari-region-overlay.mjs +847 -0
  30. package/esm2022/lib/implementations/napari-js/napari-scale-bar.mjs +92 -0
  31. package/esm2022/lib/implementations/napari-js/napari-visualizer.service.mjs +2283 -0
  32. package/esm2022/lib/implementations/napari-js/napari-volume-z-handle.mjs +126 -0
  33. package/esm2022/lib/implementations/osd/display-pipeline.mjs +143 -0
  34. package/esm2022/lib/implementations/osd/histogram-sampler.mjs +217 -0
  35. package/esm2022/lib/implementations/osd/openseadragon-visualizer.service.mjs +1780 -0
  36. package/esm2022/lib/implementations/osd/osd-coordinate-transform.mjs +25 -0
  37. package/esm2022/lib/implementations/osd/osd-coords.mjs +53 -0
  38. package/esm2022/lib/implementations/osd/osd-lib.mjs +20 -0
  39. package/esm2022/lib/implementations/osd/osd-region-overlay.mjs +1237 -0
  40. package/esm2022/lib/implementations/osd/osd-scale-bar.mjs +88 -0
  41. package/esm2022/lib/implementations/osd/slice-cache.mjs +488 -0
  42. package/esm2022/lib/implementations/osd/tile-client.mjs +29 -0
  43. package/esm2022/lib/implementations/plotly/plotly-coordinate-transform.mjs +37 -0
  44. package/esm2022/lib/implementations/plotly/plotly-region-overlay.mjs +31 -0
  45. package/esm2022/lib/implementations/plotly/plotly-trace-builders.mjs +183 -0
  46. package/esm2022/lib/implementations/plotly/plotly.service.mjs +2137 -0
  47. package/esm2022/lib/implementations/simple-slice-access.service.mjs +99 -0
  48. package/esm2022/lib/models/bezier.mjs +120 -0
  49. package/esm2022/lib/models/class-preset.mjs +46 -0
  50. package/esm2022/lib/models/geometry.mjs +198 -0
  51. package/esm2022/lib/models/region.mjs +166 -0
  52. package/esm2022/lib/models/shape.mjs +53 -0
  53. package/esm2022/lib/plot.utilities.mjs +693 -0
  54. package/esm2022/lib/processing/image-converter.service.mjs +90 -0
  55. package/esm2022/lib/processing/image-crop.mjs +62 -0
  56. package/esm2022/lib/processing/processing-image.mjs +50 -0
  57. package/esm2022/lib/provide-visualization.mjs +63 -0
  58. package/esm2022/lib/region-editor/mask-raster.mjs +95 -0
  59. package/esm2022/lib/region-editor/mask-worker.mjs +10 -0
  60. package/esm2022/lib/region-editor/region-editor.component.mjs +1190 -0
  61. package/esm2022/lib/region-ops.service.mjs +301 -0
  62. package/esm2022/lib/render-orchestrator.mjs +87 -0
  63. package/esm2022/lib/routing-visualizer.service.mjs +533 -0
  64. package/esm2022/lib/store/class-color.util.mjs +52 -0
  65. package/esm2022/lib/store/region-store.service.mjs +1029 -0
  66. package/esm2022/lib/store/visualizer-store.service.mjs +352 -0
  67. package/esm2022/lib/toolbar/brush/brush-tool.service.mjs +546 -0
  68. package/esm2022/lib/toolbar/crop/slide-crop.mjs +57 -0
  69. package/esm2022/lib/toolbar/segmentation/cell-segment-tool.service.mjs +115 -0
  70. package/esm2022/lib/toolbar/segmentation/cellpose-segmenter.service.mjs +84 -0
  71. package/esm2022/lib/toolbar/segmentation/onnx-sam-session.mjs +133 -0
  72. package/esm2022/lib/toolbar/segmentation/ort-runtime-config.mjs +31 -0
  73. package/esm2022/lib/toolbar/segmentation/sam-model-registry.mjs +108 -0
  74. package/esm2022/lib/toolbar/segmentation/sam-onnx-core.mjs +159 -0
  75. package/esm2022/lib/toolbar/segmentation/sam-point-tool.service.mjs +255 -0
  76. package/esm2022/lib/toolbar/segmentation/sam-prompt.mjs +94 -0
  77. package/esm2022/lib/toolbar/segmentation/sam-tool.service.mjs +188 -0
  78. package/esm2022/lib/toolbar/toolbar.component.mjs +311 -0
  79. package/esm2022/lib/toolbar/vertex-eraser/vertex-eraser-tool.service.mjs +234 -0
  80. package/esm2022/lib/toolbar/wand/wand-tool.service.mjs +499 -0
  81. package/esm2022/lib/toolbar/wand/wand.service.mjs +921 -0
  82. package/esm2022/lib/toolbar/zoom-to-box/zoom-to-box-tool.service.mjs +157 -0
  83. package/esm2022/lib/visualization.module.mjs +162 -0
  84. package/esm2022/lib/visualizer.component.mjs +1597 -0
  85. package/fesm2022/jax-data-science-sci-image-visualizer-mask-worker-uhepXUhM.mjs +12 -0
  86. package/fesm2022/jax-data-science-sci-image-visualizer-mask-worker-uhepXUhM.mjs.map +1 -0
  87. package/fesm2022/jax-data-science-sci-image-visualizer-onnx-sam-session-ci1q0xnJ.mjs +327 -0
  88. package/fesm2022/jax-data-science-sci-image-visualizer-onnx-sam-session-ci1q0xnJ.mjs.map +1 -0
  89. package/fesm2022/jax-data-science-sci-image-visualizer.mjs +21314 -0
  90. package/fesm2022/jax-data-science-sci-image-visualizer.mjs.map +1 -0
  91. package/fesm2022/mask.worker.js +989 -0
  92. package/fesm2022/onnx-sam.worker.js +202 -0
  93. package/index.d.ts +39 -0
  94. package/lib/channel-histogram/channel-histogram.component.d.ts +112 -0
  95. package/lib/contracts/capabilities.contract.d.ts +30 -0
  96. package/lib/contracts/cell-segmenter.contract.d.ts +40 -0
  97. package/lib/contracts/channel-histogram-api.contract.d.ts +98 -0
  98. package/lib/contracts/colormap-lut.d.ts +21 -0
  99. package/lib/contracts/coordinate-transform.contract.d.ts +43 -0
  100. package/lib/contracts/display-types.d.ts +41 -0
  101. package/lib/contracts/image.contract.d.ts +72 -0
  102. package/lib/contracts/intensity.d.ts +18 -0
  103. package/lib/contracts/plot-type.d.ts +108 -0
  104. package/lib/contracts/ports/image-state.port.d.ts +29 -0
  105. package/lib/contracts/ports/preferences.port.d.ts +19 -0
  106. package/lib/contracts/ports/region-io.port.d.ts +29 -0
  107. package/lib/contracts/ports/tile-access.port.d.ts +27 -0
  108. package/lib/contracts/region-editor-api.contract.d.ts +83 -0
  109. package/lib/contracts/region-overlay.contract.d.ts +47 -0
  110. package/lib/contracts/region-store.contract.d.ts +74 -0
  111. package/lib/contracts/sam.contract.d.ts +98 -0
  112. package/lib/contracts/toolbar-config.d.ts +24 -0
  113. package/lib/contracts/visualizer.contract.d.ts +346 -0
  114. package/lib/contracts/viz-config.d.ts +25 -0
  115. package/lib/hex-color-picker/hex-color-picker.component.d.ts +47 -0
  116. package/lib/implementations/base-store-visualizer.d.ts +71 -0
  117. package/lib/implementations/napari-js/napari-axes-labels.d.ts +47 -0
  118. package/lib/implementations/napari-js/napari-region-overlay.d.ts +115 -0
  119. package/lib/implementations/napari-js/napari-scale-bar.d.ts +31 -0
  120. package/lib/implementations/napari-js/napari-visualizer.service.d.ts +455 -0
  121. package/lib/implementations/napari-js/napari-volume-z-handle.d.ts +46 -0
  122. package/lib/implementations/osd/display-pipeline.d.ts +47 -0
  123. package/lib/implementations/osd/histogram-sampler.d.ts +85 -0
  124. package/lib/implementations/osd/openseadragon-visualizer.service.d.ts +476 -0
  125. package/lib/implementations/osd/osd-coordinate-transform.d.ts +17 -0
  126. package/lib/implementations/osd/osd-coords.d.ts +16 -0
  127. package/lib/implementations/osd/osd-lib.d.ts +19 -0
  128. package/lib/implementations/osd/osd-region-overlay.d.ts +191 -0
  129. package/lib/implementations/osd/osd-scale-bar.d.ts +17 -0
  130. package/lib/implementations/osd/slice-cache.d.ts +161 -0
  131. package/lib/implementations/osd/tile-client.d.ts +32 -0
  132. package/lib/implementations/plotly/plotly-coordinate-transform.d.ts +19 -0
  133. package/lib/implementations/plotly/plotly-region-overlay.d.ts +23 -0
  134. package/lib/implementations/plotly/plotly-trace-builders.d.ts +60 -0
  135. package/lib/implementations/plotly/plotly.service.d.ts +594 -0
  136. package/lib/implementations/simple-slice-access.service.d.ts +64 -0
  137. package/lib/models/bezier.d.ts +59 -0
  138. package/lib/models/class-preset.d.ts +39 -0
  139. package/lib/models/geometry.d.ts +66 -0
  140. package/lib/models/region.d.ts +132 -0
  141. package/lib/models/shape.d.ts +44 -0
  142. package/lib/plot.utilities.d.ts +107 -0
  143. package/lib/processing/image-converter.service.d.ts +28 -0
  144. package/lib/processing/image-crop.d.ts +18 -0
  145. package/lib/processing/processing-image.d.ts +17 -0
  146. package/lib/provide-visualization.d.ts +34 -0
  147. package/lib/region-editor/mask-raster.d.ts +61 -0
  148. package/lib/region-editor/mask-worker.d.ts +7 -0
  149. package/lib/region-editor/region-editor.component.d.ts +305 -0
  150. package/lib/region-ops.service.d.ts +92 -0
  151. package/lib/render-orchestrator.d.ts +59 -0
  152. package/lib/routing-visualizer.service.d.ts +227 -0
  153. package/lib/store/class-color.util.d.ts +26 -0
  154. package/lib/store/region-store.service.d.ts +315 -0
  155. package/lib/store/visualizer-store.service.d.ts +123 -0
  156. package/lib/toolbar/brush/brush-tool.service.d.ts +143 -0
  157. package/lib/toolbar/crop/slide-crop.d.ts +30 -0
  158. package/lib/toolbar/segmentation/cell-segment-tool.service.d.ts +32 -0
  159. package/lib/toolbar/segmentation/cellpose-segmenter.service.d.ts +39 -0
  160. package/lib/toolbar/segmentation/onnx-sam-session.d.ts +25 -0
  161. package/lib/toolbar/segmentation/ort-runtime-config.d.ts +4 -0
  162. package/lib/toolbar/segmentation/sam-model-registry.d.ts +36 -0
  163. package/lib/toolbar/segmentation/sam-onnx-core.d.ts +48 -0
  164. package/lib/toolbar/segmentation/sam-point-tool.service.d.ts +59 -0
  165. package/lib/toolbar/segmentation/sam-prompt.d.ts +34 -0
  166. package/lib/toolbar/segmentation/sam-tool.service.d.ts +50 -0
  167. package/lib/toolbar/toolbar.component.d.ts +167 -0
  168. package/lib/toolbar/vertex-eraser/vertex-eraser-tool.service.d.ts +64 -0
  169. package/lib/toolbar/wand/wand-tool.service.d.ts +149 -0
  170. package/lib/toolbar/wand/wand.service.d.ts +133 -0
  171. package/lib/toolbar/zoom-to-box/zoom-to-box-tool.service.d.ts +49 -0
  172. package/lib/visualization.module.d.ts +45 -0
  173. package/lib/visualizer.component.d.ts +378 -0
  174. package/package.json +73 -0
  175. package/src/lib/assets/3d-coordinates.svg +49 -0
  176. package/src/lib/assets/cells.svg +1 -0
  177. package/src/lib/assets/click.svg +1 -0
  178. package/src/lib/assets/colormap-luts.json +1 -0
  179. package/src/lib/assets/contour.svg +48 -0
  180. package/src/lib/assets/cube-3d.svg +1 -0
  181. package/src/lib/assets/edit-selection-white.svg +47 -0
  182. package/src/lib/assets/heatmap.svg +1 -0
  183. package/src/lib/assets/icons/colormap-Pastel1.png +0 -0
  184. package/src/lib/assets/icons/colormap-accent.png +0 -0
  185. package/src/lib/assets/icons/colormap-afmhot.png +0 -0
  186. package/src/lib/assets/icons/colormap-autumn.png +0 -0
  187. package/src/lib/assets/icons/colormap-berlin.png +0 -0
  188. package/src/lib/assets/icons/colormap-binary.png +0 -0
  189. package/src/lib/assets/icons/colormap-blackbody.png +0 -0
  190. package/src/lib/assets/icons/colormap-bluered.png +0 -0
  191. package/src/lib/assets/icons/colormap-blues.png +0 -0
  192. package/src/lib/assets/icons/colormap-bone.png +0 -0
  193. package/src/lib/assets/icons/colormap-brbg.png +0 -0
  194. package/src/lib/assets/icons/colormap-brg.png +0 -0
  195. package/src/lib/assets/icons/colormap-bugn.png +0 -0
  196. package/src/lib/assets/icons/colormap-bupu.png +0 -0
  197. package/src/lib/assets/icons/colormap-bwr.png +0 -0
  198. package/src/lib/assets/icons/colormap-cividis.png +0 -0
  199. package/src/lib/assets/icons/colormap-cmrmap.png +0 -0
  200. package/src/lib/assets/icons/colormap-cool.png +0 -0
  201. package/src/lib/assets/icons/colormap-coolwarm.png +0 -0
  202. package/src/lib/assets/icons/colormap-copper.png +0 -0
  203. package/src/lib/assets/icons/colormap-cubehelix.png +0 -0
  204. package/src/lib/assets/icons/colormap-dark2.png +0 -0
  205. package/src/lib/assets/icons/colormap-earth.png +0 -0
  206. package/src/lib/assets/icons/colormap-electric.png +0 -0
  207. package/src/lib/assets/icons/colormap-flag.png +0 -0
  208. package/src/lib/assets/icons/colormap-gist_earth.png +0 -0
  209. package/src/lib/assets/icons/colormap-gist_gray.png +0 -0
  210. package/src/lib/assets/icons/colormap-gist_heat.png +0 -0
  211. package/src/lib/assets/icons/colormap-gist_ncar.png +0 -0
  212. package/src/lib/assets/icons/colormap-gist_rainbow.png +0 -0
  213. package/src/lib/assets/icons/colormap-gist_stern.png +0 -0
  214. package/src/lib/assets/icons/colormap-gist_yarg.png +0 -0
  215. package/src/lib/assets/icons/colormap-gnbu.png +0 -0
  216. package/src/lib/assets/icons/colormap-gnuplot.png +0 -0
  217. package/src/lib/assets/icons/colormap-gnuplot2.png +0 -0
  218. package/src/lib/assets/icons/colormap-gray.png +0 -0
  219. package/src/lib/assets/icons/colormap-greens-inv.png +0 -0
  220. package/src/lib/assets/icons/colormap-greens.png +0 -0
  221. package/src/lib/assets/icons/colormap-greys-inv.png +0 -0
  222. package/src/lib/assets/icons/colormap-greys.png +0 -0
  223. package/src/lib/assets/icons/colormap-hot.png +0 -0
  224. package/src/lib/assets/icons/colormap-hsv.png +0 -0
  225. package/src/lib/assets/icons/colormap-inferno.png +0 -0
  226. package/src/lib/assets/icons/colormap-jet.png +0 -0
  227. package/src/lib/assets/icons/colormap-magma.png +0 -0
  228. package/src/lib/assets/icons/colormap-managua.png +0 -0
  229. package/src/lib/assets/icons/colormap-nipy_spectral.png +0 -0
  230. package/src/lib/assets/icons/colormap-ocean.png +0 -0
  231. package/src/lib/assets/icons/colormap-oranges.png +0 -0
  232. package/src/lib/assets/icons/colormap-orrd.png +0 -0
  233. package/src/lib/assets/icons/colormap-pastel2.png +0 -0
  234. package/src/lib/assets/icons/colormap-picnic.png +0 -0
  235. package/src/lib/assets/icons/colormap-pink.png +0 -0
  236. package/src/lib/assets/icons/colormap-piyg.png +0 -0
  237. package/src/lib/assets/icons/colormap-placeholder.png +0 -0
  238. package/src/lib/assets/icons/colormap-plasma.png +0 -0
  239. package/src/lib/assets/icons/colormap-portland.png +0 -0
  240. package/src/lib/assets/icons/colormap-prgn.png +0 -0
  241. package/src/lib/assets/icons/colormap-prism.png +0 -0
  242. package/src/lib/assets/icons/colormap-pubu.png +0 -0
  243. package/src/lib/assets/icons/colormap-pubugn.png +0 -0
  244. package/src/lib/assets/icons/colormap-puor.png +0 -0
  245. package/src/lib/assets/icons/colormap-purd.png +0 -0
  246. package/src/lib/assets/icons/colormap-purples.png +0 -0
  247. package/src/lib/assets/icons/colormap-rainbow.png +0 -0
  248. package/src/lib/assets/icons/colormap-rdbu.png +0 -0
  249. package/src/lib/assets/icons/colormap-rdgy.png +0 -0
  250. package/src/lib/assets/icons/colormap-rdpu.png +0 -0
  251. package/src/lib/assets/icons/colormap-rdylbu.png +0 -0
  252. package/src/lib/assets/icons/colormap-rdylgn.png +0 -0
  253. package/src/lib/assets/icons/colormap-reds.png +0 -0
  254. package/src/lib/assets/icons/colormap-seismic.png +0 -0
  255. package/src/lib/assets/icons/colormap-set1.png +0 -0
  256. package/src/lib/assets/icons/colormap-set2.png +0 -0
  257. package/src/lib/assets/icons/colormap-set3.png +0 -0
  258. package/src/lib/assets/icons/colormap-spectral.png +0 -0
  259. package/src/lib/assets/icons/colormap-spring.png +0 -0
  260. package/src/lib/assets/icons/colormap-summer.png +0 -0
  261. package/src/lib/assets/icons/colormap-tab10.png +0 -0
  262. package/src/lib/assets/icons/colormap-tab20.png +0 -0
  263. package/src/lib/assets/icons/colormap-tab20b.png +0 -0
  264. package/src/lib/assets/icons/colormap-tab20c.png +0 -0
  265. package/src/lib/assets/icons/colormap-terrain.png +0 -0
  266. package/src/lib/assets/icons/colormap-turbo.png +0 -0
  267. package/src/lib/assets/icons/colormap-twilight.png +0 -0
  268. package/src/lib/assets/icons/colormap-twilight_shifted.png +0 -0
  269. package/src/lib/assets/icons/colormap-vanimo.png +0 -0
  270. package/src/lib/assets/icons/colormap-viridis.png +0 -0
  271. package/src/lib/assets/icons/colormap-winter.png +0 -0
  272. package/src/lib/assets/icons/colormap-wistia.png +0 -0
  273. package/src/lib/assets/icons/colormap-ylgn.png +0 -0
  274. package/src/lib/assets/icons/colormap-ylgnbu-inv.png +0 -0
  275. package/src/lib/assets/icons/colormap-ylgnbu.png +0 -0
  276. package/src/lib/assets/icons/colormap-ylorbr.png +0 -0
  277. package/src/lib/assets/icons/colormap-ylorrd-inv.png +0 -0
  278. package/src/lib/assets/icons/colormap-ylorrd.png +0 -0
  279. package/src/lib/assets/interactive-segmentation-cursor.svg +1 -0
  280. package/src/lib/assets/invert.svg +1 -0
  281. package/src/lib/assets/isosurface.svg +7 -0
  282. package/src/lib/assets/mask.svg +1 -0
  283. package/src/lib/assets/paintbrush.svg +1 -0
  284. package/src/lib/assets/picture-segmentation.svg +43 -0
  285. package/src/lib/assets/polygon-vertices.svg +13 -0
  286. package/src/lib/assets/polyline.svg +3 -0
  287. package/src/lib/assets/redo.svg +39 -0
  288. package/src/lib/assets/region-editor.svg +37 -0
  289. package/src/lib/assets/region-move.svg +7 -0
  290. package/src/lib/assets/smooth.svg +56 -0
  291. package/src/lib/assets/spline-chart.svg +7 -0
  292. package/src/lib/assets/surface.svg +37 -0
  293. package/src/lib/assets/test/download-379.svg +1 -0
  294. package/src/lib/assets/test/download-98.svg +1 -0
  295. package/src/lib/assets/test/json-1.svg +1 -0
  296. package/src/lib/assets/test/load-53.svg +1 -0
  297. package/src/lib/assets/test/mask-44.svg +1 -0
  298. package/src/lib/assets/test/mask-download-44.svg +15 -0
  299. package/src/lib/assets/test/mask-save-44.svg +11 -0
  300. package/src/lib/assets/test/overlay-1.svg +1 -0
  301. package/src/lib/assets/test/overlay-4.svg +1 -0
  302. package/src/lib/assets/test/region-26.svg +1 -0
  303. package/src/lib/assets/test/save-56.svg +1 -0
  304. package/src/lib/assets/test/upload-43.svg +1 -0
  305. package/src/lib/assets/to-bezier.svg +15 -0
  306. package/src/lib/assets/to-polygon.svg +11 -0
  307. package/src/lib/assets/undo.svg +38 -0
  308. package/src/lib/assets/vertex-add.svg +12 -0
  309. package/src/lib/assets/vertex-delete.svg +12 -0
  310. package/src/lib/assets/wand.svg +54 -0
  311. package/src/lib/assets/zoom-box.svg +10 -0
@@ -0,0 +1,305 @@
1
+ import { OnDestroy, OnInit } from '@angular/core';
2
+ import { OverlayPanel } from 'primeng/overlaypanel';
3
+ import { Region } from '../models/region';
4
+ import { PresetSet, ClassPreset } from '../models/class-preset';
5
+ import { ConfirmationService, MessageService } from 'primeng/api';
6
+ import { IRegionEditorApi } from '../contracts/region-editor-api.contract';
7
+ import { RegionIoPort } from '../contracts/ports/region-io.port';
8
+ import * as i0 from "@angular/core";
9
+ export declare class RegionEditorComponent implements OnInit, OnDestroy {
10
+ private regionApi;
11
+ messageService: MessageService;
12
+ private confirmationService;
13
+ private regionIo;
14
+ protected readonly Array: ArrayConstructor;
15
+ overlayPanel: OverlayPanel;
16
+ regions: Region[];
17
+ regionsCopy: Region[];
18
+ selectedRegions: Region[];
19
+ showShapeLabel: boolean;
20
+ shapeColor: string;
21
+ fillColor: string;
22
+ displayHelpDialog: boolean;
23
+ showColorDialog: boolean;
24
+ /** One colour editor per unique class among the selected regions, shown in the
25
+ * "edit colour of selected regions" dialog. Unclassified regions (no label)
26
+ * are grouped under a single entry with an empty `label`. */
27
+ classColorEdits: {
28
+ label: string;
29
+ color: string;
30
+ }[];
31
+ labelColors: Map<string, string>;
32
+ selectedLabelColor: string;
33
+ /** "Edit class on selected rows" popup: chosen existing class, and a new-class name. */
34
+ bulkClass: string;
35
+ newBulkClass: string;
36
+ /** Local mirror of the per-user preset set (chip strip, Class dropdown, dialog). */
37
+ presetSet: PresetSet;
38
+ /** Class applied to newly drawn/added regions and to bulk chip-clicks. */
39
+ activeClass: string | null;
40
+ showManageDialog: boolean;
41
+ /** Working copy edited inside the Manage-classes dialog; committed on Apply/Done. */
42
+ presetDraft: PresetSet | null;
43
+ /** class name (match-mode keyed) → number of regions currently using it. */
44
+ classCounts: Map<string, number>;
45
+ /** Fallback class that a region reverts to when its class is deleted (jit-ui#70). */
46
+ readonly defaultClassName = "Region";
47
+ /** Classes as shown in the panel: sorted by region count (desc), then name. */
48
+ displayClasses: ClassPreset[];
49
+ readonly matchModeOptions: {
50
+ label: string;
51
+ value: string;
52
+ }[];
53
+ paginatorFirst: number;
54
+ paginatorRows: number;
55
+ readonly rowsPerPageOptions: number[];
56
+ /** Regions whose Class cell is currently in edit mode.
57
+ * Using object identity as the key avoids needing a unique id field. */
58
+ editingLabelRegions: Set<any>;
59
+ showSaveAsDialog: boolean;
60
+ saveAsFilename: string;
61
+ saveAsFileExists: boolean;
62
+ /** True while a GeoJSON persist is serializing/uploading — drives the dialog's
63
+ * progress bar and Cancel button (parity with the Save-mask dialog). */
64
+ saveAsBusy: boolean;
65
+ private _saveAsCheck$;
66
+ private _saveAsSub?;
67
+ /** Handle for the deferred-serialize timer so Cancel/destroy can abort it
68
+ * before it fires (otherwise the upload would still start). */
69
+ private _saveAsTimer?;
70
+ showExportDialog: boolean;
71
+ exportFilename: string;
72
+ showSaveMaskDialog: boolean;
73
+ saveMaskFilename: string;
74
+ /** Mask type chosen in the Save-mask dialog: a binary foreground/background
75
+ * mask, or a multi-class mask with a distinct id per region. */
76
+ maskMode: 'binary' | 'multiclass';
77
+ /** True while the mask worker is rasterizing/encoding — drives the progress
78
+ * bar and the Cancel button in the dialog. */
79
+ maskBusy: boolean;
80
+ /** 0–100 rasterization progress; switches to indeterminate during encoding. */
81
+ maskProgress: number;
82
+ maskEncoding: boolean;
83
+ private maskWorker?;
84
+ private pendingMaskFilename;
85
+ /**
86
+ * PrimeNG p-table multi-selection mode toggle. When true, single-click
87
+ * selects one row (replacing prior); meta/ctrl-click toggles a row in/out
88
+ * of the selection. When false, every click toggles. Default true to
89
+ * match the most common spreadsheet-like UX.
90
+ */
91
+ metaKey: boolean;
92
+ private _updatingFromEditor;
93
+ private _suppressSelectionSyncToPlot;
94
+ private _regionSub;
95
+ private _selectedIdxSub;
96
+ private _metaSub;
97
+ private _presetSub;
98
+ /** Physical pixel size (µm/pixel) of the active image, for region areas in
99
+ * µm². Undefined when the format reports no physical size. */
100
+ private mppX?;
101
+ private mppY?;
102
+ constructor(regionApi: IRegionEditorApi, messageService: MessageService, confirmationService: ConfirmationService, regionIo: RegionIoPort);
103
+ /**
104
+ * Deep copy of regions for dirty-tracking (`regionsCopy`). Returns plain-object
105
+ * clones — only structural equality matters here, not prototypes.
106
+ * TODO: replace with `structuredClone` once verified.
107
+ */
108
+ private deepClone;
109
+ ngOnInit(): void;
110
+ ngOnDestroy(): void;
111
+ /**
112
+ * Table → Plot: PrimeNG fires onRowSelect/onRowUnselect after updating
113
+ * `selectedRegions`. Push the selected regions to the contract by identity —
114
+ * the package maps them to its internal index space (which includes the
115
+ * intensity-profile lines the editor never sees).
116
+ */
117
+ onSelectionChanged(): void;
118
+ /**
119
+ * Apply classification colours and refresh the label→colour map for regions
120
+ * coming from the visualizer. The visualizer hands back neutral `Region`
121
+ * objects with bounds, colour and label already populated, so the editor no
122
+ * longer parses any backend-specific shape format — it only fills in a
123
+ * fallback colour and rebuilds its local label→colour lookup.
124
+ */
125
+ private applyRegionColors;
126
+ /**
127
+ * Push edits from the editor to the diagram in live-edit mode (no save /
128
+ * cancel buttons). The `_updatingFromEditor` guard is still used so the
129
+ * resulting regionUpdateEvent doesn't bounce back as an external change.
130
+ */
131
+ private setRegionsFromEditor;
132
+ /** Set one region's outline colour from the per-row picker and commit live.
133
+ * Remembers it as the label's colour so same-class regions added later match
134
+ * (jit-ui#85 — the Region Editor's per-region Color column). */
135
+ changeRegionColor(region: Region, color: string): void;
136
+ addRectangle(): void;
137
+ /**
138
+ * Update the label of the region on enter key pressed (when editing a label cell in the table)
139
+ * @param region
140
+ * @param setRegion
141
+ */
142
+ labelRegionUpdate(region: Region, setRegion?: boolean): void;
143
+ xRectUpdate(region: Region, event: any): void;
144
+ yRectUpdate(region: Region, event: any): void;
145
+ widthRectUpdate(region: Region, event: any): void;
146
+ heightRectUpdate(region: Region, event: any): void;
147
+ onPageChange(event: {
148
+ first?: number;
149
+ rows?: number;
150
+ }): void;
151
+ /** Select every region in the table (and highlight them on the diagram). */
152
+ selectAllRegions(): void;
153
+ deleteSelectedRegions(): void;
154
+ clearAllRegions(): void;
155
+ addPolygon(): void;
156
+ deleteRegion(shapeIdx: number): void;
157
+ private clampPaginatorFirst;
158
+ changeShowShapeLabel(showLabel: boolean): void;
159
+ isEditingLabel(region: any): boolean;
160
+ startEditLabel(region: any, event?: Event): void;
161
+ stopEditLabel(region: any, commit: boolean, event?: Event): void;
162
+ isRectangle(region: Region): boolean;
163
+ /**
164
+ * Region area for display: in µm² (or mm²) when the image reports a physical
165
+ * pixel size, otherwise in px². Empty string for degenerate regions.
166
+ */
167
+ regionArea(region: Region): string;
168
+ /**
169
+ * Choose the physical pixel size (µm/pixel) for area display from the image
170
+ * meta. The calibration may sit on any channel entry — not necessarily [0] —
171
+ * so pick the first entry with a positive mppX (mirrors
172
+ * PlotlyService.currentMpp). Falls back to square pixels (mppY = mppX) when
173
+ * only one axis is reported, so a scaled image shows µm²/mm² rather than px².
174
+ */
175
+ private pickMpp;
176
+ /** Pixel area: width·height for rectangles, shoelace formula for polygons.
177
+ * Interior rings (holes) are subtracted, so a donut reports the annulus area,
178
+ * not the filled exterior (jit-ui#85). */
179
+ private areaInPixels;
180
+ /** Polygon area: exterior shoelace minus each interior ring (hole). */
181
+ private polygonArea;
182
+ /** Absolute shoelace area of a single ring. */
183
+ private ringArea;
184
+ private fmtArea;
185
+ /**
186
+ * This method rounds all the rectangle regions lengths to multiple of 512
187
+ */
188
+ roundRectangleLengths(): void;
189
+ /**
190
+ * Stop key arrow event propagation
191
+ * @param event
192
+ */
193
+ disableArrowKeys(event: any): void;
194
+ changeShapeColor(event: any): void;
195
+ showHelp(): void;
196
+ /** Open the colour dialog for the currently-selected region(s), building one
197
+ * colour picker per unique class in the selection. Each picker is seeded with
198
+ * the class's current colour (the label→colour map, falling back to the first
199
+ * selected region of that class). */
200
+ openColorDialog(): void;
201
+ /** Apply each class's chosen colour to the selected regions of that class and
202
+ * commit live. Remembers the colour per class so same-class regions added
203
+ * later match. */
204
+ applyColorToSelected(): void;
205
+ /** Resolve the display colour for a class name (preset colour or deterministic fallback). */
206
+ colorForName(name?: string): string;
207
+ /**
208
+ * Ensure every class label present in the loaded regions exists in the preset
209
+ * list, auto-adding any that are missing (using the region's already-resolved
210
+ * colour). This makes classes carried in a loaded/imported GeoJSON show up as
211
+ * chips + Class-dropdown options (a p-dropdown can't display a value that isn't
212
+ * an option) and lets the user manage them. The placeholder 'legend' and empty
213
+ * labels are ignored. (jit-ui#70)
214
+ */
215
+ private syncClassesFromRegions;
216
+ /** Rebuild the per-class region counts shown in the panel. */
217
+ private recomputeClassCounts;
218
+ /** Rebuild the panel's display order — most-used classes first, then by name. */
219
+ private updateDisplayClasses;
220
+ /** trackBy for the class rows so re-sorting doesn't re-create the pickers. */
221
+ trackByClassName: (_: number, c: ClassPreset) => string;
222
+ /** Number of regions currently using a class (keyed by the active match mode). */
223
+ classCount(name: string): number;
224
+ /** Recolour a class from its panel swatch and repaint its (non-overridden) regions. */
225
+ setClassColor(name: string, color: string): void;
226
+ /** Tooltip for a class's delete button in the panel. */
227
+ deleteClassTooltip(name: string): string;
228
+ /** Remove a class. Any regions still using it fall back to the default
229
+ * "Region" class, so they aren't orphaned (and the class isn't immediately
230
+ * re-added from its regions by syncClassesFromRegions). */
231
+ deleteClass(name: string): void;
232
+ /** Regions labelled with any of `removedNames` revert to the default
233
+ * {@link defaultClassName} ("Region"): its class colour, override cleared.
234
+ * Skips the default itself so deleting "Region" can't self-reassign. (jit-ui#70) */
235
+ private reassignRegionsToDefaultClass;
236
+ /** Stamp a class (and its preset/fallback colour) onto one region from the Class
237
+ * dropdown; choosing a class opts the region back into the preset colour. */
238
+ applyPresetToRegion(region: Region, className: string): void;
239
+ /** Make a class active (used for new regions) and, if rows are selected, apply
240
+ * it to them in one commit. */
241
+ selectActiveClass(name: string): void;
242
+ /** Apply a class (label + preset/fallback colour) to the current selection and commit. */
243
+ private applyClassToSelected;
244
+ /** "Edit class on selected rows" popup — apply the chosen existing class. */
245
+ applyBulkClass(): void;
246
+ /** "Edit class on selected rows" popup — add a new class and set it on the selection. */
247
+ addAndApplyBulkClass(): void;
248
+ openManageDialog(): void;
249
+ private clonePresetSet;
250
+ addPresetClass(): void;
251
+ removePresetClass(i: number): void;
252
+ addFallbackColor(): void;
253
+ removeFallbackColor(i: number): void;
254
+ /** Commit the draft: drop blank/duplicate names, persist, and recolour
255
+ * non-overridden regions with the updated presets. */
256
+ applyManageDialog(close: boolean): void;
257
+ resetPresetsToDefaults(): void;
258
+ exportPresets(): void;
259
+ importPresets(event: Event): void;
260
+ importRois(event: Event): void;
261
+ /**
262
+ * Regions to serialize on save/export. For a single-file z-stack the store
263
+ * keeps only the current slice live, so pull EVERY slice's annotations (each
264
+ * tagged with its zero-based Region.z) to write one combined z-indexed
265
+ * geojson (jit-ui#93). Otherwise (single-plane image, or a folder stack whose
266
+ * slices save to their own per-slice files) the current set. (jit-ui#93)
267
+ */
268
+ private regionsForSave;
269
+ exportRois(): void;
270
+ confirmExport(): void;
271
+ /** Open the "Save mask" dialog, seeded with `<image-stem>_mask.png`. */
272
+ openSaveMaskDialog(): void;
273
+ /**
274
+ * Rasterize the regions to the chosen mask type and download as a PNG. The
275
+ * heavy work (full-res rasterize + PNG encode) runs in a Web Worker so the UI
276
+ * never freezes on large/whole-slide images and the job can be cancelled
277
+ * (jit-ui#95). The dialog stays open showing a progress bar until done.
278
+ */
279
+ confirmSaveMask(): void;
280
+ /** Cancel an in-progress mask export: terminate the worker and reset state. */
281
+ cancelSaveMask(): void;
282
+ /** Worker factory — async so the worker module (and its `import.meta.url`,
283
+ * which the CommonJS test compile rejects) is loaded via a dynamic import,
284
+ * exactly like the segmentation worker. Overridable in tests. */
285
+ protected createMaskWorker(): Promise<Worker>;
286
+ private finishMask;
287
+ private maskError;
288
+ private teardownMaskWorker;
289
+ persistRegions(): void;
290
+ /**
291
+ * Save a folder stack's regions as one geojson per slice-file (jit-ui#93).
292
+ * Groups the store's per-slice regions by slice index and serializes each on
293
+ * the default plane (z=0) — each slice-file is itself one plane, and the
294
+ * loader re-derives the slice index from the file's position in the series.
295
+ * Slices cleared since load are included (empty) so their file is overwritten.
296
+ */
297
+ private saveStackSlices;
298
+ checkSaveAsFileExists(): void;
299
+ confirmSaveAs(): void;
300
+ /** Cancel an in-progress GeoJSON persist: abort the deferred serialize and/or
301
+ * the in-flight upload, and reset state. */
302
+ cancelSaveAs(): void;
303
+ static ɵfac: i0.ɵɵFactoryDeclaration<RegionEditorComponent, never>;
304
+ static ɵcmp: i0.ɵɵComponentDeclaration<RegionEditorComponent, "region-editor", never, {}, {}, never, never, false, never>;
305
+ }
@@ -0,0 +1,92 @@
1
+ import { Region } from './models/region';
2
+ import { WandService } from './toolbar/wand/wand.service';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * Pure (DOM-free) region set-operations — merge / inverse / ungroup (jit-ui#85).
6
+ *
7
+ * Raster-based, reusing the wand/brush mask pipeline
8
+ * ({@link WandService.rasterizePolygon} → {@link WandService.maskToPolygons}),
9
+ * so "select + merge" yields the same geometry as brushing regions together:
10
+ * one engine, one set of behaviours, holes + multi-part results for free.
11
+ *
12
+ * Every method takes the current regions plus the image dimensions and returns
13
+ * new {@link Region}(s); it never mutates the store. Callers commit the result
14
+ * through the normal region-write path (so undo/redo applies). Coordinates are
15
+ * image pixels throughout.
16
+ */
17
+ export declare class RegionOpsService {
18
+ private wand;
19
+ /**
20
+ * Largest raster (in pixels) a region set-op will allocate on the main thread.
21
+ * Selections whose clipped bbox exceeds this are rasterized at a proportional
22
+ * downscale (then the traced geometry is scaled back), so merge/inverse stay
23
+ * responsive on gigapixel slides. ~16 MP keeps the synchronous contour trace
24
+ * well under a second; the downscale only affects boundary fidelity of very
25
+ * large-extent selections (small selections keep full resolution).
26
+ */
27
+ private static readonly MAX_OP_PIXELS;
28
+ constructor(wand: WandService);
29
+ /**
30
+ * Geometric union of `regions` into a single region: a {@link Polygon} when
31
+ * the union is one connected piece, a {@link MultiPolygon} when it stays
32
+ * disjoint, with holes preserved. Returns null when nothing rasterises (e.g.
33
+ * only open polylines were selected).
34
+ */
35
+ merge(regions: Region[], imageWidth: number, imageHeight: number): Region | null;
36
+ /** Downscale factor (≤ 1) keeping the selection's clipped bbox within
37
+ * {@link MAX_OP_PIXELS}; 1 when it already fits. */
38
+ private opRasterScale;
39
+ /** A copy of `p` with every coordinate (and hole coordinate) multiplied by `s`. */
40
+ private scalePolygon;
41
+ /**
42
+ * Replace `regions` with their inverse inside the image rectangle: the image
43
+ * minus the selection's union (the former regions become holes). Returns null
44
+ * for a degenerate image or an empty selection.
45
+ *
46
+ * Done *vectorially* so it scales to gigapixel images: the selection is
47
+ * unioned first (raster, bounded by the ROIs' extent — never the whole image),
48
+ * then the result is the image rectangle as the exterior with each union
49
+ * component's outline punched out as a hole. A component's own hole (a donut)
50
+ * becomes a solid island part. Only the image's corner coordinates are used —
51
+ * no full-image buffer is ever allocated.
52
+ */
53
+ inverse(regions: Region[], imageWidth: number, imageHeight: number): Region | null;
54
+ /** A closed straight-edged Polygon from parallel coord arrays. */
55
+ private ringPolygon;
56
+ /**
57
+ * Split a region into its disjoint parts — one region per {@link MultiPolygon}
58
+ * part. A single connected {@link Polygon}/{@link Rectangle} has nothing to
59
+ * split and is returned unchanged (as a one-element list).
60
+ */
61
+ ungroup(region: Region): Region[];
62
+ /** True when ungrouping `region` would actually split it (≥2 parts). */
63
+ canUngroup(region: Region): boolean;
64
+ /**
65
+ * Simplify a region's outline(s) with Douglas–Peucker — drop vertices within
66
+ * `altitudePx` pixels of the line between their kept neighbours. Applies to
67
+ * the exterior and every hole, of a polygon or each part of a MultiPolygon; a
68
+ * ring that would degenerate below a triangle is left at its previous detail
69
+ * (the part/hole is kept, not dropped). Rectangles and open polylines are
70
+ * returned unchanged. Result is always a straight-edged polygon (any Bézier
71
+ * smoothing is dropped, since the anchor set changes).
72
+ */
73
+ simplify(region: Region, altitudePx: number): Region;
74
+ /** Douglas–Peucker the exterior + each hole of one polygon. A ring that
75
+ * collapses below 3 vertices keeps its original points (never degenerates). */
76
+ private simplifyPolygon;
77
+ /** Union of every region's filled mask (exterior minus holes), or null.
78
+ * `scale` (≤ 1) downscales the raster for large selections; coordinates and
79
+ * the clip bounds are scaled to match. */
80
+ private unionMask;
81
+ /** Rasterise any region (rect / closed polygon / multi-polygon, holes punched
82
+ * out) into a bbox mask. Null for open polylines or degenerate geometry.
83
+ * `scale` (≤ 1) shrinks the coordinates and clip bounds for a downscaled raster. */
84
+ private rasterizeRegion;
85
+ /** Wrap traced parts as one region (Polygon if single, else MultiPolygon),
86
+ * inheriting colour/label from `proto`. Null when there are no parts. */
87
+ private regionFromParts;
88
+ private makeRegion;
89
+ private clonePolygon;
90
+ static ɵfac: i0.ɵɵFactoryDeclaration<RegionOpsService, never>;
91
+ static ɵprov: i0.ɵɵInjectableDeclaration<RegionOpsService>;
92
+ }
@@ -0,0 +1,59 @@
1
+ import { IImageInfo } from './contracts/image.contract';
2
+ /**
3
+ * Two-pass (small→large) render sequencing, extracted from
4
+ * VisualizerComponent (refactoring plan, Step 7 — a pure move of the
5
+ * orchestration; the component keeps the UI flags and supplies them through
6
+ * the host callbacks).
7
+ *
8
+ * When the file has small-tier URLs we render the small tier first for a fast
9
+ * blurry preview, release the loading overlay (keeping a translucent
10
+ * "sharpening" spinner), then sharpen by re-rendering the canonical large tier
11
+ * in place. Without a small tier it's the original single pass. The large pass
12
+ * retries once after a short delay — the preview endpoint can hit a transient
13
+ * 503 or a lock-contention window, and the second attempt usually lands on
14
+ * fresh pre-gen-cached PNGs.
15
+ */
16
+ export interface TwoPassRenderHost {
17
+ /** Load + plot one phase (the component owns div/screen/plot-type/z and the
18
+ * newer-click filename guard). `inPlace` updates the existing render so the
19
+ * canvas doesn't blank during the small→large swap. */
20
+ renderPhase(info: IImageInfo, inPlace: boolean): Promise<unknown>;
21
+ /** The small tier is on screen — drop the full loading overlay so the user
22
+ * sees the blurry preview, and show the sharpening spinner. */
23
+ smallShown(): void;
24
+ /** The large render settled (either way) — sharpening spinner off. */
25
+ sharpenSettled(): void;
26
+ /** Rendering finished. `viaSmall` = the overlay was already released by the
27
+ * small tier (so only release the running guard + apply the ROI); otherwise
28
+ * do the full finalize (overlay + running + ROI). */
29
+ finished(viaSmall: boolean, logTag: string): void;
30
+ /** Both large-tier attempts failed; the small tier stays on screen as the
31
+ * fallback. Surface it to the user and release the running guard + ROI. */
32
+ sharpenFailed(err: unknown): void;
33
+ }
34
+ export declare class RenderOrchestrator {
35
+ private host;
36
+ private retryDelayMs;
37
+ constructor(host: TwoPassRenderHost, retryDelayMs?: number);
38
+ /** Run the render: single-pass when `smallInfo` is null, two-pass otherwise. */
39
+ render(info: IImageInfo, smallInfo: IImageInfo | null): Promise<void>;
40
+ /** One retry after a brief delay before giving up on the large tier. */
41
+ private renderLargeWithRetry;
42
+ }
43
+ /**
44
+ * Debounced z-slice scrubbing (extracted with the orchestrator): coalesce the
45
+ * rapid changes a slider drag fires so a slice swap doesn't run on every
46
+ * pixel; the final value lands immediately via {@link commit} (onSlideEnd).
47
+ */
48
+ export declare class SliceScrubber {
49
+ private apply;
50
+ private delayMs;
51
+ private timer;
52
+ constructor(apply: (z: number) => void, delayMs?: number);
53
+ /** Debounced application of z while dragging. */
54
+ scrub(z: number): void;
55
+ /** Apply z immediately (slide end / keyboard step), dropping any pending scrub. */
56
+ commit(z: number): void;
57
+ /** Drop a pending scrub without applying (teardown). */
58
+ cancel(): void;
59
+ }