@cornerstonejs/tools 4.20.4 → 4.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,6 +16,10 @@ export type CrosshairsAnnotation = Annotation & {
16
16
  };
17
17
  declare class CrosshairsTool extends AnnotationTool {
18
18
  static toolName: any;
19
+ static minimalModeExamples: Map<string, {
20
+ enabled: boolean;
21
+ lineLengthInPx: number;
22
+ }>;
19
23
  toolCenter: Types.Point3;
20
24
  _getReferenceLineColor?: (viewportId: string) => string;
21
25
  _getReferenceLineControllable?: (viewportId: string) => boolean;
@@ -34,6 +34,11 @@ const OPERATION = {
34
34
  SLAB: 3,
35
35
  };
36
36
  class CrosshairsTool extends AnnotationTool {
37
+ static { this.minimalModeExamples = new Map([
38
+ ['Default', { enabled: false, lineLengthInPx: 40 }],
39
+ ['Minimal 40px', { enabled: true, lineLengthInPx: 40 }],
40
+ ['Minimal 80px', { enabled: true, lineLengthInPx: 80 }],
41
+ ]); }
37
42
  constructor(toolProps = {}, defaultToolProps = {
38
43
  supportedInteractionTypes: ['Mouse'],
39
44
  configuration: {
@@ -52,6 +57,10 @@ class CrosshairsTool extends AnnotationTool {
52
57
  enableHDPIHandles: false,
53
58
  referenceLinesCenterGapRadius: 20,
54
59
  referenceLinesCenterGapRatio: null,
60
+ minimal: {
61
+ enabled: false,
62
+ lineLengthInPx: 40,
63
+ },
55
64
  filterActorUIDsToSetSlabThickness: [],
56
65
  slabThicknessBlendMode: Enums.BlendModes.MAXIMUM_INTENSITY_BLEND,
57
66
  centerPoint: {
@@ -380,15 +389,15 @@ class CrosshairsTool extends AnnotationTool {
380
389
  vec2.normalize(canvasUnitVectorFromCenter, canvasUnitVectorFromCenter);
381
390
  const canvasVectorFromCenterLong = vec2.create();
382
391
  vec2.scale(canvasVectorFromCenterLong, canvasUnitVectorFromCenter, canvasDiagonalLength * 100);
383
- const canvasVectorFromCenterMid = vec2.create();
384
- vec2.scale(canvasVectorFromCenterMid, canvasUnitVectorFromCenter, canvasMinDimensionLength * 0.4);
385
392
  const canvasVectorFromCenterShort = vec2.create();
386
393
  vec2.scale(canvasVectorFromCenterShort, canvasUnitVectorFromCenter, canvasMinDimensionLength * 0.2);
387
394
  const canvasVectorFromCenterStart = vec2.create();
388
395
  const mobileConfig = this.configuration.mobile;
389
- const { referenceLinesCenterGapRatio } = mobileConfig?.enabled
396
+ const activeConfiguration = mobileConfig?.enabled
390
397
  ? mobileConfig
391
398
  : this.configuration;
399
+ const { referenceLinesCenterGapRatio } = activeConfiguration;
400
+ const minimalCrosshairConfig = getMinimalCrosshairConfig(this.configuration);
392
401
  const centerGap = referenceLinesCenterGapRatio > 0
393
402
  ? canvasMinDimensionLength * referenceLinesCenterGapRatio
394
403
  : this.configuration.referenceLinesCenterGapRadius;
@@ -407,10 +416,18 @@ class CrosshairsTool extends AnnotationTool {
407
416
  vec2.subtract(refLinePointFour, refLinesCenter, canvasVectorFromCenterLong);
408
417
  liangBarksyClip(refLinePointOne, refLinePointTwo, canvasBox);
409
418
  liangBarksyClip(refLinePointThree, refLinePointFour, canvasBox);
410
- const rotHandleOne = vec2.create();
411
- vec2.subtract(rotHandleOne, crosshairCenterCanvas, canvasVectorFromCenterMid);
412
- const rotHandleTwo = vec2.create();
413
- vec2.add(rotHandleTwo, crosshairCenterCanvas, canvasVectorFromCenterMid);
419
+ if (minimalCrosshairConfig.enabled) {
420
+ const minimalCanvasVectorFromCenterLong = vec2.create();
421
+ vec2.scale(minimalCanvasVectorFromCenterLong, canvasUnitVectorFromCenter, minimalCrosshairConfig.lineLengthInPx);
422
+ vec2.add(refLinePointOne, refLinesCenter, canvasVectorFromCenterStart);
423
+ vec2.add(refLinePointTwo, refLinePointOne, minimalCanvasVectorFromCenterLong);
424
+ vec2.subtract(refLinePointThree, refLinesCenter, canvasVectorFromCenterStart);
425
+ vec2.subtract(refLinePointFour, refLinePointThree, minimalCanvasVectorFromCenterLong);
426
+ liangBarksyClip(refLinePointOne, refLinePointTwo, canvasBox);
427
+ liangBarksyClip(refLinePointThree, refLinePointFour, canvasBox);
428
+ }
429
+ const rotHandleOne = getSegmentMidpoint(refLinePointOne, refLinePointTwo);
430
+ const rotHandleTwo = getSegmentMidpoint(refLinePointThree, refLinePointFour);
414
431
  let stHandlesCenterCanvas = vec2.clone(crosshairCenterCanvas);
415
432
  if (!otherViewportDraggableRotatable &&
416
433
  otherViewportSlabThicknessControlsOn) {
@@ -490,12 +507,15 @@ class CrosshairsTool extends AnnotationTool {
490
507
  const color = viewportColor !== undefined ? viewportColor : 'rgb(200, 200, 200)';
491
508
  referenceLines.forEach((line, lineIndex) => {
492
509
  const otherViewport = line[0];
510
+ const minimalCrosshairConfig = getMinimalCrosshairConfig(this.configuration);
493
511
  const viewportColor = this._getReferenceLineColor(otherViewport.id);
494
512
  const viewportControllable = this._getReferenceLineControllable(otherViewport.id);
495
- const viewportDraggableRotatable = this._getReferenceLineDraggableRotatable(otherViewport.id) ||
496
- this.configuration.mobile?.enabled;
497
- const viewportSlabThicknessControlsOn = this._getReferenceLineSlabThicknessControlsOn(otherViewport.id) ||
498
- this.configuration.mobile?.enabled;
513
+ const viewportDraggableRotatable = !minimalCrosshairConfig.enabled &&
514
+ (this._getReferenceLineDraggableRotatable(otherViewport.id) ||
515
+ this.configuration.mobile?.enabled);
516
+ const viewportSlabThicknessControlsOn = !minimalCrosshairConfig.enabled &&
517
+ (this._getReferenceLineSlabThicknessControlsOn(otherViewport.id) ||
518
+ this.configuration.mobile?.enabled);
499
519
  const selectedViewportId = data.activeViewportIds.find((id) => id === otherViewport.id);
500
520
  let color = viewportColor !== undefined ? viewportColor : 'rgb(200, 200, 200)';
501
521
  let lineWidth = 1;
@@ -506,7 +526,8 @@ class CrosshairsTool extends AnnotationTool {
506
526
  lineWidth = 2.5;
507
527
  }
508
528
  let lineUID = `${lineIndex}`;
509
- if (viewportControllable && viewportDraggableRotatable) {
529
+ if (viewportControllable &&
530
+ (viewportDraggableRotatable || minimalCrosshairConfig.enabled)) {
510
531
  lineUID = `${lineIndex}One`;
511
532
  drawLineSvg(svgDrawingHelper, annotationUID, lineUID, line[1], line[2], {
512
533
  color,
@@ -544,31 +565,33 @@ class CrosshairsTool extends AnnotationTool {
544
565
  newRtpoints.push(rotHandleWorldOne, rotHandleWorldTwo);
545
566
  const slabThicknessHandlesActive = data.handles.activeOperation === OPERATION.SLAB;
546
567
  const slabThicknessHandles = [line[11], line[12], line[13], line[14]];
547
- const slabThicknessHandleWorldOne = [
548
- viewport.canvasToWorld(line[11]),
549
- otherViewport,
550
- line[5],
551
- line[6],
552
- ];
553
- const slabThicknessHandleWorldTwo = [
554
- viewport.canvasToWorld(line[12]),
555
- otherViewport,
556
- line[5],
557
- line[6],
558
- ];
559
- const slabThicknessHandleWorldThree = [
560
- viewport.canvasToWorld(line[13]),
561
- otherViewport,
562
- line[7],
563
- line[8],
564
- ];
565
- const slabThicknessHandleWorldFour = [
566
- viewport.canvasToWorld(line[14]),
567
- otherViewport,
568
- line[7],
569
- line[8],
570
- ];
571
- newStpoints.push(slabThicknessHandleWorldOne, slabThicknessHandleWorldTwo, slabThicknessHandleWorldThree, slabThicknessHandleWorldFour);
568
+ if (!minimalCrosshairConfig.enabled) {
569
+ const slabThicknessHandleWorldOne = [
570
+ viewport.canvasToWorld(line[11]),
571
+ otherViewport,
572
+ line[5],
573
+ line[6],
574
+ ];
575
+ const slabThicknessHandleWorldTwo = [
576
+ viewport.canvasToWorld(line[12]),
577
+ otherViewport,
578
+ line[5],
579
+ line[6],
580
+ ];
581
+ const slabThicknessHandleWorldThree = [
582
+ viewport.canvasToWorld(line[13]),
583
+ otherViewport,
584
+ line[7],
585
+ line[8],
586
+ ];
587
+ const slabThicknessHandleWorldFour = [
588
+ viewport.canvasToWorld(line[14]),
589
+ otherViewport,
590
+ line[7],
591
+ line[8],
592
+ ];
593
+ newStpoints.push(slabThicknessHandleWorldOne, slabThicknessHandleWorldTwo, slabThicknessHandleWorldThree, slabThicknessHandleWorldFour);
594
+ }
572
595
  let handleRadius = this.configuration.handleRadius *
573
596
  (this.configuration.enableHDPIHandles ? window.devicePixelRatio : 1);
574
597
  let opacity = 1;
@@ -905,6 +928,7 @@ class CrosshairsTool extends AnnotationTool {
905
928
  emitEvent: true,
906
929
  updateViewportCameras: false,
907
930
  });
931
+ viewport.render();
908
932
  state.isInteractingWithTool = false;
909
933
  return true;
910
934
  };
@@ -1581,6 +1605,7 @@ class CrosshairsTool extends AnnotationTool {
1581
1605
  }
1582
1606
  }
1583
1607
  _getRotationHandleNearImagePoint(viewport, annotation, canvasCoords, proximity) {
1608
+ const minimalCrosshairConfig = getMinimalCrosshairConfig(this.configuration);
1584
1609
  const { data } = annotation;
1585
1610
  const { rotationPoints } = data.handles;
1586
1611
  for (let i = 0; i < rotationPoints.length; i++) {
@@ -1590,7 +1615,8 @@ class CrosshairsTool extends AnnotationTool {
1590
1615
  if (!viewportControllable) {
1591
1616
  continue;
1592
1617
  }
1593
- const viewportDraggableRotatable = this._getReferenceLineDraggableRotatable(otherViewport.id);
1618
+ const viewportDraggableRotatable = !minimalCrosshairConfig.enabled &&
1619
+ this._getReferenceLineDraggableRotatable(otherViewport.id);
1594
1620
  if (!viewportDraggableRotatable) {
1595
1621
  continue;
1596
1622
  }
@@ -1606,6 +1632,7 @@ class CrosshairsTool extends AnnotationTool {
1606
1632
  return null;
1607
1633
  }
1608
1634
  _getSlabThicknessHandleNearImagePoint(viewport, annotation, canvasCoords, proximity) {
1635
+ const minimalCrosshairConfig = getMinimalCrosshairConfig(this.configuration);
1609
1636
  const { data } = annotation;
1610
1637
  const { slabThicknessPoints } = data.handles;
1611
1638
  for (let i = 0; i < slabThicknessPoints.length; i++) {
@@ -1615,7 +1642,8 @@ class CrosshairsTool extends AnnotationTool {
1615
1642
  if (!viewportControllable) {
1616
1643
  continue;
1617
1644
  }
1618
- const viewportSlabThicknessControlsOn = this._getReferenceLineSlabThicknessControlsOn(otherViewport.id);
1645
+ const viewportSlabThicknessControlsOn = !minimalCrosshairConfig.enabled &&
1646
+ this._getReferenceLineSlabThicknessControlsOn(otherViewport.id);
1619
1647
  if (!viewportSlabThicknessControlsOn) {
1620
1648
  continue;
1621
1649
  }
@@ -1632,6 +1660,7 @@ class CrosshairsTool extends AnnotationTool {
1632
1660
  return null;
1633
1661
  }
1634
1662
  _pointNearTool(element, annotation, canvasCoords, proximity) {
1663
+ const minimalCrosshairConfig = getMinimalCrosshairConfig(this.configuration);
1635
1664
  const enabledElement = getEnabledElement(element);
1636
1665
  const { viewport } = enabledElement;
1637
1666
  const { clientWidth, clientHeight } = viewport.canvas;
@@ -1644,7 +1673,8 @@ class CrosshairsTool extends AnnotationTool {
1644
1673
  const otherViewport = rotationPoints[i][1];
1645
1674
  const viewportControllable = this._getReferenceLineControllable(otherViewport.id);
1646
1675
  const viewportDraggableRotatable = this._getReferenceLineDraggableRotatable(otherViewport.id);
1647
- if (!viewportControllable || !viewportDraggableRotatable) {
1676
+ if (!viewportControllable ||
1677
+ (!viewportDraggableRotatable && !minimalCrosshairConfig.enabled)) {
1648
1678
  continue;
1649
1679
  }
1650
1680
  const lineSegment1 = {
@@ -1681,7 +1711,8 @@ class CrosshairsTool extends AnnotationTool {
1681
1711
  continue;
1682
1712
  }
1683
1713
  const viewportControllable = this._getReferenceLineControllable(otherViewport.id);
1684
- const viewportSlabThicknessControlsOn = this._getReferenceLineSlabThicknessControlsOn(otherViewport.id);
1714
+ const viewportSlabThicknessControlsOn = !minimalCrosshairConfig.enabled &&
1715
+ this._getReferenceLineSlabThicknessControlsOn(otherViewport.id);
1685
1716
  if (!viewportControllable || !viewportSlabThicknessControlsOn) {
1686
1717
  continue;
1687
1718
  }
@@ -1734,5 +1765,28 @@ class CrosshairsTool extends AnnotationTool {
1734
1765
  return data.handles.activeOperation === OPERATION.DRAG ? true : false;
1735
1766
  }
1736
1767
  }
1768
+ function getMinimalCrosshairConfig(configuration) {
1769
+ const minimal = configuration?.minimal;
1770
+ if (!minimal?.enabled) {
1771
+ return {
1772
+ enabled: false,
1773
+ lineLengthInPx: 0,
1774
+ };
1775
+ }
1776
+ const lineLengthInPx = typeof minimal.lineLengthInPx === 'number' &&
1777
+ Number.isFinite(minimal.lineLengthInPx)
1778
+ ? minimal.lineLengthInPx
1779
+ : 40;
1780
+ return {
1781
+ enabled: true,
1782
+ lineLengthInPx: Math.max(0, lineLengthInPx),
1783
+ };
1784
+ }
1785
+ function getSegmentMidpoint(start, end) {
1786
+ const midpoint = vec2.create();
1787
+ vec2.add(midpoint, start, end);
1788
+ vec2.scale(midpoint, midpoint, 0.5);
1789
+ return midpoint;
1790
+ }
1737
1791
  CrosshairsTool.toolName = 'Crosshairs';
1738
1792
  export default CrosshairsTool;
@@ -1 +1 @@
1
- export declare const version = "4.20.4";
1
+ export declare const version = "4.21.0";
@@ -1 +1 @@
1
- export const version = '4.20.4';
1
+ export const version = '4.21.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "4.20.4",
3
+ "version": "4.21.0",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "types": "./dist/esm/index.d.ts",
6
6
  "module": "./dist/esm/index.js",
@@ -108,7 +108,7 @@
108
108
  "canvas": "3.2.0"
109
109
  },
110
110
  "peerDependencies": {
111
- "@cornerstonejs/core": "4.20.4",
111
+ "@cornerstonejs/core": "4.21.0",
112
112
  "@kitware/vtk.js": "34.15.1",
113
113
  "@types/d3-array": "3.2.1",
114
114
  "@types/d3-interpolate": "3.0.4",
@@ -127,5 +127,5 @@
127
127
  "type": "individual",
128
128
  "url": "https://ohif.org/donate"
129
129
  },
130
- "gitHead": "c2593e908c3e1adf26b7df299acded84c2e225d8"
130
+ "gitHead": "222b6625385017ae610bff2702a01262d441969a"
131
131
  }