@cornerstonejs/adapters 1.58.5 → 1.59.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.
@@ -5099,6 +5099,7 @@ var Events$2;
5099
5099
  Events["VOLUME_SCROLL_OUT_OF_BOUNDS"] = "CORNERSTONE_VOLUME_SCROLL_OUT_OF_BOUNDS";
5100
5100
  Events["CLIPPING_PLANES_UPDATED"] = "CORNERSTONE_CLIPPING_PLANES_UPDATED";
5101
5101
  Events["WEB_WORKER_PROGRESS"] = "CORNERSTONE_WEB_WORKER_PROGRESS";
5102
+ Events["COLORMAP_MODIFIED"] = "CORNERSTONE_COLORMAP_MODIFIED";
5102
5103
  })(Events$2 || (Events$2 = {}));
5103
5104
  var EVENTS = Events$2;
5104
5105
 
@@ -41587,6 +41588,13 @@ class BaseVolumeViewport extends Viewport$1 {
41587
41588
  cfun.setMappingRange(range[0], range[1]);
41588
41589
  volumeActor.getProperty().setRGBTransferFunction(0, cfun);
41589
41590
  this.viewportProperties.colormap = colormap$1;
41591
+ if (!suppressEvents) {
41592
+ const eventDetail = {
41593
+ viewportId: this.id,
41594
+ colormap: colormap$1
41595
+ };
41596
+ triggerEvent(this.element, EVENTS.COLORMAP_MODIFIED, eventDetail);
41597
+ }
41590
41598
  }
41591
41599
  setOpacity(colormap, volumeId) {
41592
41600
  const applicableVolumeActorInfo = this._getApplicableVolumeActor(volumeId);
@@ -42727,6 +42735,22 @@ function getViewportImageIds(viewport) {
42727
42735
  }
42728
42736
  }
42729
42737
 
42738
+ function getRandomSampleFromArray(array, size) {
42739
+ const clonedArray = [...array];
42740
+ if (size >= clonedArray.length) {
42741
+ shuffleArray(clonedArray);
42742
+ return clonedArray;
42743
+ }
42744
+ shuffleArray(clonedArray);
42745
+ return clonedArray.slice(0, size);
42746
+ }
42747
+ function shuffleArray(array) {
42748
+ for (let i = array.length - 1; i > 0; i--) {
42749
+ const j = Math.floor(Math.random() * (i + 1));
42750
+ [array[i], array[j]] = [array[j], array[i]];
42751
+ }
42752
+ }
42753
+
42730
42754
  function linePlaneIntersection(p0, p1, plane) {
42731
42755
  const [x0, y0, z0] = p0;
42732
42756
  const [x1, y1, z1] = p1;
@@ -42830,6 +42854,7 @@ var utilities = /*#__PURE__*/Object.freeze({
42830
42854
  getImageLegacy: getImageLegacy,
42831
42855
  getImageSliceDataForVolumeViewport: getImageSliceDataForVolumeViewport,
42832
42856
  getMinMax: getMinMax,
42857
+ getRandomSampleFromArray: getRandomSampleFromArray,
42833
42858
  getRuntimeId: getRuntimeId,
42834
42859
  getScalarDataType: getScalarDataType,
42835
42860
  getScalingParameters: getScalingParameters,
@@ -46308,6 +46333,11 @@ class StackViewport extends Viewport$1 {
46308
46333
  this.fillWithBackgroundColor();
46309
46334
  this.cpuRenderingInvalidated = true;
46310
46335
  this.render();
46336
+ const eventDetail = {
46337
+ viewportId: this.id,
46338
+ colormap: colormapData
46339
+ };
46340
+ triggerEvent(this.element, EVENTS.COLORMAP_MODIFIED, eventDetail);
46311
46341
  }
46312
46342
  setColormapGPU(colormap$1) {
46313
46343
  const ActorEntry = this.getDefaultActor();
@@ -46327,6 +46357,11 @@ class StackViewport extends Viewport$1 {
46327
46357
  }
46328
46358
  this.colormap = colormap$1;
46329
46359
  this.render();
46360
+ const eventDetail = {
46361
+ viewportId: this.id,
46362
+ colormap: colormap$1
46363
+ };
46364
+ triggerEvent(this.element, EVENTS.COLORMAP_MODIFIED, eventDetail);
46330
46365
  }
46331
46366
  unsetColormapGPU() {
46332
46367
  throw new Error('unsetColormapGPU not implemented.');