@cornerstonejs/core 1.83.4 → 1.84.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/core",
3
- "version": "1.83.4",
3
+ "version": "1.84.1",
4
4
  "description": "",
5
5
  "main": "src/index.ts",
6
6
  "types": "dist/types/index.d.ts",
@@ -47,5 +47,5 @@
47
47
  "type": "individual",
48
48
  "url": "https://ohif.org/donate"
49
49
  },
50
- "gitHead": "864a3950e445c6c7631c8eee4342e86038b69267"
50
+ "gitHead": "e14af95b33e92828f3e0c8c21f0dc9319647abda"
51
51
  }
@@ -919,6 +919,10 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
919
919
  this.setRotation(properties.rotation);
920
920
  }
921
921
 
922
+ if (properties.preset !== undefined) {
923
+ this.setPreset(properties.preset, volumeId, false);
924
+ }
925
+
922
926
  this.render();
923
927
  }
924
928
 
@@ -1,5 +1,12 @@
1
- import { BlendModes, OrientationAxis } from '../enums';
1
+ import { BlendModes, OrientationAxis, Events } from '../enums';
2
+ import { RENDERING_DEFAULTS } from '../constants';
3
+ import cache from '../cache';
4
+ import setDefaultVolumeVOI from './helpers/setDefaultVolumeVOI';
5
+ import { triggerEvent, isImageActor } from '../utilities';
6
+ import { setTransferFunctionNodes } from '../utilities/transferFunctionUtils';
7
+ import type vtkVolume from '@kitware/vtk.js/Rendering/Core/Volume';
2
8
  import type { ViewportInput } from '../types/IViewport';
9
+ import type { ImageActor } from '../types/IActor';
3
10
  import BaseVolumeViewport from './BaseVolumeViewport';
4
11
 
5
12
  /**
@@ -61,8 +68,54 @@ class VolumeViewport3D extends BaseVolumeViewport {
61
68
  return null;
62
69
  }
63
70
 
71
+ /**
72
+ * Resets the properties of the volume to their default values.
73
+ *
74
+ * @param [volumeId] - The id of the volume to reset. If not provided, the default volume will be reset.
75
+ */
64
76
  resetProperties(volumeId?: string): void {
65
- return null;
77
+ const volumeActor = volumeId
78
+ ? this.getActor(volumeId)
79
+ : this.getDefaultActor();
80
+
81
+ if (!volumeActor) {
82
+ throw new Error(`No actor found for the given volumeId: ${volumeId}`);
83
+ }
84
+
85
+ // if a custom slabThickness was set, we need to reset it
86
+ if (volumeActor.slabThickness) {
87
+ volumeActor.slabThickness = RENDERING_DEFAULTS.MINIMUM_SLAB_THICKNESS;
88
+ this.viewportProperties.slabThickness = undefined;
89
+ this.updateClippingPlanesForActors(this.getCamera());
90
+ }
91
+
92
+ const imageVolume = cache.getVolume(volumeActor.uid);
93
+
94
+ if (!imageVolume) {
95
+ throw new Error(
96
+ `imageVolume with id: ${volumeActor.uid} does not exist in cache`
97
+ );
98
+ }
99
+
100
+ setDefaultVolumeVOI(volumeActor.actor as vtkVolume, imageVolume, false);
101
+
102
+ if (isImageActor(volumeActor)) {
103
+ const transferFunction = (volumeActor.actor as ImageActor)
104
+ .getProperty()
105
+ .getRGBTransferFunction(0);
106
+
107
+ setTransferFunctionNodes(
108
+ transferFunction,
109
+ this.initialTransferFunctionNodes
110
+ );
111
+ }
112
+
113
+ this.setCamera(this.initialCamera);
114
+ triggerEvent(
115
+ this.element,
116
+ Events.VOI_MODIFIED,
117
+ super.getVOIModifiedEventDetail(volumeId)
118
+ );
66
119
  }
67
120
 
68
121
  resetSlabThickness(): void {