@cornerstonejs/tools 1.71.3 → 1.71.5

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.
Files changed (53) hide show
  1. package/dist/cjs/eventDispatchers/cameraResetEventDispatcher.d.ts +5 -0
  2. package/dist/cjs/eventDispatchers/cameraResetEventDispatcher.js +32 -0
  3. package/dist/cjs/eventDispatchers/cameraResetEventDispatcher.js.map +1 -0
  4. package/dist/cjs/eventDispatchers/index.d.ts +2 -1
  5. package/dist/cjs/eventDispatchers/index.js +3 -1
  6. package/dist/cjs/eventDispatchers/index.js.map +1 -1
  7. package/dist/cjs/store/addEnabledElement.js +1 -0
  8. package/dist/cjs/store/addEnabledElement.js.map +1 -1
  9. package/dist/cjs/store/removeEnabledElement.js +1 -0
  10. package/dist/cjs/store/removeEnabledElement.js.map +1 -1
  11. package/dist/cjs/synchronizers/callbacks/presentationViewSyncCallback.js +1 -1
  12. package/dist/cjs/synchronizers/callbacks/presentationViewSyncCallback.js.map +1 -1
  13. package/dist/cjs/tools/CrosshairsTool.d.ts +1 -0
  14. package/dist/cjs/tools/CrosshairsTool.js +11 -0
  15. package/dist/cjs/tools/CrosshairsTool.js.map +1 -1
  16. package/dist/cjs/tools/segmentation/strategies/BrushStrategy.js.map +1 -1
  17. package/dist/cjs/utilities/contours/interpolation/interpolate.js +5 -3
  18. package/dist/cjs/utilities/contours/interpolation/interpolate.js.map +1 -1
  19. package/dist/esm/eventDispatchers/cameraResetEventDispatcher.js +27 -0
  20. package/dist/esm/eventDispatchers/cameraResetEventDispatcher.js.map +1 -0
  21. package/dist/esm/eventDispatchers/index.js +2 -1
  22. package/dist/esm/eventDispatchers/index.js.map +1 -1
  23. package/dist/esm/store/addEnabledElement.js +2 -1
  24. package/dist/esm/store/addEnabledElement.js.map +1 -1
  25. package/dist/esm/store/removeEnabledElement.js +2 -1
  26. package/dist/esm/store/removeEnabledElement.js.map +1 -1
  27. package/dist/esm/synchronizers/callbacks/presentationViewSyncCallback.js +1 -1
  28. package/dist/esm/synchronizers/callbacks/presentationViewSyncCallback.js.map +1 -1
  29. package/dist/esm/tools/CrosshairsTool.js +11 -0
  30. package/dist/esm/tools/CrosshairsTool.js.map +1 -1
  31. package/dist/esm/tools/segmentation/strategies/BrushStrategy.js.map +1 -1
  32. package/dist/esm/utilities/contours/interpolation/interpolate.js +5 -3
  33. package/dist/esm/utilities/contours/interpolation/interpolate.js.map +1 -1
  34. package/dist/types/eventDispatchers/cameraResetEventDispatcher.d.ts +6 -0
  35. package/dist/types/eventDispatchers/cameraResetEventDispatcher.d.ts.map +1 -0
  36. package/dist/types/eventDispatchers/index.d.ts +2 -1
  37. package/dist/types/store/addEnabledElement.d.ts.map +1 -1
  38. package/dist/types/store/removeEnabledElement.d.ts.map +1 -1
  39. package/dist/types/tools/CrosshairsTool.d.ts +1 -0
  40. package/dist/types/tools/CrosshairsTool.d.ts.map +1 -1
  41. package/dist/types/tools/segmentation/strategies/BrushStrategy.d.ts.map +1 -1
  42. package/dist/types/utilities/contours/interpolation/interpolate.d.ts.map +1 -1
  43. package/dist/umd/index.js +1 -1
  44. package/dist/umd/index.js.map +1 -1
  45. package/package.json +3 -3
  46. package/src/eventDispatchers/cameraResetEventDispatcher.ts +41 -0
  47. package/src/eventDispatchers/index.js +2 -0
  48. package/src/store/addEnabledElement.ts +2 -0
  49. package/src/store/removeEnabledElement.ts +2 -0
  50. package/src/synchronizers/callbacks/presentationViewSyncCallback.ts +1 -1
  51. package/src/tools/CrosshairsTool.ts +18 -0
  52. package/src/tools/segmentation/strategies/BrushStrategy.ts +2 -6
  53. package/src/utilities/contours/interpolation/interpolate.ts +5 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "1.71.3",
