@aics/vole-app 2.15.0 → 3.1.2

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.
Files changed (79) hide show
  1. package/es/aics-image-viewer/components/App/ChannelUpdater.js +21 -3
  2. package/es/aics-image-viewer/components/App/index.js +156 -199
  3. package/es/aics-image-viewer/components/CellViewerCanvasWrapper/index.js +10 -9
  4. package/es/aics-image-viewer/components/ChannelsWidget.js +35 -22
  5. package/es/aics-image-viewer/components/ChannelsWidgetRow/index.js +27 -71
  6. package/es/aics-image-viewer/components/ChannelsWidgetRow/styles.css +0 -6
  7. package/es/aics-image-viewer/components/ColorPicker.js +1 -1
  8. package/es/aics-image-viewer/components/ControlPanel/index.js +5 -4
  9. package/es/aics-image-viewer/components/CustomizeWidget.js +12 -8
  10. package/es/aics-image-viewer/components/ErrorAlert/index.js +4 -4
  11. package/es/aics-image-viewer/components/GlobalVolumeControls.js +12 -10
  12. package/es/aics-image-viewer/components/StyleProvider/index.js +4 -2
  13. package/es/aics-image-viewer/components/TfEditor/index.js +304 -154
  14. package/es/aics-image-viewer/components/TfEditor/styles.css +53 -31
  15. package/es/aics-image-viewer/components/Toolbar/DownloadButton.js +1 -1
  16. package/es/aics-image-viewer/components/Toolbar/index.js +18 -16
  17. package/es/aics-image-viewer/components/shared/SharedCheckBox.js +1 -1
  18. package/es/aics-image-viewer/components/shared/SliderRow/styles.css +1 -0
  19. package/es/aics-image-viewer/components/shared/SmarterSlider.js +1 -1
  20. package/es/aics-image-viewer/components/shared/ViewerIcon.js +1 -1
  21. package/es/aics-image-viewer/components/useVolume.js +68 -59
  22. package/es/aics-image-viewer/shared/constants.js +2 -2
  23. package/es/aics-image-viewer/shared/utils/controlPointsToLut.js +57 -24
  24. package/es/aics-image-viewer/shared/utils/sceneStore.js +14 -4
  25. package/es/aics-image-viewer/shared/utils/storage.js +238 -0
  26. package/es/aics-image-viewer/shared/utils/test/storage.test.js +264 -0
  27. package/es/aics-image-viewer/shared/utils/test/urlParsing.test.js +249 -109
  28. package/es/aics-image-viewer/shared/utils/test/viewerChannelSettings.test.js +1 -1
  29. package/es/aics-image-viewer/shared/utils/urlParsing.js +287 -154
  30. package/es/aics-image-viewer/shared/utils/viewerState.js +4 -24
  31. package/es/aics-image-viewer/state/reset.js +111 -0
  32. package/es/aics-image-viewer/state/store.js +90 -0
  33. package/es/aics-image-viewer/state/subscribers.js +153 -0
  34. package/es/aics-image-viewer/state/test/reset.test.js +247 -0
  35. package/es/aics-image-viewer/state/util.js +71 -0
  36. package/es/index.js +3 -3
  37. package/package.json +18 -11
  38. package/type-declarations/aics-image-viewer/components/App/ChannelUpdater.d.ts +2 -4
  39. package/type-declarations/aics-image-viewer/components/App/types.d.ts +3 -3
  40. package/type-declarations/aics-image-viewer/components/AxisClipSliders/index.d.ts +6 -6
  41. package/type-declarations/aics-image-viewer/components/CellViewerCanvasWrapper/index.d.ts +5 -14
  42. package/type-declarations/aics-image-viewer/components/ChannelsWidget.d.ts +3 -6
  43. package/type-declarations/aics-image-viewer/components/ChannelsWidgetRow/index.d.ts +3 -6
  44. package/type-declarations/aics-image-viewer/components/ColorPicker.d.ts +1 -1
  45. package/type-declarations/aics-image-viewer/components/ControlPanel/index.d.ts +6 -7
  46. package/type-declarations/aics-image-viewer/components/CustomizeWidget.d.ts +2 -8
  47. package/type-declarations/aics-image-viewer/components/ErrorAlert/index.d.ts +4 -0
  48. package/type-declarations/aics-image-viewer/components/GlobalVolumeControls.d.ts +2 -9
  49. package/type-declarations/aics-image-viewer/components/MetadataViewer/index.d.ts +1 -1
  50. package/type-declarations/aics-image-viewer/components/StyleProvider/index.d.ts +1 -1
  51. package/type-declarations/aics-image-viewer/components/TfEditor/index.d.ts +10 -3
  52. package/type-declarations/aics-image-viewer/components/Toolbar/index.d.ts +3 -12
  53. package/type-declarations/aics-image-viewer/components/shared/SliderRow/index.d.ts +1 -1
  54. package/type-declarations/aics-image-viewer/components/shared/SmarterSlider.d.ts +1 -1
  55. package/type-declarations/aics-image-viewer/components/shared/ViewerIcon.d.ts +1 -1
  56. package/type-declarations/aics-image-viewer/components/useVolume.d.ts +7 -4
  57. package/type-declarations/aics-image-viewer/shared/constants.d.ts +5 -5
  58. package/type-declarations/aics-image-viewer/shared/types.d.ts +1 -1
  59. package/type-declarations/aics-image-viewer/shared/utils/controlPointsToLut.d.ts +9 -5
  60. package/type-declarations/aics-image-viewer/shared/utils/firebase/index.d.ts +1 -1
  61. package/type-declarations/aics-image-viewer/shared/utils/hooks.d.ts +1 -1
  62. package/type-declarations/aics-image-viewer/shared/utils/playControls.d.ts +1 -1
  63. package/type-declarations/aics-image-viewer/shared/utils/sceneStore.d.ts +8 -4
  64. package/type-declarations/aics-image-viewer/shared/utils/storage.d.ts +15 -0
  65. package/type-declarations/aics-image-viewer/shared/utils/urlParsing.d.ts +94 -31
  66. package/type-declarations/aics-image-viewer/shared/utils/viewerChannelSettings.d.ts +39 -1
  67. package/type-declarations/aics-image-viewer/shared/utils/viewerState.d.ts +3 -6
  68. package/type-declarations/aics-image-viewer/state/reset.d.ts +29 -0
  69. package/type-declarations/aics-image-viewer/state/store.d.ts +30 -0
  70. package/type-declarations/aics-image-viewer/state/subscribers.d.ts +4 -0
  71. package/type-declarations/aics-image-viewer/state/types.d.ts +46 -0
  72. package/type-declarations/aics-image-viewer/state/util.d.ts +8 -0
  73. package/type-declarations/index.d.ts +4 -4
  74. package/es/aics-image-viewer/components/ViewerStateProvider/ResetStateProvider.js +0 -163
  75. package/es/aics-image-viewer/components/ViewerStateProvider/index.js +0 -259
  76. package/type-declarations/aics-image-viewer/components/ViewerStateProvider/ResetStateProvider.d.ts +0 -34
  77. package/type-declarations/aics-image-viewer/components/ViewerStateProvider/index.d.ts +0 -33
  78. package/type-declarations/aics-image-viewer/components/ViewerStateProvider/types.d.ts +0 -107
  79. /package/es/aics-image-viewer/{components/ViewerStateProvider → state}/types.js +0 -0
