copper3d 3.10.2 → 3.10.4
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/README.md +40 -4
- package/dist/Utils/segmentation/DrawToolCore.d.ts +8 -0
- package/dist/Utils/segmentation/DrawToolCore.js +12 -0
- package/dist/Utils/segmentation/DrawToolCore.js.map +1 -1
- package/dist/Utils/segmentation/NrrdTools.d.ts +21 -1
- package/dist/Utils/segmentation/NrrdTools.js +25 -0
- package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
- package/dist/Utils/segmentation/RenderingUtils.d.ts +32 -0
- package/dist/Utils/segmentation/RenderingUtils.js +107 -12
- package/dist/Utils/segmentation/RenderingUtils.js.map +1 -1
- package/dist/Utils/segmentation/core/MarchingSquares.d.ts +26 -0
- package/dist/Utils/segmentation/core/MarchingSquares.js +113 -0
- package/dist/Utils/segmentation/core/MarchingSquares.js.map +1 -1
- package/dist/Utils/segmentation/core/UndoManager.d.ts +12 -1
- package/dist/Utils/segmentation/core/UndoManager.js +33 -17
- package/dist/Utils/segmentation/core/UndoManager.js.map +1 -1
- package/dist/Utils/segmentation/core/index.d.ts +2 -2
- package/dist/Utils/segmentation/core/index.js +1 -1
- package/dist/Utils/segmentation/core/index.js.map +1 -1
- package/dist/Utils/segmentation/core/types.d.ts +10 -0
- package/dist/Utils/segmentation/core/types.js.map +1 -1
- package/dist/Utils/segmentation/coreTools/GuiState.js +2 -0
- package/dist/Utils/segmentation/coreTools/GuiState.js.map +1 -1
- package/dist/Utils/segmentation/tools/DrawingTool.d.ts +19 -2
- package/dist/Utils/segmentation/tools/DrawingTool.js +30 -6
- package/dist/Utils/segmentation/tools/DrawingTool.js.map +1 -1
- package/dist/Utils/segmentation/tools/ToolHost.d.ts +7 -1
- package/dist/bundle.esm.js +324 -37
- package/dist/bundle.umd.js +324 -37
- package/dist/index.d.ts +2 -2
- package/dist/types/Utils/segmentation/DrawToolCore.d.ts +8 -0
- package/dist/types/Utils/segmentation/NrrdTools.d.ts +21 -1
- package/dist/types/Utils/segmentation/RenderingUtils.d.ts +32 -0
- package/dist/types/Utils/segmentation/core/MarchingSquares.d.ts +26 -0
- package/dist/types/Utils/segmentation/core/UndoManager.d.ts +12 -1
- package/dist/types/Utils/segmentation/core/index.d.ts +2 -2
- package/dist/types/Utils/segmentation/core/types.d.ts +10 -0
- package/dist/types/Utils/segmentation/tools/DrawingTool.d.ts +19 -2
- package/dist/types/Utils/segmentation/tools/ToolHost.d.ts +7 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/bundle.umd.js
CHANGED
|
@@ -107749,12 +107749,30 @@ void main() {
|
|
|
107749
107749
|
* - Undo/redo operations also trigger backend sync via getMask callback.
|
|
107750
107750
|
*/
|
|
107751
107751
|
const MAX_STACK_SIZE = 50;
|
|
107752
|
-
const LAYER_IDS = ["layer1", "layer2", "layer3"];
|
|
107753
107752
|
class UndoManager {
|
|
107754
107753
|
constructor() {
|
|
107754
|
+
this.undoStacks = new Map();
|
|
107755
|
+
this.redoStacks = new Map();
|
|
107755
107756
|
this.activeLayer = "layer1";
|
|
107756
|
-
|
|
107757
|
-
|
|
107757
|
+
}
|
|
107758
|
+
/**
|
|
107759
|
+
* The stack for a layer, created on first use.
|
|
107760
|
+
*
|
|
107761
|
+
* Stacks used to be pre-created for exactly layer1/2/3, which broke in two ways at once for
|
|
107762
|
+
* any other id -- and `NrrdTools`'s constructor has always accepted `options.layers`, so any
|
|
107763
|
+
* other id is reachable. `push*` resolved with `?? get("layer1")` and silently appended to a
|
|
107764
|
+
* different layer's history, so an undo later popped a stroke the user never made there;
|
|
107765
|
+
* `undo`/`redo` asserted non-null on the same lookup and threw instead.
|
|
107766
|
+
*
|
|
107767
|
+
* Creating on demand removes both. Nothing else needs to know which layers exist.
|
|
107768
|
+
*/
|
|
107769
|
+
stackFor(stacks, layerId) {
|
|
107770
|
+
let stack = stacks.get(layerId);
|
|
107771
|
+
if (!stack) {
|
|
107772
|
+
stack = [];
|
|
107773
|
+
stacks.set(layerId, stack);
|
|
107774
|
+
}
|
|
107775
|
+
return stack;
|
|
107758
107776
|
}
|
|
107759
107777
|
/** Set the currently active layer (determines which stack undo/redo operates on). */
|
|
107760
107778
|
setActiveLayer(layer) {
|
|
@@ -107766,17 +107784,16 @@ void main() {
|
|
|
107766
107784
|
}
|
|
107767
107785
|
/** Push a group of deltas as a single undo unit (e.g. 3D sphere spanning multiple slices). */
|
|
107768
107786
|
pushGroup(deltas) {
|
|
107769
|
-
var _a, _b;
|
|
107770
107787
|
if (deltas.length === 0)
|
|
107771
107788
|
return;
|
|
107772
107789
|
const layerId = deltas[0].layerId;
|
|
107773
|
-
const stack =
|
|
107790
|
+
const stack = this.stackFor(this.undoStacks, layerId);
|
|
107774
107791
|
stack.push(deltas);
|
|
107775
107792
|
if (stack.length > MAX_STACK_SIZE) {
|
|
107776
107793
|
stack.shift();
|
|
107777
107794
|
}
|
|
107778
107795
|
// Any new operation invalidates the redo history for that layer
|
|
107779
|
-
const redoStack =
|
|
107796
|
+
const redoStack = this.stackFor(this.redoStacks, layerId);
|
|
107780
107797
|
redoStack.length = 0;
|
|
107781
107798
|
}
|
|
107782
107799
|
/**
|
|
@@ -107786,8 +107803,7 @@ void main() {
|
|
|
107786
107803
|
* an unbounded stack would be hundreds of megabytes. Slice deltas below it survive.
|
|
107787
107804
|
*/
|
|
107788
107805
|
pushVolumeSnapshot(layerId, oldVolume, newVolume) {
|
|
107789
|
-
|
|
107790
|
-
const stack = (_a = this.undoStacks.get(layerId)) !== null && _a !== void 0 ? _a : this.undoStacks.get("layer1");
|
|
107806
|
+
const stack = this.stackFor(this.undoStacks, layerId);
|
|
107791
107807
|
for (let i = stack.length - 1; i >= 0; i--) {
|
|
107792
107808
|
if (!Array.isArray(stack[i]))
|
|
107793
107809
|
stack.splice(i, 1);
|
|
@@ -107796,7 +107812,7 @@ void main() {
|
|
|
107796
107812
|
if (stack.length > MAX_STACK_SIZE) {
|
|
107797
107813
|
stack.shift();
|
|
107798
107814
|
}
|
|
107799
|
-
const redoStack =
|
|
107815
|
+
const redoStack = this.stackFor(this.redoStacks, layerId);
|
|
107800
107816
|
redoStack.length = 0;
|
|
107801
107817
|
}
|
|
107802
107818
|
/**
|
|
@@ -107804,10 +107820,10 @@ void main() {
|
|
|
107804
107820
|
* @returns The delta(s) that were undone, or undefined if nothing to undo.
|
|
107805
107821
|
*/
|
|
107806
107822
|
undo() {
|
|
107807
|
-
const stack = this.
|
|
107823
|
+
const stack = this.stackFor(this.undoStacks, this.activeLayer);
|
|
107808
107824
|
const entry = stack.pop();
|
|
107809
107825
|
if (entry) {
|
|
107810
|
-
this.
|
|
107826
|
+
this.stackFor(this.redoStacks, this.activeLayer).push(entry);
|
|
107811
107827
|
}
|
|
107812
107828
|
return entry;
|
|
107813
107829
|
}
|
|
@@ -107816,10 +107832,10 @@ void main() {
|
|
|
107816
107832
|
* @returns The delta(s) that were redone, or undefined if nothing to redo.
|
|
107817
107833
|
*/
|
|
107818
107834
|
redo() {
|
|
107819
|
-
const stack = this.
|
|
107835
|
+
const stack = this.stackFor(this.redoStacks, this.activeLayer);
|
|
107820
107836
|
const entry = stack.pop();
|
|
107821
107837
|
if (entry) {
|
|
107822
|
-
this.
|
|
107838
|
+
this.stackFor(this.undoStacks, this.activeLayer).push(entry);
|
|
107823
107839
|
}
|
|
107824
107840
|
return entry;
|
|
107825
107841
|
}
|
|
@@ -107842,10 +107858,10 @@ void main() {
|
|
|
107842
107858
|
}
|
|
107843
107859
|
/** Clear all stacks for all layers (called on full dataset reload). */
|
|
107844
107860
|
clearAll() {
|
|
107845
|
-
for (const
|
|
107846
|
-
|
|
107847
|
-
|
|
107848
|
-
|
|
107861
|
+
for (const stack of this.undoStacks.values())
|
|
107862
|
+
stack.length = 0;
|
|
107863
|
+
for (const stack of this.redoStacks.values())
|
|
107864
|
+
stack.length = 0;
|
|
107849
107865
|
}
|
|
107850
107866
|
}
|
|
107851
107867
|
|
|
@@ -107910,6 +107926,50 @@ void main() {
|
|
|
107910
107926
|
/* 14 (TL+TR+BR, !BL) */ [[[0, 0], [1, 0], [1, 1], [0.5, 1], [0, 0.5]]],
|
|
107911
107927
|
/* 15 (full) */ [[[0, 0], [1, 0], [1, 1], [0, 1]]],
|
|
107912
107928
|
];
|
|
107929
|
+
/**
|
|
107930
|
+
* Per-cell boundary segments for the same 16 cases — the region's edge, without the region.
|
|
107931
|
+
*
|
|
107932
|
+
* Each entry is the cut line of the corresponding `CELL_POLYGONS` entry: the one edge of that
|
|
107933
|
+
* polygon which does not lie on the cell's border. Filling the polygons and stroking these
|
|
107934
|
+
* therefore describe the same silhouette, which is what lets the renderer swap fill for
|
|
107935
|
+
* outline without the mask's edge appearing to move.
|
|
107936
|
+
*
|
|
107937
|
+
* Endpoints are the midpoints of the cell's sides —
|
|
107938
|
+
* T = (0.5, 0) R = (1, 0.5) B = (0.5, 1) L = (0, 0.5)
|
|
107939
|
+
* — in the same cell-local 0..1 space as `CELL_POLYGONS`, so the caller adds (i, j) + SHIFT
|
|
107940
|
+
* identically for both.
|
|
107941
|
+
*
|
|
107942
|
+
* Cases 0 and 15 emit nothing. 15 is the whole reason an outline is cheap: solid interior has
|
|
107943
|
+
* no boundary, so the segment count follows the perimeter rather than the area.
|
|
107944
|
+
*
|
|
107945
|
+
* Saddles (5 and 10) follow `CELL_POLYGONS`' convention — the two in-corners are disconnected
|
|
107946
|
+
* (4-connectivity) — because the other reading would run a boundary straight through mask the
|
|
107947
|
+
* fill considers solid.
|
|
107948
|
+
*/
|
|
107949
|
+
const CELL_SEGMENTS = [
|
|
107950
|
+
/* 0 (empty) */ [],
|
|
107951
|
+
/* 1 (BL) */ [[[0, 0.5], [0.5, 1]]],
|
|
107952
|
+
/* 2 (BR) */ [[[0.5, 1], [1, 0.5]]],
|
|
107953
|
+
/* 3 (BR+BL) */ [[[0, 0.5], [1, 0.5]]],
|
|
107954
|
+
/* 4 (TR) */ [[[0.5, 0], [1, 0.5]]],
|
|
107955
|
+
/* 5 (TR+BL saddle) */ [
|
|
107956
|
+
[[0.5, 0], [1, 0.5]],
|
|
107957
|
+
[[0, 0.5], [0.5, 1]],
|
|
107958
|
+
],
|
|
107959
|
+
/* 6 (TR+BR) */ [[[0.5, 0], [0.5, 1]]],
|
|
107960
|
+
/* 7 (TR+BR+BL, !TL) */ [[[0.5, 0], [0, 0.5]]],
|
|
107961
|
+
/* 8 (TL) */ [[[0.5, 0], [0, 0.5]]],
|
|
107962
|
+
/* 9 (TL+BL) */ [[[0.5, 0], [0.5, 1]]],
|
|
107963
|
+
/* 10 (TL+BR saddle) */ [
|
|
107964
|
+
[[0.5, 0], [0, 0.5]],
|
|
107965
|
+
[[0.5, 1], [1, 0.5]],
|
|
107966
|
+
],
|
|
107967
|
+
/* 11 (TL+BR+BL, !TR) */ [[[0.5, 0], [1, 0.5]]],
|
|
107968
|
+
/* 12 (TL+TR) */ [[[1, 0.5], [0, 0.5]]],
|
|
107969
|
+
/* 13 (TL+TR+BL, !BR) */ [[[1, 0.5], [0.5, 1]]],
|
|
107970
|
+
/* 14 (TL+TR+BR, !BL) */ [[[0.5, 1], [0, 0.5]]],
|
|
107971
|
+
/* 15 (full) */ [],
|
|
107972
|
+
];
|
|
107913
107973
|
/**
|
|
107914
107974
|
* Emit polygons covering the voxels where `labels === targetLabel`.
|
|
107915
107975
|
* Pure geometry function — no Canvas dependency. Consumers can build a Path2D
|
|
@@ -108031,6 +108091,75 @@ void main() {
|
|
|
108031
108091
|
}
|
|
108032
108092
|
return path;
|
|
108033
108093
|
}
|
|
108094
|
+
/**
|
|
108095
|
+
* Emit the boundary of the region where `labels === targetLabel`, as open two-point segments.
|
|
108096
|
+
*
|
|
108097
|
+
* The counterpart to {@link extractLabelPolygons}: that one covers the region, this one traces
|
|
108098
|
+
* its edge. Both walk the same cells with the same sampling, the same out-of-bounds rule and
|
|
108099
|
+
* the same `+0.5` shift, so a renderer can fill one and stroke the other and have the mask end
|
|
108100
|
+
* in exactly the same place either way.
|
|
108101
|
+
*
|
|
108102
|
+
* Segments are emitted per cell and left unjoined. Canvas rasterises a whole `Path2D` in one
|
|
108103
|
+
* compositing pass, so segments meeting at a shared endpoint produce no seam and no doubled
|
|
108104
|
+
* alpha where their round caps overlap — joining them into polylines would buy nothing and
|
|
108105
|
+
* cost a chaining pass.
|
|
108106
|
+
*
|
|
108107
|
+
* Cost follows the perimeter, not the area: solid interior is case 15, which has no boundary.
|
|
108108
|
+
*
|
|
108109
|
+
* Parameters match {@link extractLabelContours}.
|
|
108110
|
+
*/
|
|
108111
|
+
function extractLabelBoundarySegments(labels, width, height, targetLabel, stride = 1, channelOffset = 0, bbox) {
|
|
108112
|
+
var _a, _b, _c, _d;
|
|
108113
|
+
const out = [];
|
|
108114
|
+
const i0 = Math.max(-1, ((_a = bbox === null || bbox === void 0 ? void 0 : bbox.x0) !== null && _a !== void 0 ? _a : 0) - 1);
|
|
108115
|
+
const j0 = Math.max(-1, ((_b = bbox === null || bbox === void 0 ? void 0 : bbox.y0) !== null && _b !== void 0 ? _b : 0) - 1);
|
|
108116
|
+
const i1 = Math.min(width, (_c = bbox === null || bbox === void 0 ? void 0 : bbox.x1) !== null && _c !== void 0 ? _c : width);
|
|
108117
|
+
const j1 = Math.min(height, (_d = bbox === null || bbox === void 0 ? void 0 : bbox.y1) !== null && _d !== void 0 ? _d : height);
|
|
108118
|
+
const sample = (x, y) => {
|
|
108119
|
+
if (x < 0 || x >= width || y < 0 || y >= height)
|
|
108120
|
+
return false;
|
|
108121
|
+
return labels[(y * width + x) * stride + channelOffset] === targetLabel;
|
|
108122
|
+
};
|
|
108123
|
+
// Same convention as extractLabelPolygons: samples sit at voxel centres.
|
|
108124
|
+
const SHIFT = 0.5;
|
|
108125
|
+
for (let j = j0; j < j1; j++) {
|
|
108126
|
+
for (let i = i0; i < i1; i++) {
|
|
108127
|
+
const code = (sample(i, j) ? 8 : 0) |
|
|
108128
|
+
(sample(i + 1, j) ? 4 : 0) |
|
|
108129
|
+
(sample(i + 1, j + 1) ? 2 : 0) |
|
|
108130
|
+
(sample(i, j + 1) ? 1 : 0);
|
|
108131
|
+
// Nothing here, or nothing but mask: neither has an edge in this cell.
|
|
108132
|
+
if (code === 0 || code === 15)
|
|
108133
|
+
continue;
|
|
108134
|
+
const segments = CELL_SEGMENTS[code];
|
|
108135
|
+
for (let s = 0; s < segments.length; s++) {
|
|
108136
|
+
const [a, b] = segments[s];
|
|
108137
|
+
out.push([
|
|
108138
|
+
[i + a[0] + SHIFT, j + a[1] + SHIFT],
|
|
108139
|
+
[i + b[0] + SHIFT, j + b[1] + SHIFT],
|
|
108140
|
+
]);
|
|
108141
|
+
}
|
|
108142
|
+
}
|
|
108143
|
+
}
|
|
108144
|
+
return out;
|
|
108145
|
+
}
|
|
108146
|
+
/**
|
|
108147
|
+
* {@link extractLabelBoundarySegments} as a `Path2D`, ready to stroke.
|
|
108148
|
+
*
|
|
108149
|
+
* The outline counterpart to {@link extractLabelContours}. Stroke this; do not stroke the
|
|
108150
|
+
* contour path — that one is per-cell polygons whose union is the silhouette, and stroking it
|
|
108151
|
+
* draws every internal cell edge as well, covering the mask in a grid.
|
|
108152
|
+
*/
|
|
108153
|
+
function extractLabelOutline(labels, width, height, targetLabel, stride = 1, channelOffset = 0, bbox) {
|
|
108154
|
+
const segments = extractLabelBoundarySegments(labels, width, height, targetLabel, stride, channelOffset, bbox);
|
|
108155
|
+
const path = new Path2D();
|
|
108156
|
+
for (let s = 0; s < segments.length; s++) {
|
|
108157
|
+
const [a, b] = segments[s];
|
|
108158
|
+
path.moveTo(a[0], a[1]);
|
|
108159
|
+
path.lineTo(b[0], b[1]);
|
|
108160
|
+
}
|
|
108161
|
+
return path;
|
|
108162
|
+
}
|
|
108034
108163
|
/**
|
|
108035
108164
|
* Detect the distinct non-zero labels present in a slice region.
|
|
108036
108165
|
*
|
|
@@ -109468,6 +109597,14 @@ void main() {
|
|
|
109468
109597
|
}
|
|
109469
109598
|
}
|
|
109470
109599
|
|
|
109600
|
+
/**
|
|
109601
|
+
* Outline stroke width, in screen pixels.
|
|
109602
|
+
*
|
|
109603
|
+
* Screen pixels rather than voxels so magnifying the image does not thicken the line over the
|
|
109604
|
+
* boundary the clinician magnified it to see. Thin enough to sit on an edge, thick enough to
|
|
109605
|
+
* stay visible against bright tissue.
|
|
109606
|
+
*/
|
|
109607
|
+
const OUTLINE_WIDTH_PX = 1.5;
|
|
109471
109608
|
/**
|
|
109472
109609
|
* RenderingUtils — Rendering / slice-buffer helper methods.
|
|
109473
109610
|
*
|
|
@@ -109499,6 +109636,12 @@ void main() {
|
|
|
109499
109636
|
* applied at fill time and intentionally *not* cached, so toggling them
|
|
109500
109637
|
* needs no recompute.
|
|
109501
109638
|
*
|
|
109639
|
+
* The render mode is not in the key either. Fill paths and outline paths
|
|
109640
|
+
* are built lazily and side by side under the same entry, so switching
|
|
109641
|
+
* mode costs one extraction per visible label the first time and is a
|
|
109642
|
+
* cache hit every time after — and a session that never leaves fill mode
|
|
109643
|
+
* never builds an outline.
|
|
109644
|
+
*
|
|
109502
109645
|
* One entry per layer (the current slice). Switching slice/axis or
|
|
109503
109646
|
* editing overwrites it.
|
|
109504
109647
|
*/
|
|
@@ -109585,6 +109728,22 @@ void main() {
|
|
|
109585
109728
|
return null; // Volume not ready
|
|
109586
109729
|
}
|
|
109587
109730
|
}
|
|
109731
|
+
/**
|
|
109732
|
+
* Populate one cache entry's paths for one render mode.
|
|
109733
|
+
*
|
|
109734
|
+
* Split out because the two modes are built at different times: whichever is in use when
|
|
109735
|
+
* a slice is first drawn, and the other one only if the clinician switches while still on
|
|
109736
|
+
* that slice. Building both eagerly would make every slice scrub pay for a mode most
|
|
109737
|
+
* sessions never turn on.
|
|
109738
|
+
*/
|
|
109739
|
+
buildPaths(entry, data, stride, outline) {
|
|
109740
|
+
const target = outline ? entry.outlines : entry.fills;
|
|
109741
|
+
for (const lbl of entry.labels) {
|
|
109742
|
+
target.set(lbl, outline
|
|
109743
|
+
? extractLabelOutline(data, entry.W, entry.H, lbl, stride, 0)
|
|
109744
|
+
: extractLabelContours(data, entry.W, entry.H, lbl, stride, 0));
|
|
109745
|
+
}
|
|
109746
|
+
}
|
|
109588
109747
|
/**
|
|
109589
109748
|
* Render a layer's slice onto the target canvas as vector contours.
|
|
109590
109749
|
*
|
|
@@ -109597,6 +109756,27 @@ void main() {
|
|
|
109597
109756
|
* is no longer used on this path — callers may pass any valid ImageData.
|
|
109598
109757
|
*/
|
|
109599
109758
|
renderSliceToCanvas(layer, axis, sliceIndex, _buffer, targetCtx, scaledWidth, scaledHeight) {
|
|
109759
|
+
this.drawSlice(layer, axis, sliceIndex, targetCtx, scaledWidth, scaledHeight, this.state.gui_states.drawing.maskRenderMode === "outline");
|
|
109760
|
+
}
|
|
109761
|
+
/**
|
|
109762
|
+
* Render a layer's slice FILLED, whatever the clinician is currently looking at.
|
|
109763
|
+
*
|
|
109764
|
+
* For the tools that bake (`syncLayerSliceData` — pencil and eraser) the layer canvas is
|
|
109765
|
+
* not a picture of the mask, it is the input the mask is rebuilt from: the bake replaces
|
|
109766
|
+
* the whole slice in `MaskVolume` with whatever pixels it finds there.
|
|
109767
|
+
*
|
|
109768
|
+
* An outline is a lossy picture — it says where a mask ends, not what it contains — so
|
|
109769
|
+
* baking one back writes rings and erases every interior on that slice, taking every other
|
|
109770
|
+
* finding on the layer with it. One pencil stroke was enough.
|
|
109771
|
+
*
|
|
109772
|
+
* Hence a separate entry point rather than a flag threaded through the display path: a
|
|
109773
|
+
* render that is about to be read back has a different requirement from one that is about
|
|
109774
|
+
* to be looked at, and the two only coincided while there was one way to draw a mask.
|
|
109775
|
+
*/
|
|
109776
|
+
renderSliceForBake(layer, axis, sliceIndex, targetCtx, scaledWidth, scaledHeight) {
|
|
109777
|
+
this.drawSlice(layer, axis, sliceIndex, targetCtx, scaledWidth, scaledHeight, false);
|
|
109778
|
+
}
|
|
109779
|
+
drawSlice(layer, axis, sliceIndex, targetCtx, scaledWidth, scaledHeight, outline) {
|
|
109600
109780
|
try {
|
|
109601
109781
|
const volume = this.getVolumeForLayer(layer);
|
|
109602
109782
|
if (!volume)
|
|
@@ -109604,28 +109784,72 @@ void main() {
|
|
|
109604
109784
|
const stride = volume.getChannels();
|
|
109605
109785
|
const cacheKey = `${axis}:${sliceIndex}:${volume.getVersion()}`;
|
|
109606
109786
|
// Cache miss → run the expensive extraction once. Hits (zoom,
|
|
109607
|
-
// recomposite, contrast toggle) skip straight to the
|
|
109787
|
+
// recomposite, contrast toggle) skip straight to the draw below.
|
|
109608
109788
|
let entry = this._contourCache.get(layer);
|
|
109609
109789
|
if (!entry || entry.key !== cacheKey) {
|
|
109610
109790
|
const slice = volume.getSliceUint8(sliceIndex, axis);
|
|
109611
|
-
|
|
109612
|
-
|
|
109613
|
-
|
|
109614
|
-
|
|
109615
|
-
|
|
109616
|
-
|
|
109617
|
-
|
|
109618
|
-
|
|
109791
|
+
entry = {
|
|
109792
|
+
key: cacheKey,
|
|
109793
|
+
W: slice.width,
|
|
109794
|
+
H: slice.height,
|
|
109795
|
+
labels: findLabelsInSlice(slice.data, slice.width, slice.height, stride, 0),
|
|
109796
|
+
fills: new Map(),
|
|
109797
|
+
outlines: new Map(),
|
|
109798
|
+
};
|
|
109619
109799
|
this._contourCache.set(layer, entry);
|
|
109800
|
+
this.buildPaths(entry, slice.data, stride, outline);
|
|
109801
|
+
}
|
|
109802
|
+
else if ((outline ? entry.outlines : entry.fills).size !== entry.labels.length) {
|
|
109803
|
+
// The mode changed since this slice was last drawn, so the other set of
|
|
109804
|
+
// paths is cached and this one is not. Re-read the slice and build it; from
|
|
109805
|
+
// here on both are present and toggling is a pure cache hit.
|
|
109806
|
+
const slice = volume.getSliceUint8(sliceIndex, axis);
|
|
109807
|
+
this.buildPaths(entry, slice.data, stride, outline);
|
|
109620
109808
|
}
|
|
109621
109809
|
if (entry.labels.length === 0)
|
|
109622
109810
|
return;
|
|
109623
|
-
const { W, H, labels
|
|
109811
|
+
const { W, H, labels } = entry;
|
|
109812
|
+
const paths = outline ? entry.outlines : entry.fills;
|
|
109624
109813
|
const channelVis = this.state.gui_states.layerChannel.channelVisibility[layer];
|
|
109625
109814
|
targetCtx.save();
|
|
109626
|
-
// Vector
|
|
109815
|
+
// Vector drawing — imageSmoothingEnabled is irrelevant here, but keep
|
|
109627
109816
|
// it off to match the rest of the pipeline.
|
|
109628
109817
|
targetCtx.imageSmoothingEnabled = false;
|
|
109818
|
+
if (outline) {
|
|
109819
|
+
// Stroke on an UNTRANSFORMED context, with the voxel→display mapping carried
|
|
109820
|
+
// in the path instead. `lineWidth` is then measured in screen pixels, which
|
|
109821
|
+
// is what the other two options get wrong: stroking under `ctx.scale(sx, sy)`
|
|
109822
|
+
// thickens the line with the zoom, exactly when the clinician has magnified
|
|
109823
|
+
// the image to look at the boundary — and because voxels are rarely isotropic
|
|
109824
|
+
// (sx !== sy), it also comes out thicker in one axis than the other.
|
|
109825
|
+
const matrix = new DOMMatrix();
|
|
109826
|
+
if (axis === 'y') {
|
|
109827
|
+
matrix.scaleSelf(1, -1);
|
|
109828
|
+
matrix.translateSelf(0, -scaledHeight);
|
|
109829
|
+
}
|
|
109830
|
+
matrix.scaleSelf(scaledWidth / W, scaledHeight / H);
|
|
109831
|
+
targetCtx.lineWidth = OUTLINE_WIDTH_PX;
|
|
109832
|
+
// Segments are emitted per cell and meet at shared endpoints; round caps
|
|
109833
|
+
// close those joins. Canvas composites a whole Path2D in one pass, so the
|
|
109834
|
+
// overlap costs no doubled alpha.
|
|
109835
|
+
targetCtx.lineJoin = 'round';
|
|
109836
|
+
targetCtx.lineCap = 'round';
|
|
109837
|
+
for (const lbl of labels) {
|
|
109838
|
+
if (channelVis && channelVis[lbl] === false)
|
|
109839
|
+
continue;
|
|
109840
|
+
const path = paths.get(lbl);
|
|
109841
|
+
if (!path)
|
|
109842
|
+
continue;
|
|
109843
|
+
const color = volume.getChannelColor(lbl);
|
|
109844
|
+
targetCtx.strokeStyle =
|
|
109845
|
+
`rgba(${color.r}, ${color.g}, ${color.b}, ${color.a / 255})`;
|
|
109846
|
+
const display = new Path2D();
|
|
109847
|
+
display.addPath(path, matrix);
|
|
109848
|
+
targetCtx.stroke(display);
|
|
109849
|
+
}
|
|
109850
|
+
targetCtx.restore();
|
|
109851
|
+
return;
|
|
109852
|
+
}
|
|
109629
109853
|
// Coronal (axis='y') Z-flip: mirrors the flip applied by the write
|
|
109630
109854
|
// path (syncLayerSliceData). Apply BEFORE the voxel→display scale
|
|
109631
109855
|
// so the flip operates in display coordinates.
|
|
@@ -110843,6 +111067,11 @@ void main() {
|
|
|
110843
111067
|
this.ctx.nrrd_states.interaction.drawStartPos.y = e.offsetY;
|
|
110844
111068
|
// Capture pre-draw slice snapshot for undo
|
|
110845
111069
|
this.capturePreDrawSnapshot();
|
|
111070
|
+
// The eraser works on canvas pixels and then bakes the canvas back into the volume, so
|
|
111071
|
+
// it needs the layer solid rather than outlined for the length of the stroke. The display
|
|
111072
|
+
// mode comes back at pointerup, via refreshLayerFromVolume.
|
|
111073
|
+
if (this.ctx.gui_states.mode.eraser)
|
|
111074
|
+
this.solidifyLayerForErase();
|
|
110846
111075
|
// Brush mode: initialize voxel tracking and write first dot
|
|
110847
111076
|
if (!this.ctx.gui_states.mode.pencil && !this.ctx.gui_states.mode.eraser) {
|
|
110848
111077
|
const voxel = this.canvasToVoxel3D(e.offsetX, e.offsetY);
|
|
@@ -111255,17 +111484,36 @@ void main() {
|
|
|
111255
111484
|
this.preDrawSlice = null;
|
|
111256
111485
|
}
|
|
111257
111486
|
/**
|
|
111258
|
-
* Redraws persisted layer data onto ctx before new pencil fill.
|
|
111259
|
-
*
|
|
111487
|
+
* Redraws persisted layer data onto ctx before the new pencil fill.
|
|
111488
|
+
*
|
|
111489
|
+
* Uses the BAKE renderer, not the display one. What lands on this canvas is about to be
|
|
111490
|
+
* read straight back into the MaskVolume by `syncLayerSliceData`, which replaces the whole
|
|
111491
|
+
* slice -- so this render is the data, not a picture of it. Drawing outlines here would
|
|
111492
|
+
* bake rings and erase the interior of every mask on the layer.
|
|
111260
111493
|
*/
|
|
111261
111494
|
redrawPreviousImageToLayerCtx(ctx) {
|
|
111262
111495
|
const axis = this.ctx.protectedData.axis;
|
|
111263
111496
|
const W = this.ctx.nrrd_states.view.changedWidth;
|
|
111264
111497
|
const H = this.ctx.nrrd_states.view.changedHeight;
|
|
111265
|
-
|
|
111266
|
-
|
|
111267
|
-
|
|
111268
|
-
|
|
111498
|
+
this.callbacks.renderSliceForBake(this.ctx.gui_states.layerChannel.layer, axis, this.ctx.nrrd_states.view.currentSliceIndex, ctx, W, H);
|
|
111499
|
+
}
|
|
111500
|
+
/**
|
|
111501
|
+
* Put the active layer's canvas into the solid state the eraser and the bake both need.
|
|
111502
|
+
*
|
|
111503
|
+
* The eraser removes pixels matching the active channel's colour, and `syncLayerSliceData`
|
|
111504
|
+
* then rebuilds the whole slice from what is left on the canvas. Against an outline there
|
|
111505
|
+
* is nothing to match inside a mask, so a drag over a lesion erases nothing -- and the bake
|
|
111506
|
+
* that follows writes the ring back and loses every interior on the layer.
|
|
111507
|
+
*
|
|
111508
|
+
* Unconditional rather than checked against the display mode: in fill mode this redraws
|
|
111509
|
+
* what is already on screen, and a mode-dependent branch here is one more thing that can
|
|
111510
|
+
* fall out of step with the renderer.
|
|
111511
|
+
*/
|
|
111512
|
+
solidifyLayerForErase() {
|
|
111513
|
+
const target = this.callbacks.setCurrentLayer();
|
|
111514
|
+
target.canvas.width = target.canvas.width; // clear
|
|
111515
|
+
this.callbacks.renderSliceForBake(this.ctx.gui_states.layerChannel.layer, this.ctx.protectedData.axis, this.ctx.nrrd_states.view.currentSliceIndex, target.ctx, this.ctx.nrrd_states.view.changedWidth, this.ctx.nrrd_states.view.changedHeight);
|
|
111516
|
+
this.callbacks.compositeAllLayers();
|
|
111269
111517
|
}
|
|
111270
111518
|
/** Draw a line segment on a layer canvas (pencil mode only) */
|
|
111271
111519
|
drawLinesOnLayer(ctx, x, y) {
|
|
@@ -113147,6 +113395,7 @@ void main() {
|
|
|
113147
113395
|
getVolumeForLayer: (layer) => this.renderer.getVolumeForLayer(layer),
|
|
113148
113396
|
pushUndoDelta: (delta) => this.undoManager.push(delta),
|
|
113149
113397
|
renderSliceToCanvas: (layer, axis, sliceIndex, buffer, ctx, w, h) => this.renderer.renderSliceToCanvas(layer, axis, sliceIndex, buffer, ctx, w, h),
|
|
113398
|
+
renderSliceForBake: (layer, axis, sliceIndex, ctx, w, h) => this.renderer.renderSliceForBake(layer, axis, sliceIndex, ctx, w, h),
|
|
113150
113399
|
getOrCreateSliceBuffer: (axis) => this.renderer.getOrCreateSliceBuffer(axis),
|
|
113151
113400
|
});
|
|
113152
113401
|
this.sphereBrushTool = new SphereBrushTool(toolCtx, {
|
|
@@ -113839,6 +114088,17 @@ void main() {
|
|
|
113839
114088
|
this.state.annotationCallbacks.onLayerVolumeReplaced(layerId);
|
|
113840
114089
|
}
|
|
113841
114090
|
}
|
|
114091
|
+
/**
|
|
114092
|
+
* A copy of one layer's voxel buffer, or null if the layer has no volume.
|
|
114093
|
+
*
|
|
114094
|
+
* The read-only counterpart to replaceLayerVolume, and a copy rather than the live buffer:
|
|
114095
|
+
* handing out the renderer's own array would let a caller mutate the volume behind it, with
|
|
114096
|
+
* nothing invalidating the slice cache.
|
|
114097
|
+
*/
|
|
114098
|
+
getLayerVolume(layerId) {
|
|
114099
|
+
const vol = this.renderer.getVolumeForLayer(layerId);
|
|
114100
|
+
return vol ? new Uint8Array(vol.getRawData()) : null;
|
|
114101
|
+
}
|
|
113842
114102
|
/**
|
|
113843
114103
|
* Replace a layer's entire volume, optionally recording it as one undo step.
|
|
113844
114104
|
*
|
|
@@ -114047,6 +114307,8 @@ void main() {
|
|
|
114047
114307
|
fillColor: (_b = opts.defaultFillColor) !== null && _b !== void 0 ? _b : "#f50a33",
|
|
114048
114308
|
brushColor: (_c = opts.defaultBrushColor) !== null && _c !== void 0 ? _c : "#f50a33",
|
|
114049
114309
|
brushAndEraserSize: 10,
|
|
114310
|
+
// Filled is what every existing caller already gets; outline is opt-in.
|
|
114311
|
+
maskRenderMode: "fill",
|
|
114050
114312
|
};
|
|
114051
114313
|
this.viewConfig = {
|
|
114052
114314
|
mainAreaSize: 3,
|
|
@@ -116237,6 +116499,21 @@ void main() {
|
|
|
116237
116499
|
setLayerOpacity(layerId, opacity) { this.layerChannelManager.setLayerOpacity(layerId, opacity); }
|
|
116238
116500
|
getLayerOpacity(layerId) { return this.layerChannelManager.getLayerOpacity(layerId); }
|
|
116239
116501
|
getLayerOpacityMap() { return this.layerChannelManager.getLayerOpacityMap(); }
|
|
116502
|
+
/**
|
|
116503
|
+
* Fill every mask, or stroke only its boundary — for every layer and channel at once.
|
|
116504
|
+
*
|
|
116505
|
+
* A display decision, and nothing but: `MaskVolume` is not read differently and not written
|
|
116506
|
+
* at all, so what is stored, uploaded, exported and undone is the complete mask either way.
|
|
116507
|
+
*
|
|
116508
|
+
* Repaints immediately, the same way `setChannelVisible` does, because there is no other
|
|
116509
|
+
* event that would bring the change to the screen — a clinician who switched the mode and
|
|
116510
|
+
* then had to scrub a slice to see it would reasonably call that broken.
|
|
116511
|
+
*/
|
|
116512
|
+
setMaskRenderMode(mode) {
|
|
116513
|
+
this.state.gui_states.drawing.maskRenderMode = mode;
|
|
116514
|
+
this.reloadMasksFromVolume();
|
|
116515
|
+
}
|
|
116516
|
+
getMaskRenderMode() { return this.state.gui_states.drawing.maskRenderMode; }
|
|
116240
116517
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
116241
116518
|
// 8. Delegated — SliceRenderPipeline
|
|
116242
116519
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
@@ -116658,6 +116935,16 @@ void main() {
|
|
|
116658
116935
|
// Refresh the display so all three axes reflect the new data
|
|
116659
116936
|
this.reloadMasksFromVolume();
|
|
116660
116937
|
}
|
|
116938
|
+
/**
|
|
116939
|
+
* A copy of one layer's voxel buffer, or null if the layer has no volume.
|
|
116940
|
+
*
|
|
116941
|
+
* Pairs with `replaceLayerVolume`, so a caller can move a mask from one layer to another
|
|
116942
|
+
* through the undoable path rather than through `copyLayerData`, which writes the target
|
|
116943
|
+
* buffer directly and leaves nothing for Ctrl+Z.
|
|
116944
|
+
*/
|
|
116945
|
+
getLayerVolume(layerId) {
|
|
116946
|
+
return this.drawCore.getLayerVolume(layerId);
|
|
116947
|
+
}
|
|
116661
116948
|
/**
|
|
116662
116949
|
* Replace a layer's entire voxel buffer.
|
|
116663
116950
|
*
|
|
@@ -117843,15 +118130,15 @@ void main() {
|
|
|
117843
118130
|
}
|
|
117844
118131
|
|
|
117845
118132
|
// import * as kiwrious from "copper3d_plugin_heart_k";
|
|
117846
|
-
// "v3.10.
|
|
118133
|
+
// "v3.10.4" is injected at build time by rollup @rollup/plugin-replace, sourced from package.json version.
|
|
117847
118134
|
// When copper3d is consumed from local source (no rollup replace step), the identifier is undefined and
|
|
117848
118135
|
// referencing it throws a ReferenceError — guard it so local loading still works.
|
|
117849
118136
|
let _revision = "unknown";
|
|
117850
118137
|
try {
|
|
117851
|
-
_revision = "v3.10.
|
|
118138
|
+
_revision = "v3.10.4";
|
|
117852
118139
|
}
|
|
117853
118140
|
catch (_a) {
|
|
117854
|
-
/* "v3.10.
|
|
118141
|
+
/* "v3.10.4" not injected (local source build) */
|
|
117855
118142
|
}
|
|
117856
118143
|
const REVISION = _revision;
|
|
117857
118144
|
// Expose on global so the version can be read in a production browser console via window.__COPPER3D_VERSION__
|
package/dist/index.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ import { nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadR
|
|
|
55
55
|
import { IPaintImage, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, IGuiMeta } from "./Utils/segmentation/core/types";
|
|
56
56
|
import { NrrdState } from "./Utils/segmentation/coreTools/NrrdState";
|
|
57
57
|
import { GuiState } from "./Utils/segmentation/coreTools/GuiState";
|
|
58
|
-
import type { ToolMode, IAnnotationCallbacks } from "./Utils/segmentation/core/types";
|
|
58
|
+
import type { ToolMode, IAnnotationCallbacks, MaskRenderMode } from "./Utils/segmentation/core/types";
|
|
59
59
|
import { CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss } from "./Utils/segmentation/core/index";
|
|
60
60
|
import type { LayerId, ChannelValue } from "./Utils/segmentation/core/index";
|
|
61
61
|
import { MAX_ENGINE_CHANNEL } from "./Utils/segmentation/core/index";
|
|
@@ -63,5 +63,5 @@ import type { AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult } from
|
|
|
63
63
|
import "./css/style.css";
|
|
64
64
|
export declare const REVISION: string;
|
|
65
65
|
export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, loadKiwrious, NrrdTools, registerNiftiMaskGrid, loading, Copper3dTrackballControls, Copper3dOrbitControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, MAX_ENGINE_CHANNEL, CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, GaussianSmoother, SurfaceAnnotator, exposureExponent, DEFAULT_TARGET_GREY, disposeObject3D, disposeMaterial, collectFadeTargets, setFade, restoreFade, createSceneBudget, defaultBudgetBytes, disposeScene, removeSceneFromMap, fitDistance, fitView, isRotateEnabled, setRotateEnabled, isPanEnabled, setPanEnabled, isZoomEnabled, setZoomEnabled, beginGesture, isGestureActive, setCameraPose, addVolumeBoundingBox, VOLUME_BOUNDS_NAME, DEFAULT_AXES, ensureAxisExtracted, copperGltfLoader, setDracoDecoderPath, setKTX2TranscoderPath, easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, installFastSliceRepaint, };
|
|
66
|
-
export type { positionType, screenPosType, optsType, NrrdHeaderLike, GltfLoadOpts, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, aligned4DSurfaceType, aligned4DOptsType, Aligned4DController, raw4DVolumeTransformType, raw4DVolumeOptsType, Raw4DVolumeController, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, NrrdState, GuiState, IGuiMeta, ToolMode, IAnnotationCallbacks, LayerId, ChannelValue, AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult, SurfaceAnnotatorOptions, Annotation, AnnotationMode, ExportOptions, ExposureVolume, DisposableObject3D, DisposableMaterial, FadeTarget, FadeableMaterial, SceneBudget, DisposableScene, SceneDisposalHost, FitBounds, FitViewScene, AxisGatedControls, GestureAxes, PosableScene, BoundingBoxHost, VolumeBoundingBoxOpts, NrrdAxis, Pose, };
|
|
66
|
+
export type { positionType, screenPosType, optsType, NrrdHeaderLike, GltfLoadOpts, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, aligned4DSurfaceType, aligned4DOptsType, Aligned4DController, raw4DVolumeTransformType, raw4DVolumeOptsType, Raw4DVolumeController, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, NrrdState, GuiState, IGuiMeta, ToolMode, IAnnotationCallbacks, MaskRenderMode, LayerId, ChannelValue, AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult, SurfaceAnnotatorOptions, Annotation, AnnotationMode, ExportOptions, ExposureVolume, DisposableObject3D, DisposableMaterial, FadeTarget, FadeableMaterial, SceneBudget, DisposableScene, SceneDisposalHost, FitBounds, FitViewScene, AxisGatedControls, GestureAxes, PosableScene, BoundingBoxHost, VolumeBoundingBoxOpts, NrrdAxis, Pose, };
|
|
67
67
|
export type { CameraViewPreset } from "./Controls/orbitFraming";
|
|
@@ -161,6 +161,14 @@ export declare class DrawToolCore {
|
|
|
161
161
|
* app persists the volume in a single request rather than one call per slice.
|
|
162
162
|
*/
|
|
163
163
|
private applyVolumeSnapshot;
|
|
164
|
+
/**
|
|
165
|
+
* A copy of one layer's voxel buffer, or null if the layer has no volume.
|
|
166
|
+
*
|
|
167
|
+
* The read-only counterpart to replaceLayerVolume, and a copy rather than the live buffer:
|
|
168
|
+
* handing out the renderer's own array would let a caller mutate the volume behind it, with
|
|
169
|
+
* nothing invalidating the slice cache.
|
|
170
|
+
*/
|
|
171
|
+
getLayerVolume(layerId: string): Uint8Array | null;
|
|
164
172
|
/**
|
|
165
173
|
* Replace a layer's entire volume, optionally recording it as one undo step.
|
|
166
174
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { nrrdSliceType, storeExportPaintImageType, loadingBarType } from "../../types/types";
|
|
2
2
|
import { GUI } from "dat.gui";
|
|
3
|
-
import { IMaskData, IDragOpts, IKeyBoardSettings, ToolMode, IGuiMeta } from "./core/types";
|
|
3
|
+
import { IMaskData, IDragOpts, IKeyBoardSettings, ToolMode, IGuiMeta, MaskRenderMode } from "./core/types";
|
|
4
4
|
import { DragOperator } from "./DragOperator";
|
|
5
5
|
import type { ChannelValue, RGBAColor, ChannelColorMap } from "./core";
|
|
6
6
|
import type { SphereType } from "./tools/SphereTool";
|
|
@@ -254,6 +254,18 @@ export declare class NrrdTools {
|
|
|
254
254
|
setLayerOpacity(layerId: string, opacity: number): void;
|
|
255
255
|
getLayerOpacity(layerId: string): number;
|
|
256
256
|
getLayerOpacityMap(): Record<string, number>;
|
|
257
|
+
/**
|
|
258
|
+
* Fill every mask, or stroke only its boundary — for every layer and channel at once.
|
|
259
|
+
*
|
|
260
|
+
* A display decision, and nothing but: `MaskVolume` is not read differently and not written
|
|
261
|
+
* at all, so what is stored, uploaded, exported and undone is the complete mask either way.
|
|
262
|
+
*
|
|
263
|
+
* Repaints immediately, the same way `setChannelVisible` does, because there is no other
|
|
264
|
+
* event that would bring the change to the screen — a clinician who switched the mode and
|
|
265
|
+
* then had to scrub a slice to see it would reasonably call that broken.
|
|
266
|
+
*/
|
|
267
|
+
setMaskRenderMode(mode: MaskRenderMode): void;
|
|
268
|
+
getMaskRenderMode(): MaskRenderMode;
|
|
257
269
|
updateOriginAndChangedWH(): void;
|
|
258
270
|
setSyncsliceNum(): void;
|
|
259
271
|
resetPaintAreaUIPosition(l?: number, t?: number): void;
|
|
@@ -433,6 +445,14 @@ export declare class NrrdTools {
|
|
|
433
445
|
* ```
|
|
434
446
|
*/
|
|
435
447
|
copyLayerData(sourceLayerId: string, targetLayerId: string): void;
|
|
448
|
+
/**
|
|
449
|
+
* A copy of one layer's voxel buffer, or null if the layer has no volume.
|
|
450
|
+
*
|
|
451
|
+
* Pairs with `replaceLayerVolume`, so a caller can move a mask from one layer to another
|
|
452
|
+
* through the undoable path rather than through `copyLayerData`, which writes the target
|
|
453
|
+
* buffer directly and leaves nothing for Ctrl+Z.
|
|
454
|
+
*/
|
|
455
|
+
getLayerVolume(layerId: string): Uint8Array | null;
|
|
436
456
|
/**
|
|
437
457
|
* Replace a layer's entire voxel buffer.
|
|
438
458
|
*
|