3
+ "version": "1.71.5",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "main": "src/index.ts",
6
6
  "types": "dist/types/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  "webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
30
30
  },
31
31
  "dependencies": {
32
- "@cornerstonejs/core": "^1.71.3",
32
+ "@cornerstonejs/core": "^1.71.5",
33
33
  "@icr/polyseg-wasm": "0.4.0",
34
34
  "@types/offscreencanvas": "2019.7.3",
35
35
  "comlink": "^4.4.1",
@@ -59,5 +59,5 @@
59
59
  "type": "individual",
60
60
  "url": "https://ohif.org/donate"
61
61
  },
62
- "gitHead": "1f8cced111f519d18a4f832acf9204c8b160d0ab"
62
+ "gitHead": "589239e007a87fa5316efa222054c518e6f00098"
63
63
  }
@@ -0,0 +1,41 @@
1
+ import { Enums, Types } from '@cornerstonejs/core';
2
+ import { ToolModes } from '../enums';
3
+ import getToolsWithModesForMouseEvent from './shared/getToolsWithModesForMouseEvent';
4
+
5
+ const { Active, Passive, Enabled } = ToolModes;
6
+
7
+ /**
8
+ * When the camera is reset, check what tools need to react to this.
9
+ *
10
+ * - First we get all tools which are active, passive or enabled on the element.
11
+ * - If any of these tools have a `onCameraReset` method, we call it.
12
+ *
13
+ * @param evt - The normalized camera reset event.
14
+ */
15
+ const onCameraReset = function (evt: Types.EventTypes.CameraResetEvent) {
16
+ // @ts-ignore
17
+ const enabledTools = getToolsWithModesForMouseEvent(evt, [
18
+ Active,
19
+ Passive,
20
+ Enabled,
21
+ ]);
22
+
23
+ enabledTools.forEach((tool) => {
24
+ if (tool.onResetCamera) {
25
+ tool.onResetCamera(evt);
26
+ }
27
+ });
28
+ };
29
+
30
+ const enable = function (element) {
31
+ element.addEventListener(Enums.Events.CAMERA_RESET, onCameraReset);
32
+ };
33
+
34
+ const disable = function (element) {
35
+ element.removeEventListener(Enums.Events.CAMERA_RESET, onCameraReset);
36
+ };
37
+
38
+ export default {
39
+ enable,
40
+ disable,
41
+ };
@@ -5,6 +5,7 @@ import cameraModifiedEventDispatcher from './cameraModifiedEventDispatcher';
5
5
  import imageSpacingCalibratedEventDispatcher from './imageSpacingCalibratedEventDispatcher';
6
6
  import touchToolEventDispatcher from './touchToolEventDispatcher';
7
7
  import annotationInterpolationEventDispatcher from './annotationInterpolationEventDispatcher';
8
+ import cameraResetEventDispatcher from './cameraResetEventDispatcher';
8
9
 
