@cornerstonejs/core 3.14.1 → 3.14.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.
@@ -13,7 +13,7 @@ import * as colormapUtils from '../utilities/colormap';
13
13
  import invertRgbTransferFunction from '../utilities/invertRgbTransferFunction';
14
14
  import createSigmoidRGBTransferFunction from '../utilities/createSigmoidRGBTransferFunction';
15
15
  import transformWorldToIndex from '../utilities/transformWorldToIndex';
16
- import { findMatchingColormap, updateOpacity as colormapUpdateOpacity, updateThreshold as colormapUpdateThreshold, } from '../utilities/colormap';
16
+ import { findMatchingColormap, updateOpacity as colormapUpdateOpacity, updateThreshold as colormapUpdateThreshold, getThresholdValue, getMaxOpacity, } from '../utilities/colormap';
17
17
  import { getTransferFunctionNodes } from '../utilities/transferFunctionUtils';
18
18
  import createVolumeActor from './helpers/createVolumeActor';
19
19
  import volumeNewImageEventDispatcher, { resetVolumeNewImageState, } from './helpers/volumeNewImageEventDispatcher';
@@ -127,6 +127,10 @@ class BaseVolumeViewport extends Viewport {
127
127
  return acc;
128
128
  }, []);
129
129
  const matchedColormap = findMatchingColormap(RGBPoints, volumeActor);
130
+ const threshold = getThresholdValue(volumeActor);
131
+ const opacity = getMaxOpacity(volumeActor);
132
+ matchedColormap.threshold = threshold;
133
+ matchedColormap.opacity = opacity;
130
134
  return matchedColormap;
131
135
  };
132
136
  this.getRotation = () => {
@@ -317,9 +321,10 @@ class BaseVolumeViewport extends Viewport {
317
321
  volumeActor.getProperty().setRGBTransferFunction(0, cfun);
318
322
  this.viewportProperties.colormap = colormap;
319
323
  if (!suppressEvents) {
324
+ const completeColormap = this.getColormap(volumeId);
320
325
  const eventDetail = {
321
326
  viewportId: this.id,
322
- colormap,
327
+ colormap: completeColormap,
323
328
  volumeId,
324
329
  };
325
330
  triggerEvent(this.element, Events.VOI_MODIFIED, eventDetail);
@@ -346,6 +351,13 @@ class BaseVolumeViewport extends Viewport {
346
351
  this.viewportProperties.colormap = {};
347
352
  }
348
353
  this.viewportProperties.colormap.opacity = colormap.opacity;
354
+ const matchedColormap = this.getColormap(volumeId);
355
+ const eventDetail = {
356
+ viewportId: this.id,
357
+ colormap: matchedColormap,
358
+ volumeId,
359
+ };
360
+ triggerEvent(this.element, Events.COLORMAP_MODIFIED, eventDetail);
349
361
  }
350
362
  setInvert(inverted, volumeId, suppressEvents) {
351
363
  const applicableVolumeActorInfo = this._getApplicableVolumeActor(volumeId);
@@ -586,6 +598,13 @@ class BaseVolumeViewport extends Viewport {
586
598
  this.viewportProperties.colormap = {};
587
599
  }
588
600
  this.viewportProperties.colormap.threshold = colormap.threshold;
601
+ const matchedColormap = this.getColormap(volumeId);
602
+ const eventDetail = {
603
+ viewportId: this.id,
604
+ colormap: matchedColormap,
605
+ volumeId,
606
+ };
607
+ triggerEvent(this.element, Events.COLORMAP_MODIFIED, eventDetail);
589
608
  }
590
609
  setProperties({ voiRange, VOILUTFunction, invert, colormap, preset, interpolationType, slabThickness, } = {}, volumeId, suppressEvents = false) {
591
610
  if (this.globalDefaultProperties == null) {
@@ -6,4 +6,6 @@ declare function findMatchingColormap(rgbPoints: any, actor: any): ColormapPubli
6
6
  export declare function setColorMapTransferFunctionForVolumeActor(volumeInfo: any): void;
7
7
  export declare function updateOpacity(volumeActor: any, newOpacity: any): void;
8
8
  export declare function updateThreshold(volumeActor: any, newThreshold: any): void;
9
- export { getColormap, getColormapNames, registerColormap, findMatchingColormap, };
9
+ declare function getThresholdValue(volumeActor: any): any;
10
+ declare function getMaxOpacity(volumeActor: any): number;
11
+ export { getColormap, getColormapNames, registerColormap, findMatchingColormap, getThresholdValue, getMaxOpacity, };
@@ -76,8 +76,11 @@ export function updateThreshold(volumeActor, newThreshold) {
76
76
  updateOpacityWithThreshold(volumeActor, currentOpacity, newThreshold);
77
77
  }
78
78
  function updateOpacityWithThreshold(volumeActor, opacity, threshold) {
79
- const transferFunction = volumeActor.getProperty().getRGBTransferFunction(0);
80
- const range = transferFunction.getRange();
79
+ const meta = volumeActor.getMapper().getInputData().get('voxelManager');
80
+ if (!meta?.voxelManager) {
81
+ throw new Error('No voxel manager was found for the volume actor, or you cannot yet update opacity with a threshold using stacked images');
82
+ }
83
+ const range = meta.voxelManager.getRange();
81
84
  const ofun = vtkPiecewiseFunction.newInstance();
82
85
  if (threshold !== null) {
83
86
  const delta = Math.abs(range[1] - range[0]) * 0.001;
@@ -130,4 +133,4 @@ function getMaxOpacity(volumeActor) {
130
133
  }
131
134
  return maxOpacity;
132
135
  }
133
- export { getColormap, getColormapNames, registerColormap, findMatchingColormap, };
136
+ export { getColormap, getColormapNames, registerColormap, findMatchingColormap, getThresholdValue, getMaxOpacity, };
@@ -1 +1 @@
1
- export declare const version = "3.14.1";
1
+ export declare const version = "3.14.3";
@@ -1 +1 @@
1
- export const version = '3.14.1';
1
+ export const version = '3.14.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/core",
3
- "version": "3.14.1",
3
+ "version": "3.14.3",
4
4
  "description": "Cornerstone3D Core",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "./dist/esm/index.d.ts",
@@ -97,5 +97,5 @@
97
97
  "type": "individual",
98
98
  "url": "https://ohif.org/donate"
99
99
  },
100
- "gitHead": "4fd9d63750a79b46c97d25260bbfec92bedde7c2"
100
+ "gitHead": "902ff8c03f0bb19963532fcf6286155ecbdd2d98"
101
101
  }