@cornerstonejs/tools 0.58.0 → 0.59.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "0.58.0",
3
+ "version": "0.59.1",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "main": "dist/umd/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -52,5 +52,5 @@
52
52
  "type": "individual",
53
53
  "url": "https://ohif.org/donate"
54
54
  },
55
- "gitHead": "9a2711ca032949079e7b96ba332b6e01b3316da8"
55
+ "gitHead": "9afbe1a42ec510313a29c0c5b6f953bb26813079"
56
56
  }
@@ -12,17 +12,19 @@ function drawHandles(
12
12
  handlePoints: Array<Types.Point2>,
13
13
  options = {}
14
14
  ): void {
15
- const { color, handleRadius, width, lineWidth, fill, type } = Object.assign(
16
- {
17
- color: 'dodgerblue',
18
- handleRadius: '6',
19
- width: '2',
20
- lineWidth: undefined,
21
- fill: 'transparent',
22
- type: 'circle',
23
- },
24
- options
25
- );
15
+ const { color, handleRadius, width, lineWidth, fill, type, opacity } =
16
+ Object.assign(
17
+ {
18
+ color: 'dodgerblue',
19
+ handleRadius: '6',
20
+ width: '2',
21
+ lineWidth: undefined,
22
+ fill: 'transparent',
23
+ type: 'circle',
24
+ opacity: 1,
25
+ },
26
+ options
27
+ );
26
28
 
27
29
  // for supporting both lineWidth and width options
28
30
  const strokeWidth = lineWidth || width;
@@ -47,6 +49,7 @@ function drawHandles(
47
49
  stroke: color,
48
50
  fill,
49
51
  'stroke-width': strokeWidth,
52
+ opacity: opacity,
50
53
  };
51
54
  } else if (type === 'rect') {
52
55
  const handleRadiusFloat = parseFloat(handleRadius);
@@ -63,6 +66,7 @@ function drawHandles(
63
66
  fill,
64
67
  'stroke-width': strokeWidth,
65
68
  rx: `${side * 0.1}`,
69
+ opacity: opacity,
66
70
  };
67
71
  } else {
68
72
  throw new Error(`Unsupported handle type: ${type}`);
@@ -22,6 +22,7 @@ import {
22
22
  getAnnotations,
23
23
  removeAnnotation,
24
24
  } from '../stateManagement/annotation/annotationState';
25
+
25
26
  import {
26
27
  drawCircle as drawCircleSvg,
27
28
  drawHandles as drawHandlesSvg,
@@ -61,6 +62,15 @@ interface ToolConfiguration {
61
62
  getReferenceLineDraggableRotatable?: (viewportId: string) => boolean;
62
63
  getReferenceLineSlabThicknessControlsOn?: (viewportId: string) => boolean;
63
64
  shadow?: boolean;
65
+ autopan?: {
66
+ enabled: boolean;
67
+ panSize: number;
68
+ };
69
+ mobile?: {
70
+ enabled: boolean;
71
+ opacity: number;
72
+ handleRadius: number;
73
+ };
64
74
  };
65
75
  }
66
76
 
@@ -113,11 +123,6 @@ const EPSILON = 1e-3;
113
123
  class CrosshairsTool extends AnnotationTool {
114
124
  static toolName;
115
125
 
116
- // define the stroke width for mobile/web screen
117
- private widthStrokeAnnotation = /Mobi|Android/i.test(navigator.userAgent)
118
- ? 2.5
119
- : 1;
120
-
121
126
  toolCenter: Types.Point3 = [0, 0, 0]; // NOTE: it is assumed that all the active/linked viewports share the same crosshair center.
122
127
  // This because the rotation operation rotates also all the other active/intersecting reference lines of the same angle
123
128
  _getReferenceLineColor?: (viewportId: string) => string;
@@ -152,6 +157,11 @@ class CrosshairsTool extends AnnotationTool {
152
157
  filterActorUIDsToSetSlabThickness: [],
153
158
  // blend mode for slabThickness modifications
154
159
  slabThicknessBlendMode: Enums.BlendModes.MAXIMUM_INTENSITY_BLEND,
160
+ mobile: {
161
+ enabled: false,
162
+ opacity: 0.8,
163
+ handleRadius: 9,
164
+ },
155
165
  },
156
166
  }
157
167
  ) {
@@ -476,7 +486,6 @@ class CrosshairsTool extends AnnotationTool {
476
486
  ): void => {
477
487
  const eventDetail = evt.detail;
478
488
  const { element } = eventDetail;
479
-
480
489
  annotation.highlighted = true;
481
490
 
482
491
  // NOTE: handle index or coordinates are not used when dragging.
@@ -523,7 +532,6 @@ class CrosshairsTool extends AnnotationTool {
523
532
  const eventDetail = evt.detail;
524
533
  const { element } = eventDetail;
525
534
  annotation.highlighted = true;
526
-
527
535
  this._activateModify(element);
528
536
 
529
537
  hideElementCursor(element);
@@ -1104,9 +1112,11 @@ class CrosshairsTool extends AnnotationTool {
1104
1112
  otherViewport.id
1105
1113
  );
1106
1114
  const viewportDraggableRotatable =
1107
- this._getReferenceLineDraggableRotatable(otherViewport.id);
1115
+ this._getReferenceLineDraggableRotatable(otherViewport.id) ||
1116
+ this.configuration.mobile?.enabled;
1108
1117
  const viewportSlabThicknessControlsOn =
1109
- this._getReferenceLineSlabThicknessControlsOn(otherViewport.id);
1118
+ this._getReferenceLineSlabThicknessControlsOn(otherViewport.id) ||
1119
+ this.configuration.mobile?.enabled;
1110
1120
  const selectedViewportId = data.activeViewportIds.find(
1111
1121
  (id) => id === otherViewport.id
1112
1122
  );
@@ -1114,7 +1124,7 @@ class CrosshairsTool extends AnnotationTool {
1114
1124
  let color =
1115
1125
  viewportColor !== undefined ? viewportColor : 'rgb(200, 200, 200)';
1116
1126
 
1117
- let lineWidth = this.widthStrokeAnnotation;
1127
+ let lineWidth = 1;
1118
1128
 
1119
1129
  const lineActive =
1120
1130
  data.handles.activeOperation !== null &&
@@ -1224,7 +1234,7 @@ class CrosshairsTool extends AnnotationTool {
1224
1234
  );
1225
1235
 
1226
1236
  if (
1227
- lineActive &&
1237
+ (lineActive || this.configuration.mobile?.enabled) &&
1228
1238
  !rotHandlesActive &&
1229
1239
  !slabThicknessHandlesActive &&
1230
1240
  viewportDraggableRotatable &&
@@ -1239,7 +1249,12 @@ class CrosshairsTool extends AnnotationTool {
1239
1249
  rotationHandles,
1240
1250
  {
1241
1251
  color,
1242
- handleRadius: 3,
1252
+ handleRadius: this.configuration.mobile?.enabled
1253
+ ? this.configuration.mobile?.handleRadius
1254
+ : 3,
1255
+ opacity: this.configuration.mobile?.enabled
1256
+ ? this.configuration.mobile?.opacity
1257
+ : 1,
1243
1258
  type: 'circle',
1244
1259
  }
1245
1260
  );
@@ -1251,7 +1266,12 @@ class CrosshairsTool extends AnnotationTool {
1251
1266
  slabThicknessHandles,
1252
1267
  {
1253
1268
  color,
1254
- handleRadius: 3,
1269
+ handleRadius: this.configuration.mobile?.enabled
1270
+ ? this.configuration.mobile?.handleRadius
1271
+ : 3,
1272
+ opacity: this.configuration.mobile?.enabled
1273
+ ? this.configuration.mobile?.opacity
1274
+ : 1,
1255
1275
  type: 'rect',
1256
1276
  }
1257
1277
  );
@@ -1270,7 +1290,12 @@ class CrosshairsTool extends AnnotationTool {
1270
1290
  rotationHandles,
1271
1291
  {
1272
1292
  color,
1273
- handleRadius: 3,
1293
+ handleRadius: this.configuration.mobile?.enabled
1294
+ ? this.configuration.mobile?.handleRadius
1295
+ : 3,
1296
+ opacity: this.configuration.mobile?.enabled
1297
+ ? this.configuration.mobile?.opacity
1298
+ : 1,
1274
1299
  type: 'circle',
1275
1300
  }
1276
1301
  );
@@ -1289,7 +1314,12 @@ class CrosshairsTool extends AnnotationTool {
1289
1314
  slabThicknessHandles,
1290
1315
  {
1291
1316
  color,
1292
- handleRadius: 3,
1317
+ handleRadius: this.configuration.mobile?.enabled
1318
+ ? this.configuration.mobile?.handleRadius
1319
+ : 3,
1320
+ opacity: this.configuration.mobile?.enabled
1321
+ ? this.configuration.mobile?.opacity
1322
+ : 1,
1293
1323
  type: 'rect',
1294
1324
  }
1295
1325
  );
@@ -1903,7 +1933,10 @@ class CrosshairsTool extends AnnotationTool {
1903
1933
  };
1904
1934
 
1905
1935
  _activateModify = (element) => {
1906
- state.isInteractingWithTool = true;
1936
+ // mobile sometimes has lingering interaction even when touchEnd triggers
1937
+ // this check allows for multiple handles to be active which doesn't affect
1938
+ // tool usage.
1939
+ state.isInteractingWithTool = !this.configuration.mobile?.enabled;
1907
1940
 
1908
1941
  element.addEventListener(Events.MOUSE_UP, this._endCallback);
1909
1942
  element.addEventListener(Events.MOUSE_DRAG, this._dragCallback);
@@ -410,7 +410,7 @@ function _needsTransferFunctionUpdate(
410
410
  renderFill,
411
411
  renderOutline,
412
412
  outlineWidth,
413
- segmentColor,
413
+ segmentColor: segmentColor.slice(), // Create a copy
414
414
  segmentsHidden: new Set(segmentsHidden), // Create a copy
415
415
  });
416
416