@cornerstonejs/tools 4.15.26 → 4.15.28

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.
@@ -13,7 +13,12 @@ export default function mouseDownActivate(evt) {
13
13
  return;
14
14
  }
15
15
  if (activeTool.addNewAnnotation) {
16
- const annotation = activeTool.addNewAnnotation(evt, 'mouse');
17
- setAnnotationSelected(annotation.annotationUID);
16
+ try {
17
+ const annotation = activeTool.addNewAnnotation(evt, 'mouse');
18
+ setAnnotationSelected(annotation.annotationUID);
19
+ }
20
+ catch (error) {
21
+ console.warn('Error adding new annotation, viewport not ready:', error);
22
+ }
18
23
  }
19
24
  }
@@ -492,12 +492,14 @@ class CircleROITool extends AnnotationTool {
492
492
  const targetId = targetIds[i];
493
493
  const image = this.getTargetImageData(targetId);
494
494
  if (!image) {
495
+ console.warn('image not found for stats:', targetId);
496
+ delete cachedStats[targetId];
495
497
  continue;
496
498
  }
497
499
  const { dimensions, imageData, metadata, voxelManager } = image;
498
500
  const handles = points.map((point) => imageData.worldToIndex(point));
499
501
  const calibrate = getCalibratedLengthUnitsAndScale(image, handles);
500
- const radius = CircleROITool.calculateLengthInIndex(calibrate, handles);
502
+ const radius = CircleROITool.calculateLengthInIndex(calibrate, handles.slice(0, 2));
501
503
  const area = Math.PI * radius * radius;
502
504
  const perimeter = 2 * Math.PI * radius;
503
505
  const isEmptyArea = radius === 0;
@@ -1,5 +1,6 @@
1
1
  import { AnnotationTool } from '../base';
2
2
  import { getEnabledElement, VolumeViewport, utilities as csUtils, getEnabledElementByViewportId, } from '@cornerstonejs/core';
3
+ import { vec3 } from 'gl-matrix';
3
4
  import { getCalibratedLengthUnitsAndScale } from '../../utilities/getCalibratedUnits';
4
5
  import throttle from '../../utilities/throttle';
5
6
  import { addAnnotation, getAnnotations, removeAnnotation, } from '../../stateManagement';
@@ -12,7 +13,6 @@ import { ChangeTypes, Events } from '../../enums';
12
13
  import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters';
13
14
  import * as rectangle from '../../utilities/math/rectangle';
14
15
  import { getTextBoxCoordsCanvas } from '../../utilities/drawing';
15
- import getWorldWidthAndHeightFromCorners from '../../utilities/planar/getWorldWidthAndHeightFromCorners';
16
16
  import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCursor';
17
17
  import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
18
18
  import { getPixelValueUnits } from '../../utilities/getPixelValueUnits';
@@ -448,8 +448,7 @@ class RectangleROITool extends AnnotationTool {
448
448
  const { data } = annotation;
449
449
  const { viewport } = enabledElement;
450
450
  const { element } = viewport;
451
- const worldPos1 = data.handles.points[0];
452
- const worldPos2 = data.handles.points[3];
451
+ const worldHandles = data.handles.points;
453
452
  const { cachedStats } = data;
454
453
  const targetIds = Object.keys(cachedStats);
455
454
  for (let i = 0; i < targetIds.length; i++) {
@@ -459,14 +458,9 @@ class RectangleROITool extends AnnotationTool {
459
458
  continue;
460
459
  }
461
460
  const { dimensions, imageData, metadata, voxelManager } = image;
462
- const pos1Index = transformWorldToIndex(imageData, worldPos1);
463
- pos1Index[0] = Math.floor(pos1Index[0]);
464
- pos1Index[1] = Math.floor(pos1Index[1]);
465
- pos1Index[2] = Math.floor(pos1Index[2]);
466
- const pos2Index = transformWorldToIndex(imageData, worldPos2);
467
- pos2Index[0] = Math.floor(pos2Index[0]);
468
- pos2Index[1] = Math.floor(pos2Index[1]);
469
- pos2Index[2] = Math.floor(pos2Index[2]);
461
+ const indexHandles = worldHandles.map((worldHandle) => transformWorldToIndex(imageData, worldHandle));
462
+ const pos1Index = indexHandles[0].map(Math.floor);
463
+ const pos2Index = indexHandles[3].map(Math.floor);
470
464
  if (this._isInsideVolume(pos1Index, pos2Index, dimensions)) {
471
465
  this.isHandleOutsideImage = false;
472
466
  const iMin = Math.min(pos1Index[0], pos2Index[0]);
@@ -480,10 +474,12 @@ class RectangleROITool extends AnnotationTool {
480
474
  [jMin, jMax],
481
475
  [kMin, kMax],
482
476
  ];
483
- const { worldWidth, worldHeight } = getWorldWidthAndHeightFromCorners(viewPlaneNormal, viewUp, worldPos1, worldPos2);
484
477
  const handles = [pos1Index, pos2Index];
485
- const { scale, areaUnit } = getCalibratedLengthUnitsAndScale(image, handles);
486
- const area = Math.abs(worldWidth * worldHeight) / (scale * scale);
478
+ const calibrate = getCalibratedLengthUnitsAndScale(image, handles);
479
+ const width = RectangleROITool.calculateLengthInIndex(calibrate, indexHandles.slice(0, 2));
480
+ const height = RectangleROITool.calculateLengthInIndex(calibrate, indexHandles.slice(2, 4));
481
+ const area = Math.abs(width * height);
482
+ const { areaUnit } = calibrate;
487
483
  const pixelUnitsOptions = {
488
484
  isPreScaled: isViewportPreScaled(viewport, targetId),
489
485
  isSuvScaled: this.isSuvScaled(viewport, targetId, annotation.metadata.referencedImageId),
@@ -13,7 +13,10 @@ export function getReferenceVolumeForSegmentationVolume(segmentationVolumeId) {
13
13
  const imageIds = segmentationVolume.imageIds;
14
14
  const image = cache.getImage(imageIds[0]);
15
15
  const referencedImageId = image.referencedImageId;
16
- const volumeInfo = cache.getVolumeContainingImageId(referencedImageId);
16
+ let volumeInfo = cache.getVolumeContainingImageId(referencedImageId);
17
+ if (!volumeInfo?.volume) {
18
+ volumeInfo = cache.getVolumeContainingImageId(image.imageId);
19
+ }
17
20
  imageVolume = volumeInfo?.volume;
18
21
  }
19
22
  return imageVolume;
@@ -1 +1 @@
1
- export declare const version = "4.15.26";
1
+ export declare const version = "4.15.28";
@@ -1 +1 @@
1
- export const version = '4.15.26';
1
+ export const version = '4.15.28';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "4.15.26",
3
+ "version": "4.15.28",
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.15.26",
111
+ "@cornerstonejs/core": "4.15.28",
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": "740af8d0a34bdced61440107cb8f0334dce93c47"
130
+ "gitHead": "18081f1a9b93118efed26ee9a5111c1d089bb076"
131
131
  }