@cornerstonejs/core 1.56.2 → 1.57.0

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.56.2",
3
+ "version": "1.57.0",
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": "f0e02324b49825859090ffd7b92523680a6616ce"
50
+ "gitHead": "1699f915a5e7a5cf9295707fb5b62fe01d7e491b"
51
51
  }
@@ -663,7 +663,7 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
663
663
  *
664
664
  * @returns void
665
665
  */
666
- private setPreset(presetName, volumeId, suppressEvents) {
666
+ private setPreset(presetNameOrObj, volumeId, suppressEvents) {
667
667
  const applicableVolumeActorInfo = this._getApplicableVolumeActor(volumeId);
668
668
 
669
669
  if (!applicableVolumeActorInfo) {
@@ -672,9 +672,13 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
672
672
 
673
673
  const { volumeActor } = applicableVolumeActorInfo;
674
674
 
675
- const preset = VIEWPORT_PRESETS.find((preset) => {
676
- return preset.name === presetName;
677
- });
675
+ let preset = presetNameOrObj;
676
+
677
+ if (typeof preset === 'string') {
678
+ preset = VIEWPORT_PRESETS.find((preset) => {
679
+ return preset.name === presetNameOrObj;
680
+ });
681
+ }
678
682
 
679
683
  if (!preset) {
680
684
  return;
@@ -682,7 +686,14 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
682
686
 
683
687
  applyPreset(volumeActor, preset);
684
688
 
685
- this.viewportProperties.preset = presetName;
689
+ if (!suppressEvents) {
690
+ triggerEvent(this.element, Events.PRESET_MODIFIED, {
691
+ viewportId: this.id,
692
+ volumeId: applicableVolumeActorInfo.volumeId,
693
+ actor: volumeActor,
694
+ presetName: preset.name,
695
+ });
696
+ }
686
697
  }
687
698
 
688
699
  /**
@@ -38,6 +38,12 @@ enum Events {
38
38
  * and see what event detail is included in {@link EventTypes.VoiModifiedEventDetail | VoiModified Event Detail }
39
39
  */
40
40
  VOI_MODIFIED = 'CORNERSTONE_VOI_MODIFIED',
41
+ /**
42
+ * Triggers on the HTML element when viewport modifies its preset (used in volume viewport 3D)
43
+ *
44
+ * Make use of {@link EventTypes.PresetModifiedEvent | PresetModified Event Type } for typing your event listeners for PRESET_MODIFIED event,
45
+ */
46
+ PRESET_MODIFIED = 'CORNERSTONE_VIEWPORT_RENDERING_PRESET_MODIFIED',
41
47
  /**
42
48
  * Triggers on the HTML element when viewport modifies its display area
43
49
  *
@@ -57,8 +57,9 @@ export default function applyPreset(
57
57
 
58
58
  applyPointsToPiecewiseFunction(normPoints, shiftRange, ofun);
59
59
 
60
- actor.getProperty().setScalarOpacity(0, ofun);
60
+ const property = actor.getProperty();
61
61
 
62
+ property.setScalarOpacity(0, ofun);
62
63
  const [
63
64
  gradientMinValue,
64
65
  gradientMinOpacity,
@@ -66,26 +67,28 @@ export default function applyPreset(
66
67
  gradientMaxOpacity,
67
68
  ] = preset.gradientOpacity.split(' ').splice(1).map(parseFloat);
68
69
 
69
- actor.getProperty().setUseGradientOpacity(0, true);
70
- actor.getProperty().setGradientOpacityMinimumValue(0, gradientMinValue);
71
- actor.getProperty().setGradientOpacityMinimumOpacity(0, gradientMinOpacity);
72
- actor.getProperty().setGradientOpacityMaximumValue(0, gradientMaxValue);
73
- actor.getProperty().setGradientOpacityMaximumOpacity(0, gradientMaxOpacity);
70
+ property.setUseGradientOpacity(0, true);
71
+ property.setGradientOpacityMinimumValue(0, gradientMinValue);
72
+ property.setGradientOpacityMinimumOpacity(0, gradientMinOpacity);
73
+ property.setGradientOpacityMaximumValue(0, gradientMaxValue);
74
+ property.setGradientOpacityMaximumOpacity(0, gradientMaxOpacity);
74
75
 
75
76
  if (preset.interpolation === '1') {
76
- actor.getProperty().setInterpolationTypeToFastLinear();
77
- //actor.getProperty().setInterpolationTypeToLinear()
77
+ property.setInterpolationTypeToFastLinear();
78
+ //property.setInterpolationTypeToLinear()
78
79
  }
79
80
 
81
+ property.setShade(preset.shade === '1');
82
+
80
83
  const ambient = parseFloat(preset.ambient);
81
84
  const diffuse = parseFloat(preset.diffuse);
82
85
  const specular = parseFloat(preset.specular);
83
86
  const specularPower = parseFloat(preset.specularPower);
84
87
 
85
- actor.getProperty().setAmbient(ambient);
86
- actor.getProperty().setDiffuse(diffuse);
87
- actor.getProperty().setSpecular(specular);
88
- actor.getProperty().setSpecularPower(specularPower);
88
+ property.setAmbient(ambient);
89
+ property.setDiffuse(diffuse);
90
+ property.setSpecular(specular);
91
+ property.setSpecularPower(specularPower);
89
92
  }
90
93
 
91
94
  function getShiftRange(colorTransferArray) {