@cornerstonejs/tools 2.3.0 → 2.3.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.
@@ -17,6 +17,9 @@ declare class AngleTool extends AnnotationTool {
17
17
  isDrawing: boolean;
18
18
  isHandleOutsideImage: boolean;
19
19
  constructor(toolProps?: PublicToolProps, defaultToolProps?: ToolProps);
20
+ static hydrate: (viewportId: string, points: Types.Point3[], options?: {
21
+ annotationUID?: string;
22
+ }) => AngleAnnotation;
20
23
  addNewAnnotation: (evt: EventTypes.InteractionEventType) => AngleAnnotation;
21
24
  isPointNearTool: (element: HTMLDivElement, annotation: AngleAnnotation, canvasCoords: Types.Point2, proximity: number) => boolean;
22
25
  toolSelectedCallback: (evt: EventTypes.InteractionEventType, annotation: AngleAnnotation) => void;
@@ -1,5 +1,5 @@
1
1
  import { Events } from '../../enums';
2
- import { getEnabledElement, utilities as csUtils } from '@cornerstonejs/core';
2
+ import { getEnabledElement, utilities as csUtils, getEnabledElementByViewportId, } from '@cornerstonejs/core';
3
3
  import { AnnotationTool } from '../base';
4
4
  import throttle from '../../utilities/throttle';
5
5
  import { addAnnotation, getAnnotations, removeAnnotation, } from '../../stateManagement/annotation/annotationState';
@@ -377,6 +377,39 @@ class AngleTool extends AnnotationTool {
377
377
  };
378
378
  this._throttledCalculateCachedStats = throttle(this._calculateCachedStats, 100, { trailing: true });
379
379
  }
