cloudmr-ux 4.5.6 → 4.5.8

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.
@@ -565,13 +565,37 @@ 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 penValue = raw;
571
- nv.setPenValue(penValue & 7, penValue > 0);
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.deferFreehandCommit = false;
580
+ nv.opts.deferShapeCommit = false;
581
+ nv.opts.polylinePenMode = false;
582
+ (_a = nv.cloudMrResetPolyline) === null || _a === void 0 ? void 0 : _a.call(nv);
583
+ if (penDraftRef.current) {
584
+ cancelPenDraft(nv, penDraftRef.current);
585
+ setPenDraft(null);
586
+ penDraftRef.current = null;
587
+ nv._cloudMrPenDraftActive = false;
588
+ setPolylineVertexCount(0);
589
+ }
590
+ if (shapeDraftRef.current) {
591
+ cancelShapeDraft();
592
+ }
593
+ }
594
+ else if (drawShapeToolRef.current === "pen") {
595
+ nv.opts.deferFreehandCommit = penDrawModeRef.current === "freehand";
596
+ nv.opts.polylinePenMode = penDrawModeRef.current === "polyline";
597
+ nv.opts.isFilledPen = penDrawModeRef.current === "freehand";
598
+ }
575
599
  }
576
600
  function nvUpdateDrawOpacity(a) {
577
601
  setDrawOpacity(a);
@@ -122,10 +122,12 @@ export function MroDrawToolkit(props) {
122
122
  }
123
123
  }
124
124
  function clickEraser() {
125
+ var _a;
125
126
  if (expandedOption === "e") {
126
127
  setExpandedOption("n");
127
128
  }
128
129
  else {
130
+ (_a = props.onExitDrawMode) === null || _a === void 0 ? void 0 : _a.call(props);
129
131
  props.updateDrawPen({ target: { value: 8 } });
130
132
  setExpandedOption("e");
131
133
  }
@@ -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; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudmr-ux",
3
- "version": "4.5.6",
3
+ "version": "4.5.8",
4
4
  "author": "erosmontin@gmail.com",
5
5
  "license": "MIT",
6
6
  "repository": "erosmontin/cloudmr-ux",