cloudmr-ux 4.7.4 → 4.7.6
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/dist/CmrComponents/niivue-viewer/CloudMrNiivuePanel.js +2 -2
- package/dist/CmrComponents/niivue-viewer/CloudMrNiivueViewer.js +47 -9
- package/dist/CmrComponents/niivue-viewer/NiivuePatcher.js +43 -9
- package/dist/CmrComponents/niivue-viewer/PenDraftOverlay.d.ts +6 -4
- package/dist/CmrComponents/niivue-viewer/PenDraftOverlay.js +11 -1
- package/dist/CmrComponents/niivue-viewer/ShapeDraftOverlay.d.ts +3 -2
- package/dist/CmrComponents/niivue-viewer/ShapeDraftOverlay.js +11 -2
- package/dist/CmrComponents/niivue-viewer/mro-draw-toolkit/DrawColorPlatte.d.ts +2 -1
- package/dist/CmrComponents/niivue-viewer/mro-draw-toolkit/DrawColorPlatte.js +5 -2
- package/dist/CmrComponents/niivue-viewer/mro-draw-toolkit/MroDrawToolkit.js +1 -1
- package/package.json +1 -1
|
@@ -125,7 +125,7 @@ export function CloudMrNiivuePanel(props) {
|
|
|
125
125
|
if (tool === "pen") {
|
|
126
126
|
nv.opts.polylinePenMode = penMode === "polyline";
|
|
127
127
|
nv.opts.isFilledPen = penMode === "freehand";
|
|
128
|
-
nv.opts.deferFreehandCommit =
|
|
128
|
+
nv.opts.deferFreehandCommit = false;
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
131
131
|
nv.opts.polylinePenMode = false;
|
|
@@ -195,7 +195,7 @@ export function CloudMrNiivuePanel(props) {
|
|
|
195
195
|
left: 0,
|
|
196
196
|
width: "100%",
|
|
197
197
|
height: "100%"
|
|
198
|
-
} }), props.shapeDraft && (_jsx(ShapeDraftOverlay, { nv: props.nv, draft: props.shapeDraft, onDraftChange: props.onShapeDraftChange, overlayKey: props.mms })), props.penDraft && (_jsx(PenDraftOverlay, { nv: props.nv, draft: props.penDraft, onDraftChange: props.onPenDraftChange, overlayKey: props.mms }))] }))] })), _jsxs(Box, __assign({ sx: {
|
|
198
|
+
} }), props.shapeDraft && (_jsx(ShapeDraftOverlay, { nv: props.nv, draft: props.shapeDraft, onDraftChange: props.onShapeDraftChange, onApplyDraft: props.onApplyShapeDraft, overlayKey: props.mms })), props.penDraft && (_jsx(PenDraftOverlay, { nv: props.nv, draft: props.penDraft, onDraftChange: props.onPenDraftChange, onApplyDraft: props.onApplyPenDraft, overlayKey: props.mms }))] }))] })), _jsxs(Box, __assign({ sx: {
|
|
199
199
|
width: {
|
|
200
200
|
xs: "100%",
|
|
201
201
|
md: "35%"
|
|
@@ -63,7 +63,7 @@ import { SettingsPanel } from './SettingsPanel';
|
|
|
63
63
|
import { NumberPicker } from './NumberPicker';
|
|
64
64
|
import { ColorPicker } from './ColorPicker';
|
|
65
65
|
import { LayersPanel } from './LayersPanel';
|
|
66
|
-
import { applyPenDraft, cancelPenDraft, fillPolylineDraft, unfillPolylineDraft, polylineDraftFromNv, syncPolylineDraftToNv, registerAppliedPolyline, restoreCommittedPolyline, collectPolylineAppliedVoxelIndices, } from './penDraftUtils';
|
|
66
|
+
import { applyPenDraft, cancelPenDraft, captureFreehandDraft, fillPolylineDraft, unfillPolylineDraft, polylineDraftFromNv, syncPolylineDraftToNv, registerAppliedPolyline, restoreCommittedPolyline, collectPolylineAppliedVoxelIndices, } from './penDraftUtils';
|
|
67
67
|
import { CloudMrNiivuePanel } from './CloudMrNiivuePanel';
|
|
68
68
|
import { Niivue } from './NiivuePatcher';
|
|
69
69
|
import NVSwitch from './Switch';
|
|
@@ -593,7 +593,7 @@ export default function CloudMrNiivueViewer(props) {
|
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
595
|
else if (drawShapeToolRef.current === "pen") {
|
|
596
|
-
nv.opts.deferFreehandCommit =
|
|
596
|
+
nv.opts.deferFreehandCommit = false;
|
|
597
597
|
nv.opts.polylinePenMode = penDrawModeRef.current === "polyline";
|
|
598
598
|
nv.opts.isFilledPen = penDrawModeRef.current === "freehand";
|
|
599
599
|
}
|
|
@@ -821,16 +821,42 @@ export default function CloudMrNiivueViewer(props) {
|
|
|
821
821
|
}
|
|
822
822
|
}
|
|
823
823
|
function syncPenDrawMode(mode) {
|
|
824
|
-
var _a;
|
|
824
|
+
var _a, _b;
|
|
825
|
+
var prevMode = penDrawModeRef.current;
|
|
826
|
+
// Commit an in-progress freehand before switching to polyline so it stays
|
|
827
|
+
// marked as pen (kind 2) and is not misidentified as a shape on click.
|
|
828
|
+
if (prevMode === "freehand" && mode === "polyline") {
|
|
829
|
+
var draft = penDraftRef.current;
|
|
830
|
+
if ((draft === null || draft === void 0 ? void 0 : draft.kind) === "freehand") {
|
|
831
|
+
applyPenDraft(nv, draft);
|
|
832
|
+
markPenVoxelKind(draft, 2);
|
|
833
|
+
setPenDraft(null);
|
|
834
|
+
penDraftRef.current = null;
|
|
835
|
+
nv._cloudMrPenDraftActive = false;
|
|
836
|
+
}
|
|
837
|
+
else if (nv._cloudMrFreehandSessionStartBitmap) {
|
|
838
|
+
var axCorSag = nv._cloudMrFreehandAxCorSag >= 0 ? nv._cloudMrFreehandAxCorSag : nv.drawPenAxCorSag;
|
|
839
|
+
var captured = captureFreehandDraft(nv, nv._cloudMrFreehandSessionStartBitmap, axCorSag);
|
|
840
|
+
nv._cloudMrFreehandSessionStartBitmap = null;
|
|
841
|
+
if (captured)
|
|
842
|
+
markPenVoxelKind(captured, 2);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
if (mode === "freehand") {
|
|
846
|
+
(_a = nv.cloudMrCancelPolyline) === null || _a === void 0 ? void 0 : _a.call(nv);
|
|
847
|
+
if (((_b = penDraftRef.current) === null || _b === void 0 ? void 0 : _b.kind) === "polyline") {
|
|
848
|
+
cancelPenDraft(nv, penDraftRef.current);
|
|
849
|
+
setPenDraft(null);
|
|
850
|
+
penDraftRef.current = null;
|
|
851
|
+
nv._cloudMrPenDraftActive = false;
|
|
852
|
+
setPolylineVertexCount(0);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
825
855
|
setPenDrawMode(mode);
|
|
826
856
|
penDrawModeRef.current = mode;
|
|
827
857
|
nv.opts.polylinePenMode = mode === "polyline";
|
|
828
858
|
nv.opts.isFilledPen = mode === "freehand";
|
|
829
|
-
nv.opts.deferFreehandCommit =
|
|
830
|
-
drawShapeToolRef.current === "pen" && mode === "freehand";
|
|
831
|
-
if (mode === "freehand") {
|
|
832
|
-
(_a = nv.cloudMrCancelPolyline) === null || _a === void 0 ? void 0 : _a.call(nv);
|
|
833
|
-
}
|
|
859
|
+
nv.opts.deferFreehandCommit = false;
|
|
834
860
|
}
|
|
835
861
|
function cancelPenDraftHandler() {
|
|
836
862
|
var _a;
|
|
@@ -885,7 +911,7 @@ export default function CloudMrNiivueViewer(props) {
|
|
|
885
911
|
var mode = penDrawModeRef.current;
|
|
886
912
|
nv.opts.polylinePenMode = mode === "polyline";
|
|
887
913
|
nv.opts.isFilledPen = mode === "freehand";
|
|
888
|
-
nv.opts.deferFreehandCommit =
|
|
914
|
+
nv.opts.deferFreehandCommit = false;
|
|
889
915
|
nvSetDrawingEnabled(true);
|
|
890
916
|
}
|
|
891
917
|
else {
|
|
@@ -916,6 +942,17 @@ export default function CloudMrNiivueViewer(props) {
|
|
|
916
942
|
function cancelPolylineDraft() {
|
|
917
943
|
cancelPenDraftHandler();
|
|
918
944
|
}
|
|
945
|
+
nv.onShapeCommitted = function (draft) {
|
|
946
|
+
nv.drawAddUndoBitmap(nv.drawFillOverwrites);
|
|
947
|
+
markShapeVoxelKind(draft);
|
|
948
|
+
setDrawingChanged(true);
|
|
949
|
+
resampleImage();
|
|
950
|
+
};
|
|
951
|
+
nv.onFreehandCommitted = function (draft) {
|
|
952
|
+
markPenVoxelKind(draft, 2);
|
|
953
|
+
setDrawingChanged(true);
|
|
954
|
+
resampleImage();
|
|
955
|
+
};
|
|
919
956
|
nv.onPenDraftReady = function (draft) {
|
|
920
957
|
setPenDraft(draft);
|
|
921
958
|
penDraftRef.current = draft;
|
|
@@ -1657,6 +1694,7 @@ export default function CloudMrNiivueViewer(props) {
|
|
|
1657
1694
|
onCancelPenDraft: cancelPenDraftHandler,
|
|
1658
1695
|
onFillPenDraft: fillPolylineDraftHandler,
|
|
1659
1696
|
penDraftActive: penDraft != null,
|
|
1697
|
+
penDraftKind: penDraft === null || penDraft === void 0 ? void 0 : penDraft.kind,
|
|
1660
1698
|
penDraftFilled: (penDraft === null || penDraft === void 0 ? void 0 : penDraft.filled) === true,
|
|
1661
1699
|
brushSize: brushSize,
|
|
1662
1700
|
updateBrushSize: nvUpdateBrushSize,
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
captureFreehandDraft,
|
|
26
26
|
capturePenDraftFromClick,
|
|
27
27
|
capturePolylineDraftFromClick,
|
|
28
|
+
isFreehandPenActive,
|
|
28
29
|
isRegisteredPolylineClick,
|
|
29
30
|
redrawFreehandDraft,
|
|
30
31
|
redrawPolylineDraft,
|
|
@@ -537,6 +538,19 @@ Niivue.prototype.drawPenFilled = function () {
|
|
|
537
538
|
return;
|
|
538
539
|
}
|
|
539
540
|
this.drawAddUndoBitmap()
|
|
541
|
+
if (this._cloudMrFreehandSessionStartBitmap && isFreehandPenActive(this)) {
|
|
542
|
+
const axCorSag =
|
|
543
|
+
this.drawPenAxCorSag >= 0 ? this.drawPenAxCorSag : this._cloudMrFreehandAxCorSag;
|
|
544
|
+
const draft = captureFreehandDraft(
|
|
545
|
+
this,
|
|
546
|
+
this._cloudMrFreehandSessionStartBitmap,
|
|
547
|
+
axCorSag,
|
|
548
|
+
);
|
|
549
|
+
this._cloudMrFreehandSessionStartBitmap = null;
|
|
550
|
+
if (draft && typeof this.onFreehandCommitted === "function") {
|
|
551
|
+
this.onFreehandCommitted(draft);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
540
554
|
// Post-processing to hide hidden voxels
|
|
541
555
|
this.hiddenBitmap = new Uint8Array(this.drawBitmap.length);
|
|
542
556
|
for (let i = 0; i < this.drawBitmap.length; i++) {
|
|
@@ -1506,6 +1520,28 @@ function clickedVoxelToolKind(nv) {
|
|
|
1506
1520
|
return bitmap[idx] || 0;
|
|
1507
1521
|
}
|
|
1508
1522
|
|
|
1523
|
+
/**
|
|
1524
|
+
* Re-open an applied ROI for editing based on stored (or inferred) tool kind.
|
|
1525
|
+
* Unmarked pen strokes (kind 0) must try pen reopen before shape inference —
|
|
1526
|
+
* otherwise freehand blobs get misclassified as ellipse/rectangle shapes.
|
|
1527
|
+
*/
|
|
1528
|
+
function cloudMrTryReopenDraftOnClick(nv) {
|
|
1529
|
+
if (nv._cloudMrShapeDraftActive || nv._cloudMrPenDraftActive) return;
|
|
1530
|
+
if (!isClickWithoutDrag(nv.uiData)) return;
|
|
1531
|
+
|
|
1532
|
+
const kind = clickedVoxelToolKind(nv);
|
|
1533
|
+
if (kind === 1) {
|
|
1534
|
+
cloudMrTryReopenShapeDraftOnClick(nv);
|
|
1535
|
+
return;
|
|
1536
|
+
}
|
|
1537
|
+
if (kind === 2 || kind === 3) {
|
|
1538
|
+
cloudMrTryReopenPenDraftOnClick(nv);
|
|
1539
|
+
return;
|
|
1540
|
+
}
|
|
1541
|
+
if (cloudMrTryReopenPenDraftOnClick(nv)) return;
|
|
1542
|
+
cloudMrTryReopenShapeDraftOnClick(nv);
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1509
1545
|
/**
|
|
1510
1546
|
* Re-enter rectangle/ellipse edit mode when clicking an existing applied shape ROI.
|
|
1511
1547
|
* Skips voxels that were drawn with the pen tool (those are handled by pen reopen).
|
|
@@ -1569,12 +1605,12 @@ Niivue.prototype.mouseDownListener = function cloudMrMouseDownListener(e) {
|
|
|
1569
1605
|
if (e.button === RIGHT_MOUSE_BUTTON && cloudMrTryApplyDraftOnRightClick(this, e)) {
|
|
1570
1606
|
return;
|
|
1571
1607
|
}
|
|
1572
|
-
if (
|
|
1608
|
+
if (isFreehandPenActive(this) && this.drawBitmap) {
|
|
1573
1609
|
this._cloudMrFreehandSessionStartBitmap = this.drawBitmap.slice();
|
|
1574
1610
|
this._cloudMrFreehandAxCorSag = -1;
|
|
1575
1611
|
}
|
|
1576
1612
|
_mouseDownListener.call(this, e);
|
|
1577
|
-
if (
|
|
1613
|
+
if (isFreehandPenActive(this) && this._cloudMrFreehandSessionStartBitmap) {
|
|
1578
1614
|
const axCorSag = axCorSagFromMouse(this);
|
|
1579
1615
|
if (axCorSag >= 0) {
|
|
1580
1616
|
this._cloudMrFreehandAxCorSag = axCorSag;
|
|
@@ -1637,22 +1673,20 @@ Niivue.prototype.mouseUpListener = function cloudMrMouseUpListener() {
|
|
|
1637
1673
|
}
|
|
1638
1674
|
|
|
1639
1675
|
if (!pendingDraft?.baseBitmap) {
|
|
1640
|
-
|
|
1641
|
-
cloudMrTryReopenPenDraftOnClick(this);
|
|
1642
|
-
}
|
|
1676
|
+
cloudMrTryReopenDraftOnClick(this);
|
|
1643
1677
|
return;
|
|
1644
1678
|
}
|
|
1645
1679
|
if (isDraftTooSmall(pendingDraft.ptA, pendingDraft.ptB)) {
|
|
1646
1680
|
this.drawBitmap.set(pendingDraft.baseBitmap);
|
|
1647
1681
|
this.refreshDrawing(true, false);
|
|
1648
1682
|
this.drawScene();
|
|
1649
|
-
|
|
1650
|
-
cloudMrTryReopenPenDraftOnClick(this);
|
|
1651
|
-
}
|
|
1683
|
+
cloudMrTryReopenDraftOnClick(this);
|
|
1652
1684
|
return;
|
|
1653
1685
|
}
|
|
1654
1686
|
this._cloudMrSuppressDrawingChangedMouseUp = true;
|
|
1655
|
-
if (typeof this.
|
|
1687
|
+
if (typeof this.onShapeCommitted === "function") {
|
|
1688
|
+
this.onShapeCommitted(pendingDraft);
|
|
1689
|
+
} else if (typeof this.onShapeDraftReady === "function") {
|
|
1656
1690
|
this.onShapeDraftReady(pendingDraft);
|
|
1657
1691
|
}
|
|
1658
1692
|
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Adjust handles for polyline (vertex drag) or freehand (move only) drafts.
|
|
3
|
+
* @param {{ nv: any, draft: import('./penDraftUtils').PenDraft, onDraftChange: (d: any) => void, onApplyDraft?: () => void, overlayKey?: unknown }} props
|
|
3
4
|
*/
|
|
4
|
-
export function PenDraftOverlay({ nv, draft, onDraftChange, overlayKey }: {
|
|
5
|
+
export function PenDraftOverlay({ nv, draft, onDraftChange, onApplyDraft, overlayKey }: {
|
|
5
6
|
nv: any;
|
|
6
|
-
draft:
|
|
7
|
-
onDraftChange: any;
|
|
8
|
-
|
|
7
|
+
draft: import('./penDraftUtils').PenDraft;
|
|
8
|
+
onDraftChange: (d: any) => void;
|
|
9
|
+
onApplyDraft?: (() => void) | undefined;
|
|
10
|
+
overlayKey?: unknown;
|
|
9
11
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
10
12
|
export default PenDraftOverlay;
|
|
@@ -29,14 +29,17 @@ function cloneFreehandDraft(draft) {
|
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* Adjust handles for polyline (vertex drag) or freehand (move only) drafts.
|
|
32
|
+
* @param {{ nv: any, draft: import('./penDraftUtils').PenDraft, onDraftChange: (d: any) => void, onApplyDraft?: () => void, overlayKey?: unknown }} props
|
|
32
33
|
*/
|
|
33
34
|
export function PenDraftOverlay(_a) {
|
|
34
|
-
var nv = _a.nv, draft = _a.draft, onDraftChange = _a.onDraftChange, overlayKey = _a.overlayKey;
|
|
35
|
+
var nv = _a.nv, draft = _a.draft, onDraftChange = _a.onDraftChange, onApplyDraft = _a.onApplyDraft, overlayKey = _a.overlayKey;
|
|
35
36
|
var dragRef = useRef(null);
|
|
36
37
|
var draftRef = useRef(draft);
|
|
37
38
|
draftRef.current = draft;
|
|
38
39
|
var onPointerMoveRef = useRef(null);
|
|
39
40
|
var finishDragRef = useRef(null);
|
|
41
|
+
var onApplyDraftRef = useRef(onApplyDraft);
|
|
42
|
+
onApplyDraftRef.current = onApplyDraft;
|
|
40
43
|
var _b = useState(0), setTick = _b[1];
|
|
41
44
|
var bump = useCallback(function () { return setTick(function (t) { return t + 1; }); }, []);
|
|
42
45
|
useEffect(function () {
|
|
@@ -109,6 +112,8 @@ export function PenDraftOverlay(_a) {
|
|
|
109
112
|
onDraftChange(nextDraft);
|
|
110
113
|
}, [nv, onDraftChange]);
|
|
111
114
|
finishDragRef.current = function () {
|
|
115
|
+
var _a, _b;
|
|
116
|
+
var hadDrag = (_a = dragRef.current) === null || _a === void 0 ? void 0 : _a.didMove;
|
|
112
117
|
dragRef.current = null;
|
|
113
118
|
if (onPointerMoveRef.current) {
|
|
114
119
|
window.removeEventListener("pointermove", onPointerMoveRef.current);
|
|
@@ -116,11 +121,15 @@ export function PenDraftOverlay(_a) {
|
|
|
116
121
|
if (finishDragRef.current) {
|
|
117
122
|
window.removeEventListener("pointerup", finishDragRef.current);
|
|
118
123
|
}
|
|
124
|
+
if (hadDrag) {
|
|
125
|
+
(_b = onApplyDraftRef.current) === null || _b === void 0 ? void 0 : _b.call(onApplyDraftRef);
|
|
126
|
+
}
|
|
119
127
|
};
|
|
120
128
|
onPointerMoveRef.current = function (event) {
|
|
121
129
|
var drag = dragRef.current;
|
|
122
130
|
if (!drag)
|
|
123
131
|
return;
|
|
132
|
+
drag.didMove = true;
|
|
124
133
|
event.preventDefault();
|
|
125
134
|
var canvas = nv.canvas || document.getElementById("niiCanvas");
|
|
126
135
|
if (!canvas)
|
|
@@ -154,6 +163,7 @@ export function PenDraftOverlay(_a) {
|
|
|
154
163
|
mode: mode,
|
|
155
164
|
cornerIndex: cornerIndex,
|
|
156
165
|
kind: current.kind,
|
|
166
|
+
didMove: false,
|
|
157
167
|
startClientX: event.clientX,
|
|
158
168
|
startClientY: event.clientY,
|
|
159
169
|
startDraft: current,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Overlay handles for adjusting a rectangle/ellipse draft before commit.
|
|
3
|
-
* @param {{ nv: any, draft: import('./shapeDraftUtils').ShapeDraft, onDraftChange: (d: any) => void, overlayKey?: unknown }} props
|
|
3
|
+
* @param {{ nv: any, draft: import('./shapeDraftUtils').ShapeDraft, onDraftChange: (d: any) => void, onApplyDraft?: () => void, overlayKey?: unknown }} props
|
|
4
4
|
*/
|
|
5
|
-
export function ShapeDraftOverlay({ nv, draft, onDraftChange, overlayKey }: {
|
|
5
|
+
export function ShapeDraftOverlay({ nv, draft, onDraftChange, onApplyDraft, overlayKey }: {
|
|
6
6
|
nv: any;
|
|
7
7
|
draft: import('./shapeDraftUtils').ShapeDraft;
|
|
8
8
|
onDraftChange: (d: any) => void;
|
|
9
|
+
onApplyDraft?: (() => void) | undefined;
|
|
9
10
|
overlayKey?: unknown;
|
|
10
11
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
11
12
|
export default ShapeDraftOverlay;
|
|
@@ -25,16 +25,18 @@ var HANDLE_SIZE = 10;
|
|
|
25
25
|
var ACCENT = "#580f8b";
|
|
26
26
|
/**
|
|
27
27
|
* Overlay handles for adjusting a rectangle/ellipse draft before commit.
|
|
28
|
-
* @param {{ nv: any, draft: import('./shapeDraftUtils').ShapeDraft, onDraftChange: (d: any) => void, overlayKey?: unknown }} props
|
|
28
|
+
* @param {{ nv: any, draft: import('./shapeDraftUtils').ShapeDraft, onDraftChange: (d: any) => void, onApplyDraft?: () => void, overlayKey?: unknown }} props
|
|
29
29
|
*/
|
|
30
30
|
export function ShapeDraftOverlay(_a) {
|
|
31
31
|
var _b;
|
|
32
|
-
var nv = _a.nv, draft = _a.draft, onDraftChange = _a.onDraftChange, overlayKey = _a.overlayKey;
|
|
32
|
+
var nv = _a.nv, draft = _a.draft, onDraftChange = _a.onDraftChange, onApplyDraft = _a.onApplyDraft, overlayKey = _a.overlayKey;
|
|
33
33
|
var dragRef = useRef(null);
|
|
34
34
|
var draftRef = useRef(draft);
|
|
35
35
|
draftRef.current = draft;
|
|
36
36
|
var onPointerMoveRef = useRef(null);
|
|
37
37
|
var finishDragRef = useRef(null);
|
|
38
|
+
var onApplyDraftRef = useRef(onApplyDraft);
|
|
39
|
+
onApplyDraftRef.current = onApplyDraft;
|
|
38
40
|
var _c = useState(0), setTick = _c[1];
|
|
39
41
|
var bump = useCallback(function () { return setTick(function (t) { return t + 1; }); }, []);
|
|
40
42
|
useEffect(function () {
|
|
@@ -84,6 +86,8 @@ export function ShapeDraftOverlay(_a) {
|
|
|
84
86
|
onDraftChange(nextDraft);
|
|
85
87
|
}, [nv, onDraftChange]);
|
|
86
88
|
finishDragRef.current = function () {
|
|
89
|
+
var _a, _b;
|
|
90
|
+
var hadDrag = (_a = dragRef.current) === null || _a === void 0 ? void 0 : _a.didMove;
|
|
87
91
|
dragRef.current = null;
|
|
88
92
|
if (onPointerMoveRef.current) {
|
|
89
93
|
window.removeEventListener("pointermove", onPointerMoveRef.current);
|
|
@@ -91,12 +95,16 @@ export function ShapeDraftOverlay(_a) {
|
|
|
91
95
|
if (finishDragRef.current) {
|
|
92
96
|
window.removeEventListener("pointerup", finishDragRef.current);
|
|
93
97
|
}
|
|
98
|
+
if (hadDrag) {
|
|
99
|
+
(_b = onApplyDraftRef.current) === null || _b === void 0 ? void 0 : _b.call(onApplyDraftRef);
|
|
100
|
+
}
|
|
94
101
|
};
|
|
95
102
|
onPointerMoveRef.current = function (event) {
|
|
96
103
|
var drag = dragRef.current;
|
|
97
104
|
var currentDraft = draftRef.current;
|
|
98
105
|
if (!drag || !currentDraft)
|
|
99
106
|
return;
|
|
107
|
+
drag.didMove = true;
|
|
100
108
|
event.preventDefault();
|
|
101
109
|
if (drag.mode === "move") {
|
|
102
110
|
var canvas = nv.canvas || document.getElementById("niiCanvas");
|
|
@@ -124,6 +132,7 @@ export function ShapeDraftOverlay(_a) {
|
|
|
124
132
|
dragRef.current = {
|
|
125
133
|
mode: mode,
|
|
126
134
|
cornerIndex: cornerIndex,
|
|
135
|
+
didMove: false,
|
|
127
136
|
startClientX: event.clientX,
|
|
128
137
|
startClientY: event.clientY,
|
|
129
138
|
startPtA: __spreadArray([], draft.ptA, true),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default function DrawColorPlatte({ expanded, updateDrawPen, setDrawingEnabled, showPenModes, penDrawMode, onPenDrawModeChange, polylineVertexCount, penDraftActive, penDraftFilled, onApplyPenDraft, onFillPenDraft, brushSize, updateBrushSize, shapeDraftActive, onApplyShapeDraft, }: {
|
|
1
|
+
export default function DrawColorPlatte({ expanded, updateDrawPen, setDrawingEnabled, showPenModes, penDrawMode, onPenDrawModeChange, polylineVertexCount, penDraftActive, penDraftKind, penDraftFilled, onApplyPenDraft, onFillPenDraft, brushSize, updateBrushSize, shapeDraftActive, onApplyShapeDraft, }: {
|
|
2
2
|
expanded: any;
|
|
3
3
|
updateDrawPen: any;
|
|
4
4
|
setDrawingEnabled: any;
|
|
@@ -7,6 +7,7 @@ export default function DrawColorPlatte({ expanded, updateDrawPen, setDrawingEna
|
|
|
7
7
|
onPenDrawModeChange: any;
|
|
8
8
|
polylineVertexCount?: number | undefined;
|
|
9
9
|
penDraftActive?: boolean | undefined;
|
|
10
|
+
penDraftKind: any;
|
|
10
11
|
penDraftFilled?: boolean | undefined;
|
|
11
12
|
onApplyPenDraft: any;
|
|
12
13
|
onFillPenDraft: any;
|
|
@@ -36,7 +36,7 @@ var modeBtnSx = function (active) { return ({
|
|
|
36
36
|
px: 0.75
|
|
37
37
|
}); };
|
|
38
38
|
export default function DrawColorPlatte(_a) {
|
|
39
|
-
var expanded = _a.expanded, updateDrawPen = _a.updateDrawPen, setDrawingEnabled = _a.setDrawingEnabled, _b = _a.showPenModes, showPenModes = _b === void 0 ? false : _b, _c = _a.penDrawMode, penDrawMode = _c === void 0 ? "freehand" : _c, onPenDrawModeChange = _a.onPenDrawModeChange, _d = _a.polylineVertexCount, polylineVertexCount = _d === void 0 ? 0 : _d, _e = _a.penDraftActive, penDraftActive = _e === void 0 ? false : _e, _f = _a.penDraftFilled, penDraftFilled = _f === void 0 ? false : _f, onApplyPenDraft = _a.onApplyPenDraft, onFillPenDraft = _a.onFillPenDraft, _g = _a.brushSize, brushSize = _g === void 0 ? 1 : _g, updateBrushSize = _a.updateBrushSize, _h = _a.shapeDraftActive, shapeDraftActive = _h === void 0 ? false : _h, onApplyShapeDraft = _a.onApplyShapeDraft;
|
|
39
|
+
var expanded = _a.expanded, updateDrawPen = _a.updateDrawPen, setDrawingEnabled = _a.setDrawingEnabled, _b = _a.showPenModes, showPenModes = _b === void 0 ? false : _b, _c = _a.penDrawMode, penDrawMode = _c === void 0 ? "freehand" : _c, onPenDrawModeChange = _a.onPenDrawModeChange, _d = _a.polylineVertexCount, polylineVertexCount = _d === void 0 ? 0 : _d, _e = _a.penDraftActive, penDraftActive = _e === void 0 ? false : _e, penDraftKind = _a.penDraftKind, _f = _a.penDraftFilled, penDraftFilled = _f === void 0 ? false : _f, onApplyPenDraft = _a.onApplyPenDraft, onFillPenDraft = _a.onFillPenDraft, _g = _a.brushSize, brushSize = _g === void 0 ? 1 : _g, updateBrushSize = _a.updateBrushSize, _h = _a.shapeDraftActive, shapeDraftActive = _h === void 0 ? false : _h, onApplyShapeDraft = _a.onApplyShapeDraft;
|
|
40
40
|
return (_jsxs(Stack, __assign({ style: {
|
|
41
41
|
position: "absolute",
|
|
42
42
|
top: "100%",
|
|
@@ -53,7 +53,10 @@ export default function DrawColorPlatte(_a) {
|
|
|
53
53
|
}, direction: "column", spacing: 0.5, sx: { py: expanded ? 0.5 : 0 } }, { children: [showPenModes && expanded && (_jsxs(Stack, __assign({ direction: "row", alignItems: "center", spacing: 0.5, sx: { px: 0.75, pt: 0.25 } }, { children: [_jsx(Button, __assign({ size: "small", onClick: function () { return onPenDrawModeChange === null || onPenDrawModeChange === void 0 ? void 0 : onPenDrawModeChange("freehand"); }, sx: modeBtnSx(penDrawMode === "freehand") }, { children: "Freehand" })), _jsx(Button, __assign({ size: "small", onClick: function () { return onPenDrawModeChange === null || onPenDrawModeChange === void 0 ? void 0 : onPenDrawModeChange("polyline"); }, sx: modeBtnSx(penDrawMode === "polyline") }, { children: "Polyline" }))] }))), showPenModes && expanded && updateBrushSize && (_jsx(BrushSizeSlider, { label: "Line thickness", brushSize: brushSize, updateBrushSize: updateBrushSize })), _jsx(Stack, __assign({ direction: "row" }, { children: FILLED_COLORS.map(function (color, index) { return (_jsx(IconButton, __assign({ onClick: function () {
|
|
54
54
|
updateDrawPen({ target: { value: index + 1 } });
|
|
55
55
|
setDrawingEnabled(true);
|
|
56
|
-
} }, { children: _jsx(FiberManualRecordIcon, { sx: color.sx }) }), index)); }) })), showPenModes && penDrawMode === "polyline" && expanded && polylineVertexCount === 0 && (_jsx(Typography, __assign({ sx: { px: 1, pb: 0.5, fontSize: "0.68rem", color: "#aaa", userSelect: "none" } }, { children: "Click each vertex to draw connected line segments" }))), showPenModes &&
|
|
56
|
+
} }, { children: _jsx(FiberManualRecordIcon, { sx: color.sx }) }), index)); }) })), showPenModes && penDrawMode === "polyline" && expanded && polylineVertexCount === 0 && (_jsx(Typography, __assign({ sx: { px: 1, pb: 0.5, fontSize: "0.68rem", color: "#aaa", userSelect: "none" } }, { children: "Click each vertex to draw connected line segments" }))), showPenModes &&
|
|
57
|
+
penDraftActive &&
|
|
58
|
+
(penDrawMode === "polyline" || penDraftKind === "freehand") &&
|
|
59
|
+
expanded && (_jsxs(Stack, __assign({ direction: "row", alignItems: "center", justifyContent: "flex-end", spacing: 1, sx: { px: 1, py: 0.5, borderTop: "1px solid #555", width: "100%" } }, { children: [penDrawMode === "polyline" && polylineVertexCount >= 3 && (_jsx(Tooltip, __assign({ title: penDraftFilled
|
|
57
60
|
? "Remove fill (keeps outline editable)"
|
|
58
61
|
: "Fill interior (keeps outline editable until Apply)" }, { children: _jsx(Button, __assign({ size: "small", "aria-label": penDraftFilled ? "undo fill polyline" : "fill polyline", onClick: function () { return onFillPenDraft === null || onFillPenDraft === void 0 ? void 0 : onFillPenDraft(); }, sx: {
|
|
59
62
|
color: penDraftFilled ? "#ffb74d" : "#c9a0e8",
|
|
@@ -189,7 +189,7 @@ export function MroDrawToolkit(props) {
|
|
|
189
189
|
alignItems: "center",
|
|
190
190
|
gap: 4,
|
|
191
191
|
overflow: "visible"
|
|
192
|
-
} }, { children: [_jsxs(Box, __assign({ sx: { position: "relative", zIndex: expandedOption === "d" ? 1600 : "auto", display: "inline-flex", alignItems: "center" } }, { children: [_jsx(Tooltip, __assign({ title: "Pen" }, { children: _jsx(IconButton, __assign({ "aria-label": "pen", size: "small", onClick: clickPen, sx: __assign(__assign({}, toolBtnSx), shapeSelectedSx("pen")) }, { children: _jsx(DrawIcon, { sx: { color: "inherit" } }) })) })), _jsx(DrawColorPlatte, { expanded: expandedOption === "d", updateDrawPen: props.updateDrawPen, setDrawingEnabled: props.setDrawingEnabled, showPenModes: true, penDrawMode: props.penDrawMode, onPenDrawModeChange: props.onPenDrawModeChange, polylineVertexCount: props.polylineVertexCount, onCancelPolyline: props.onCancelPolyline, penDraftActive: props.penDraftActive, penDraftFilled: props.penDraftFilled, onApplyPenDraft: props.onApplyPenDraft, onFillPenDraft: props.onFillPenDraft, brushSize: props.brushSize, updateBrushSize: props.updateBrushSize })] })), _jsxs(Box, __assign({ sx: { position: "relative", zIndex: expandedOption === "r" ? 1600 : "auto", display: "inline-flex", alignItems: "center" } }, { children: [_jsx(Tooltip, __assign({ title: "Rectangle" }, { children: _jsx(IconButton, __assign({ "aria-label": "rectangle", size: "small", onClick: clickRectangle, sx: __assign(__assign({}, toolBtnSx), shapeSelectedSx("rectangle")) }, { children: _jsx(CropSquareOutlinedIcon, { sx: { color: "inherit" } }) })) })), _jsx(DrawColorPlatte, { expanded: expandedOption === "r", updateDrawPen: props.updateDrawPen, setDrawingEnabled: props.setDrawingEnabled, shapeDraftActive: props.shapeDraftActive && drawShapeTool === "rectangle", onApplyShapeDraft: props.onApplyShapeDraft })] })), _jsxs(Box, __assign({ sx: { position: "relative", zIndex: expandedOption === "l" ? 1600 : "auto", display: "inline-flex", alignItems: "center" } }, { children: [_jsx(Tooltip, __assign({ title: "Ellipse" }, { children: _jsx(IconButton, __assign({ "aria-label": "ellipse", size: "small", onClick: clickEllipse, sx: __assign(__assign({}, toolBtnSx), shapeSelectedSx("ellipse")) }, { children: _jsx(CircleOutlinedIcon, { sx: { color: "inherit" } }) })) })), _jsx(DrawColorPlatte, { expanded: expandedOption === "l", updateDrawPen: props.updateDrawPen, setDrawingEnabled: props.setDrawingEnabled, shapeDraftActive: props.shapeDraftActive && drawShapeTool === "ellipse", onApplyShapeDraft: props.onApplyShapeDraft })] })), _jsxs(Box, __assign({ sx: { position: "relative", zIndex: expandedOption === "e" ? 1600 : "auto", display: "inline-flex", alignItems: "center" } }, { children: [_jsx(Tooltip, __assign({ title: "Eraser" }, { children: _jsx(IconButton, __assign({ "aria-label": "erase", size: "small", onClick: clickEraser, sx: __assign(__assign({}, toolBtnSx), (eraserActive
|
|
192
|
+
} }, { children: [_jsxs(Box, __assign({ sx: { position: "relative", zIndex: expandedOption === "d" ? 1600 : "auto", display: "inline-flex", alignItems: "center" } }, { children: [_jsx(Tooltip, __assign({ title: "Pen" }, { children: _jsx(IconButton, __assign({ "aria-label": "pen", size: "small", onClick: clickPen, sx: __assign(__assign({}, toolBtnSx), shapeSelectedSx("pen")) }, { children: _jsx(DrawIcon, { sx: { color: "inherit" } }) })) })), _jsx(DrawColorPlatte, { expanded: expandedOption === "d", updateDrawPen: props.updateDrawPen, setDrawingEnabled: props.setDrawingEnabled, showPenModes: true, penDrawMode: props.penDrawMode, onPenDrawModeChange: props.onPenDrawModeChange, polylineVertexCount: props.polylineVertexCount, onCancelPolyline: props.onCancelPolyline, penDraftActive: props.penDraftActive, penDraftKind: props.penDraftKind, penDraftFilled: props.penDraftFilled, onApplyPenDraft: props.onApplyPenDraft, onFillPenDraft: props.onFillPenDraft, brushSize: props.brushSize, updateBrushSize: props.updateBrushSize })] })), _jsxs(Box, __assign({ sx: { position: "relative", zIndex: expandedOption === "r" ? 1600 : "auto", display: "inline-flex", alignItems: "center" } }, { children: [_jsx(Tooltip, __assign({ title: "Rectangle" }, { children: _jsx(IconButton, __assign({ "aria-label": "rectangle", size: "small", onClick: clickRectangle, sx: __assign(__assign({}, toolBtnSx), shapeSelectedSx("rectangle")) }, { children: _jsx(CropSquareOutlinedIcon, { sx: { color: "inherit" } }) })) })), _jsx(DrawColorPlatte, { expanded: expandedOption === "r", updateDrawPen: props.updateDrawPen, setDrawingEnabled: props.setDrawingEnabled, shapeDraftActive: props.shapeDraftActive && drawShapeTool === "rectangle", onApplyShapeDraft: props.onApplyShapeDraft })] })), _jsxs(Box, __assign({ sx: { position: "relative", zIndex: expandedOption === "l" ? 1600 : "auto", display: "inline-flex", alignItems: "center" } }, { children: [_jsx(Tooltip, __assign({ title: "Ellipse" }, { children: _jsx(IconButton, __assign({ "aria-label": "ellipse", size: "small", onClick: clickEllipse, sx: __assign(__assign({}, toolBtnSx), shapeSelectedSx("ellipse")) }, { children: _jsx(CircleOutlinedIcon, { sx: { color: "inherit" } }) })) })), _jsx(DrawColorPlatte, { expanded: expandedOption === "l", updateDrawPen: props.updateDrawPen, setDrawingEnabled: props.setDrawingEnabled, shapeDraftActive: props.shapeDraftActive && drawShapeTool === "ellipse", onApplyShapeDraft: props.onApplyShapeDraft })] })), _jsxs(Box, __assign({ sx: { position: "relative", zIndex: expandedOption === "e" ? 1600 : "auto", display: "inline-flex", alignItems: "center" } }, { children: [_jsx(Tooltip, __assign({ title: "Eraser" }, { children: _jsx(IconButton, __assign({ "aria-label": "erase", size: "small", onClick: clickEraser, sx: __assign(__assign({}, toolBtnSx), (eraserActive
|
|
193
193
|
? { backgroundColor: "rgba(88, 15, 139, 0.12)", color: "#580f8b" }
|
|
194
194
|
: {})) }, { children: filled || !eraserActive ? (_jsx(EraserIcon, {})) : (_jsx(AutoFixNormalOutlinedIcon, { sx: { color: ICON_COLOR } })) })) })), _jsx(EraserPlatte, { expandEraseOptions: expandedOption === "e", updateDrawPen: props.updateDrawPen, setDrawingEnabled: props.setDrawingEnabled, brushSize: props.brushSize, updateBrushSize: props.updateBrushSize })] })), _jsx(Tooltip, __assign({ title: "Undo" }, { children: _jsx(IconButton, __assign({ "aria-label": "revert", size: "small", onClick: function () { return props.drawUndo(); }, sx: toolBtnSx }, { children: _jsx(ReplyIcon, { sx: { color: ICON_COLOR } }) })) })), _jsx(Tooltip, __assign({ title: "Save screenshot" }, { children: _jsx("span", { children: _jsx(IconButton, __assign({ "aria-label": "capture", size: "small", disabled: !vol, onClick: function () { return vol && props.nv.saveScene("".concat(vol.name, "_drawing.png")); }, sx: toolBtnSx }, { children: _jsx(CameraAltIcon, { sx: { color: ICON_COLOR } }) })) }) })), _jsx(Tooltip, __assign({ title: "Clear drawing" }, { children: _jsx(IconButton, __assign({ "aria-label": "delete", size: "small", onClick: function () {
|
|
195
195
|
var _a;
|