@cornerstonejs/tools 0.67.2 → 0.67.3

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.67.2",
3
+ "version": "0.67.3",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "main": "dist/umd/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -26,7 +26,7 @@
26
26
  "webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
27
27
  },
28
28
  "dependencies": {
29
- "@cornerstonejs/core": "^0.46.2",
29
+ "@cornerstonejs/core": "^0.47.0",
30
30
  "lodash.clonedeep": "4.5.0",
31
31
  "lodash.get": "^4.4.2"
32
32
  },
@@ -49,5 +49,5 @@
49
49
  "type": "individual",
50
50
  "url": "https://ohif.org/donate"
51
51
  },
52
- "gitHead": "1e5e0ec2e760c409d532f14b145f52853a9f50ec"
52
+ "gitHead": "2c2efd8536d4af3ede72a47bdab199efe67bb1d3"
53
53
  }
@@ -1793,9 +1793,9 @@ class CrosshairsTool extends AnnotationTool {
1793
1793
  for (let i = 0; i < otherViewportAnnotations.length; ++i) {
1794
1794
  const annotation = otherViewportAnnotations[i];
1795
1795
  if (
1796
- otherViewportsAnnotationsWithUniqueCameras.find(
1796
+ otherViewportsAnnotationsWithUniqueCameras.some(
1797
1797
  (element) => element === annotation
1798
- ) === true
1798
+ )
1799
1799
  ) {
1800
1800
  continue;
1801
1801
  }
@@ -1,11 +1,7 @@
1
- import {
2
- getEnabledElement,
3
- VolumeViewport,
4
- StackViewport,
5
- } from '@cornerstonejs/core';
1
+ import { getEnabledElement } from '@cornerstonejs/core';
6
2
  import { BaseTool } from './base';
7
3
  import { MouseWheelEventType } from '../types/EventTypes';
8
- import { scrollVolume } from '../utilities/scroll';
4
+ import scroll from '../utilities/scroll';
9
5
 
10
6
  /**
11
7
  * The StackScrollMouseWheelTool is a tool that allows the user to scroll through a
@@ -37,20 +33,15 @@ class StackScrollMouseWheelTool extends BaseTool {
37
33
  const { viewport } = getEnabledElement(element);
38
34
  const delta = direction * (invert ? -1 : 1);
39
35
 
40
- if (viewport instanceof StackViewport) {
41
- viewport.scroll(
42
- delta,
43
- this.configuration.debounceIfNotLoaded,
44
- this.configuration.loop
45
- );
46
- } else if (viewport instanceof VolumeViewport) {
47
- const targetId = this.getTargetId(viewport);
48
- const volumeId = targetId.split('volumeId:')[1];
49
- // TODO: add loop implemention for scroll volume.
50
- scrollVolume(viewport, volumeId, delta);
51
- } else {
52
- throw new Error('StackScrollMouseWheelTool: Unsupported viewport type');
53
- }
36
+ const targetId = this.getTargetId(viewport);
37
+ const volumeId = targetId.split('volumeId:')[1];
38
+
39
+ scroll(viewport, {
40
+ delta,
41
+ debounceLoading: this.configuration.debounceIfNotLoaded,
42
+ loop: this.configuration.loop,
43
+ volumeId,
44
+ });
54
45
  }
55
46
  }
56
47
 
@@ -653,7 +653,7 @@ class RectangleROITool extends AnnotationTool {
653
653
  // force to recalculate the stats from the points
654
654
  if (
655
655
  !data.cachedStats[targetId] ||
656
- data.cachedStats[targetId].unit === undefined
656
+ data.cachedStats[targetId].areaUnit === undefined
657
657
  ) {
658
658
  data.cachedStats[targetId] = {
659
659
  Modality: null,
@@ -5,6 +5,7 @@ import {
5
5
  eventTarget,
6
6
  EVENTS,
7
7
  utilities as csUtils,
8
+ getEnabledElement,
8
9
  } from '@cornerstonejs/core';
9
10
  import { ScrollOptions, EventTypes } from '../types';
10
11
 
@@ -21,6 +22,20 @@ export default function scroll(
21
22
  viewport: Types.IStackViewport | Types.IVolumeViewport,
22
23
  options: ScrollOptions
23
24
  ): void {
25
+ // check if viewport is disabled then throw error
26
+ const enabledElement = getEnabledElement(viewport.element);
27
+
28
+ if (!enabledElement) {
29
+ throw new Error('Scroll::Viewport is not enabled (it might be disabled)');
30
+ }
31
+
32
+ if (
33
+ viewport instanceof StackViewport &&
34
+ viewport.getImageIds().length === 0
35
+ ) {
36
+ throw new Error('Scroll::Stack Viewport has no images');
37
+ }
38
+
24
39
  const { type: viewportType } = viewport;
25
40
  const { volumeId, delta } = options;
26
41