@cornerstonejs/adapters 1.56.1 → 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.
@@ -5072,6 +5072,7 @@ var Events$2;
5072
5072
  Events["CAMERA_MODIFIED"] = "CORNERSTONE_CAMERA_MODIFIED";
5073
5073
  Events["CAMERA_RESET"] = "CORNERSTONE_CAMERA_RESET";
5074
5074
  Events["VOI_MODIFIED"] = "CORNERSTONE_VOI_MODIFIED";
5075
+ Events["PRESET_MODIFIED"] = "CORNERSTONE_VIEWPORT_RENDERING_PRESET_MODIFIED";
5075
5076
  Events["DISPLAY_AREA_MODIFIED"] = "CORNERSTONE_DISPLAY_AREA_MODIFIED";
5076
5077
  Events["ELEMENT_DISABLED"] = "CORNERSTONE_ELEMENT_DISABLED";
5077
5078
  Events["ELEMENT_ENABLED"] = "CORNERSTONE_ELEMENT_ENABLED";
@@ -38139,24 +38140,26 @@ function applyPreset(actor, preset) {
38139
38140
  normPoints.push([value, opacity]);
38140
38141
  }
38141
38142
  applyPointsToPiecewiseFunction(normPoints, shiftRange, ofun);
38142
- actor.getProperty().setScalarOpacity(0, ofun);
38143
+ const property = actor.getProperty();
38144
+ property.setScalarOpacity(0, ofun);
38143
38145
  const [gradientMinValue, gradientMinOpacity, gradientMaxValue, gradientMaxOpacity] = preset.gradientOpacity.split(' ').splice(1).map(parseFloat);
38144
- actor.getProperty().setUseGradientOpacity(0, true);
38145
- actor.getProperty().setGradientOpacityMinimumValue(0, gradientMinValue);
38146
- actor.getProperty().setGradientOpacityMinimumOpacity(0, gradientMinOpacity);
38147
- actor.getProperty().setGradientOpacityMaximumValue(0, gradientMaxValue);
38148
- actor.getProperty().setGradientOpacityMaximumOpacity(0, gradientMaxOpacity);
38146
+ property.setUseGradientOpacity(0, true);
38147
+ property.setGradientOpacityMinimumValue(0, gradientMinValue);
38148
+ property.setGradientOpacityMinimumOpacity(0, gradientMinOpacity);
38149
+ property.setGradientOpacityMaximumValue(0, gradientMaxValue);
38150
+ property.setGradientOpacityMaximumOpacity(0, gradientMaxOpacity);
38149
38151
  if (preset.interpolation === '1') {
38150
- actor.getProperty().setInterpolationTypeToFastLinear();
38152
+ property.setInterpolationTypeToFastLinear();
38151
38153
  }
38154
+ property.setShade(preset.shade === '1');
38152
38155
  const ambient = parseFloat(preset.ambient);
38153
38156
  const diffuse = parseFloat(preset.diffuse);
38154
38157
  const specular = parseFloat(preset.specular);
38155
38158
  const specularPower = parseFloat(preset.specularPower);
38156
- actor.getProperty().setAmbient(ambient);
38157
- actor.getProperty().setDiffuse(diffuse);
38158
- actor.getProperty().setSpecular(specular);
38159
- actor.getProperty().setSpecularPower(specularPower);
38159
+ property.setAmbient(ambient);
38160
+ property.setDiffuse(diffuse);
38161
+ property.setSpecular(specular);
38162
+ property.setSpecularPower(specularPower);
38160
38163
  }
38161
38164
  function getShiftRange(colorTransferArray) {
38162
38165
  let min = Infinity;
@@ -41786,7 +41789,7 @@ class BaseVolumeViewport extends Viewport$1 {
41786
41789
  }
41787
41790
  this.render();
41788
41791
  }
41789
- setPreset(presetName, volumeId, suppressEvents) {
41792
+ setPreset(presetNameOrObj, volumeId, suppressEvents) {
41790
41793
  const applicableVolumeActorInfo = this._getApplicableVolumeActor(volumeId);
41791
41794
  if (!applicableVolumeActorInfo) {
41792
41795
  return;
@@ -41794,14 +41797,24 @@ class BaseVolumeViewport extends Viewport$1 {
41794
41797
  const {
41795
41798
  volumeActor
41796
41799
  } = applicableVolumeActorInfo;
41797
- const preset = VIEWPORT_PRESETS.find(preset => {
41798
- return preset.name === presetName;
41799
- });
41800
+ let preset = presetNameOrObj;
41801
+ if (typeof preset === 'string') {
41802
+ preset = VIEWPORT_PRESETS.find(preset => {
41803
+ return preset.name === presetNameOrObj;
41804
+ });
41805
+ }
41800
41806
  if (!preset) {
41801
41807
  return;
41802
41808
  }
41803
41809
  applyPreset(volumeActor, preset);
41804
- this.viewportProperties.preset = presetName;
41810
+ if (!suppressEvents) {
41811
+ triggerEvent(this.element, EVENTS.PRESET_MODIFIED, {
41812
+ viewportId: this.id,
41813
+ volumeId: applicableVolumeActorInfo.volumeId,
41814
+ actor: volumeActor,
41815
+ presetName: preset.name
41816
+ });
41817
+ }
41805
41818
  }
41806
41819
  async setVolumes(volumeInputArray, immediate = false, suppressEvents = false) {
41807
41820
  const firstImageVolume = cache$1.getVolume(volumeInputArray[0].volumeId);
@@ -48250,11 +48263,11 @@ let state = {
48250
48263
  const {
48251
48264
  isEqual: isEqual$1
48252
48265
  } = utilities;
48253
- function getViewportForAnnotation(annotation) {
48266
+ function getViewportsForAnnotation(annotation) {
48254
48267
  const {
48255
48268
  metadata
48256
48269
  } = annotation;
48257
- const enabledElement = getEnabledElements().find(enabledElement => {
48270
+ return getEnabledElements().filter(enabledElement => {
48258
48271
  if (enabledElement.FrameOfReferenceUID === metadata.FrameOfReferenceUID) {
48259
48272
  const viewport = enabledElement.viewport;
48260
48273
  const {
@@ -48264,8 +48277,12 @@ function getViewportForAnnotation(annotation) {
48264
48277
  return isEqual$1(viewPlaneNormal, metadata.viewPlaneNormal) && (!metadata.viewUp || isEqual$1(viewUp, metadata.viewUp));
48265
48278
  }
48266
48279
  return;
48267
- });
48268
- return enabledElement?.viewport;
48280
+ }).map(enabledElement => enabledElement.viewport);
48281
+ }
48282
+
48283
+ function getViewportForAnnotation(annotation) {
48284
+ const viewports = getViewportsForAnnotation(annotation);
48285
+ return viewports.length ? viewports[0] : undefined;
48269
48286
  }
48270
48287
 
48271
48288
  function areCoplanarContours(firstAnnotation, secondAnnotation) {