@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.
- package/LICENSE +21 -0
- package/README.md +404 -0
- package/esm2022/index.mjs +52 -0
- package/esm2022/jax-data-science-sci-image-visualizer.mjs +5 -0
- package/esm2022/lib/channel-histogram/channel-histogram.component.mjs +398 -0
- package/esm2022/lib/contracts/capabilities.contract.mjs +32 -0
- package/esm2022/lib/contracts/cell-segmenter.contract.mjs +12 -0
- package/esm2022/lib/contracts/channel-histogram-api.contract.mjs +14 -0
- package/esm2022/lib/contracts/colormap-lut.mjs +95 -0
- package/esm2022/lib/contracts/coordinate-transform.contract.mjs +2 -0
- package/esm2022/lib/contracts/display-types.mjs +8 -0
- package/esm2022/lib/contracts/image.contract.mjs +11 -0
- package/esm2022/lib/contracts/intensity.mjs +28 -0
- package/esm2022/lib/contracts/plot-type.mjs +112 -0
- package/esm2022/lib/contracts/ports/image-state.port.mjs +3 -0
- package/esm2022/lib/contracts/ports/preferences.port.mjs +3 -0
- package/esm2022/lib/contracts/ports/region-io.port.mjs +3 -0
- package/esm2022/lib/contracts/ports/tile-access.port.mjs +3 -0
- package/esm2022/lib/contracts/region-editor-api.contract.mjs +4 -0
- package/esm2022/lib/contracts/region-overlay.contract.mjs +2 -0
- package/esm2022/lib/contracts/region-store.contract.mjs +2 -0
- package/esm2022/lib/contracts/sam.contract.mjs +12 -0
- package/esm2022/lib/contracts/toolbar-config.mjs +8 -0
- package/esm2022/lib/contracts/visualizer.contract.mjs +10 -0
- package/esm2022/lib/contracts/viz-config.mjs +3 -0
- package/esm2022/lib/hex-color-picker/hex-color-picker.component.mjs +260 -0
- package/esm2022/lib/implementations/base-store-visualizer.mjs +76 -0
- package/esm2022/lib/implementations/napari-js/napari-axes-labels.mjs +106 -0
- package/esm2022/lib/implementations/napari-js/napari-region-overlay.mjs +847 -0
- package/esm2022/lib/implementations/napari-js/napari-scale-bar.mjs +92 -0
- package/esm2022/lib/implementations/napari-js/napari-visualizer.service.mjs +2283 -0
- package/esm2022/lib/implementations/napari-js/napari-volume-z-handle.mjs +126 -0
- package/esm2022/lib/implementations/osd/display-pipeline.mjs +143 -0
- package/esm2022/lib/implementations/osd/histogram-sampler.mjs +217 -0
- package/esm2022/lib/implementations/osd/openseadragon-visualizer.service.mjs +1780 -0
- package/esm2022/lib/implementations/osd/osd-coordinate-transform.mjs +25 -0
- package/esm2022/lib/implementations/osd/osd-coords.mjs +53 -0
- package/esm2022/lib/implementations/osd/osd-lib.mjs +20 -0
- package/esm2022/lib/implementations/osd/osd-region-overlay.mjs +1237 -0
- package/esm2022/lib/implementations/osd/osd-scale-bar.mjs +88 -0
- package/esm2022/lib/implementations/osd/slice-cache.mjs +488 -0
- package/esm2022/lib/implementations/osd/tile-client.mjs +29 -0
- package/esm2022/lib/implementations/plotly/plotly-coordinate-transform.mjs +37 -0
- package/esm2022/lib/implementations/plotly/plotly-region-overlay.mjs +31 -0
- package/esm2022/lib/implementations/plotly/plotly-trace-builders.mjs +183 -0
- package/esm2022/lib/implementations/plotly/plotly.service.mjs +2137 -0
- package/esm2022/lib/implementations/simple-slice-access.service.mjs +99 -0
- package/esm2022/lib/models/bezier.mjs +120 -0
- package/esm2022/lib/models/class-preset.mjs +46 -0
- package/esm2022/lib/models/geometry.mjs +198 -0
- package/esm2022/lib/models/region.mjs +166 -0
- package/esm2022/lib/models/shape.mjs +53 -0
- package/esm2022/lib/plot.utilities.mjs +693 -0
- package/esm2022/lib/processing/image-converter.service.mjs +90 -0
- package/esm2022/lib/processing/image-crop.mjs +62 -0
- package/esm2022/lib/processing/processing-image.mjs +50 -0
- package/esm2022/lib/provide-visualization.mjs +63 -0
- package/esm2022/lib/region-editor/mask-raster.mjs +95 -0
- package/esm2022/lib/region-editor/mask-worker.mjs +10 -0
- package/esm2022/lib/region-editor/region-editor.component.mjs +1190 -0
- package/esm2022/lib/region-ops.service.mjs +301 -0
- package/esm2022/lib/render-orchestrator.mjs +87 -0
- package/esm2022/lib/routing-visualizer.service.mjs +533 -0
- package/esm2022/lib/store/class-color.util.mjs +52 -0
- package/esm2022/lib/store/region-store.service.mjs +1029 -0
- package/esm2022/lib/store/visualizer-store.service.mjs +352 -0
- package/esm2022/lib/toolbar/brush/brush-tool.service.mjs +546 -0
- package/esm2022/lib/toolbar/crop/slide-crop.mjs +57 -0
- package/esm2022/lib/toolbar/segmentation/cell-segment-tool.service.mjs +115 -0
- package/esm2022/lib/toolbar/segmentation/cellpose-segmenter.service.mjs +84 -0
- package/esm2022/lib/toolbar/segmentation/onnx-sam-session.mjs +133 -0
- package/esm2022/lib/toolbar/segmentation/ort-runtime-config.mjs +31 -0
- package/esm2022/lib/toolbar/segmentation/sam-model-registry.mjs +108 -0
- package/esm2022/lib/toolbar/segmentation/sam-onnx-core.mjs +159 -0
- package/esm2022/lib/toolbar/segmentation/sam-point-tool.service.mjs +255 -0
- package/esm2022/lib/toolbar/segmentation/sam-prompt.mjs +94 -0
- package/esm2022/lib/toolbar/segmentation/sam-tool.service.mjs +188 -0
- package/esm2022/lib/toolbar/toolbar.component.mjs +311 -0
- package/esm2022/lib/toolbar/vertex-eraser/vertex-eraser-tool.service.mjs +234 -0
- package/esm2022/lib/toolbar/wand/wand-tool.service.mjs +499 -0
- package/esm2022/lib/toolbar/wand/wand.service.mjs +921 -0
- package/esm2022/lib/toolbar/zoom-to-box/zoom-to-box-tool.service.mjs +157 -0
- package/esm2022/lib/visualization.module.mjs +162 -0
- package/esm2022/lib/visualizer.component.mjs +1597 -0
- package/fesm2022/jax-data-science-sci-image-visualizer-mask-worker-uhepXUhM.mjs +12 -0
- package/fesm2022/jax-data-science-sci-image-visualizer-mask-worker-uhepXUhM.mjs.map +1 -0
- package/fesm2022/jax-data-science-sci-image-visualizer-onnx-sam-session-ci1q0xnJ.mjs +327 -0
- package/fesm2022/jax-data-science-sci-image-visualizer-onnx-sam-session-ci1q0xnJ.mjs.map +1 -0
- package/fesm2022/jax-data-science-sci-image-visualizer.mjs +21314 -0
- package/fesm2022/jax-data-science-sci-image-visualizer.mjs.map +1 -0
- package/fesm2022/mask.worker.js +989 -0
- package/fesm2022/onnx-sam.worker.js +202 -0
- package/index.d.ts +39 -0
- package/lib/channel-histogram/channel-histogram.component.d.ts +112 -0
- package/lib/contracts/capabilities.contract.d.ts +30 -0
- package/lib/contracts/cell-segmenter.contract.d.ts +40 -0
- package/lib/contracts/channel-histogram-api.contract.d.ts +98 -0
- package/lib/contracts/colormap-lut.d.ts +21 -0
- package/lib/contracts/coordinate-transform.contract.d.ts +43 -0
- package/lib/contracts/display-types.d.ts +41 -0
- package/lib/contracts/image.contract.d.ts +72 -0
- package/lib/contracts/intensity.d.ts +18 -0
- package/lib/contracts/plot-type.d.ts +108 -0
- package/lib/contracts/ports/image-state.port.d.ts +29 -0
- package/lib/contracts/ports/preferences.port.d.ts +19 -0
- package/lib/contracts/ports/region-io.port.d.ts +29 -0
- package/lib/contracts/ports/tile-access.port.d.ts +27 -0
- package/lib/contracts/region-editor-api.contract.d.ts +83 -0
- package/lib/contracts/region-overlay.contract.d.ts +47 -0
- package/lib/contracts/region-store.contract.d.ts +74 -0
- package/lib/contracts/sam.contract.d.ts +98 -0
- package/lib/contracts/toolbar-config.d.ts +24 -0
- package/lib/contracts/visualizer.contract.d.ts +346 -0
- package/lib/contracts/viz-config.d.ts +25 -0
- package/lib/hex-color-picker/hex-color-picker.component.d.ts +47 -0
- package/lib/implementations/base-store-visualizer.d.ts +71 -0
- package/lib/implementations/napari-js/napari-axes-labels.d.ts +47 -0
- package/lib/implementations/napari-js/napari-region-overlay.d.ts +115 -0
- package/lib/implementations/napari-js/napari-scale-bar.d.ts +31 -0
- package/lib/implementations/napari-js/napari-visualizer.service.d.ts +455 -0
- package/lib/implementations/napari-js/napari-volume-z-handle.d.ts +46 -0
- package/lib/implementations/osd/display-pipeline.d.ts +47 -0
- package/lib/implementations/osd/histogram-sampler.d.ts +85 -0
- package/lib/implementations/osd/openseadragon-visualizer.service.d.ts +476 -0
- package/lib/implementations/osd/osd-coordinate-transform.d.ts +17 -0
- package/lib/implementations/osd/osd-coords.d.ts +16 -0
- package/lib/implementations/osd/osd-lib.d.ts +19 -0
- package/lib/implementations/osd/osd-region-overlay.d.ts +191 -0
- package/lib/implementations/osd/osd-scale-bar.d.ts +17 -0
- package/lib/implementations/osd/slice-cache.d.ts +161 -0
- package/lib/implementations/osd/tile-client.d.ts +32 -0
- package/lib/implementations/plotly/plotly-coordinate-transform.d.ts +19 -0
- package/lib/implementations/plotly/plotly-region-overlay.d.ts +23 -0
- package/lib/implementations/plotly/plotly-trace-builders.d.ts +60 -0
- package/lib/implementations/plotly/plotly.service.d.ts +594 -0
- package/lib/implementations/simple-slice-access.service.d.ts +64 -0
- package/lib/models/bezier.d.ts +59 -0
- package/lib/models/class-preset.d.ts +39 -0
- package/lib/models/geometry.d.ts +66 -0
- package/lib/models/region.d.ts +132 -0
- package/lib/models/shape.d.ts +44 -0
- package/lib/plot.utilities.d.ts +107 -0
- package/lib/processing/image-converter.service.d.ts +28 -0
- package/lib/processing/image-crop.d.ts +18 -0
- package/lib/processing/processing-image.d.ts +17 -0
- package/lib/provide-visualization.d.ts +34 -0
- package/lib/region-editor/mask-raster.d.ts +61 -0
- package/lib/region-editor/mask-worker.d.ts +7 -0
- package/lib/region-editor/region-editor.component.d.ts +305 -0
- package/lib/region-ops.service.d.ts +92 -0
- package/lib/render-orchestrator.d.ts +59 -0
- package/lib/routing-visualizer.service.d.ts +227 -0
- package/lib/store/class-color.util.d.ts +26 -0
- package/lib/store/region-store.service.d.ts +315 -0
- package/lib/store/visualizer-store.service.d.ts +123 -0
- package/lib/toolbar/brush/brush-tool.service.d.ts +143 -0
- package/lib/toolbar/crop/slide-crop.d.ts +30 -0
- package/lib/toolbar/segmentation/cell-segment-tool.service.d.ts +32 -0
- package/lib/toolbar/segmentation/cellpose-segmenter.service.d.ts +39 -0
- package/lib/toolbar/segmentation/onnx-sam-session.d.ts +25 -0
- package/lib/toolbar/segmentation/ort-runtime-config.d.ts +4 -0
- package/lib/toolbar/segmentation/sam-model-registry.d.ts +36 -0
- package/lib/toolbar/segmentation/sam-onnx-core.d.ts +48 -0
- package/lib/toolbar/segmentation/sam-point-tool.service.d.ts +59 -0
- package/lib/toolbar/segmentation/sam-prompt.d.ts +34 -0
- package/lib/toolbar/segmentation/sam-tool.service.d.ts +50 -0
- package/lib/toolbar/toolbar.component.d.ts +167 -0
- package/lib/toolbar/vertex-eraser/vertex-eraser-tool.service.d.ts +64 -0
- package/lib/toolbar/wand/wand-tool.service.d.ts +149 -0
- package/lib/toolbar/wand/wand.service.d.ts +133 -0
- package/lib/toolbar/zoom-to-box/zoom-to-box-tool.service.d.ts +49 -0
- package/lib/visualization.module.d.ts +45 -0
- package/lib/visualizer.component.d.ts +378 -0
- package/package.json +73 -0
- package/src/lib/assets/3d-coordinates.svg +49 -0
- package/src/lib/assets/cells.svg +1 -0
- package/src/lib/assets/click.svg +1 -0
- package/src/lib/assets/colormap-luts.json +1 -0
- package/src/lib/assets/contour.svg +48 -0
- package/src/lib/assets/cube-3d.svg +1 -0
- package/src/lib/assets/edit-selection-white.svg +47 -0
- package/src/lib/assets/heatmap.svg +1 -0
- package/src/lib/assets/icons/colormap-Pastel1.png +0 -0
- package/src/lib/assets/icons/colormap-accent.png +0 -0
- package/src/lib/assets/icons/colormap-afmhot.png +0 -0
- package/src/lib/assets/icons/colormap-autumn.png +0 -0
- package/src/lib/assets/icons/colormap-berlin.png +0 -0
- package/src/lib/assets/icons/colormap-binary.png +0 -0
- package/src/lib/assets/icons/colormap-blackbody.png +0 -0
- package/src/lib/assets/icons/colormap-bluered.png +0 -0
- package/src/lib/assets/icons/colormap-blues.png +0 -0
- package/src/lib/assets/icons/colormap-bone.png +0 -0
- package/src/lib/assets/icons/colormap-brbg.png +0 -0
- package/src/lib/assets/icons/colormap-brg.png +0 -0
- package/src/lib/assets/icons/colormap-bugn.png +0 -0
- package/src/lib/assets/icons/colormap-bupu.png +0 -0
- package/src/lib/assets/icons/colormap-bwr.png +0 -0
- package/src/lib/assets/icons/colormap-cividis.png +0 -0
- package/src/lib/assets/icons/colormap-cmrmap.png +0 -0
- package/src/lib/assets/icons/colormap-cool.png +0 -0
- package/src/lib/assets/icons/colormap-coolwarm.png +0 -0
- package/src/lib/assets/icons/colormap-copper.png +0 -0
- package/src/lib/assets/icons/colormap-cubehelix.png +0 -0
- package/src/lib/assets/icons/colormap-dark2.png +0 -0
- package/src/lib/assets/icons/colormap-earth.png +0 -0
- package/src/lib/assets/icons/colormap-electric.png +0 -0
- package/src/lib/assets/icons/colormap-flag.png +0 -0
- package/src/lib/assets/icons/colormap-gist_earth.png +0 -0
- package/src/lib/assets/icons/colormap-gist_gray.png +0 -0
- package/src/lib/assets/icons/colormap-gist_heat.png +0 -0
- package/src/lib/assets/icons/colormap-gist_ncar.png +0 -0
- package/src/lib/assets/icons/colormap-gist_rainbow.png +0 -0
- package/src/lib/assets/icons/colormap-gist_stern.png +0 -0
- package/src/lib/assets/icons/colormap-gist_yarg.png +0 -0
- package/src/lib/assets/icons/colormap-gnbu.png +0 -0
- package/src/lib/assets/icons/colormap-gnuplot.png +0 -0
- package/src/lib/assets/icons/colormap-gnuplot2.png +0 -0
- package/src/lib/assets/icons/colormap-gray.png +0 -0
- package/src/lib/assets/icons/colormap-greens-inv.png +0 -0
- package/src/lib/assets/icons/colormap-greens.png +0 -0
- package/src/lib/assets/icons/colormap-greys-inv.png +0 -0
- package/src/lib/assets/icons/colormap-greys.png +0 -0
- package/src/lib/assets/icons/colormap-hot.png +0 -0
- package/src/lib/assets/icons/colormap-hsv.png +0 -0
- package/src/lib/assets/icons/colormap-inferno.png +0 -0
- package/src/lib/assets/icons/colormap-jet.png +0 -0
- package/src/lib/assets/icons/colormap-magma.png +0 -0
- package/src/lib/assets/icons/colormap-managua.png +0 -0
- package/src/lib/assets/icons/colormap-nipy_spectral.png +0 -0
- package/src/lib/assets/icons/colormap-ocean.png +0 -0
- package/src/lib/assets/icons/colormap-oranges.png +0 -0
- package/src/lib/assets/icons/colormap-orrd.png +0 -0
- package/src/lib/assets/icons/colormap-pastel2.png +0 -0
- package/src/lib/assets/icons/colormap-picnic.png +0 -0
- package/src/lib/assets/icons/colormap-pink.png +0 -0
- package/src/lib/assets/icons/colormap-piyg.png +0 -0
- package/src/lib/assets/icons/colormap-placeholder.png +0 -0
- package/src/lib/assets/icons/colormap-plasma.png +0 -0
- package/src/lib/assets/icons/colormap-portland.png +0 -0
- package/src/lib/assets/icons/colormap-prgn.png +0 -0
- package/src/lib/assets/icons/colormap-prism.png +0 -0
- package/src/lib/assets/icons/colormap-pubu.png +0 -0
- package/src/lib/assets/icons/colormap-pubugn.png +0 -0
- package/src/lib/assets/icons/colormap-puor.png +0 -0
- package/src/lib/assets/icons/colormap-purd.png +0 -0
- package/src/lib/assets/icons/colormap-purples.png +0 -0
- package/src/lib/assets/icons/colormap-rainbow.png +0 -0
- package/src/lib/assets/icons/colormap-rdbu.png +0 -0
- package/src/lib/assets/icons/colormap-rdgy.png +0 -0
- package/src/lib/assets/icons/colormap-rdpu.png +0 -0
- package/src/lib/assets/icons/colormap-rdylbu.png +0 -0
- package/src/lib/assets/icons/colormap-rdylgn.png +0 -0
- package/src/lib/assets/icons/colormap-reds.png +0 -0
- package/src/lib/assets/icons/colormap-seismic.png +0 -0
- package/src/lib/assets/icons/colormap-set1.png +0 -0
- package/src/lib/assets/icons/colormap-set2.png +0 -0
- package/src/lib/assets/icons/colormap-set3.png +0 -0
- package/src/lib/assets/icons/colormap-spectral.png +0 -0
- package/src/lib/assets/icons/colormap-spring.png +0 -0
- package/src/lib/assets/icons/colormap-summer.png +0 -0
- package/src/lib/assets/icons/colormap-tab10.png +0 -0
- package/src/lib/assets/icons/colormap-tab20.png +0 -0
- package/src/lib/assets/icons/colormap-tab20b.png +0 -0
- package/src/lib/assets/icons/colormap-tab20c.png +0 -0
- package/src/lib/assets/icons/colormap-terrain.png +0 -0
- package/src/lib/assets/icons/colormap-turbo.png +0 -0
- package/src/lib/assets/icons/colormap-twilight.png +0 -0
- package/src/lib/assets/icons/colormap-twilight_shifted.png +0 -0
- package/src/lib/assets/icons/colormap-vanimo.png +0 -0
- package/src/lib/assets/icons/colormap-viridis.png +0 -0
- package/src/lib/assets/icons/colormap-winter.png +0 -0
- package/src/lib/assets/icons/colormap-wistia.png +0 -0
- package/src/lib/assets/icons/colormap-ylgn.png +0 -0
- package/src/lib/assets/icons/colormap-ylgnbu-inv.png +0 -0
- package/src/lib/assets/icons/colormap-ylgnbu.png +0 -0
- package/src/lib/assets/icons/colormap-ylorbr.png +0 -0
- package/src/lib/assets/icons/colormap-ylorrd-inv.png +0 -0
- package/src/lib/assets/icons/colormap-ylorrd.png +0 -0
- package/src/lib/assets/interactive-segmentation-cursor.svg +1 -0
- package/src/lib/assets/invert.svg +1 -0
- package/src/lib/assets/isosurface.svg +7 -0
- package/src/lib/assets/mask.svg +1 -0
- package/src/lib/assets/paintbrush.svg +1 -0
- package/src/lib/assets/picture-segmentation.svg +43 -0
- package/src/lib/assets/polygon-vertices.svg +13 -0
- package/src/lib/assets/polyline.svg +3 -0
- package/src/lib/assets/redo.svg +39 -0
- package/src/lib/assets/region-editor.svg +37 -0
- package/src/lib/assets/region-move.svg +7 -0
- package/src/lib/assets/smooth.svg +56 -0
- package/src/lib/assets/spline-chart.svg +7 -0
- package/src/lib/assets/surface.svg +37 -0
- package/src/lib/assets/test/download-379.svg +1 -0
- package/src/lib/assets/test/download-98.svg +1 -0
- package/src/lib/assets/test/json-1.svg +1 -0
- package/src/lib/assets/test/load-53.svg +1 -0
- package/src/lib/assets/test/mask-44.svg +1 -0
- package/src/lib/assets/test/mask-download-44.svg +15 -0
- package/src/lib/assets/test/mask-save-44.svg +11 -0
- package/src/lib/assets/test/overlay-1.svg +1 -0
- package/src/lib/assets/test/overlay-4.svg +1 -0
- package/src/lib/assets/test/region-26.svg +1 -0
- package/src/lib/assets/test/save-56.svg +1 -0
- package/src/lib/assets/test/upload-43.svg +1 -0
- package/src/lib/assets/to-bezier.svg +15 -0
- package/src/lib/assets/to-polygon.svg +11 -0
- package/src/lib/assets/undo.svg +38 -0
- package/src/lib/assets/vertex-add.svg +12 -0
- package/src/lib/assets/vertex-delete.svg +12 -0
- package/src/lib/assets/wand.svg +54 -0
- package/src/lib/assets/zoom-box.svg +10 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { IRegionStore } from '../../contracts/visualizer.contract';
|
|
2
|
+
import { IRegionEditApi } from '../../contracts/region-store.contract';
|
|
3
|
+
import { IRegionOverlay, RegionToolMode } from '../../contracts/region-overlay.contract';
|
|
4
|
+
/**
|
|
5
|
+
* The shared region store as the overlay needs it: the cross-backend
|
|
6
|
+
* {@link IRegionStore} (read regions, selection, colours) plus the Region-native
|
|
7
|
+
* {@link IRegionEditApi} (add/move/resize/vertex edits). The shared RegionStore
|
|
8
|
+
* satisfies both. The overlay edits through these typed operations on the
|
|
9
|
+
* neutral Region model — it never touches a backend's own shape representation
|
|
10
|
+
* (e.g. Plotly's `x0/y0/x1/y1` / `M…L…Z` dicts).
|
|
11
|
+
*/
|
|
12
|
+
export type RegionEditStore = IRegionStore & IRegionEditApi;
|
|
13
|
+
/**
|
|
14
|
+
* OpenSeadragon implementation of {@link IRegionOverlay}.
|
|
15
|
+
*
|
|
16
|
+
* - Renders the store's regions (rect/polygon) in image-pixel space, kept
|
|
17
|
+
* aligned on every pan/zoom via the OSD viewport API.
|
|
18
|
+
* - Draws new rectangle and polygon regions (committed to the shared store).
|
|
19
|
+
* - Click-to-select in 'select' mode.
|
|
20
|
+
*
|
|
21
|
+
* Reads/writes the shared {@link IRegionStore}, so regions stay in sync with the
|
|
22
|
+
* Region Editor and the Plotly backend. The wand, vertex-eraser and zoom-to-box
|
|
23
|
+
* tools are NOT handled here — they're owned by OpenSeadragonVisualizerService
|
|
24
|
+
* (which binds them to OSD via the shared coordinate transform + viewport pixel
|
|
25
|
+
* readback), the same singleton tool services the Plotly backend uses.
|
|
26
|
+
*/
|
|
27
|
+
export declare class OsdRegionOverlay implements IRegionOverlay {
|
|
28
|
+
private viewer;
|
|
29
|
+
private store;
|
|
30
|
+
private readonly svg;
|
|
31
|
+
private readonly subs;
|
|
32
|
+
private readonly osd;
|
|
33
|
+
private selected;
|
|
34
|
+
private mode;
|
|
35
|
+
private tracker;
|
|
36
|
+
private rectStart;
|
|
37
|
+
private rectCurrent;
|
|
38
|
+
private polyPoints;
|
|
39
|
+
/** True while dragging a freehand path (freeform / polyline). */
|
|
40
|
+
private freehandDragging;
|
|
41
|
+
/** True while placing a click-to-add polygon ('drawpolygon' mode). */
|
|
42
|
+
private drawingPolygon;
|
|
43
|
+
/** Last element-pixel point appended, to thin the freehand path. */
|
|
44
|
+
private lastFreehandPx;
|
|
45
|
+
/**
|
|
46
|
+
* In-progress edit of the selected region:
|
|
47
|
+
* - kind 'bounds' — rectangle resize/move or whole-region move (uses `zone`);
|
|
48
|
+
* - kind 'vertex' — dragging a single polygon vertex (uses `vertexIndex`).
|
|
49
|
+
*/
|
|
50
|
+
private edit;
|
|
51
|
+
private editDragged;
|
|
52
|
+
/** Rubber-band (marquee) multi-select in 'select' mode: press on empty space
|
|
53
|
+
* and drag to select every region the band intersects. Image coords. */
|
|
54
|
+
private bandStart;
|
|
55
|
+
private bandCurrent;
|
|
56
|
+
private bandDragged;
|
|
57
|
+
private readonly redrawHandler;
|
|
58
|
+
constructor(viewer: any, store: RegionEditStore);
|
|
59
|
+
/** Switch drawing/selection mode; toggles OSD navigation accordingly. */
|
|
60
|
+
setMode(mode: RegionToolMode): void;
|
|
61
|
+
/** Drive OSD zoom from the wheel while any tool owns the pointer.
|
|
62
|
+
*
|
|
63
|
+
* OSD's native scroll-zoom is part of mouse-nav, so `setMouseNavEnabled(false)`
|
|
64
|
+
* (used by every region tool and by the wand/brush/eraser/SAM tools) disables
|
|
65
|
+
* it. The covering-canvas tools also sit above the OSD canvas and swallow the
|
|
66
|
+
* wheel outright. This listener is bound once to the viewer element — an
|
|
67
|
+
* ancestor of both the OSD canvas and the tool overlays — and forwards the
|
|
68
|
+
* wheel to a cursor-centred zoom whenever mouse-nav is off. When nav is on (no
|
|
69
|
+
* tool active) it does nothing and OSD zooms natively. (jit-ui#94) */
|
|
70
|
+
private readonly wheelZoomHandler;
|
|
71
|
+
/** Cursor feedback per mode (crosshair while drawing; pointer over a region
|
|
72
|
+
* in select mode). */
|
|
73
|
+
private updateCursor;
|
|
74
|
+
/** Whether the selected region's vertices/handles should be drawn. Shown
|
|
75
|
+
* whenever a region is selected — including `none` (display) mode and while
|
|
76
|
+
* another tool (wand, brush, SAM…) is active — so a selection always reveals
|
|
77
|
+
* its vertices. Suppressed only while actively drawing a brand-new shape,
|
|
78
|
+
* where stray handles would be noise. */
|
|
79
|
+
private get showsSelectedVertices();
|
|
80
|
+
destroy(): void;
|
|
81
|
+
/** Image-pixel point -> element pixel point. */
|
|
82
|
+
private toPx;
|
|
83
|
+
/** Element pixel point (from a MouseTracker event) -> image-pixel point. */
|
|
84
|
+
private toImage;
|
|
85
|
+
redraw(): void;
|
|
86
|
+
/** A small vertex handle (filled for an emphasised marker, hollow otherwise).
|
|
87
|
+
* Colour defaults to the global shape colour (used by the in-progress draw
|
|
88
|
+
* preview); selected-region handles pass the region's own colour. */
|
|
89
|
+
private vertexMarker;
|
|
90
|
+
private buildRegionEl;
|
|
91
|
+
/** Marquee rectangle for rubber-band multi-select (dashed outline + faint fill). */
|
|
92
|
+
private selectionBand;
|
|
93
|
+
private rectPreview;
|
|
94
|
+
private polyPreview;
|
|
95
|
+
/** SVG path `d` (element-pixel coords) for a straight-edged ring/polyline. */
|
|
96
|
+
private straightPathD;
|
|
97
|
+
/** SVG path `d` (element-pixel coords) for the smooth cubic bezier through a
|
|
98
|
+
* polygon's anchors — the paper.js-equivalent curve. */
|
|
99
|
+
private bezierPathD;
|
|
100
|
+
/** SVG cubic-bezier path `d` (element px) for any ring (exterior or hole). Uses the stored
|
|
101
|
+
* per-vertex handle offsets when present, else the Catmull-Rom default (resolveHandles). */
|
|
102
|
+
private ringBezierPathD;
|
|
103
|
+
/**
|
|
104
|
+
* Draw the bezier editing handles for the selected region, paper.js-style:
|
|
105
|
+
* each anchor as a small square, with tangent lines out to its two control
|
|
106
|
+
* points (drawn as small circles).
|
|
107
|
+
*/
|
|
108
|
+
private drawBezierHandles;
|
|
109
|
+
/** A tangent line from an anchor to a control point, with a circle at the end. */
|
|
110
|
+
private drawHandle;
|
|
111
|
+
/** A filled-white anchor square (the editable vertex). */
|
|
112
|
+
private anchorSquare;
|
|
113
|
+
private rgba;
|
|
114
|
+
private get isFreehand();
|
|
115
|
+
private onPress;
|
|
116
|
+
/** Begin an edit gesture (move/resize or single-vertex drag) and open a store
|
|
117
|
+
* batch so the live drag emits once on release. */
|
|
118
|
+
private startEdit;
|
|
119
|
+
private onDrag;
|
|
120
|
+
private onRelease;
|
|
121
|
+
private onClick;
|
|
122
|
+
/**
|
|
123
|
+
* Click-to-place polygon ('drawpolygon'): the first click starts the
|
|
124
|
+
* polygon, each subsequent click adds a vertex, and clicking near the first
|
|
125
|
+
* vertex (with at least 3 placed) closes and commits it.
|
|
126
|
+
*/
|
|
127
|
+
private onDrawPolygonClick;
|
|
128
|
+
/**
|
|
129
|
+
* Hover feedback in select mode: move/resize cursors over the selected
|
|
130
|
+
* region's body/edges/corners, a pointer over any other region.
|
|
131
|
+
*/
|
|
132
|
+
private onMove;
|
|
133
|
+
/**
|
|
134
|
+
* The move/resize zone under the cursor for the currently-selected region
|
|
135
|
+
* (rectangles get edge/corner handles + body; polygons get body-move only),
|
|
136
|
+
* or null if the cursor isn't over the selected region.
|
|
137
|
+
*/
|
|
138
|
+
private editZoneAt;
|
|
139
|
+
/** The currently-selected region (the last one selected), or null. */
|
|
140
|
+
private selectedRegionInfo;
|
|
141
|
+
/** The vertex of the selected polygon under the cursor (screen-pixel
|
|
142
|
+
* tolerance), or null. Rectangles have no editable vertices. */
|
|
143
|
+
private hitVertex;
|
|
144
|
+
/** The bezier control handle of the selected region under the cursor (which
|
|
145
|
+
* anchor, and whether the in- or out-handle), or null. */
|
|
146
|
+
private hitBezierHandle;
|
|
147
|
+
/** The edge of `region`'s polygon nearest the cursor (within tolerance), with
|
|
148
|
+
* the clicked point in image coords as the insertion position, or null. */
|
|
149
|
+
private hitEdge;
|
|
150
|
+
/** Classify a screen point against a screen-space rectangle into a zone. */
|
|
151
|
+
private rectZone;
|
|
152
|
+
/** Snapshot the selected region's geometry at the start of an edit. */
|
|
153
|
+
private snapshot;
|
|
154
|
+
/**
|
|
155
|
+
* Apply the in-progress move/resize to the region, live, through the
|
|
156
|
+
* Region-native edit API. Recomputed absolutely from the gesture-start
|
|
157
|
+
* snapshot (`orig`) + the total delta, so each frame is idempotent.
|
|
158
|
+
*/
|
|
159
|
+
private applyEdit;
|
|
160
|
+
private selectAt;
|
|
161
|
+
/** Indices of every region whose bounding box intersects the image-space
|
|
162
|
+
* rectangle [x0,y0]–[x1,y1] (rubber-band multi-select). */
|
|
163
|
+
private regionsInRect;
|
|
164
|
+
/** Axis-aligned bounding box of a region in image coords, or null if empty. */
|
|
165
|
+
private regionBBox;
|
|
166
|
+
/** Index of the topmost region under a point, or -1. */
|
|
167
|
+
private regionIndexAt;
|
|
168
|
+
private containsPoint;
|
|
169
|
+
/** Point-in-closed-polygon (image coords) honouring interior rings (holes):
|
|
170
|
+
* inside the exterior AND outside every hole (even-odd). */
|
|
171
|
+
private closedPolygonContains;
|
|
172
|
+
/** Shortest distance from point p to segment a–b, all in screen pixels. */
|
|
173
|
+
private distToSegmentPx;
|
|
174
|
+
private resetInProgress;
|
|
175
|
+
private commitRectangle;
|
|
176
|
+
private commitPolygon;
|
|
177
|
+
/**
|
|
178
|
+
* Add a freshly-drawn region to the shared store and redraw immediately. The
|
|
179
|
+
* store mints the id, selects the new region (so it renders solid/highlighted
|
|
180
|
+
* rather than as a dashed in-progress shape) and emits the full region list to
|
|
181
|
+
* the Region Editor — we still redraw locally rather than relying solely on
|
|
182
|
+
* the store's update event, which can be swallowed when Plotly isn't active.
|
|
183
|
+
*/
|
|
184
|
+
private commitRegion;
|
|
185
|
+
/**
|
|
186
|
+
* Convert the selected region(s) to/from a bezier curve (toBezier = true /
|
|
187
|
+
* toPolygon = false). One-shot; the anchors are unchanged,
|
|
188
|
+
* only the smooth-curve rendering is toggled.
|
|
189
|
+
*/
|
|
190
|
+
setSelectedBezier(bezier: boolean): void;
|
|
191
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A physical scale bar drawn over an OpenSeadragon viewer. Recomputes on every
|
|
3
|
+
* pan/zoom from the viewport's image→screen scale and the image's µm/pixel
|
|
4
|
+
* (`mppX`, from Bio-Formats). Hidden when the image has no physical pixel size.
|
|
5
|
+
*/
|
|
6
|
+
export declare class OsdScaleBar {
|
|
7
|
+
private viewer;
|
|
8
|
+
private mppX;
|
|
9
|
+
private readonly osd;
|
|
10
|
+
private readonly bar;
|
|
11
|
+
private readonly line;
|
|
12
|
+
private readonly label;
|
|
13
|
+
private readonly redrawHandler;
|
|
14
|
+
constructor(viewer: any, mppX: number);
|
|
15
|
+
private update;
|
|
16
|
+
destroy(): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stack-slice cache for the OpenSeadragon backend (refactoring plan, Step 3 —
|
|
3
|
+
* a pure move of the cache cluster out of the visualizer service).
|
|
4
|
+
*
|
|
5
|
+
* Scrubbing the z-slider used to viewer.open() a fresh tile source per slice,
|
|
6
|
+
* which destroys the current tiled image (and its decoded+recolored tiles), so
|
|
7
|
+
* revisiting a slice re-fetched everything. Instead we keep each visited slice
|
|
8
|
+
* as its own tiled image in the world and just toggle opacity — a revisited
|
|
9
|
+
* slice is instant (no network, no re-decode, no re-recolor). Bounded by an
|
|
10
|
+
* LRU so deep stacks don't grow without limit. Multichannel slices cache one
|
|
11
|
+
* TiledImage per channel (additively composited); composite slices cache one.
|
|
12
|
+
* A background loader pre-fills the rest of the stack, one slice at a time,
|
|
13
|
+
* yielding to the visible slice so on-screen tiles always win the connection.
|
|
14
|
+
*/
|
|
15
|
+
/** What the cache needs from the visualizer service. All accessors are live
|
|
16
|
+
* (called at use time, never captured) so the cache always sees the current
|
|
17
|
+
* viewer/descriptor/z — matching the field reads it replaced. */
|
|
18
|
+
export interface SliceCacheHost {
|
|
19
|
+
/** The mounted viewer, or null. */
|
|
20
|
+
viewer(): any | null;
|
|
21
|
+
/** True when a viewer, descriptor and infoB64 are all present. */
|
|
22
|
+
hasImage(): boolean;
|
|
23
|
+
/** Stack depth (descriptor.z, 1 for single images). */
|
|
24
|
+
sliceCount(): number;
|
|
25
|
+
/** The currently displayed z-slice. */
|
|
26
|
+
currentZ(): number;
|
|
27
|
+
/** Per-channel rendering (multichannel fluorescence) vs composite. */
|
|
28
|
+
isMultiChannel(): boolean;
|
|
29
|
+
/** Channel count for a multichannel group add. */
|
|
30
|
+
channelCount(): number;
|
|
31
|
+
/** Channel visibility (drives group reveal opacity). */
|
|
32
|
+
channelVisible(c: number): boolean;
|
|
33
|
+
/** Tile source for slice z (optionally one channel). */
|
|
34
|
+
buildTileSource(z: number, channel?: number): any;
|
|
35
|
+
/** A composite slice landed in the world — the service samples its window. */
|
|
36
|
+
onCompositeSliceAdded(z: number): void;
|
|
37
|
+
}
|
|
38
|
+
export declare class SliceCache {
|
|
39
|
+
private host;
|
|
40
|
+
/** z-slice → its TiledImage in the viewer world (composite path). */
|
|
41
|
+
private sliceItems;
|
|
42
|
+
/** Multichannel per-slice cache: z → the N channel TiledImages for that slice
|
|
43
|
+
* (additively composited by OSD; index = channel). Only the active slice's
|
|
44
|
+
* visible channels have opacity > 0. */
|
|
45
|
+
private channelSliceItems;
|
|
46
|
+
/** Cached multichannel slices whose tiles were tinted before the latest
|
|
47
|
+
* display change; re-tinted lazily when next revealed by z-scrub. */
|
|
48
|
+
private staleSlices;
|
|
49
|
+
/** Most-recently-shown z last; drives LRU eviction. */
|
|
50
|
+
private sliceLru;
|
|
51
|
+
/** z-slices whose tiled image is being added (dedupe rapid scrubbing). */
|
|
52
|
+
private slicesLoading;
|
|
53
|
+
/** Bumped whenever the loaded image changes; in-flight background slice adds
|
|
54
|
+
* captured under an older token are dropped (cancelled image switch). */
|
|
55
|
+
private sliceLoadToken;
|
|
56
|
+
/** The slice the background loader is currently waiting on (its tiles are
|
|
57
|
+
* still streaming): addTiledImage 'success' fires on add, not on tile load,
|
|
58
|
+
* so we gate the next slice on getFullyLoaded(). */
|
|
59
|
+
private bgLoadingZ;
|
|
60
|
+
/** When bgLoadingZ started loading — a fallback so a slow/stuck slice can't
|
|
61
|
+
* stall the whole background pass forever. */
|
|
62
|
+
private bgLoadingSince;
|
|
63
|
+
/** Slices the background loader has already attempted (no tight retry loop). */
|
|
64
|
+
private bgAttempted;
|
|
65
|
+
/** Max cached slice tiled images kept resident before LRU eviction. */
|
|
66
|
+
private maxCachedSlices;
|
|
67
|
+
/** Upper bound on resident slices, regardless of stack depth (memory guard). */
|
|
68
|
+
private readonly MAX_CACHED_SLICES_CAP;
|
|
69
|
+
/** Fit-view tile budget above which background preloading is skipped: a huge
|
|
70
|
+
* no-pyramid stack would preload every slice at full resolution and
|
|
71
|
+
* flood/timeout. Normal stacks stay below it and KEEP the flicker-free
|
|
72
|
+
* pre-cache. */
|
|
73
|
+
private readonly MAX_PREFETCH_FIT_TILES;
|
|
74
|
+
/** True only for stacks too large to background-preload. */
|
|
75
|
+
private skipSlicePrefetch;
|
|
76
|
+
private prefetchTimer;
|
|
77
|
+
constructor(host: SliceCacheHost);
|
|
78
|
+
/** Size the cache for the loaded image: keep the whole stack resident
|
|
79
|
+
* (capped) so the background loader fills every slice without evicting
|
|
80
|
+
* itself; skip preloading entirely when even the coarsest level's tile
|
|
81
|
+
* grid is too large (its slices only exist at full resolution). */
|
|
82
|
+
configure(stackDepth: number, coarseFitTiles: number): void;
|
|
83
|
+
/** Current LRU cap (the viewer sizes its tile cache from it). */
|
|
84
|
+
maxSlices(): number;
|
|
85
|
+
/** Drop the per-channel groups (on a fresh plot). */
|
|
86
|
+
clearChannelGroups(): void;
|
|
87
|
+
/** Seed the cache with the just-opened composite slice (world item 0), so
|
|
88
|
+
* scrubbing back to it later is an instant opacity toggle, not a re-open. */
|
|
89
|
+
seedComposite(z: number, item: any): void;
|
|
90
|
+
/** Show slice z: reveal it instantly when cached (re-tinting a stale
|
|
91
|
+
* multichannel group), otherwise add it once. The current slice stays
|
|
92
|
+
* visible until the new one is in — no white-flicker. */
|
|
93
|
+
showSlice(z: number): void;
|
|
94
|
+
/** Add a never-seen slice as a hidden tiled image, then reveal it once loaded
|
|
95
|
+
* (composite path; multichannel routes to addChannelSlice). */
|
|
96
|
+
private addSlice;
|
|
97
|
+
/**
|
|
98
|
+
* Add slice z's channel group: one additively-composited ('lighter' = Fiji
|
|
99
|
+
* "Composite") TiledImage per channel, hidden (opacity 0) until revealed.
|
|
100
|
+
* Each is preloaded so the background loader can pre-fill every slice.
|
|
101
|
+
* Cached so a revisit is an instant opacity toggle — no re-fetch, no
|
|
102
|
+
* white-flicker. Mirrors addSlice for the composite path.
|
|
103
|
+
*/
|
|
104
|
+
addChannelSlice(z: number): void;
|
|
105
|
+
/** Reveal slice z's channel group (each visible channel → opacity 1) and
|
|
106
|
+
* hide every other cached slice's group. Instant; no fetch/decode. */
|
|
107
|
+
revealChannelSlice(z: number): void;
|
|
108
|
+
/** Show the given composite slice (opacity 1) and hide all other cached slices. */
|
|
109
|
+
private showOnlySlice;
|
|
110
|
+
/** Re-tint after a display change: invalidate ONLY the visible slice's
|
|
111
|
+
* channel images — invalidating the whole world would re-process every
|
|
112
|
+
* hidden/preloaded slice's tiles (hundreds), flooding OSD and wasting work
|
|
113
|
+
* on tiles that aren't on screen. The other cached slices are marked stale
|
|
114
|
+
* and re-tinted lazily when revealed. */
|
|
115
|
+
invalidateChannelDisplay(z: number): void;
|
|
116
|
+
/** Invalidate (restore + re-recolor) just the channel images of one cached
|
|
117
|
+
* slice. A shared timestamp batches the per-image invalidations into one
|
|
118
|
+
* processing pass (OSD dedupes tiles already stamped at >= tStamp). */
|
|
119
|
+
private invalidateSlice;
|
|
120
|
+
/** Debounce so a burst of viewport/slice events coalesces, then advance the
|
|
121
|
+
* background stack loader by one slice. */
|
|
122
|
+
schedulePrefetch(): void;
|
|
123
|
+
/**
|
|
124
|
+
* Background-load the whole stack: add each not-yet-cached slice as a
|
|
125
|
+
* hidden, preloaded tiled image, one at a time, working outward from the
|
|
126
|
+
* current slice — and never blocking the visible slice (it yields while the
|
|
127
|
+
* current view is still streaming tiles; only one slice is in flight at a
|
|
128
|
+
* time so the on-screen tiles always win the connection).
|
|
129
|
+
*/
|
|
130
|
+
private loadNextBackgroundSlice;
|
|
131
|
+
/** The not-yet-cached slice closest to the current one (load nearest first),
|
|
132
|
+
* skipping any already attempted so a failed/slow one isn't retried in a loop. */
|
|
133
|
+
private nearestUncachedSlice;
|
|
134
|
+
/**
|
|
135
|
+
* Stop background stack preloading and invalidate any in-flight slice add.
|
|
136
|
+
* Called when a different image is selected so the previous stack stops
|
|
137
|
+
* loading immediately instead of finishing in the background.
|
|
138
|
+
*/
|
|
139
|
+
cancelBackgroundLoad(): void;
|
|
140
|
+
/** Remove every cached slice except the currently displayed one, aborting
|
|
141
|
+
* their in-flight tile requests. */
|
|
142
|
+
private dropHiddenSlices;
|
|
143
|
+
/** Whether slice z is in the active cache (composite single image, or the
|
|
144
|
+
* multichannel per-channel group). */
|
|
145
|
+
private sliceCacheHas;
|
|
146
|
+
/** The cached TiledImage(s) for slice z (0–1 for composite, N for multichannel). */
|
|
147
|
+
private sliceGroup;
|
|
148
|
+
/** Whether slice z's tiles are still streaming (any cached image not fully loaded). */
|
|
149
|
+
private sliceTilesLoading;
|
|
150
|
+
/** Remove slice z's cached image(s) from the world and the active cache. */
|
|
151
|
+
private removeCachedSlice;
|
|
152
|
+
/** Is the tiled image still in the world (not evicted)? */
|
|
153
|
+
private sliceInWorld;
|
|
154
|
+
/** Mark z as most-recently-used. */
|
|
155
|
+
private touchSliceLru;
|
|
156
|
+
/** Drop the least-recently-used cached slices beyond the cap (never the
|
|
157
|
+
* current one), removing their tiled images so memory stays bounded. */
|
|
158
|
+
private evictSliceLru;
|
|
159
|
+
/** Clear the cache (on teardown / image switch). */
|
|
160
|
+
reset(): void;
|
|
161
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { HttpClient } from '@angular/common/http';
|
|
2
|
+
/**
|
|
3
|
+
* Single source of truth for jit-service `/tile` access from the OSD backend
|
|
4
|
+
* (refactoring plan, Step 2). Before this module the tile URL was string-built
|
|
5
|
+
* in four places and the fetch→decode pipeline copy-pasted in three — every
|
|
6
|
+
* query-param change had to be repeated per site.
|
|
7
|
+
*
|
|
8
|
+
* Error handling is deliberately left to the CALL SITES: these helpers
|
|
9
|
+
* propagate failures so each caller keeps its own tagged catch
|
|
10
|
+
* (`[viz:histogram]`, `[viz:window]`, `[viz:export]`) and its own
|
|
11
|
+
* skip/fallback semantics.
|
|
12
|
+
*/
|
|
13
|
+
/** Tile coordinates for one `/tile` request. `channel == null` (or omitted)
|
|
14
|
+
* requests the server-composited tile; an index (including 0) requests that
|
|
15
|
+
* single channel as grayscale. */
|
|
16
|
+
export interface TileCoords {
|
|
17
|
+
res: number;
|
|
18
|
+
col: number;
|
|
19
|
+
row: number;
|
|
20
|
+
z: number;
|
|
21
|
+
tileSize: number;
|
|
22
|
+
channel?: number | null;
|
|
23
|
+
}
|
|
24
|
+
/** Build the `/tile` request URL — the one place its query shape lives. */
|
|
25
|
+
export declare function buildTileUrl(api: string, infoB64: string, c: TileCoords): string;
|
|
26
|
+
/** Fetch a tile PNG and decode it to an ImageBitmap. The caller owns the
|
|
27
|
+
* bitmap (call `close()` when done). Throws on network/decode failure. */
|
|
28
|
+
export declare function fetchTileBitmap(http: HttpClient, url: string, timeoutMs: number): Promise<ImageBitmap>;
|
|
29
|
+
/** Fetch a tile and read its pixels back as RGBA ImageData (via an offscreen
|
|
30
|
+
* canvas). Returns null only when a 2d context can't be created; throws on
|
|
31
|
+
* network/decode failure (the caller's tagged catch handles it). */
|
|
32
|
+
export declare function fetchTileRgba(http: HttpClient, url: string, timeoutMs: number): Promise<ImageData | null>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ICoordinateTransform } from '../../contracts/coordinate-transform.contract';
|
|
2
|
+
/**
|
|
3
|
+
* Plotly implementation of {@link ICoordinateTransform}. Wraps the axis objects
|
|
4
|
+
* on the plot's `_fullLayout`. This is the exact math the wand / vertex-eraser
|
|
5
|
+
* used inline before they were decoupled — lifted here verbatim so Plotly
|
|
6
|
+
* behaviour is unchanged.
|
|
7
|
+
*/
|
|
8
|
+
export declare class PlotlyCoordinateTransform implements ICoordinateTransform {
|
|
9
|
+
private getGraphDiv;
|
|
10
|
+
private getContainer;
|
|
11
|
+
constructor(getGraphDiv: () => any, getContainer: () => HTMLElement | null);
|
|
12
|
+
private axes;
|
|
13
|
+
isReady(): boolean;
|
|
14
|
+
clientToData(clientX: number, clientY: number): {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
};
|
|
18
|
+
dataLengthToScreen(dataLength: number): number;
|
|
19
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PlotlyService } from './plotly.service';
|
|
2
|
+
import { IRegionOverlay, RegionToolMode } from '../../contracts/region-overlay.contract';
|
|
3
|
+
/**
|
|
4
|
+
* Plotly implementation of {@link IRegionOverlay}.
|
|
5
|
+
*
|
|
6
|
+
* Plotly renders region shapes natively in its plot layout and edits them via
|
|
7
|
+
* its own drag modes, so this adapter is thin: it maps the neutral
|
|
8
|
+
* {@link RegionToolMode} onto Plotly drag modes and lets Plotly draw. `redraw`
|
|
9
|
+
* is a no-op because Plotly re-renders its shapes itself on relayout.
|
|
10
|
+
*
|
|
11
|
+
* It is the symmetric counterpart to {@link OsdRegionOverlay}: both render the
|
|
12
|
+
* same shared `IRegionStore`, each onto its own backend's canvas.
|
|
13
|
+
*/
|
|
14
|
+
export declare class PlotlyRegionOverlay implements IRegionOverlay {
|
|
15
|
+
private plotly;
|
|
16
|
+
constructor(plotly: PlotlyService);
|
|
17
|
+
setMode(mode: RegionToolMode): void;
|
|
18
|
+
redraw(): void;
|
|
19
|
+
/** Bezier regions are an OpenSeadragon-only feature (Plotly has no native
|
|
20
|
+
* curved-shape rendering), so this is a no-op here. */
|
|
21
|
+
setSelectedBezier(_bezier: boolean): void;
|
|
22
|
+
destroy(): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { PlotType } from '../../contracts/plot-type';
|
|
2
|
+
/**
|
|
3
|
+
* Pluggable Plotly trace builders for the plot types added on top of the
|
|
4
|
+
* original HEATMAP / SURFACE / RGB-image renderers.
|
|
5
|
+
*
|
|
6
|
+
* DESIGN / EXTRACTION ALIGNMENT
|
|
7
|
+
* -----------------------------
|
|
8
|
+
* Every function here is **pure** — it takes a `TraceBuildInput` and returns
|
|
9
|
+
* Plotly trace dicts. There is no Angular, no RxJS, no host-state coupling
|
|
10
|
+
* (`MainState`, `FilesService`, …). That keeps the module relocatable into the
|
|
11
|
+
* future `@jax-data-science/image-visualization` library core (see the
|
|
12
|
+
* `sketch/jit-plotting-extraction` SOW) without port surgery.
|
|
13
|
+
*
|
|
14
|
+
* Layout building stays in `PlotlyService` (it needs live service state such
|
|
15
|
+
* as screen height, scale ratio and the current shapes); only TRACE building
|
|
16
|
+
* is pluggable here. To add a new plot type: write a builder, register it in
|
|
17
|
+
* `PLOTLY_PLOT_TYPE_IMPLS`, and add a descriptor in `contracts/plot-type.ts`.
|
|
18
|
+
*
|
|
19
|
+
* The original HEATMAP/SURFACE/RGB types intentionally keep their dedicated
|
|
20
|
+
* renderers in `PlotlyService` (they are also reused by the high-def zoom
|
|
21
|
+
* re-fetch path), so they are NOT registered here.
|
|
22
|
+
*/
|
|
23
|
+
/** Normalised input for a trace builder. Frames are per-z-plane matrices:
|
|
24
|
+
* grayscale cells are scalars, RGB cells are `[r, g, b]`. */
|
|
25
|
+
export interface TraceBuildInput {
|
|
26
|
+
frames: any[];
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
/** [xRatio, yRatio] — data units per pixel. */
|
|
30
|
+
ratios: number[];
|
|
31
|
+
/** [x0, x1, y0, y1] — true image extent in data units. */
|
|
32
|
+
trueImageSize: number[];
|
|
33
|
+
isGrayscale: boolean;
|
|
34
|
+
/** Plotly colorscale value (e.g. from the active colormap). */
|
|
35
|
+
colorscale: any;
|
|
36
|
+
reversescale: boolean;
|
|
37
|
+
/** Region polygons in data coords, for region-sourced plots (SCATTER). */
|
|
38
|
+
regions: {
|
|
39
|
+
xpoints: number[];
|
|
40
|
+
ypoints: number[];
|
|
41
|
+
}[];
|
|
42
|
+
/** Default marker/line colour for derived (non-image-LUT) traces. */
|
|
43
|
+
shapeColor: string;
|
|
44
|
+
/** ISOSURFACE intensity bounds (0–255): surfaces are drawn for values in
|
|
45
|
+
* [isoMin, isoMax], mapped straight onto Plotly's isomin/isomax. */
|
|
46
|
+
isoMin: number;
|
|
47
|
+
isoMax: number;
|
|
48
|
+
}
|
|
49
|
+
export type TraceBuilder = (input: TraceBuildInput) => any[];
|
|
50
|
+
export type PlotLayoutKind = '2d-image' | '2d-overlay' | '2d-chart' | '3d-volume';
|
|
51
|
+
export interface PlotlyPlotTypeImpl {
|
|
52
|
+
buildTraces: TraceBuilder;
|
|
53
|
+
/** Which layout `PlotlyService` should build for this type. */
|
|
54
|
+
layoutKind: PlotLayoutKind;
|
|
55
|
+
/** True for scene-based (3D) traces — picks the 3D Plotly config. */
|
|
56
|
+
threeD: boolean;
|
|
57
|
+
}
|
|
58
|
+
/** Registry of the pluggable (non-original) plot types. */
|
|
59
|
+
export declare const PLOTLY_PLOT_TYPE_IMPLS: Partial<Record<PlotType, PlotlyPlotTypeImpl>>;
|
|
60
|
+
export declare function getPlotTypeImpl(type: PlotType): PlotlyPlotTypeImpl | undefined;
|