380
+ static { this.hydrate = (viewportId, points, options) => {
381
+ const enabledElement = getEnabledElementByViewportId(viewportId);
382
+ if (!enabledElement) {
383
+ return;
384
+ }
385
+ const { viewport } = enabledElement;
386
+ const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
387
+ const { viewPlaneNormal, viewUp } = viewport.getCamera();
388
+ const instance = new this();
389
+ const referencedImageId = instance.getReferencedImageId(viewport, points[0], viewPlaneNormal, viewUp);
390
+ const annotation = {
391
+ annotationUID: options?.annotationUID || csUtils.uuidv4(),
392
+ data: {
393
+ handles: {
394
+ points,
395
+ },
396
+ },
397
+ highlighted: false,
398
+ autoGenerated: false,
399
+ invalidated: false,
400
+ isLocked: false,
401
+ isVisible: true,
402
+ metadata: {
403
+ toolName: instance.getToolName(),
404
+ viewPlaneNormal,
405
+ FrameOfReferenceUID,
406
+ referencedImageId,
407
+ ...options,
408
+ },
409
+ };
410
+ addAnnotation(annotation, viewport.element);
411
+ triggerAnnotationRenderForViewportIds([viewport.id]);
412
+ }; }
380
413
  handleSelectedCallback(evt, annotation, handle) {
381
414
  const eventDetail = evt.detail;
382
415
  const { element } = eventDetail;
@@ -16,6 +16,9 @@ declare class ArrowAnnotateTool extends AnnotationTool {
16
16
  isDrawing: boolean;
17
17
  isHandleOutsideImage: boolean;
18
18
  constructor(toolProps?: PublicToolProps, defaultToolProps?: ToolProps);
19
+ static hydrate: (viewportId: string, points: Types.Point3[], text?: string, options?: {
20
+ annotationUID?: string;
21
+ }) => ArrowAnnotation;
19
22
  addNewAnnotation: (evt: EventTypes.InteractionEventType) => ArrowAnnotation;
20
23
  isPointNearTool: (element: HTMLDivElement, annotation: ArrowAnnotation, canvasCoords: Types.Point2, proximity: number) => boolean;
21
24
  toolSelectedCallback: (evt: EventTypes.InteractionEventType, annotation: ArrowAnnotation) => void;
@@ -1,5 +1,5 @@
1
1
  import { Events } from '../../enums';
2
- import { getEnabledElement, utilities as csUtils } from '@cornerstonejs/core';
2
+ import { getEnabledElement, utilities as csUtils, getEnabledElementByViewportId, } from '@cornerstonejs/core';
3
3
  import { AnnotationTool } from '../base';
4
4
  import { addAnnotation, getAnnotations, removeAnnotation, } from '../../stateManagement/annotation/annotationState';
5
5
  import { isAnnotationLocked } from '../../stateManagement/annotation/annotationLocking';
@@ -372,6 +372,40 @@ class ArrowAnnotateTool extends AnnotationTool {
372
372
  return renderStatus;
373
373
  };
374
374
  }
375
+ static { this.hydrate = (viewportId, points, text, options) => {
376
+ const enabledElement = getEnabledElementByViewportId(viewportId);
377
+ if (!enabledElement) {
378
+ return;
379
+ }
380
+ const { viewport } = enabledElement;
381
+ const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
382
+ const { viewPlaneNormal, viewUp } = viewport.getCamera();
383
+ const instance = new this();
384
+ const referencedImageId = instance.getReferencedImageId(viewport, points[0], viewPlaneNormal, viewUp);
385
+ const annotation = {
386
+ annotationUID: options?.annotationUID || csUtils.uuidv4(),
387
+ data: {
388
+ text: text || '',
389
+ handles: {
390
+ points,
391
+ },
392
+ },
393
+ highlighted: false,
394
+ autoGenerated: false,
395
+ invalidated: false,
396
+ isLocked: false,
397
+ isVisible: true,
398
+ metadata: {
399
+ toolName: instance.getToolName(),
400
+ viewPlaneNormal,
401
+ FrameOfReferenceUID,
402
+ referencedImageId,
403
+ ...options,
404
+ },
405
+ };
406
+ addAnnotation(annotation, viewport.element);
407
+ triggerAnnotationRenderForViewportIds([viewport.id]);
408
+ }; }
375
409
  handleSelectedCallback(evt, annotation, handle) {
376
410
  const eventDetail = evt.detail;
377
411
  const { element } = eventDetail;
@@ -20,6 +20,9 @@ declare class EllipticalROITool extends AnnotationTool {
20
20
  isDrawing: boolean;
21
21
  isHandleOutsideImage: boolean;
22
22
  constructor(toolProps?: PublicToolProps, defaultToolProps?: ToolProps);
23
+ static hydrate: (viewportId: string, points: Types.Point3[], options?: {
24
+ annotationUID?: string;
25
+ }) => EllipticalROIAnnotation;
23
26
  addNewAnnotation: (evt: EventTypes.InteractionEventType) => EllipticalROIAnnotation;
24
27
  isPointNearTool: (element: HTMLDivElement, annotation: EllipticalROIAnnotation, canvasCoords: Types.Point2, proximity: number) => boolean;
25
28
  toolSelectedCallback: (evt: EventTypes.InteractionEventType, annotation: EllipticalROIAnnotation) => void;
@@ -1,5 +1,5 @@
1
1
  import { AnnotationTool } from '../base';
2
- import { getEnabledElement, VolumeViewport, utilities as csUtils, } from '@cornerstonejs/core';
2
+ import { getEnabledElement, VolumeViewport, utilities as csUtils, getEnabledElementByViewportId, } from '@cornerstonejs/core';
3
3
  import { getCalibratedLengthUnitsAndScale } from '../../utilities/getCalibratedUnits';
4
4
  import throttle from '../../utilities/throttle';
5
5
  import { addAnnotation, getAnnotations, removeAnnotation, } from '../../stateManagement/annotation/annotationState';
@@ -626,6 +626,42 @@ class EllipticalROITool extends AnnotationTool {
626
626
  };
627
627
  this._throttledCalculateCachedStats = throttle(this._calculateCachedStats, 100, { trailing: true });
628
628
  }
629
+ static { this.hydrate = (viewportId, points, options) => {
630
+ const enabledElement = getEnabledElementByViewportId(viewportId);
631
+ if (!enabledElement) {
632
+ return;
633
+ }
634
+ const { viewport } = enabledElement;
635
+ const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
636
+ const { viewPlaneNormal, viewUp } = viewport.getCamera();
637
+ const instance = new this();
638
+ const referencedImageId = instance.getReferencedImageId(viewport, points[0], viewPlaneNormal, viewUp);
639
+ const annotation = {
640
+ annotationUID: options?.annotationUID || csUtils.uuidv4(),
641
+ data: {
642
+ handles: {
643
+ points,
644
+ activeHandleIndex: null,
645
+ },
646
+ label: '',
647
+ cachedStats: {},
648
+ },
649
+ highlighted: false,
650
+ autoGenerated: false,
651
+ invalidated: false,
652
+ isLocked: false,
653
+ isVisible: true,
654
+ metadata: {
655
+ toolName: instance.getToolName(),
656
+ viewPlaneNormal,
657
+ FrameOfReferenceUID,
658
+ referencedImageId,
659
+ ...options,
660
+ },
661
+ };
662
+ addAnnotation(annotation, viewport.element);
663
+ triggerAnnotationRenderForViewportIds([viewport.id]);
664
+ }; }
629
665
  _pointInEllipseCanvas(ellipse, location) {
630
666
  const xRadius = ellipse.width / 2;
631
667
  const yRadius = ellipse.height / 2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "types": "./dist/esm/index.d.ts",
6
6
  "module": "./dist/esm/index.js",
@@ -104,7 +104,7 @@
104
104
  "canvas": "^2.11.2"
105
105
  },
106
106
  "peerDependencies": {
107
- "@cornerstonejs/core": "^2.3.0",
107
+ "@cornerstonejs/core": "^2.3.1",
108
108
  "@kitware/vtk.js": "32.1.1",
109
109
  "@types/d3-array": "^3.0.4",
110
110
  "@types/d3-interpolate": "^3.0.1",
@@ -123,5 +123,5 @@
123
123
  "type": "individual",
124
124
  "url": "https://ohif.org/donate"
125
125
  },
126
- "gitHead": "bb71a514486a519a45468b1f474b5c2c0bb25575"
126
+ "gitHead": "2f69e663044b481066b5d8c942f831b0de4446c3"
127
127
  }