@cornerstonejs/tools 4.1.4 → 4.2.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.
@@ -1,8 +1,11 @@
1
1
  import { state } from '../../store/state';
2
2
  import { ToolModes } from '../../enums';
3
3
  import filterToolsWithAnnotationsForElement from '../../store/filterToolsWithAnnotationsForElement';
4
+ import { getToolGroupForViewport } from '../../store/ToolGroupManager';
4
5
  import getToolsWithModesForMouseEvent from '../shared/getToolsWithModesForMouseEvent';
5
6
  import triggerAnnotationRender from '../../utilities/triggerAnnotationRender';
7
+ import { setCursorForElement } from '../../cursors';
8
+ import { getStyleProperty } from '../../stateManagement/annotation/config/helpers';
6
9
  const { Active, Passive } = ToolModes;
7
10
  export default function mouseMove(evt) {
8
11
  if (state.isInteractingWithTool || state.isMultiPartToolActive) {
@@ -13,17 +16,36 @@ export default function mouseMove(evt) {
13
16
  Passive,
14
17
  ]);
15
18
  const eventDetail = evt.detail;
16
- const { element } = eventDetail;
19
+ const { element, currentPoints, renderingEngineId, viewportId } = eventDetail;
17
20
  const toolsWithAnnotations = filterToolsWithAnnotationsForElement(element, activeAndPassiveTools);
18
21
  const toolsWithoutAnnotations = activeAndPassiveTools.filter((tool) => {
19
22
  const doesNotHaveAnnotations = !toolsWithAnnotations.some((toolAndAnnotation) => toolAndAnnotation.tool.getToolName() === tool.getToolName());
20
23
  return doesNotHaveAnnotations;
21
24
  });
22
25
  let annotationsNeedToBeRedrawn = false;
26
+ let showCrosshairsCursor = false;
23
27
  for (const { tool, annotations } of toolsWithAnnotations) {
24
28
  if (typeof tool.mouseMoveCallback === 'function') {
25
29
  annotationsNeedToBeRedrawn =
26
30
  tool.mouseMoveCallback(evt, annotations) || annotationsNeedToBeRedrawn;
31
+ for (const annotation of annotations) {
32
+ showCrosshairsCursor =
33
+ !!tool.getHandleNearImagePoint(element, annotation, currentPoints.canvas, 6) || showCrosshairsCursor;
34
+ }
35
+ }
36
+ }
37
+ const showGrabCursorEnabled = Boolean(getStyleProperty('showGrabCursor', {}));
38
+ if (showCrosshairsCursor && showGrabCursorEnabled) {
39
+ setCursorForElement(element, 'move');
40
+ }
41
+ else {
42
+ const toolGroup = getToolGroupForViewport(viewportId, renderingEngineId);
43
+ const activeTool = toolGroup?.getActivePrimaryMouseButtonTool();
44
+ if (activeTool) {
45
+ setCursorForElement(element, activeTool);
46
+ }
47
+ else {
48
+ setCursorForElement(element, 'default');
27
49
  }
28
50
  }
29
51
  toolsWithoutAnnotations.forEach((tool) => {
@@ -13,6 +13,7 @@ import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnota
13
13
  import { triggerAnnotationCompleted, triggerAnnotationModified, } from '../../stateManagement/annotation/helpers/state';
14
14
  import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCursor';
15
15
  import { isAnnotationVisible } from '../../stateManagement/annotation/annotationVisibility';
16
+ import { getStyleProperty } from '../../stateManagement/annotation/config/helpers';
16
17
  class AngleTool extends AnnotationTool {
17
18
  static { this.toolName = 'Angle'; }
18
19
  constructor(toolProps = {}, defaultToolProps = {
@@ -295,7 +296,8 @@ class AngleTool extends AnnotationTool {
295
296
  if (!isAnnotationVisible(annotationUID)) {
296
297
  continue;
297
298
  }
298
- if (activeHandleCanvasCoords) {
299
+ const showHandlesAlways = Boolean(getStyleProperty('showHandlesAlways', {}));
300
+ if (activeHandleCanvasCoords || showHandlesAlways) {
299
301
  const handleGroupUID = '0';
300
302
  drawHandlesSvg(svgDrawingHelper, annotationUID, handleGroupUID, canvasCoordinates, {
301
303
  color,
@@ -12,6 +12,7 @@ import { triggerAnnotationCompleted, triggerAnnotationModified, } from '../../st
12
12
  import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCursor';
13
13
  import { isAnnotationVisible } from '../../stateManagement/annotation/annotationVisibility';
14
14
  import { setAnnotationLabel } from '../../utilities';
15
+ import { getStyleProperty } from '../../stateManagement/annotation/config/helpers';
15
16
  class ArrowAnnotateTool extends AnnotationTool {
16
17
  static { this.toolName = 'ArrowAnnotate'; }
17
18
  constructor(toolProps = {}, defaultToolProps = {
@@ -296,7 +297,8 @@ class ArrowAnnotateTool extends AnnotationTool {
296
297
  if (!isAnnotationVisible(annotationUID)) {
297
298
  continue;
298
299
  }
299
- if (activeHandleCanvasCoords) {
300
+ const showHandlesAlways = Boolean(getStyleProperty('showHandlesAlways', {}));
301
+ if (activeHandleCanvasCoords || showHandlesAlways) {
300
302
  const handleGroupUID = '0';
301
303
  drawHandlesSvg(svgDrawingHelper, annotationUID, handleGroupUID, canvasCoordinates, {
302
304
  color,
@@ -15,6 +15,7 @@ import * as lineSegment from '../../utilities/math/line';
15
15
  import { getTextBoxCoordsCanvas } from '../../utilities/drawing';
16
16
  import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCursor';
17
17
  import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
18
+ import { getStyleProperty } from '../../stateManagement/annotation/config/helpers';
18
19
  const { transformWorldToIndex } = csUtils;
19
20
  class BidirectionalTool extends AnnotationTool {
20
21
  static { this.toolName = 'Bidirectional'; }
@@ -514,9 +515,10 @@ class BidirectionalTool extends AnnotationTool {
514
515
  activeHandleIndex !== null) {
515
516
  activeHandleCanvasCoords = [canvasCoordinates[activeHandleIndex]];
516
517
  }
517
- if (activeHandleCanvasCoords) {
518
+ const showHandlesAlways = Boolean(getStyleProperty('showHandlesAlways', {}));
519
+ if (activeHandleCanvasCoords || showHandlesAlways) {
518
520
  const handleGroupUID = '0';
519
- drawHandlesSvg(svgDrawingHelper, annotationUID, handleGroupUID, activeHandleCanvasCoords, {
521
+ drawHandlesSvg(svgDrawingHelper, annotationUID, handleGroupUID, showHandlesAlways ? canvasCoordinates : activeHandleCanvasCoords, {
520
522
  color,
521
523
  });
522
524
  }
@@ -20,6 +20,7 @@ import { getCanvasCircleCorners, getCanvasCircleRadius, } from '../../utilities/
20
20
  import { pointInEllipse } from '../../utilities/math/ellipse';
21
21
  import { BasicStatsCalculator } from '../../utilities/math/basic';
22
22
  import { vec2, vec3 } from 'gl-matrix';
23
+ import { getStyleProperty } from '../../stateManagement/annotation/config/helpers';
23
24
  const { transformWorldToIndex } = csUtils;
24
25
  class CircleROITool extends AnnotationTool {
25
26
  static { this.toolName = 'CircleROI'; }
@@ -409,9 +410,10 @@ class CircleROITool extends AnnotationTool {
409
410
  activeHandleCanvasCoords = canvasCoordinates;
410
411
  }
411
412
  }
412
- if (activeHandleCanvasCoords) {
413
+ const showHandlesAlways = Boolean(getStyleProperty('showHandlesAlways', {}));
414
+ if (activeHandleCanvasCoords || showHandlesAlways) {
413
415
  const handleGroupUID = '0';
414
- drawHandlesSvg(svgDrawingHelper, annotationUID, handleGroupUID, activeHandleCanvasCoords, {
416
+ drawHandlesSvg(svgDrawingHelper, annotationUID, handleGroupUID, showHandlesAlways ? canvasCoordinates : activeHandleCanvasCoords, {
415
417
  color,
416
418
  });
417
419
  }
@@ -16,6 +16,7 @@ import { getTextBoxCoordsCanvas } from '../../utilities/drawing';
16
16
  import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
17
17
  import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCursor';
18
18
  import { isAnnotationVisible } from '../../stateManagement/annotation/annotationVisibility';
19
+ import { getStyleProperty } from '../../stateManagement/annotation/config/helpers';
19
20
  class CobbAngleTool extends AnnotationTool {
20
21
  static { this.toolName = 'CobbAngle'; }
21
22
  constructor(toolProps = {}, defaultToolProps = {
@@ -350,7 +351,8 @@ class CobbAngleTool extends AnnotationTool {
350
351
  if (!isAnnotationVisible(annotationUID)) {
351
352
  continue;
352
353
  }
353
- if (activeHandleCanvasCoords) {
354
+ const showHandlesAlways = Boolean(getStyleProperty('showHandlesAlways', {}));
355
+ if (activeHandleCanvasCoords || showHandlesAlways) {
354
356
  const handleGroupUID = '0';
355
357
  drawHandlesSvg(svgDrawingHelper, annotationUID, handleGroupUID, canvasCoordinates, {
356
358
  color,
@@ -19,6 +19,7 @@ import { getPixelValueUnits } from '../../utilities/getPixelValueUnits';
19
19
  import { isViewportPreScaled } from '../../utilities/viewport/isViewportPreScaled';
20
20
  import { BasicStatsCalculator } from '../../utilities/math/basic';
21
21
  import { vec2 } from 'gl-matrix';
22
+ import { getStyleProperty } from '../../stateManagement/annotation/config/helpers';
22
23
  const { transformWorldToIndex } = csUtils;
23
24
  class EllipticalROITool extends AnnotationTool {
24
25
  static { this.toolName = 'EllipticalROI'; }
@@ -444,9 +445,10 @@ class EllipticalROITool extends AnnotationTool {
444
445
  activeHandleIndex !== null) {
445
446
  activeHandleCanvasCoords = [canvasCoordinates[activeHandleIndex]];
446
447
  }
447
- if (activeHandleCanvasCoords) {
448
+ const showHandlesAlways = Boolean(getStyleProperty('showHandlesAlways', {}));
449
+ if (activeHandleCanvasCoords || showHandlesAlways) {
448
450
  const handleGroupUID = '0';
449
- drawHandlesSvg(svgDrawingHelper, annotationUID, handleGroupUID, activeHandleCanvasCoords, {
451
+ drawHandlesSvg(svgDrawingHelper, annotationUID, handleGroupUID, showHandlesAlways ? canvasCoordinates : activeHandleCanvasCoords, {
450
452
  color,
451
453
  });
452
454
  }
@@ -14,6 +14,7 @@ import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters'
14
14
  import { getTextBoxCoordsCanvas } from '../../utilities/drawing';
15
15
  import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
16
16
  import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCursor';
17
+ import { getStyleProperty } from '../../stateManagement/annotation/config/helpers';
17
18
  const { transformWorldToIndex } = csUtils;
18
19
  class HeightTool extends AnnotationTool {
19
20
  static { this.toolName = 'Height'; }
@@ -258,7 +259,8 @@ class HeightTool extends AnnotationTool {
258
259
  activeHandleIndex !== null) {
259
260
  activeHandleCanvasCoords = [canvasCoordinates[activeHandleIndex]];
260
261
  }
261
- if (activeHandleCanvasCoords) {
262
+ const showHandlesAlways = Boolean(getStyleProperty('showHandlesAlways', {}));
263
+ if (activeHandleCanvasCoords || showHandlesAlways) {
262
264
  const handleGroupUID = '0';
263
265
  drawHandlesSvg(svgDrawingHelper, annotationUID, handleGroupUID, canvasCoordinates, {
264
266
  color,
@@ -14,6 +14,7 @@ import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters'
14
14
  import { getTextBoxCoordsCanvas } from '../../utilities/drawing';
15
15
  import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
16
16
  import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCursor';
17
+ import { getStyleProperty } from '../../stateManagement/annotation/config/helpers';
17
18
  const { transformWorldToIndex } = csUtils;
18
19
  class LengthTool extends AnnotationTool {
19
20
  static { this.toolName = 'Length'; }
@@ -271,7 +272,8 @@ class LengthTool extends AnnotationTool {
271
272
  activeHandleIndex !== null) {
272
273
  activeHandleCanvasCoords = [canvasCoordinates[activeHandleIndex]];
273
274
  }
274
- if (activeHandleCanvasCoords) {
275
+ const showHandlesAlways = Boolean(getStyleProperty('showHandlesAlways', {}));
276
+ if (activeHandleCanvasCoords || showHandlesAlways) {
275
277
  const handleGroupUID = '0';
276
278
  drawHandlesSvg(svgDrawingHelper, annotationUID, handleGroupUID, canvasCoordinates, {
277
279
  color,
@@ -18,6 +18,7 @@ import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnota
18
18
  import { getPixelValueUnits } from '../../utilities/getPixelValueUnits';
19
19
  import { isViewportPreScaled } from '../../utilities/viewport/isViewportPreScaled';
20
20
  import { BasicStatsCalculator } from '../../utilities/math/basic';
21
+ import { getStyleProperty } from '../../stateManagement/annotation/config/helpers';
21
22
  const { transformWorldToIndex } = csUtils;
22
23
  class RectangleROITool extends AnnotationTool {
23
24
  static { this.toolName = 'RectangleROI'; }
@@ -380,9 +381,10 @@ class RectangleROITool extends AnnotationTool {
380
381
  activeHandleIndex !== undefined) {
381
382
  activeHandleCanvasCoords = [canvasCoordinates[activeHandleIndex]];
382
383
  }
383
- if (activeHandleCanvasCoords) {
384
+ const showHandlesAlways = Boolean(getStyleProperty('showHandlesAlways', {}));
385
+ if (activeHandleCanvasCoords || showHandlesAlways) {
384
386
  const handleGroupUID = '0';
385
- drawHandlesSvg(svgDrawingHelper, annotationUID, handleGroupUID, activeHandleCanvasCoords, {
387
+ drawHandlesSvg(svgDrawingHelper, annotationUID, handleGroupUID, showHandlesAlways ? canvasCoordinates : activeHandleCanvasCoords, {
386
388
  color,
387
389
  });
388
390
  }
@@ -1,6 +1,6 @@
1
1
  type Modes = '' | 'Active' | 'Passive' | 'Enabled';
2
2
  type States = '' | 'Highlighted' | 'Selected' | 'Locked' | 'AutoGenerated';
3
- type Properties = 'color' | 'colorAutoGenerated' | 'lineWidth' | 'lineWidthAutoGenerated' | 'lineDash' | 'textBoxFontFamily' | 'textBoxFontSize' | 'textBoxColor' | 'textBoxBackground' | 'textBoxLinkLineWidth' | 'textBoxLinkLineDash' | 'locked' | 'fillColor' | 'fillOpacity' | 'textbox' | 'shadow' | 'visibility' | 'markerSize' | 'angleArcLineDash' | 'pointerStrokeWidth';
3
+ type Properties = 'color' | 'colorAutoGenerated' | 'lineWidth' | 'lineWidthAutoGenerated' | 'lineDash' | 'textBoxFontFamily' | 'textBoxFontSize' | 'textBoxColor' | 'textBoxBackground' | 'textBoxLinkLineWidth' | 'textBoxLinkLineDash' | 'locked' | 'fillColor' | 'fillOpacity' | 'textbox' | 'shadow' | 'visibility' | 'markerSize' | 'angleArcLineDash' | 'pointerStrokeWidth' | 'showHandlesAlways' | 'showGrabCursor';
4
4
  export type AnnotationStyle = {
5
5
  [key in `${Properties}${States}${Modes}`]?: string | number | boolean | Record<string, unknown>;
6
6
  };
@@ -1 +1 @@
1
- export declare const version = "4.1.4";
1
+ export declare const version = "4.2.1";
@@ -1 +1 @@
1
- export const version = '4.1.4';
1
+ export const version = '4.2.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "4.1.4",
3
+ "version": "4.2.1",
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.1.0"
109
109
  },
110
110
  "peerDependencies": {
111
- "@cornerstonejs/core": "^4.1.4",
111
+ "@cornerstonejs/core": "^4.2.1",
112
112
  "@kitware/vtk.js": "32.12.1",
113
113
  "@types/d3-array": "^3.0.4",
114
114
  "@types/d3-interpolate": "^3.0.1",
@@ -127,5 +127,5 @@
127
127
  "type": "individual",
128
128
  "url": "https://ohif.org/donate"
129
129
  },
130
- "gitHead": "abe7ccc901f1dd79ee7604eddca77c74f58b5784"
130
+ "gitHead": "086ca005e5f4911e76dcc3e9ec4389822746b5c8"
131
131
  }