@@ -1,18 +1,22 @@
1
- .channel-row .tf-editor-svg.dragging.basic{
2
- cursor:ew-resize;
3
- }
1
+ .channel-row .tf-editor{
2
+ margin-top:27px;
3
+ }
4
4
 
5
- .channel-row .tf-editor-svg.dragging.advanced{
6
- cursor:move;
7
- }
5
+ .channel-row .tf-editor .tf-editor-svg.dragging-slider{
6
+ cursor:ew-resize;
7
+ }
8
8
 
9
- .channel-row .tf-editor-popover{
9
+ .channel-row .tf-editor .tf-editor-svg.dragging-point{
10
+ cursor:move;
11
+ }
12
+
13
+ .channel-row .tf-editor .tf-editor-popover{
10
14
  position:absolute;
11
15
  z-index:9999;
12
16
  width:100%;
13
17
  }
14
18
 
15
- .channel-row .tf-editor-cover{
19
+ .channel-row .tf-editor .tf-editor-cover{
16
20
  position:fixed;
17
21
  top:0;
18
22
  left:0;
@@ -20,32 +24,39 @@
20
24
  bottom:0;
21
25
  }
22
26
 
23
- .channel-row .tf-editor-control-row{
27
+ .channel-row .tf-editor .tf-editor-control-row{
24
28
  display:flex;
25
29
  color:var(--color-controlpanel-text);
30
+ justify-content:space-between;
26
31
  align-items:center;
27
32
  min-height:24px;
28
- gap:5px;
29
33
  }
30
34
 
31
- .channel-row .tf-editor-control-row.ramp-row{
32
- margin-top:15px;
35
+ .channel-row .tf-editor .tf-editor-control-row:not(:first-child){
36
+ margin-bottom:12px;
33
37
  }
34
38
 
35
- .channel-row .tf-editor-control-row.plot-range-row{
36
- margin-bottom:20px;
39
+ .channel-row .tf-editor .tf-editor-control-row > div{
40
+ display:flex;
41
+ gap:5px;
37
42
  }
38
43
 
39
- .channel-row .tf-editor-control-row .ant-input-number{
44
+ .channel-row .tf-editor .tf-editor-control-row .ant-input-number{
40
45
  border-color:var(--color-button-tertiary-outline);
41
46
  width:64px;
42
47
  }
43
48
 
44
- .channel-row .tf-editor-control-row .ant-input-number input{
49
+ .channel-row .tf-editor .tf-editor-control-row .ant-input-number input{
45
50
  text-align:right;
46
51
  }
47
52
 
48
- .channel-row .tick text{
53
+ .channel-row .tf-editor h4{
54
+ font-size:16px;
55
+ margin-top:0;
56
+ margin-bottom:12px;
57
+ }
58
+
59
+ .channel-row .tf-editor .tick text{
49
60
  fill:var(--color-controlpanel-text);
50
61
  user-select:none;
51
62
  -o-user-select:none;
@@ -54,47 +65,58 @@
54
65
  -webkit-user-select:none;
55
66
  }
56
67
 
57
- .channel-row rect.bar{
68
+ .channel-row .tf-editor rect.bar{
58
69
  fill:var(--color-controlpanel-border);
59
70
  }
60
71
 
61
- .channel-row .axis path,
62
- .channel-row .axis line{
72
+ .channel-row .tf-editor .axis path,
73
+ .channel-row .tf-editor .axis line{
63
74
  stroke:var(--color-controlpanel-border);
64
75
  }
65
76
 
66
- .channel-row rect{
77
+ .channel-row .tf-editor rect{
67
78
  fill:none;
68
79
  pointer-events:all;
69
80
  }
70
81
 
71
- .channel-row .line{
82
+ .channel-row .tf-editor .line{
72
83
  stroke:#aeacae;
73
84
  stroke-width:1px;
74
85
  }
75
86
 
76
- .channel-row .ramp-sliders path{
77
- fill:var(--color-controlpanel-ramp-slider);
87
+ .channel-row .tf-editor .sliders path,
88
+ .channel-row .tf-editor .sliders line{
78
89
  cursor:ew-resize;
79
90
  }
80
91
 
81
- .channel-row .ramp-sliders line{
82
- stroke:var(--color-controlpanel-ramp-slider);
83
- cursor:ew-resize;
92
+ .channel-row .tf-editor .sliders line.slider-click-target{
93
+ stroke:transparent;
84
94
  }
85
95
 
86
- .channel-row .ramp-sliders line.ramp-slider-click-target{
87
- stroke:transparent;
96
+ .channel-row .tf-editor .sliders.sliders-ramp path{
97
+ fill:var(--color-controlpanel-ramp-slider);
98
+ }
99
+
100
+ .channel-row .tf-editor .sliders.sliders-ramp line:not(.slider-click-target){
101
+ stroke:var(--color-controlpanel-ramp-slider);
102
+ }
103
+
104
+ .channel-row .tf-editor .sliders.sliders-isovalue path{
105
+ fill:var(--color-controlpanel-isovalue-slider);
106
+ }
107
+
108
+ .channel-row .tf-editor .sliders.sliders-isovalue line:not(.slider-click-target){
109
+ stroke:var(--color-controlpanel-isovalue-slider);
88
110
  }
89
111
 
90
- .channel-row circle{
112
+ .channel-row .tf-editor circle{
91
113
  fill-opacity:0.6;
92
114
  cursor:move;
93
115
  stroke:#aeacae;
94
116
  stroke-width:1.5px;
95
117
  }
96
118
 
97
- .channel-row circle.selected{
119
+ .channel-row .tf-editor circle.selected{
98
120
  fill:white;
99
121
  stroke:white;
100
122
  }
@@ -1,5 +1,5 @@
1
+ import { Button, Dropdown, Tooltip } from "antd";
1
2
  import React from "react";
2
- import { Dropdown, Button, Tooltip } from "antd";
3
3
  import ViewerIcon from "../shared/ViewerIcon";
4
4
  var DownloadButton = function DownloadButton(_ref) {
5
5
  var fovDownloadHref = _ref.fovDownloadHref,
@@ -9,8 +9,8 @@ import { Button, Radio, Select, Tooltip } from "antd";
9
9
  import { debounce } from "lodash";
10
10
  import React from "react";
11
11
  import { ImageType, RenderMode, ViewMode } from "../../shared/enums";
12
+ import { select, useViewerState } from "../../state/store";
12
13
  import ViewerIcon from "../shared/ViewerIcon";
13
- import { connectToViewerState } from "../ViewerStateProvider";
14
14
  import DownloadButton from "./DownloadButton";
15
15
  import ViewModeRadioButtons from "./ViewModeRadioButtons";
16
16
  import "./styles.css";
@@ -44,6 +44,13 @@ var Toolbar = function Toolbar(props) {
44
44
  _React$useState6 = _slicedToArray(_React$useState5, 2),
45
45
  showScrollBtnRight = _React$useState6[0],
46
46
  setScrollBtnRight = _React$useState6[1];
47
+ var imageType = useViewerState(select("imageType"));
48
+ var renderMode = useViewerState(select("renderMode"));
49
+ var viewMode = useViewerState(select("viewMode"));
50
+ var autorotate = useViewerState(select("autorotate"));
51
+ var showAxes = useViewerState(select("showAxes"));
52
+ var showBoundingBox = useViewerState(select("showBoundingBox"));
53
+ var changeViewerSetting = useViewerState(select("changeViewerSetting"));
47
54
 
48
55
  // Scroll buttons are only visible when toolbar can be scrolled in that direction.
49
56
  // This may change on either scroll or resize.
@@ -105,22 +112,17 @@ var Toolbar = function Toolbar(props) {
105
112
  scrollX(e.deltaY);
106
113
  };
107
114
  var toggleAxis = function toggleAxis() {
108
- return props.changeViewerSetting("showAxes", !props.showAxes);
115
+ return changeViewerSetting("showAxes", !showAxes);
109
116
  };
110
117
  var toggleBoundingBox = function toggleBoundingBox() {
111
- return props.changeViewerSetting("showBoundingBox", !props.showBoundingBox);
118
+ return changeViewerSetting("showBoundingBox", !showBoundingBox);
112
119
  };
113
120
  // TODO remove ant-btn-icon-only hack when upgrading antd
114
121
  var classForToggleBtn = function classForToggleBtn(active) {
115
122
  return "ant-btn-icon-only btn-borderless" + (active ? " btn-active" : "");
116
123
  };
117
- var changeViewerSetting = props.changeViewerSetting,
118
- resetToSavedViewerState = props.resetToSavedViewerState,
119
- visibleControls = props.visibleControls,
120
- showAxes = props.showAxes,
121
- showBoundingBox = props.showBoundingBox,
122
- autorotate = props.autorotate;
123
- var twoDMode = props.viewMode !== ViewMode.threeD;
124
+ var visibleControls = props.visibleControls;
125
+ var twoDMode = viewMode !== ViewMode.threeD;
124
126
  var renderGroup1 = visibleControls.viewModeRadioButtons || visibleControls.resetCameraButton || visibleControls.autoRotateButton;
125
127
  var renderGroup4 = visibleControls.showAxesButton || visibleControls.showBoundingBoxButton;
126
128
  var axesToggleTitle = showAxes ? "Hide axes" : "Show axes";
@@ -160,7 +162,7 @@ var Toolbar = function Toolbar(props) {
160
162
  trigger: ["focus", "hover"]
161
163
  }, /*#__PURE__*/React.createElement(Button, {
162
164
  className: "ant-btn-icon-only btn-borderless",
163
- onClick: resetToSavedViewerState
165
+ onClick: props.resetToSavedViewerState
164
166
  }, /*#__PURE__*/React.createElement(ReloadOutlined, null), /*#__PURE__*/React.createElement("span", {
165
167
  style: visuallyHiddenStyle
166
168
  }, "Reset to initial settings")))), /*#__PURE__*/React.createElement("div", {
@@ -169,7 +171,7 @@ var Toolbar = function Toolbar(props) {
169
171
  }, renderGroup1 && /*#__PURE__*/React.createElement("div", {
170
172
  className: "viewer-toolbar-group"
171
173
  }, visibleControls.viewModeRadioButtons && /*#__PURE__*/React.createElement(ViewModeRadioButtons, {
172
- mode: props.viewMode,
174
+ mode: viewMode,
173
175
  onViewModeChange: function onViewModeChange(newMode) {
174
176
  return changeViewerSetting("viewMode", newMode);
175
177
  }
@@ -186,7 +188,7 @@ var Toolbar = function Toolbar(props) {
186
188
  title: turntableToggleTitle
187
189
  }, /*#__PURE__*/React.createElement(Button, {
188
190
  className: classForToggleBtn(autorotate && !twoDMode),
189
- disabled: twoDMode || props.renderMode === RenderMode.pathTrace,
191
+ disabled: twoDMode || renderMode === RenderMode.pathTrace,
190
192
  onClick: function onClick() {
191
193
  return changeViewerSetting("autorotate", !autorotate);
192
194
  }
@@ -195,7 +197,7 @@ var Toolbar = function Toolbar(props) {
195
197
  })))), visibleControls.fovCellSwitchControls && props.hasCellId && props.hasParentImage && /*#__PURE__*/React.createElement("div", {
196
198
  className: "viewer-toolbar-group"
197
199
  }, /*#__PURE__*/React.createElement(Radio.Group, {
198
- value: props.imageType,
200
+ value: imageType,
199
201
  onChange: function onChange(_ref) {
200
202
  var target = _ref.target;
201
203
  return changeViewerSetting("imageType", target.value);
@@ -209,7 +211,7 @@ var Toolbar = function Toolbar(props) {
209
211
  }, /*#__PURE__*/React.createElement(Select, {
210
212
  className: "select-render-setting",
211
213
  popupClassName: "viewer-toolbar-dropdown",
212
- value: props.renderMode,
214
+ value: renderMode,
213
215
  onChange: function onChange(value) {
214
216
  return changeViewerSetting("renderMode", value);
215
217
  },
@@ -275,4 +277,4 @@ var Toolbar = function Toolbar(props) {
275
277
  }
276
278
  })));
277
279
  };
278
- export default connectToViewerState(Toolbar, ["imageType", "renderMode", "viewMode", "autorotate", "showAxes", "showBoundingBox", "changeViewerSetting", "resetToSavedViewerState"]);
280
+ export default Toolbar;
@@ -1,5 +1,5 @@
1
- import React from "react";
2
1
  import { Checkbox } from "antd";
2
+ import React from "react";
3
3
  var SharedCheckbox = function SharedCheckbox(props) {
4
4
  var onCheckAllChange = function onCheckAllChange(_ref) {
5
5
  var target = _ref.target;
@@ -2,6 +2,7 @@
2
2
  display:flex;
3
3
  align-items:center;
4
4
  margin-right:10px;
5
+ gap:5px;
5
6
  }
6
7
 
7
8
  .viewer-control-row:not(:last-child){
@@ -10,8 +10,8 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
10
10
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
11
11
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
12
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
13
- import React from "react";
14
13
  import Nouislider from "nouislider-react";
14
+ import React from "react";
15
15
  var MemoedNouislider = /*#__PURE__*/React.memo(Nouislider, function (_prevProps, _ref) {
16
16
  var noUpdate = _ref.noUpdate;
17
17
  return noUpdate;
@@ -5,8 +5,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
5
5
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
6
6
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
7
7
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
- import React from "react";
9
8
  import Icon from "@ant-design/icons";
9
+ import React from "react";
10
10
  import ICONS from "../../assets/icons";
11
11
  var STYLE = {
12
12
  fontSize: "19px"
@@ -1,5 +1,13 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
2
+ function _regeneratorRuntime() { "use strict"; var r = _regenerator(), e = r.m(_regeneratorRuntime), t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor; function n(r) { var e = "function" == typeof r && r.constructor; return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name)); } var o = { "throw": 1, "return": 2, "break": 3, "continue": 3 }; function a(r) { var e, t; return function (n) { e || (e = { stop: function stop() { return t(n.a, 2); }, "catch": function _catch() { return n.v; }, abrupt: function abrupt(r, e) { return t(n.a, o[r], e); }, delegateYield: function delegateYield(r, o, a) { return e.resultName = o, t(n.d, _regeneratorValues(r), a); }, finish: function finish(r) { return t(n.f, r); } }, t = function t(r, _t, o) { n.p = e.prev, n.n = e.next; try { return r(_t, o); } finally { e.next = n.n; } }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n; try { return r.call(this, e); } finally { n.p = e.prev, n.n = e.next; } }; } return (_regeneratorRuntime = function _regeneratorRuntime() { return { wrap: function wrap(e, t, n, o) { return r.w(a(e), t, n, o && o.reverse()); }, isGeneratorFunction: n, mark: r.m, awrap: function awrap(r, e) { return new _OverloadYield(r, e); }, AsyncIterator: _regeneratorAsyncIterator, async: function async(r, e, t, o, u) { return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u); }, keys: _regeneratorKeys, values: _regeneratorValues }; })(); }
3
+ function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function next() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(_typeof(e) + " is not iterable"); }
4
+ function _regeneratorKeys(e) { var n = Object(e), r = []; for (var t in n) r.unshift(t); return function e() { for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e; return e.done = !0, e; }; }
5
+ function _regeneratorAsync(n, e, r, t, o) { var a = _regeneratorAsyncGen(n, e, r, t, o); return a.next().then(function (n) { return n.done ? n.value : a.next(); }); }
6
+ function _regeneratorAsyncGen(r, e, t, o, n) { return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise); }
7
+ function _regeneratorAsyncIterator(t, e) { function n(r, o, i, f) { try { var c = t[r](o), u = c.value; return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) { n("next", t, i, f); }, function (t) { n("throw", t, i, f); }) : e.resolve(u).then(function (t) { c.value = t, i(c); }, function (t) { return n("throw", t, i, f); }); } catch (t) { f(t); } } var r; this.next || (_regeneratorDefine2(_regeneratorAsyncIterator.prototype), _regeneratorDefine2(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () { return this; })), _regeneratorDefine2(this, "_invoke", function (t, o, i) { function f() { return new e(function (e, r) { n(t, i, e, r); }); } return r = r ? r.then(f, f) : f(); }, !0); }
8
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
9
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
10
+ function _OverloadYield(e, d) { this.v = e, this.k = d; }
3
11
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
4
12
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
5
13
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -14,16 +22,16 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
14
22
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
15
23
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
16
24
  import { LoadSpec, VolumeLoaderContext } from "@aics/vole-core";
17
- import { useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
25
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
18
26
  import { Box3, Vector3 } from "three";
19
- import { AXIS_TO_LOADER_PRIORITY, CACHE_MAX_SIZE, getDefaultChannelColor, QUEUE_MAX_LOW_PRIORITY_SIZE, QUEUE_MAX_SIZE } from "../shared/constants";
27
+ import { AXIS_TO_LOADER_PRIORITY, CACHE_MAX_SIZE, getDefaultChannelColor, getDefaultViewerChannelSettings, QUEUE_MAX_LOW_PRIORITY_SIZE, QUEUE_MAX_SIZE } from "../shared/constants";
20
28
  import { ViewMode } from "../shared/enums";
21
29
  import { useConstructor, useRefWithSetter } from "../shared/utils/hooks";
22
30
  import PlayControls from "../shared/utils/playControls";
23
31
  import SceneStore from "../shared/utils/sceneStore";
24
- import { getDisplayName, makeChannelIndexGrouping } from "../shared/utils/viewerChannelSettings";
32
+ import { makeChannelIndexGrouping } from "../shared/utils/viewerChannelSettings";
25
33
  import { initializeOneChannelSetting } from "../shared/utils/viewerState";
26
- import { ViewerStateContext } from "./ViewerStateProvider";
34
+ import { select, useViewerState } from "../state/store";
27
35
  export var ImageLoadStatus = /*#__PURE__*/function (ImageLoadStatus) {
28
36
  ImageLoadStatus[ImageLoadStatus["REQUESTED"] = 0] = "REQUESTED";
29
37
  ImageLoadStatus[ImageLoadStatus["LOADING"] = 1] = "LOADING";
@@ -31,8 +39,11 @@ export var ImageLoadStatus = /*#__PURE__*/function (ImageLoadStatus) {
31
39
  ImageLoadStatus[ImageLoadStatus["ERROR"] = 3] = "ERROR";
32
40
  return ImageLoadStatus;
33
41
  }({});
34
-
35
- // Used by `channelVersions` (see below)
42
+ var LoadType = /*#__PURE__*/function (LoadType) {
43
+ LoadType[LoadType["TIME"] = 0] = "TIME";
44
+ LoadType[LoadType["SCENE"] = 1] = "SCENE";
45
+ return LoadType;
46
+ }(LoadType || {}); // Used by `channelVersions` (see below)
36
47
  var CHANNEL_INITIAL_LOAD = -1;
37
48
  var CHANNEL_RELOAD = 0;
38
49
  /**
@@ -63,9 +74,12 @@ var useEffectEventRef = function useEffectEventRef(callback) {
63
74
  * @returns An object with the current image, its load status, and controls for playback and loading.
64
75
  */
65
76
  var useVolume = function useVolume(scenePaths, options) {
66
- var viewerStateRef = useContext(ViewerStateContext).ref;
77
+ var channelSettings = useViewerState(select("channelSettings"));
78
+ var changeViewerSetting = useViewerState(select("changeViewerSetting"));
79
+ var replaceAllChannelSettings = useViewerState(select("replaceAllChannelSettings"));
67
80
  var onErrorRef = useEffectEventRef(options === null || options === void 0 ? void 0 : options.onError);
68
81
  var onChannelLoadedRef = useEffectEventRef(options === null || options === void 0 ? void 0 : options.onChannelLoaded);
82
+ var onChangeSceneRef = useEffectEventRef(options === null || options === void 0 ? void 0 : options.onChangeScene);
69
83
  var onCreateImageRef = useEffectEventRef(options === null || options === void 0 ? void 0 : options.onCreateImage);
70
84
  var maskChannelName = options === null || options === void 0 ? void 0 : options.maskChannelName;
71
85
 
@@ -117,7 +131,7 @@ var useVolume = function useVolume(scenePaths, options) {
117
131
  _useRefWithSetter2 = _slicedToArray(_useRefWithSetter, 2),
118
132
  channelVersionsRef = _useRefWithSetter2[0],
119
133
  setChannelVersions = _useRefWithSetter2[1];
120
- var channelSettings = viewerStateRef.current.channelSettings;
134
+
121
135
  // Some extra items for tracking load status
122
136
  var _useState7 = useState(false),
123
137
  _useState8 = _slicedToArray(_useState7, 2),
@@ -149,10 +163,13 @@ var useVolume = function useVolume(scenePaths, options) {
149
163
  }
150
164
  return noneLoaded ? ImageLoadStatus.REQUESTED : allLoaded ? ImageLoadStatus.LOADED : ImageLoadStatus.LOADING;
151
165
  }, [channelVersions, channelSettings, maskChannelName, loadThrewError]);
152
- var setIsLoading = useCallback(function () {
166
+ var setIsLoading = useCallback(function (loadType) {
153
167
  setLoadThrewError(false);
154
168
  setChannelVersions(channelVersionsRef.current.map(function (version) {
155
- return Math.min(version, CHANNEL_RELOAD);
169
+ return (
170
+ // For scenes, reinitialize all channels.
171
+ Math.min(version, loadType === LoadType.SCENE ? CHANNEL_INITIAL_LOAD : CHANNEL_RELOAD)
172
+ );
156
173
  }));
157
174
  }, [channelVersionsRef, setChannelVersions]);
158
175
  var onError = useCallback(function (e) {
@@ -186,55 +203,41 @@ var useVolume = function useVolume(scenePaths, options) {
186
203
 
187
204
  // effect to start the initial load of the image
188
205
  useEffect(function () {
189
- var _viewerStateRef$curre = viewerStateRef.current,
190
- changeViewerSetting = _viewerStateRef$curre.changeViewerSetting,
191
- channelSettings = _viewerStateRef$curre.channelSettings,
192
- getCurrentViewerChannelSettings = _viewerStateRef$curre.getCurrentViewerChannelSettings,
193
- setChannelSettings = _viewerStateRef$curre.setChannelSettings;
206
+ var channelSettings = useViewerState.getState().channelSettings;
194
207
  setChannelVersions(new Array(channelVersionsRef.current.length).fill(CHANNEL_INITIAL_LOAD));
195
208
  setLoadThrewError(false);
196
209
  inInitialLoadRef.current = true;
197
210
  var setChannelStateForNewImage = function setChannelStateForNewImage(channelNames) {
198
- var viewerChannelSettings = getCurrentViewerChannelSettings();
211
+ var _useViewerState$getSt = useViewerState.getState(),
212
+ useDefaultViewerChannelSettings = _useViewerState$getSt.useDefaultViewerChannelSettings;
213
+ var viewerChannelSettings = useDefaultViewerChannelSettings ? getDefaultViewerChannelSettings() : options === null || options === void 0 ? void 0 : options.viewerChannelSettings;
199
214
  var grouping = makeChannelIndexGrouping(channelNames, viewerChannelSettings);
200
215
  setChannelGroupedByType(grouping);
201
-
202
- // compare each channel's new displayName to the old displayNames currently in state:
203
- // same number of channels, and each channel has same displayName
204
- var allNamesAreEqual = channelNames.every(function (name, idx) {
205
- var _channelSettings$idx;
206
- var displayName = getDisplayName(name, idx, viewerChannelSettings);
207
- return displayName === ((_channelSettings$idx = channelSettings[idx]) === null || _channelSettings$idx === void 0 ? void 0 : _channelSettings$idx.displayName);
208
- });
209
- if (allNamesAreEqual) {
210
- var _newChannelSettings = channelNames.map(function (channel, index) {
211
- return _objectSpread(_objectSpread({}, channelSettings[index]), {}, {
212
- name: channel
213
- });
214
- });
215
- setChannelSettings(_newChannelSettings);
216
- return _newChannelSettings;
217
- }
218
- var newChannelSettings = channelNames.map(function (channel, index) {
216
+ var newChannelSettings = channelNames.map(function (name, index) {
217
+ var _channelSettings$inde;
219
218
  var color = getDefaultChannelColor(index);
220
- return initializeOneChannelSetting(channel, index, color, viewerChannelSettings);
219
+ var channelSetting = (_channelSettings$inde = channelSettings[index]) !== null && _channelSettings$inde !== void 0 ? _channelSettings$inde : initializeOneChannelSetting(name, index, color, viewerChannelSettings);
220
+ return _objectSpread(_objectSpread({}, channelSetting), {}, {
221
+ name: name
222
+ });
221
223
  });
222
- setChannelSettings(newChannelSettings);
224
+ replaceAllChannelSettings(newChannelSettings);
223
225
  return newChannelSettings;
224
226
  };
225
227
  var openImage = /*#__PURE__*/function () {
226
228
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
227
- var _onCreateImageRef$cur, _getCurrentViewerChan;
228
- var _viewerStateRef$curre2, scene, time, loadSpec, aimg, channelNames, newChannelSettings, requiredLoadSpec, requiredChannelsToLoad, maskChannelName, maskChannelIndex, slice;
229
+ var _onCreateImageRef$cur;
230
+ var scene, time, loadSpec, aimg, channelNames, newChannelSettings, requiredLoadSpec, requiredChannelsToLoad, _useViewerState$getSt2, useDefaultViewerChannelSettings, viewerChannelSettings, maskChannelName, maskChannelIndex, viewMode, slice, onCreateScene;
229
231
  return _regeneratorRuntime().wrap(function _callee$(_context) {
230
232
  while (1) switch (_context.prev = _context.next) {
231
233
  case 0:
232
- _viewerStateRef$curre2 = viewerStateRef.current, scene = _viewerStateRef$curre2.scene, time = _viewerStateRef$curre2.time;
234
+ scene = useViewerState.getState().scene;
235
+ time = useViewerState.getState().time;
233
236
  loadSpec = new LoadSpec();
234
237
  loadSpec.time = time;
235
- _context.next = 5;
238
+ _context.next = 6;
236
239
  return sceneLoader.createVolume(scene, loadSpec, onChannelDataLoaded)["catch"](onError);
237
- case 5:
240
+ case 6:
238
241
  aimg = _context.sent;
239
242
  channelNames = aimg.imageInfo.channelNames;
240
243
  newChannelSettings = setChannelStateForNewImage(channelNames);
@@ -242,9 +245,8 @@ var useVolume = function useVolume(scenePaths, options) {
242
245
  setImage(aimg);
243
246
  (_onCreateImageRef$cur = onCreateImageRef.current) === null || _onCreateImageRef$cur === void 0 || _onCreateImageRef$cur.call(onCreateImageRef, aimg);
244
247
  playControls.stepAxis = function (axis) {
245
- var _viewerStateRef$curre3 = viewerStateRef.current,
246
- time = _viewerStateRef$curre3.time,
247
- slice = _viewerStateRef$curre3.slice;
248
+ var time = useViewerState.getState().time;
249
+ var slice = useViewerState.getState().slice;
248
250
  if (axis === "t") {
249
251
  changeViewerSetting("time", (time + 1) % aimg.imageInfo.times);
250
252
  } else {
@@ -264,7 +266,9 @@ var useVolume = function useVolume(scenePaths, options) {
264
266
  }).filter(function (index) {
265
267
  return index >= 0;
266
268
  }) : []; // add mask channel to required channels, if specified
267
- maskChannelName = (_getCurrentViewerChan = getCurrentViewerChannelSettings()) === null || _getCurrentViewerChan === void 0 ? void 0 : _getCurrentViewerChan.maskChannelName;
269
+ _useViewerState$getSt2 = useViewerState.getState(), useDefaultViewerChannelSettings = _useViewerState$getSt2.useDefaultViewerChannelSettings;
270
+ viewerChannelSettings = useDefaultViewerChannelSettings ? getDefaultViewerChannelSettings() : options === null || options === void 0 ? void 0 : options.viewerChannelSettings;
271
+ maskChannelName = viewerChannelSettings === null || viewerChannelSettings === void 0 ? void 0 : viewerChannelSettings.maskChannelName;
268
272
  if (maskChannelName) {
269
273
  maskChannelIndex = channelNames.indexOf(maskChannelName);
270
274
  if (maskChannelIndex >= 0 && !requiredChannelsToLoad.includes(maskChannelIndex)) {
@@ -272,22 +276,24 @@ var useVolume = function useVolume(scenePaths, options) {
272
276
  }
273
277
  }
274
278
  requiredLoadSpec.channels = requiredChannelsToLoad;
275
-
276
- // When in 2D Z-axis view mode, we restrict the subregion to only the current slice. This is
279
+ viewMode = useViewerState.getState().viewMode;
280
+ slice = useViewerState.getState().slice; // When in 2D Z-axis view mode, we restrict the subregion to only the current slice. This is
277
281
  // to match an optimization that volume viewer does by loading Z-slices at a higher resolution,
278
282
  // and ensures the very first volume that is loaded is the same as the one that
279
283
  // will be shown whenever we switch back to the same viewer settings (2D Z-axis view mode).
280
284
  // (We don't do this for ZX and YZ modes because we assume that the data won't be chunked along the
281
285
  // X or Y axes in ways that would improve loading resolution, and we load the full 3D volume instead.)
282
- if (viewerStateRef.current.viewMode === ViewMode.xy) {
283
- slice = viewerStateRef.current.slice;
286
+ if (viewMode === ViewMode.xy) {
284
287
  requiredLoadSpec.subregion = new Box3(new Vector3(0, 0, slice.z), new Vector3(1, 1, slice.z));
285
288
  }
286
289
 
287
290
  // initiate loading only after setting up new channel settings,
288
291
  // in case the loader callback fires before the state is set
289
- sceneLoader.loadScene(scene, aimg, requiredLoadSpec)["catch"](onError);
290
- case 21:
292
+ onCreateScene = onChangeSceneRef.current;
293
+ sceneLoader.loadScene(scene, aimg, requiredLoadSpec, {
294
+ onCreateScene: onCreateScene
295
+ })["catch"](onError);
296
+ case 27:
291
297
  case "end":
292
298
  return _context.stop();
293
299
  }
@@ -298,21 +304,24 @@ var useVolume = function useVolume(scenePaths, options) {
298
304
  };
299
305
  }();
300
306
  openImage();
301
- }, [sceneLoader, onError, onCreateImageRef, onChannelLoadedRef, viewerStateRef, channelVersionsRef, setChannelVersions, playControls, setIsLoading, onChannelDataLoaded]);
307
+ }, [sceneLoader, onError, onCreateImageRef, onChangeSceneRef, onChannelLoadedRef, channelVersionsRef, setChannelVersions, playControls, setIsLoading, onChannelDataLoaded, changeViewerSetting, replaceAllChannelSettings, options === null || options === void 0 ? void 0 : options.viewerChannelSettings]);
302
308
  // of the above dependencies, we expect only `sceneLoader` to change.
303
309
 
304
310
  var setTime = useCallback(function (view3d, time) {
305
311
  if (image && !inInitialLoadRef.current) {
306
- view3d.setTime(image, time, onChannelDataLoaded)["catch"](onError);
307
- setIsLoading();
312
+ view3d.setTime(image, time)["catch"](onError);
313
+ setIsLoading(LoadType.TIME);
308
314
  }
309
- }, [image, onError, setIsLoading, inInitialLoadRef, onChannelDataLoaded]);
315
+ }, [image, onError, setIsLoading, inInitialLoadRef]);
310
316
  var setScene = useCallback(function (scene) {
311
317
  if (image && !inInitialLoadRef.current) {
312
- sceneLoader.loadScene(scene, image, undefined, onChannelDataLoaded)["catch"](onError);
313
- setIsLoading();
318
+ var onCreateScene = onChangeSceneRef.current;
319
+ sceneLoader.loadScene(scene, image, undefined, {
320
+ onCreateScene: onCreateScene
321
+ })["catch"](onError);
322
+ setIsLoading(LoadType.SCENE);
314
323
  }
315
- }, [image, onError, sceneLoader, setIsLoading, inInitialLoadRef, onChannelDataLoaded]);
324
+ }, [image, onError, sceneLoader, setIsLoading, inInitialLoadRef, onChangeSceneRef]);
316
325
  return useMemo(function () {
317
326
  return {
318
327
  image: image,
@@ -19,7 +19,6 @@ export var
19
19
  // and linearly increase intensity up to the LUT_MAX_PERCENTILE fraction of pixels.
20
20
  LUT_MIN_PERCENTILE = 0.5,
21
21
  LUT_MAX_PERCENTILE = 0.983,
22
- ISOSURFACE_OPACITY_SLIDER_MAX = 255.0,
23
22
  ALPHA_MASK_SLIDER_DEFAULT = 0,
24
23
  BRIGHTNESS_SLIDER_LEVEL_DEFAULT = 70,
25
24
  DENSITY_SLIDER_LEVEL_DEFAULT = 50,
@@ -208,6 +207,7 @@ export var getDefaultChannelState = function getDefaultChannelState() {
208
207
  color: [255, 255, 255]
209
208
  }],
210
209
  plotMin: 0,
211
- plotMax: TFEDITOR_MAX_BIN
210
+ plotMax: TFEDITOR_MAX_BIN,
211
+ keepIntensityRange: false
212
212
  };
213
213
  };