dwv 0.31.0-beta.20 → 0.31.0-beta.21

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/dist/dwv.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! dwv 0.31.0-beta.20 2022-12-19 10:41:20 */
1
+ /*! dwv 0.31.0-beta.21 2023-01-09 17:12:44 */
2
2
  // Inspired from umdjs
3
3
  // See https://github.com/umdjs/umd/blob/master/templates/returnExports.js
4
4
  (function (root, factory) {
@@ -617,7 +617,6 @@ dwv.App = function () {
617
617
  */
618
618
  this.fitToContainer = function () {
619
619
  stage.syncLayerGroupScale();
620
-
621
620
  };
622
621
 
623
622
  /**
@@ -4695,7 +4694,7 @@ dwv.dicom = dwv.dicom || {};
4695
4694
  * @returns {string} The version of the library.
4696
4695
  */
4697
4696
  dwv.getVersion = function () {
4698
- return '0.31.0-beta.20';
4697
+ return '0.31.0-beta.21';
4699
4698
  };
4700
4699
 
4701
4700
  /**
@@ -14004,23 +14003,19 @@ dwv.gui.LayerGroup = function (containerDiv) {
14004
14003
  var p2D = vc.getPlanePositionFromPosition(position);
14005
14004
  var displayPos = layer0.planePosToDisplay(p2D.x, p2D.y);
14006
14005
 
14007
- // 10px offset
14008
- // TODO: find why...
14009
- var offY = 10;
14010
-
14011
14006
  var lineH = document.createElement('hr');
14012
14007
  lineH.id = self.getDivId() + '-scroll-crosshair-horizontal';
14013
14008
  lineH.className = 'horizontal';
14014
14009
  lineH.style.width = containerDiv.offsetWidth + 'px';
14015
14010
  lineH.style.left = '0px';
14016
- lineH.style.top = (displayPos.y - offY) + 'px';
14011
+ lineH.style.top = displayPos.y + 'px';
14017
14012
 
14018
14013
  var lineV = document.createElement('hr');
14019
14014
  lineV.id = self.getDivId() + '-scroll-crosshair-vertical';
14020
14015
  lineV.className = 'vertical';
14021
14016
  lineV.style.width = containerDiv.offsetHeight + 'px';
14022
14017
  lineV.style.left = (displayPos.x) + 'px';
14023
- lineV.style.top = (-offY) + 'px';
14018
+ lineV.style.top = '0px';
14024
14019
 
14025
14020
  containerDiv.appendChild(lineH);
14026
14021
  containerDiv.appendChild(lineV);
@@ -14176,6 +14171,11 @@ dwv.gui.LayerGroup = function (containerDiv) {
14176
14171
  for (var j = 0; j < layers.length; ++j) {
14177
14172
  layers[j].fitToContainer(scaleIn, containerSize, fitOffset);
14178
14173
  }
14174
+
14175
+ // update crosshair
14176
+ if (showCrosshair) {
14177
+ showCrosshairDiv();
14178
+ }
14179
14179
  };
14180
14180
 
14181
14181
  /**
@@ -15741,8 +15741,8 @@ dwv.gui.ViewLayer = function (containerDiv) {
15741
15741
  if (viewOffset.x !== newViewOffset.x || viewOffset.y !== newViewOffset.y) {
15742
15742
  viewOffset = newViewOffset;
15743
15743
  offset = {
15744
- x: viewOffset.x + baseOffset.x + zoomOffset.x,
15745
- y: viewOffset.y + baseOffset.y + zoomOffset.y
15744
+ x: viewOffset.x + baseOffset.x + zoomOffset.x + flipOffset.x,
15745
+ y: viewOffset.y + baseOffset.y + zoomOffset.y + flipOffset.y
15746
15746
  };
15747
15747
  // update draw flag
15748
15748
  needsDraw = true;
@@ -19743,6 +19743,42 @@ dwv.image.getVariableRegionSliceIterator = function (
19743
19743
  1, offsetRegions);
19744
19744
  };
19745
19745
 
19746
+ /**
19747
+ * Get a colour iterator. The input array defines the colours and
19748
+ * their start index.
19749
+ *
19750
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols
19751
+ * @param {Array} colours An array of {index, colour} pairs.
19752
+ * @param {number} end The end of the range (excluded).
19753
+ * @returns {object} An iterator folowing the iterator and iterable protocol.
19754
+ */
19755
+ dwv.image.colourRange = function (colours, end) {
19756
+ var nextIndex = 0;
19757
+ var nextColourIndex = 0;
19758
+ // result
19759
+ return {
19760
+ next: function () {
19761
+ if (nextIndex < end) {
19762
+ if (nextColourIndex + 1 < colours.length &&
19763
+ nextIndex >= colours[nextColourIndex + 1].index) {
19764
+ ++nextColourIndex;
19765
+ }
19766
+ var result = {
19767
+ value: colours[nextColourIndex].colour,
19768
+ done: false,
19769
+ index: nextIndex
19770
+ };
19771
+ ++nextIndex;
19772
+ return result;
19773
+ }
19774
+ return {
19775
+ done: true,
19776
+ index: end
19777
+ };
19778
+ }
19779
+ };
19780
+ };
19781
+
19746
19782
  // namespaces
19747
19783
  var dwv = dwv || {};
19748
19784
  dwv.image = dwv.image || {};
@@ -20726,6 +20762,22 @@ dwv.image.MaskFactory.prototype.create = function (
20726
20762
  var tmpGeometry = new dwv.image.Geometry(
20727
20763
  frameOrigins[0], size, newSpacing, orientationMatrix);
20728
20764
 
20765
+ // origin distance test
20766
+ var isNotSmall = function (value) {
20767
+ var res = value > dwv.math.REAL_WORLD_EPSILON;
20768
+ if (res) {
20769
+ // try larger epsilon
20770
+ res = value > dwv.math.REAL_WORLD_EPSILON * 10;
20771
+ if (!res) {
20772
+ // warn if epsilon < value < epsilon * 10
20773
+ dwv.logger.warn(
20774
+ 'Using larger real world epsilon in SEG pos pat adding'
20775
+ );
20776
+ }
20777
+ }
20778
+ return res;
20779
+ };
20780
+
20729
20781
  // add possibly missing posPats
20730
20782
  var posPats = [];
20731
20783
  posPats.push(framePosPats[0]);
@@ -20737,8 +20789,9 @@ dwv.image.MaskFactory.prototype.create = function (
20737
20789
  var frameOrigin = frameOrigins[g];
20738
20790
  // check if more pos pats are needed
20739
20791
  var dist = frameOrigin.getDistance(point);
20792
+ var distPrevious = dist;
20740
20793
  // TODO: good threshold?
20741
- while (dist > dwv.math.REAL_WORLD_EPSILON) {
20794
+ while (isNotSmall(dist)) {
20742
20795
  dwv.logger.debug('Adding intermediate pos pats for DICOM seg at ' +
20743
20796
  point.toString());
20744
20797
  posPats.push([point.getX(), point.getY(), point.getZ()]);
@@ -20746,6 +20799,10 @@ dwv.image.MaskFactory.prototype.create = function (
20746
20799
  index = new dwv.math.Index([0, 0, sliceIndex]);
20747
20800
  point = tmpGeometry.indexToWorld(index).get3D();
20748
20801
  dist = frameOrigin.getDistance(point);
20802
+ if (dist > distPrevious) {
20803
+ throw new Error(
20804
+ 'Test distance is increasing when adding intermediate pos pats');
20805
+ }
20749
20806
  }
20750
20807
  // add frame pos pat
20751
20808
  posPats.push(framePosPats[g]);
@@ -26722,17 +26779,23 @@ dwv.math.getEllipseIndices = function (center, radius, dir) {
26722
26779
  values[dj] = jmax;
26723
26780
  indices.push(new dwv.math.Index(values.slice()));
26724
26781
  // right - bottom
26725
- values[dj] = jmin;
26726
- indices.push(new dwv.math.Index(values.slice()));
26782
+ if (jmin !== jmax) {
26783
+ values[dj] = jmin;
26784
+ indices.push(new dwv.math.Index(values.slice()));
26785
+ }
26727
26786
 
26728
26787
  // left
26729
- values[di] = imin;
26730
- // left - top
26731
- values[dj] = jmax;
26732
- indices.push(new dwv.math.Index(values.slice()));
26733
- // left - bottom
26734
- values[dj] = jmin;
26735
- indices.push(new dwv.math.Index(values.slice()));
26788
+ if (imin !== imax) {
26789
+ values[di] = imin;
26790
+ // left - top
26791
+ values[dj] = jmax;
26792
+ indices.push(new dwv.math.Index(values.slice()));
26793
+ // left - bottom
26794
+ if (jmin !== jmax) {
26795
+ values[dj] = jmin;
26796
+ indices.push(new dwv.math.Index(values.slice()));
26797
+ }
26798
+ }
26736
26799
  }
26737
26800
  }
26738
26801
  return indices;