dwv 0.30.4 → 0.30.5

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/changelog.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.30.5](https://github.com/ivmartel/dwv/releases/tag/v0.30.5) - 16/12/2021
4
+
5
+ ### Fixed
6
+
7
+ - Allow to play multi-frame data [#1064](https://github.com/ivmartel/dwv/issues/1064)
8
+ - Allow scroll for multi-frame data [#1063](https://github.com/ivmartel/dwv/issues/1063)
9
+ - Stop worker if no tasks left [#1062](https://github.com/ivmartel/dwv/issues/1062)
10
+
11
+ ---
12
+
3
13
  ## [v0.30.4](https://github.com/ivmartel/dwv/releases/tag/v0.30.4) - 10/12/2021
4
14
 
5
15
  ### Fixed
package/dist/dwv.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! dwv 0.30.4 2021-12-10 19:20:41 */
1
+ /*! dwv 0.30.5 2021-12-16 11:23:07 */
2
2
  // Inspired from umdjs
3
3
  // See https://github.com/umdjs/umd/blob/master/templates/returnExports.js
4
4
  (function (root, factory) {
@@ -2813,7 +2813,8 @@ dwv.ctrl.ViewController = function (view) {
2813
2813
  /**
2814
2814
  * Can the data be scrolled?
2815
2815
  *
2816
- * @returns {boolean} True if the data has a third dimension greater than one.
2816
+ * @returns {boolean} True if the data has either the third dimension
2817
+ * or above greater than one.
2817
2818
  */
2818
2819
  this.canScroll = function () {
2819
2820
  return view.getImage().canScroll(view.getOrientation());
@@ -2959,22 +2960,36 @@ dwv.ctrl.ViewController = function (view) {
2959
2960
  * Scroll play: loop through all slices.
2960
2961
  */
2961
2962
  this.play = function () {
2963
+ // ensure data is scrollable: dim >= 3
2962
2964
  if (!this.canScroll()) {
2963
2965
  return;
2964
2966
  }
2965
2967
  if (playerID === null) {
2968
+ var image = view.getImage();
2966
2969
  var recommendedDisplayFrameRate =
2967
- view.getImage().getMeta().RecommendedDisplayFrameRate;
2970
+ image.getMeta().RecommendedDisplayFrameRate;
2968
2971
  var milliseconds = view.getPlaybackMilliseconds(
2969
2972
  recommendedDisplayFrameRate);
2973
+ var size = image.getGeometry().getSize();
2974
+ var canScroll3D = size.canScroll3D();
2970
2975
 
2971
2976
  playerID = setInterval(function () {
2977
+ var canDoMore = false;
2978
+ if (canScroll3D) {
2979
+ canDoMore = self.incrementScrollIndex();
2980
+ } else {
2981
+ canDoMore = self.incrementIndex(3);
2982
+ }
2972
2983
  // end of scroll, loop back
2973
- if (!self.incrementScrollIndex()) {
2984
+ if (!canDoMore) {
2974
2985
  var pos1 = self.getCurrentIndex();
2975
2986
  var values = pos1.getValues();
2976
2987
  var orientation = view.getOrientation();
2977
- values[orientation.getThirdColMajorDirection()] = 0;
2988
+ if (canScroll3D) {
2989
+ values[orientation.getThirdColMajorDirection()] = 0;
2990
+ } else {
2991
+ values[3] = 0;
2992
+ }
2978
2993
  var index = new dwv.math.Index(values);
2979
2994
  var geometry = view.getImage().getGeometry();
2980
2995
  self.setCurrentPosition(geometry.indexToWorld(index));
@@ -4404,7 +4419,7 @@ dwv.dicom = dwv.dicom || {};
4404
4419
  * @returns {string} The version of the library.
4405
4420
  */
4406
4421
  dwv.getVersion = function () {
4407
- return '0.30.4';
4422
+ return '0.30.5';
4408
4423
  };
4409
4424
 
4410
4425
  /**
@@ -17743,13 +17758,12 @@ dwv.image.Size.prototype.moreThanOne = function (dimension) {
17743
17758
  };
17744
17759
 
17745
17760
  /**
17746
- * Check if the third direction of an orientation matrix has a size
17747
- * of more than one.
17761
+ * Check if the associated data is scrollable in 3D.
17748
17762
  *
17749
17763
  * @param {dwv.math.Matrix33} viewOrientation The orientation matrix.
17750
17764
  * @returns {boolean} True if scrollable.
17751
17765
  */
17752
- dwv.image.Size.prototype.canScroll = function (viewOrientation) {
17766
+ dwv.image.Size.prototype.canScroll3D = function (viewOrientation) {
17753
17767
  var dimension = 2;
17754
17768
  if (typeof viewOrientation !== 'undefined') {
17755
17769
  dimension = viewOrientation.getThirdColMajorDirection();
@@ -17757,6 +17771,22 @@ dwv.image.Size.prototype.canScroll = function (viewOrientation) {
17757
17771
  return this.moreThanOne(dimension);
17758
17772
  };
17759
17773
 
17774
+ /**
17775
+ * Check if the associated data is scrollable: either in 3D or
17776
+ * in other directions.
17777
+ *
17778
+ * @param {dwv.math.Matrix33} viewOrientation The orientation matrix.
17779
+ * @returns {boolean} True if scrollable.
17780
+ */
17781
+ dwv.image.Size.prototype.canScroll = function (viewOrientation) {
17782
+ var canScroll = this.canScroll3D(viewOrientation);
17783
+ // check possible other dimensions
17784
+ for (var i = 3; i < this.length(); ++i) {
17785
+ canScroll = canScroll || this.moreThanOne(i);
17786
+ }
17787
+ return canScroll;
17788
+ };
17789
+
17760
17790
  /**
17761
17791
  * Get the size of a given dimension.
17762
17792
  *
@@ -31012,9 +31042,9 @@ dwv.tool.Scroll = function (app) {
31012
31042
  if (xMove && imageSize.moreThanOne(3)) {
31013
31043
  // update view controller
31014
31044
  if (diffX > 0) {
31015
- viewController.decrementIndex(3);
31016
- } else {
31017
31045
  viewController.incrementIndex(3);
31046
+ } else {
31047
+ viewController.decrementIndex(3);
31018
31048
  }
31019
31049
  }
31020
31050
 
@@ -34037,6 +34067,8 @@ dwv.utils.ThreadPool = function (poolSize) {
34037
34067
  // use input thread to run the waiting task
34038
34068
  workerThread.run(workerTask);
34039
34069
  } else {
34070
+ // stop the worker
34071
+ workerThread.stop();
34040
34072
  // no task to run, add to free list
34041
34073
  freeThreads.push(workerThread);
34042
34074
  // remove from running list