9
10
  export {
10
11
  imageRenderedEventDispatcher,
@@ -14,4 +15,5 @@ export {
14
15
  imageSpacingCalibratedEventDispatcher,
15
16
  touchToolEventDispatcher,
16
17
  annotationInterpolationEventDispatcher,
18
+ cameraResetEventDispatcher,
17
19
  };
@@ -13,6 +13,7 @@ import {
13
13
  touchToolEventDispatcher,
14
14
  keyboardToolEventDispatcher,
15
15
  imageSpacingCalibratedEventDispatcher,
16
+ cameraResetEventDispatcher,
16
17
  } from '../eventDispatchers';
17
18
  import { state } from './state';
18
19
 
@@ -48,6 +49,7 @@ export default function addEnabledElement(
48
49
  imageRenderedEventDispatcher.enable(element);
49
50
  cameraModifiedEventDispatcher.enable(element);
50
51
  imageSpacingCalibratedEventDispatcher.enable(element);
52
+ cameraResetEventDispatcher.enable(element);
51
53
  // Dispatchers: interaction
52
54
  mouseToolEventDispatcher.enable(element);
53
55
  keyboardToolEventDispatcher.enable(element);
@@ -13,6 +13,7 @@ import {
13
13
  keyboardToolEventDispatcher,
14
14
  imageSpacingCalibratedEventDispatcher,
15
15
  touchToolEventDispatcher,
16
+ cameraResetEventDispatcher,
16
17
  } from '../eventDispatchers';
17
18
  // ~~
18
19
 
@@ -52,6 +53,7 @@ function removeEnabledElement(
52
53
  imageRenderedEventDispatcher.disable(element);
53
54
  cameraModifiedEventDispatcher.disable(element);
54
55
  imageSpacingCalibratedEventDispatcher.disable(element);
56
+ cameraResetEventDispatcher.disable(element);
55
57
 
56
58
  // Dispatchers: interaction
57
59
  mouseToolEventDispatcher.disable(element);
@@ -30,7 +30,7 @@ export default function presentationViewSyncCallback(
30
30
 
31
31
  const presentationView = sViewport.getViewPresentation(options);
32
32
 
33
- tViewport.setView(null, presentationView);
33
+ tViewport.setViewPresentation(presentationView);
34
34
 
35
35
  tViewport.render();
36
36
  }
@@ -319,6 +319,19 @@ class CrosshairsTool extends AnnotationTool {
319
319
  renderingEngineId
320
320
  );
321
321
  const { viewport } = enabledElement;
322
+ const resetPan = true;
323
+ const resetZoom = true;
324
+ const resetToCenter = true;
325
+ const resetRotation = true;
326
+ const supressEvents = true;
327
+ viewport.resetCamera(
328
+ resetPan,
329
+ resetZoom,
330
+ resetToCenter,
331
+ resetRotation,
332
+ supressEvents
333
+ );
334
+ (viewport as Types.IVolumeViewport).resetSlabThickness();
322
335
  const { element } = viewport;
323
336
  let annotations = this._getAnnotations(enabledElement);
324
337
  annotations = this.filterInteractableAnnotationsForElement(
@@ -328,6 +341,7 @@ class CrosshairsTool extends AnnotationTool {
328
341
  if (annotations.length) {
329
342
  removeAnnotation(annotations[0].annotationUID);
330
343
  }
344
+ viewport.render();
331
345
  });
332
346
 
333
347
  this.computeToolCenter(viewportsInfo);
@@ -684,6 +698,10 @@ class CrosshairsTool extends AnnotationTool {
684
698
  triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
685
699
  };
686
700
 
701
+ onResetCamera = (evt) => {
702
+ this.resetCrosshairs();
703
+ };
704
+
687
705
  mouseMoveCallback = (
688
706
  evt: EventTypes.MouseMoveEventType,
689
707
  filteredToolAnnotations: Annotations
@@ -1,15 +1,11 @@
1
1
  import type { Types } from '@cornerstonejs/core';
2
- import { cache, utilities as csUtils } from '@cornerstonejs/core';
2
+ import { utilities as csUtils } from '@cornerstonejs/core';
3
3
 
4
4
  import { triggerSegmentationDataModified } from '../../../stateManagement/segmentation/triggerSegmentationEvents';
5
5
  import compositions from './compositions';
6
6
  import { getStrategyData } from './utils/getStrategyData';
7
- import { isVolumeSegmentation } from './utils/stackVolumeCheck';
8
7
  import { StrategyCallbacks } from '../../../enums';
9
- import type {
10
- LabelmapToolOperationDataAny,
11
- LabelmapToolOperationDataVolume,
12
- } from '../../../types/LabelmapToolOperationData';
8
+ import type { LabelmapToolOperationDataAny } from '../../../types/LabelmapToolOperationData';
13
9
  import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
14
10
 
15
11
  const { VoxelManager } = csUtils;
@@ -248,9 +248,11 @@ function _addInterpolatedContour(
248
248
  referencedToolData
249
249
  );
250
250
 
251
- const targetId = viewport.getReferenceId({ sliceIndex });
252
- interpolatedAnnotation.metadata.referencedImageId = targetId;
253
- interpolatedAnnotation.metadata.sliceIndex = sliceIndex;
251
+ const viewRef = viewport.getViewReference({ sliceIndex });
252
+ if (!viewRef) {
253
+ throw new Error(`Can't find slice ${sliceIndex}`);
254
+ }
255
+ Object.assign(interpolatedAnnotation.metadata, viewRef);
254
256
  annotationState.state.addAnnotation(interpolatedAnnotation, viewport.element);
255
257
  referencedToolData.onInterpolationComplete?.(
256
258
  interpolatedAnnotation,