cloudmr-ux 4.5.6 → 4.5.9
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.d.ts +2 -0
- package/dist/CmrComponents/niivue-viewer/CloudMrNiivuePanel.js +2 -7
- package/dist/CmrComponents/niivue-viewer/CloudMrNiivueViewer.js +78 -4
- package/dist/CmrComponents/niivue-viewer/mro-draw-toolkit/MroDrawToolkit.js +22 -8
- package/dist/CmrComponents/niivue-viewer/penDraftUtils.d.ts +1 -0
- package/dist/CmrComponents/niivue-viewer/penDraftUtils.js +7 -1
- package/dist/CmrComponents/niivue-viewer/polylinePenUtils.js +2 -1
- package/package.json +1 -1
|
@@ -11,6 +11,8 @@ export type CloudMrDrawToolkitProps = Omit<DrawToolkitProps, "rois" | "selectedR
|
|
|
11
11
|
onCancelPenDraft?: () => void;
|
|
12
12
|
onFillPenDraft?: () => void;
|
|
13
13
|
penDraftActive?: boolean;
|
|
14
|
+
onActivateEraser?: () => void;
|
|
15
|
+
onDeactivateDrawTools?: () => void;
|
|
14
16
|
shapeDraftActive?: boolean;
|
|
15
17
|
onApplyShapeDraft?: () => void;
|
|
16
18
|
onCancelShapeDraft?: () => void;
|
|
@@ -153,13 +153,8 @@ export function CloudMrNiivuePanel(props) {
|
|
|
153
153
|
justifyContent: "flex-start",
|
|
154
154
|
mb: { xs: 2, md: 0 }
|
|
155
155
|
} }, { children: [_jsx(MroDrawToolkit, __assign({}, props.drawToolkitProps, { drawShapeTool: props.drawShapeTool, onDrawShapeToolChange: applyDrawShapeTool, onExitDrawMode: function () {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
if (props.penDraft) {
|
|
160
|
-
props.onCancelPenDraft();
|
|
161
|
-
}
|
|
162
|
-
props.setDrawShapeTool(null);
|
|
156
|
+
var _a, _b;
|
|
157
|
+
(_b = (_a = props.drawToolkitProps).onDeactivateDrawTools) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
163
158
|
}, shapeDraftActive: props.shapeDraft != null, penDraftActive: props.penDraft != null, onApplyShapeDraft: props.onApplyShapeDraft, onCancelShapeDraft: props.onCancelShapeDraft, style: {
|
|
164
159
|
marginBottom: 0,
|
|
165
160
|
width: "100%",
|
|
@@ -565,13 +565,85 @@ export default function CloudMrNiivueViewer(props) {
|
|
|
565
565
|
nv.opts.penSize = size;
|
|
566
566
|
}
|
|
567
567
|
function nvUpdateDrawPen(a) {
|
|
568
|
+
var _a;
|
|
568
569
|
var raw = Number(a.target.value);
|
|
569
570
|
setDrawPen(raw);
|
|
570
|
-
var
|
|
571
|
-
|
|
572
|
-
if (penValue == 8) {
|
|
571
|
+
var isEraser = raw === 0 || raw === 8;
|
|
572
|
+
if (raw === 8) {
|
|
573
573
|
nv.setPenValue(0, true);
|
|
574
574
|
}
|
|
575
|
+
else {
|
|
576
|
+
nv.setPenValue(raw & 7, raw > 0);
|
|
577
|
+
}
|
|
578
|
+
if (isEraser) {
|
|
579
|
+
nv.opts.penType = NI_PEN_TYPE.PEN;
|
|
580
|
+
nv.opts.deferFreehandCommit = false;
|
|
581
|
+
nv.opts.deferShapeCommit = false;
|
|
582
|
+
nv.opts.polylinePenMode = false;
|
|
583
|
+
(_a = nv.cloudMrResetPolyline) === null || _a === void 0 ? void 0 : _a.call(nv);
|
|
584
|
+
if (penDraftRef.current) {
|
|
585
|
+
cancelPenDraft(nv, penDraftRef.current);
|
|
586
|
+
setPenDraft(null);
|
|
587
|
+
penDraftRef.current = null;
|
|
588
|
+
nv._cloudMrPenDraftActive = false;
|
|
589
|
+
setPolylineVertexCount(0);
|
|
590
|
+
}
|
|
591
|
+
if (shapeDraftRef.current) {
|
|
592
|
+
cancelShapeDraft();
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
else if (drawShapeToolRef.current === "pen") {
|
|
596
|
+
nv.opts.deferFreehandCommit = penDrawModeRef.current === "freehand";
|
|
597
|
+
nv.opts.polylinePenMode = penDrawModeRef.current === "polyline";
|
|
598
|
+
nv.opts.isFilledPen = penDrawModeRef.current === "freehand";
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
function deactivateDrawTools() {
|
|
602
|
+
var _a, _b;
|
|
603
|
+
if (shapeDraftRef.current) {
|
|
604
|
+
cancelShapeDraft();
|
|
605
|
+
}
|
|
606
|
+
if (penDraftRef.current) {
|
|
607
|
+
cancelPenDraft(nv, penDraftRef.current);
|
|
608
|
+
(_a = nv.cloudMrResetPolyline) === null || _a === void 0 ? void 0 : _a.call(nv);
|
|
609
|
+
setPolylineVertexCount(0);
|
|
610
|
+
setPenDraft(null);
|
|
611
|
+
penDraftRef.current = null;
|
|
612
|
+
nv._cloudMrPenDraftActive = false;
|
|
613
|
+
}
|
|
614
|
+
setDrawShapeTool(null);
|
|
615
|
+
nv.opts.penType = NI_PEN_TYPE.PEN;
|
|
616
|
+
nv.opts.deferShapeCommit = false;
|
|
617
|
+
nv.opts.deferFreehandCommit = false;
|
|
618
|
+
nv.opts.polylinePenMode = false;
|
|
619
|
+
(_b = nv.cloudMrResetPolyline) === null || _b === void 0 ? void 0 : _b.call(nv);
|
|
620
|
+
nvSetDrawingEnabled(false);
|
|
621
|
+
if (drawPen === 0 || drawPen === 8) {
|
|
622
|
+
setDrawPen(1);
|
|
623
|
+
nv.setPenValue(1, false);
|
|
624
|
+
nv.opts.isFilledPen = false;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
function activateEraser() {
|
|
628
|
+
var _a;
|
|
629
|
+
setDrawShapeTool(null);
|
|
630
|
+
nv.opts.penType = NI_PEN_TYPE.PEN;
|
|
631
|
+
nv.opts.deferShapeCommit = false;
|
|
632
|
+
nv.opts.deferFreehandCommit = false;
|
|
633
|
+
nv.opts.polylinePenMode = false;
|
|
634
|
+
if (shapeDraftRef.current) {
|
|
635
|
+
cancelShapeDraft();
|
|
636
|
+
}
|
|
637
|
+
if (penDraftRef.current) {
|
|
638
|
+
cancelPenDraft(nv, penDraftRef.current);
|
|
639
|
+
(_a = nv.cloudMrResetPolyline) === null || _a === void 0 ? void 0 : _a.call(nv);
|
|
640
|
+
setPolylineVertexCount(0);
|
|
641
|
+
setPenDraft(null);
|
|
642
|
+
penDraftRef.current = null;
|
|
643
|
+
nv._cloudMrPenDraftActive = false;
|
|
644
|
+
}
|
|
645
|
+
nvUpdateDrawPen({ target: { value: 8 } });
|
|
646
|
+
nvSetDrawingEnabled(true);
|
|
575
647
|
}
|
|
576
648
|
function nvUpdateDrawOpacity(a) {
|
|
577
649
|
setDrawOpacity(a);
|
|
@@ -1446,7 +1518,9 @@ export default function CloudMrNiivueViewer(props) {
|
|
|
1446
1518
|
onFillPenDraft: fillPolylineDraftHandler,
|
|
1447
1519
|
penDraftActive: penDraft != null,
|
|
1448
1520
|
brushSize: brushSize,
|
|
1449
|
-
updateBrushSize: nvUpdateBrushSize
|
|
1521
|
+
updateBrushSize: nvUpdateBrushSize,
|
|
1522
|
+
onActivateEraser: activateEraser,
|
|
1523
|
+
onDeactivateDrawTools: deactivateDrawTools
|
|
1450
1524
|
};
|
|
1451
1525
|
return (_jsxs(Box, __assign({ sx: {
|
|
1452
1526
|
display: 'flex',
|
|
@@ -85,7 +85,17 @@ export function MroDrawToolkit(props) {
|
|
|
85
85
|
? { backgroundColor: "rgba(88, 15, 139, 0.12)", color: "#580f8b" }
|
|
86
86
|
: {};
|
|
87
87
|
};
|
|
88
|
+
var eraserActive = expandedOption === "e";
|
|
89
|
+
function leaveEraserIfActive() {
|
|
90
|
+
var _a;
|
|
91
|
+
if (!eraserActive && props.drawPen !== 0 && props.drawPen !== 8) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
(_a = props.onDeactivateDrawTools) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
95
|
+
setExpandedOption("n");
|
|
96
|
+
}
|
|
88
97
|
function clickPen() {
|
|
98
|
+
leaveEraserIfActive();
|
|
89
99
|
onDrawShapeToolChange === null || onDrawShapeToolChange === void 0 ? void 0 : onDrawShapeToolChange("pen");
|
|
90
100
|
if (expandedOption === "d") {
|
|
91
101
|
setExpandedOption("n");
|
|
@@ -98,6 +108,7 @@ export function MroDrawToolkit(props) {
|
|
|
98
108
|
}
|
|
99
109
|
}
|
|
100
110
|
function clickRectangle() {
|
|
111
|
+
leaveEraserIfActive();
|
|
101
112
|
onDrawShapeToolChange === null || onDrawShapeToolChange === void 0 ? void 0 : onDrawShapeToolChange("rectangle");
|
|
102
113
|
if (expandedOption === "r") {
|
|
103
114
|
setExpandedOption("n");
|
|
@@ -110,6 +121,7 @@ export function MroDrawToolkit(props) {
|
|
|
110
121
|
}
|
|
111
122
|
}
|
|
112
123
|
function clickEllipse() {
|
|
124
|
+
leaveEraserIfActive();
|
|
113
125
|
onDrawShapeToolChange === null || onDrawShapeToolChange === void 0 ? void 0 : onDrawShapeToolChange("ellipse");
|
|
114
126
|
if (expandedOption === "l") {
|
|
115
127
|
setExpandedOption("n");
|
|
@@ -122,14 +134,15 @@ export function MroDrawToolkit(props) {
|
|
|
122
134
|
}
|
|
123
135
|
}
|
|
124
136
|
function clickEraser() {
|
|
137
|
+
var _a, _b;
|
|
125
138
|
if (expandedOption === "e") {
|
|
126
139
|
setExpandedOption("n");
|
|
140
|
+
(_a = props.onDeactivateDrawTools) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
141
|
+
return;
|
|
127
142
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
props.setDrawingEnabled(expandedOption !== "e");
|
|
143
|
+
leaveEraserIfActive();
|
|
144
|
+
(_b = props.onActivateEraser) === null || _b === void 0 ? void 0 : _b.call(props);
|
|
145
|
+
setExpandedOption("e");
|
|
133
146
|
}
|
|
134
147
|
function clickMask() {
|
|
135
148
|
if (expandedOption === "m") {
|
|
@@ -155,8 +168,7 @@ export function MroDrawToolkit(props) {
|
|
|
155
168
|
return;
|
|
156
169
|
setExpandedOption("n");
|
|
157
170
|
setExpandOpacityOptions(false);
|
|
158
|
-
props.
|
|
159
|
-
(_a = props.onExitDrawMode) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
171
|
+
(_a = props.onDeactivateDrawTools) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
160
172
|
} }, { children: _jsxs("div", __assign({ style: __assign({ width: "100%", position: "relative", zIndex: 1080 }, props.style) }, { children: [_jsx("div", __assign({ className: "title", style: { width: "100%" } }, { children: "ROI Tools" })), _jsx(Card, __assign({ variant: "outlined", sx: {
|
|
161
173
|
mb: 2,
|
|
162
174
|
borderTopLeftRadius: 0,
|
|
@@ -172,7 +184,9 @@ export function MroDrawToolkit(props) {
|
|
|
172
184
|
alignItems: "center",
|
|
173
185
|
gap: 4,
|
|
174
186
|
overflow: "visible"
|
|
175
|
-
} }, { 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, onApplyPenDraft: props.onApplyPenDraft, onCancelPenDraft: props.onCancelPenDraft, 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, onCancelShapeDraft: props.onCancelShapeDraft })] })), _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, onCancelShapeDraft: props.onCancelShapeDraft })] })), _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:
|
|
187
|
+
} }, { 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, onApplyPenDraft: props.onApplyPenDraft, onCancelPenDraft: props.onCancelPenDraft, 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, onCancelShapeDraft: props.onCancelShapeDraft })] })), _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, onCancelShapeDraft: props.onCancelShapeDraft })] })), _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
|
|
188
|
+
? { backgroundColor: "rgba(88, 15, 139, 0.12)", color: "#580f8b" }
|
|
189
|
+
: {})) }, { 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 () {
|
|
176
190
|
props.nv.clearDrawing();
|
|
177
191
|
props.resampleImage();
|
|
178
192
|
props.setDrawingChanged(false);
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* @property {{ x1: number, y1: number, x2: number, y2: number, z1: number, z2: number }} [bounds]
|
|
11
11
|
* @property {boolean} [filled]
|
|
12
12
|
*/
|
|
13
|
+
export function isEraserActive(nv: any): any;
|
|
13
14
|
export function isFreehandPenActive(nv: any): any;
|
|
14
15
|
export function shouldDeferFreehandCommit(nv: any): any;
|
|
15
16
|
export function redrawPolylineDraft(nv: any, draft: any): void;
|
|
@@ -32,11 +32,17 @@ import { NI_PEN_TYPE } from "./niivuePenType";
|
|
|
32
32
|
* @property {{ x1: number, y1: number, x2: number, y2: number, z1: number, z2: number }} [bounds]
|
|
33
33
|
* @property {boolean} [filled]
|
|
34
34
|
*/
|
|
35
|
+
export function isEraserActive(nv) {
|
|
36
|
+
return (nv.opts.drawingEnabled &&
|
|
37
|
+
nv.opts.penType === NI_PEN_TYPE.PEN &&
|
|
38
|
+
nv.opts.penValue === 0);
|
|
39
|
+
}
|
|
35
40
|
export function isFreehandPenActive(nv) {
|
|
36
41
|
return (nv.opts.isFilledPen &&
|
|
37
42
|
nv.opts.drawingEnabled &&
|
|
38
43
|
nv.opts.penType === NI_PEN_TYPE.PEN &&
|
|
39
|
-
!nv.opts.polylinePenMode
|
|
44
|
+
!nv.opts.polylinePenMode &&
|
|
45
|
+
nv.opts.penValue > 0);
|
|
40
46
|
}
|
|
41
47
|
export function shouldDeferFreehandCommit(nv) {
|
|
42
48
|
return !!nv.opts.deferFreehandCommit && isFreehandPenActive(nv);
|
|
@@ -12,7 +12,8 @@ var CLICK_DRAG_PX = 5;
|
|
|
12
12
|
export function isPolylinePenActive(nv) {
|
|
13
13
|
return (nv.opts.polylinePenMode &&
|
|
14
14
|
nv.opts.drawingEnabled &&
|
|
15
|
-
nv.opts.penType === NI_PEN_TYPE.PEN
|
|
15
|
+
nv.opts.penType === NI_PEN_TYPE.PEN &&
|
|
16
|
+
nv.opts.penValue > 0);
|
|
16
17
|
}
|
|
17
18
|
export function isClickWithoutDrag(uiData, thresholdPx) {
|
|
18
19
|
if (thresholdPx === void 0) { thresholdPx = CLICK_DRAG_PX; }
|