@aics/vole-app 3.3.1 → 3.4.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.
- package/es/aics-image-viewer/components/App/index.js +1 -0
- package/es/aics-image-viewer/components/BottomPanel/index.js +48 -19
- package/es/aics-image-viewer/components/BottomPanel/styles.css +16 -7
- package/es/aics-image-viewer/components/CellViewerCanvasWrapper/index.js +39 -19
- package/es/aics-image-viewer/components/ControlPanel/index.js +2 -0
- package/es/aics-image-viewer/components/dimension_sliders/AxisClipSliders.js +148 -0
- package/es/aics-image-viewer/components/dimension_sliders/RotationSliders.js +167 -0
- package/es/aics-image-viewer/components/dimension_sliders/SliderRows.js +167 -0
- package/es/aics-image-viewer/components/{AxisClipSliders → dimension_sliders}/styles.css +7 -1
- package/es/aics-image-viewer/components/shared/NumericInput/index.js +4 -2
- package/es/aics-image-viewer/components/shared/SliderRow/index.js +2 -0
- package/es/aics-image-viewer/components/shared/SliderRow/styles.css +2 -1
- package/es/aics-image-viewer/shared/constants.js +1 -1
- package/es/aics-image-viewer/shared/utils/camera.js +122 -0
- package/es/aics-image-viewer/shared/utils/test/camera.test.js +127 -0
- package/es/aics-image-viewer/shared/utils/test/urlParsing.test.js +23 -702
- package/es/aics-image-viewer/shared/utils/urlParsing.js +14 -828
- package/es/aics-image-viewer/state/deserialize.js +437 -0
- package/es/aics-image-viewer/state/serialize.js +145 -0
- package/es/aics-image-viewer/state/test/deserialize.test.js +432 -0
- package/es/aics-image-viewer/state/test/serialize.test.js +97 -0
- package/es/aics-image-viewer/state/test/test_data.js +168 -0
- package/es/aics-image-viewer/state/types.js +265 -1
- package/package.json +2 -1
- package/type-declarations/aics-image-viewer/components/App/types.d.ts +1 -1
- package/type-declarations/aics-image-viewer/components/BottomPanel/index.d.ts +6 -3
- package/type-declarations/aics-image-viewer/components/CellViewerCanvasWrapper/index.d.ts +1 -0
- package/type-declarations/aics-image-viewer/components/{AxisClipSliders/index.d.ts → dimension_sliders/AxisClipSliders.d.ts} +2 -3
- package/type-declarations/aics-image-viewer/components/dimension_sliders/RotationSliders.d.ts +6 -0
- package/type-declarations/aics-image-viewer/components/dimension_sliders/SliderRows.d.ts +31 -0
- package/type-declarations/aics-image-viewer/components/shared/NumericInput/index.d.ts +1 -0
- package/type-declarations/aics-image-viewer/components/shared/SliderRow/index.d.ts +3 -1
- package/type-declarations/aics-image-viewer/shared/utils/camera.d.ts +19 -0
- package/type-declarations/aics-image-viewer/shared/utils/urlParsing.d.ts +1 -307
- package/type-declarations/aics-image-viewer/state/deserialize.d.ts +70 -0
- package/type-declarations/aics-image-viewer/state/serialize.d.ts +20 -0
- package/type-declarations/aics-image-viewer/state/types.d.ts +216 -0
- package/es/aics-image-viewer/components/AxisClipSliders/index.js +0 -295
|
@@ -1,5 +1,3 @@
|
|
|
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
|
-
var _ViewerChannelSetting, _ViewerChannelSetting2, _ViewerChannelSetting3, _ViewerChannelSetting4, _ViewerChannelSetting5, _ViewerChannelSetting6, _ViewerChannelSetting7, _ViewerChannelSetting8, _ViewerChannelSetting9, _ViewerChannelSetting10, _ViewerChannelSetting11, _ViewerChannelSetting12, _ViewerChannelSetting13, _ViewerChannelSetting14, _ViewerStateKeys$View, _ViewerStateKeys$Mode, _ViewerStateKeys$Mask, _ViewerStateKeys$Imag, _ViewerStateKeys$Axes, _ViewerStateKeys$Boun, _ViewerStateKeys$Sing, _ViewerStateKeys$Sing2, _ViewerStateKeys$Boun2, _ViewerStateKeys$Back, _ViewerStateKeys$Auto, _ViewerStateKeys$Brig, _ViewerStateKeys$Dens, _ViewerStateKeys$Leve, _ViewerStateKeys$Inte, _ViewerStateKeys$Regi, _ViewerStateKeys$Slic, _ViewerStateKeys$Time, _ViewerStateKeys$Scen, _ViewerStateKeys$UseE, _ViewerStateKeys$Scal, _ViewerStateKeys$Came;
|
|
3
1
|
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 }; })(); }
|
|
4
2
|
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"); }
|
|
5
3
|
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; }; }
|
|
@@ -9,10 +7,11 @@ function _regeneratorAsyncIterator(t, e) { function n(r, o, i, f) { try { var c
|
|
|
9
7
|
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 }; })(); }
|
|
10
8
|
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); }
|
|
11
9
|
function _OverloadYield(e, d) { this.v = e, this.k = d; }
|
|
12
|
-
function
|
|
13
|
-
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); }); }; }
|
|
10
|
+
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); }
|
|
14
11
|
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; }
|
|
15
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
+
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); }
|
|
14
|
+
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); }); }; }
|
|
16
15
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
17
16
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
18
17
|
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; } }
|
|
@@ -30,324 +29,19 @@ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Can
|
|
|
30
29
|
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; }
|
|
31
30
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
32
31
|
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); }
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
32
|
+
import { deserializeViewerChannelSetting, deserializeViewerState, parseKeyValueList } from "../../state/deserialize";
|
|
33
|
+
import { objectToKeyValueList, serializeViewerChannelSetting, serializeViewerState } from "../../state/serialize";
|
|
34
|
+
import { ViewerStateParams } from "../../state/types";
|
|
35
|
+
import { removeUndefinedProperties } from "./datatypes";
|
|
37
36
|
import FirebaseRequest from "./firebase";
|
|
38
|
-
import { clamp } from "./math";
|
|
39
37
|
import { readStoredMetadata, readStoredScenes } from "./storage";
|
|
40
|
-
export var ENCODED_COMMA_REGEX = /%2C/g;
|
|
41
|
-
export var ENCODED_COLON_REGEX = /%3A/g;
|
|
42
|
-
var DEFAULT_CONTROL_POINT_COLOR = [255, 255, 255];
|
|
43
|
-
var DEFAULT_CONTROL_POINT_COLOR_CODE = "1";
|
|
44
|
-
var FLOAT_REGEX = /-?[0-9]*.?[0-9]+/;
|
|
45
38
|
var CHANNEL_STATE_KEY_REGEX = /^c[0-9]+$/;
|
|
46
39
|
|
|
47
|
-
/** Match colon-separated pairs of alphanumeric strings */
|
|
48
|
-
var LUT_REGEX = /^-?[a-z0-9.]*:[ ]*-?[a-z0-9.]*$/;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Match colon-separated pairs of numeric strings, representing histogram bin
|
|
52
|
-
* indices or intensity values.
|
|
53
|
-
*/
|
|
54
|
-
var RAMP_REGEX = new RegExp("^".concat(FLOAT_REGEX.source, ":").concat(FLOAT_REGEX.source, "$"));
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Match comma-separated triplet of numeric strings.
|
|
58
|
-
*/
|
|
59
|
-
var SLICE_REGEX = new RegExp("^".concat(FLOAT_REGEX.source, ",").concat(FLOAT_REGEX.source, ",").concat(FLOAT_REGEX.source, "$"));
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Matches a sequence of three comma-separated min:max number pairs, representing
|
|
63
|
-
* the x, y, and z axes.
|
|
64
|
-
*/
|
|
65
|
-
var REGION_REGEX = new RegExp("^(".concat(FLOAT_REGEX.source, ":").concat(FLOAT_REGEX.source, ")(,").concat(FLOAT_REGEX.source, ":").concat(FLOAT_REGEX.source, "){2}$"));
|
|
66
|
-
var HEX_COLOR_REGEX = new RegExp("(([0-9a-fA-F]{6})|".concat(DEFAULT_CONTROL_POINT_COLOR_CODE, ")"));
|
|
67
|
-
|
|
68
|
-
/** Represents control points specified by bin indices. */
|
|
69
|
-
var CONTROL_POINT_REGEX = new RegExp("(".concat(FLOAT_REGEX.source, ":").concat(FLOAT_REGEX.source, ":").concat(HEX_COLOR_REGEX.source, ")"));
|
|
70
|
-
var HEX_COLOR_STR_REGEX = new RegExp("^".concat(HEX_COLOR_REGEX.source, "$"));
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* LEGACY: Matches a COMMA-separated list of control points, where each control point is represented
|
|
74
|
-
* by a triplet of `{x}:{opacity}:{hex color}`.
|
|
75
|
-
* The hex color can be replaced with `1` to represent white (`ffffff`).
|
|
76
|
-
*/
|
|
77
|
-
export var LEGACY_CONTROL_POINTS_REGEX = new RegExp("^".concat(CONTROL_POINT_REGEX.source, "(,").concat(CONTROL_POINT_REGEX.source, ")*$"));
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Matches a COLON-separated list of control points, where each control point is
|
|
81
|
-
* represented by a triplet of `{x}:{opacity}:{hex color}`.
|
|
82
|
-
* - `x` is a value that will either be parsed as a histogram bin index (legacy,
|
|
83
|
-
* for `ControlPointsLegacy`) or intensity value (for `ControlPoints`),
|
|
84
|
-
* depending on on which field is being parsed.
|
|
85
|
-
* - Opacity is a float in the [0, 1] range.
|
|
86
|
-
* - The hex color is a 6-digit hex color (e.g. `ffeecc`), and can be replaced
|
|
87
|
-
* with `1` to represent white (`ffffff`).
|
|
88
|
-
*/
|
|
89
|
-
export var CONTROL_POINTS_REGEX = new RegExp("^".concat(CONTROL_POINT_REGEX.source, "(:").concat(CONTROL_POINT_REGEX.source, ")*$"));
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Enum keys for URL parameters. These are stored as enums for better readability,
|
|
93
|
-
* and are mapped to types in `ViewerStateParams`.
|
|
94
|
-
*/
|
|
95
|
-
export var ViewerStateKeys = /*#__PURE__*/function (ViewerStateKeys) {
|
|
96
|
-
ViewerStateKeys["View"] = "view";
|
|
97
|
-
ViewerStateKeys["Mode"] = "mode";
|
|
98
|
-
ViewerStateKeys["Mask"] = "mask";
|
|
99
|
-
ViewerStateKeys["Image"] = "image";
|
|
100
|
-
ViewerStateKeys["Axes"] = "axes";
|
|
101
|
-
ViewerStateKeys["BoundingBox"] = "bb";
|
|
102
|
-
ViewerStateKeys["BoundingBoxColor"] = "bbcol";
|
|
103
|
-
ViewerStateKeys["BackgroundColor"] = "bgcol";
|
|
104
|
-
ViewerStateKeys["Autorotate"] = "rot";
|
|
105
|
-
ViewerStateKeys["Brightness"] = "bright";
|
|
106
|
-
ViewerStateKeys["Density"] = "dens";
|
|
107
|
-
ViewerStateKeys["Levels"] = "lvl";
|
|
108
|
-
ViewerStateKeys["Interpolation"] = "interp";
|
|
109
|
-
ViewerStateKeys["Region"] = "reg";
|
|
110
|
-
ViewerStateKeys["Slice"] = "slice";
|
|
111
|
-
ViewerStateKeys["Time"] = "t";
|
|
112
|
-
ViewerStateKeys["Scene"] = "scene";
|
|
113
|
-
ViewerStateKeys["CameraState"] = "cam";
|
|
114
|
-
ViewerStateKeys["SingleChannelMode"] = "scm";
|
|
115
|
-
ViewerStateKeys["SingleChannelIndex"] = "sci";
|
|
116
|
-
ViewerStateKeys["UseExactScaleLevel"] = "esl";
|
|
117
|
-
ViewerStateKeys["ScaleLevelIndex"] = "scl";
|
|
118
|
-
return ViewerStateKeys;
|
|
119
|
-
}({});
|
|
120
|
-
export var CameraTransformKeys = /*#__PURE__*/function (CameraTransformKeys) {
|
|
121
|
-
CameraTransformKeys["Position"] = "pos";
|
|
122
|
-
CameraTransformKeys["Target"] = "tar";
|
|
123
|
-
CameraTransformKeys["Up"] = "up";
|
|
124
|
-
CameraTransformKeys["OrthoScale"] = "ort";
|
|
125
|
-
CameraTransformKeys["Fov"] = "fov";
|
|
126
|
-
return CameraTransformKeys;
|
|
127
|
-
}({});
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Mapped to types in `ViewerChannelSettingParams`
|
|
131
|
-
*/
|
|
132
|
-
export var ViewerChannelSettingKeys = /*#__PURE__*/function (ViewerChannelSettingKeys) {
|
|
133
|
-
ViewerChannelSettingKeys["Color"] = "col";
|
|
134
|
-
ViewerChannelSettingKeys["Colorize"] = "clz";
|
|
135
|
-
ViewerChannelSettingKeys["ColorizeAlpha"] = "cza";
|
|
136
|
-
ViewerChannelSettingKeys["IsosurfaceAlpha"] = "isa";
|
|
137
|
-
ViewerChannelSettingKeys["Lut"] = "lut";
|
|
138
|
-
ViewerChannelSettingKeys["ControlPoints"] = "cpt";
|
|
139
|
-
ViewerChannelSettingKeys["ControlPointsLegacy"] = "cps";
|
|
140
|
-
ViewerChannelSettingKeys["Ramp"] = "ram";
|
|
141
|
-
ViewerChannelSettingKeys["RampLegacy"] = "rmp";
|
|
142
|
-
ViewerChannelSettingKeys["ControlPointsEnabled"] = "cpe";
|
|
143
|
-
ViewerChannelSettingKeys["VolumeEnabled"] = "ven";
|
|
144
|
-
ViewerChannelSettingKeys["SurfaceEnabled"] = "sen";
|
|
145
|
-
ViewerChannelSettingKeys["IsosurfaceValue"] = "isv";
|
|
146
|
-
ViewerChannelSettingKeys["KeepRange"] = "pin";
|
|
147
|
-
return ViewerChannelSettingKeys;
|
|
148
|
-
}({});
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* The serialized form of a ViewerChannelSetting, as a dictionary object.
|
|
152
|
-
*/
|
|
153
|
-
_ViewerChannelSetting = ViewerChannelSettingKeys.Color;
|
|
154
|
-
_ViewerChannelSetting2 = ViewerChannelSettingKeys.Colorize;
|
|
155
|
-
_ViewerChannelSetting3 = ViewerChannelSettingKeys.ColorizeAlpha;
|
|
156
|
-
_ViewerChannelSetting4 = ViewerChannelSettingKeys.IsosurfaceAlpha;
|
|
157
|
-
_ViewerChannelSetting5 = ViewerChannelSettingKeys.Lut;
|
|
158
|
-
_ViewerChannelSetting6 = ViewerChannelSettingKeys.ControlPointsLegacy;
|
|
159
|
-
_ViewerChannelSetting7 = ViewerChannelSettingKeys.ControlPoints;
|
|
160
|
-
_ViewerChannelSetting8 = ViewerChannelSettingKeys.ControlPointsEnabled;
|
|
161
|
-
_ViewerChannelSetting9 = ViewerChannelSettingKeys.RampLegacy;
|
|
162
|
-
_ViewerChannelSetting10 = ViewerChannelSettingKeys.Ramp;
|
|
163
|
-
_ViewerChannelSetting11 = ViewerChannelSettingKeys.VolumeEnabled;
|
|
164
|
-
_ViewerChannelSetting12 = ViewerChannelSettingKeys.SurfaceEnabled;
|
|
165
|
-
_ViewerChannelSetting13 = ViewerChannelSettingKeys.IsosurfaceValue;
|
|
166
|
-
_ViewerChannelSetting14 = ViewerChannelSettingKeys.KeepRange;
|
|
167
|
-
export var ViewerChannelSettingParams = /*#__PURE__*/_createClass(function ViewerChannelSettingParams() {
|
|
168
|
-
_classCallCheck(this, ViewerChannelSettingParams);
|
|
169
|
-
/** Color, as a 6-digit hex color. */
|
|
170
|
-
_defineProperty(this, _ViewerChannelSetting, undefined);
|
|
171
|
-
/** Colorize. "1" is enabled. Disabled by default. */
|
|
172
|
-
_defineProperty(this, _ViewerChannelSetting2, undefined);
|
|
173
|
-
/** Colorize alpha, in the [0, 1] range. Set to `1.0` by default. */
|
|
174
|
-
_defineProperty(this, _ViewerChannelSetting3, undefined);
|
|
175
|
-
/** Isosurface alpha, in the [0, 1 range]. Set to `1.0` by default.*/
|
|
176
|
-
_defineProperty(this, _ViewerChannelSetting4, undefined);
|
|
177
|
-
/**
|
|
178
|
-
* Lookup table (LUT) to map from volume intensity to opacity. Should be two
|
|
179
|
-
* alphanumeric values separated by a colon, where the first value is the
|
|
180
|
-
* minimum and the second is the maximum. Defaults to [0, 255].
|
|
181
|
-
*
|
|
182
|
-
* Min and max values are determined as following:
|
|
183
|
-
* - Plain numbers are indices of histogram bins, typically in the range [0,
|
|
184
|
-
* 255].
|
|
185
|
-
* - `v{n}` represents a raw intensity value, where `n` is a number.
|
|
186
|
-
* - `p{n}` represents a percentile, where `n` is a percentile in the [0, 100]
|
|
187
|
-
* range.
|
|
188
|
-
* - `m{n}` represents the median multiplied by `n / 100`.
|
|
189
|
-
* - `autoij` in either the min or max fields will use the "auto" algorithm
|
|
190
|
-
* from ImageJ to select the min and max.
|
|
191
|
-
*
|
|
192
|
-
* Values will be used to determine the initial control points and ramp if
|
|
193
|
-
* those fields are not provided.
|
|
194
|
-
*
|
|
195
|
-
* @example
|
|
196
|
-
* ```
|
|
197
|
-
* "0:255" // min: intensity 0, max: intensity 255.
|
|
198
|
-
* "p50:p90" // min: 50th percentile, max: 90th percentile.
|
|
199
|
-
* "m1:p75" // min: median, max: 75th percentile.
|
|
200
|
-
* "autoij:0" // use Auto-IJ to calculate min and max.
|
|
201
|
-
* ```
|
|
202
|
-
*/
|
|
203
|
-
_defineProperty(this, _ViewerChannelSetting5, undefined);
|
|
204
|
-
/**
|
|
205
|
-
* Legacy specifier for control points for the transfer function as a list of
|
|
206
|
-
* `x:opacity:color` triplets, separated by colon. Uses histogram bin indices
|
|
207
|
-
* instead of intensity values.
|
|
208
|
-
* - `x` is a histogram bin index in the [0, 255] range.
|
|
209
|
-
* - `opacity` is a float in the [0, 1] range.
|
|
210
|
-
* - `color` is a 6-digit hex color, e.g. `ff0000`.
|
|
211
|
-
*
|
|
212
|
-
* Will be overridden by the ControlPoints field (`cpt`) if provided.
|
|
213
|
-
*/
|
|
214
|
-
_defineProperty(this, _ViewerChannelSetting6, undefined);
|
|
215
|
-
/**
|
|
216
|
-
* Control points for the transfer function, formatted as a list of
|
|
217
|
-
* `x:opacity:color` triplets, separated by colons.
|
|
218
|
-
* - `x` is a numeric intensity value.
|
|
219
|
-
* - `opacity` is a float in the [0, 1] range.
|
|
220
|
-
* - `color` is a 6-digit hex color, e.g. `ff0000`.
|
|
221
|
-
*
|
|
222
|
-
* If provided, overrides the `lut` field when calculating the control points.
|
|
223
|
-
*/
|
|
224
|
-
_defineProperty(this, _ViewerChannelSetting7, undefined);
|
|
225
|
-
/**
|
|
226
|
-
* Whether to show advanced mode, which will show control points instead of
|
|
227
|
-
* ramp values defined by the LUT. "1" is enabled, disabled by default.
|
|
228
|
-
*/
|
|
229
|
-
_defineProperty(this, _ViewerChannelSetting8, undefined);
|
|
230
|
-
/**
|
|
231
|
-
* Legacy specifier for the transfer function ramp which uses histogram bin
|
|
232
|
-
* indices instead of intensity values, formatted as `min:max`. Will be
|
|
233
|
-
* overridden by the Ramp field (`ram`) if provided.
|
|
234
|
-
*/
|
|
235
|
-
_defineProperty(this, _ViewerChannelSetting9, undefined);
|
|
236
|
-
/**
|
|
237
|
-
* Ramp min and max intensity values (`min:max`). If provided, overrides the
|
|
238
|
-
* `lut` field when calculating the ramp.
|
|
239
|
-
*/
|
|
240
|
-
_defineProperty(this, _ViewerChannelSetting10, undefined);
|
|
241
|
-
/** Volume enabled. "1" is enabled. Disabled by default. */
|
|
242
|
-
_defineProperty(this, _ViewerChannelSetting11, undefined);
|
|
243
|
-
/** Isosurface enabled. "1" is enabled. Disabled by default. */
|
|
244
|
-
_defineProperty(this, _ViewerChannelSetting12, undefined);
|
|
245
|
-
/** Isosurface value, in the [0, 255] range. Set to `128` by default. */
|
|
246
|
-
_defineProperty(this, _ViewerChannelSetting13, undefined);
|
|
247
|
-
/**
|
|
248
|
-
* Whether to keep the current contrast settings when loading a new volume.
|
|
249
|
-
* "1" is enabled. Disabled by default.
|
|
250
|
-
*/
|
|
251
|
-
_defineProperty(this, _ViewerChannelSetting14, undefined);
|
|
252
|
-
});
|
|
253
40
|
/**
|
|
254
41
|
* Channels, matching the pattern `c0`, `c1`, etc. corresponding to the index of the channel being configured.
|
|
255
42
|
* The channel parameter should have a value that is a comma-separated list of `key:value` pairs, with keys
|
|
256
43
|
* defined in `ViewerChannelSettingJson`.
|
|
257
44
|
*/
|
|
258
|
-
_ViewerStateKeys$View = ViewerStateKeys.View;
|
|
259
|
-
_ViewerStateKeys$Mode = ViewerStateKeys.Mode;
|
|
260
|
-
_ViewerStateKeys$Mask = ViewerStateKeys.Mask;
|
|
261
|
-
_ViewerStateKeys$Imag = ViewerStateKeys.Image;
|
|
262
|
-
_ViewerStateKeys$Axes = ViewerStateKeys.Axes;
|
|
263
|
-
_ViewerStateKeys$Boun = ViewerStateKeys.BoundingBox;
|
|
264
|
-
_ViewerStateKeys$Sing = ViewerStateKeys.SingleChannelMode;
|
|
265
|
-
_ViewerStateKeys$Sing2 = ViewerStateKeys.SingleChannelIndex;
|
|
266
|
-
_ViewerStateKeys$Boun2 = ViewerStateKeys.BoundingBoxColor;
|
|
267
|
-
_ViewerStateKeys$Back = ViewerStateKeys.BackgroundColor;
|
|
268
|
-
_ViewerStateKeys$Auto = ViewerStateKeys.Autorotate;
|
|
269
|
-
_ViewerStateKeys$Brig = ViewerStateKeys.Brightness;
|
|
270
|
-
_ViewerStateKeys$Dens = ViewerStateKeys.Density;
|
|
271
|
-
_ViewerStateKeys$Leve = ViewerStateKeys.Levels;
|
|
272
|
-
_ViewerStateKeys$Inte = ViewerStateKeys.Interpolation;
|
|
273
|
-
_ViewerStateKeys$Regi = ViewerStateKeys.Region;
|
|
274
|
-
_ViewerStateKeys$Slic = ViewerStateKeys.Slice;
|
|
275
|
-
_ViewerStateKeys$Time = ViewerStateKeys.Time;
|
|
276
|
-
_ViewerStateKeys$Scen = ViewerStateKeys.Scene;
|
|
277
|
-
_ViewerStateKeys$UseE = ViewerStateKeys.UseExactScaleLevel;
|
|
278
|
-
_ViewerStateKeys$Scal = ViewerStateKeys.ScaleLevelIndex;
|
|
279
|
-
_ViewerStateKeys$Came = ViewerStateKeys.CameraState;
|
|
280
|
-
/** Serialized version of `ViewerState`. */
|
|
281
|
-
export var ViewerStateParams = /*#__PURE__*/_createClass(function ViewerStateParams() {
|
|
282
|
-
_classCallCheck(this, ViewerStateParams);
|
|
283
|
-
/** Axis to view. Valid values are "3D", "X", "Y", and "Z". Defaults to "3D". */
|
|
284
|
-
_defineProperty(this, _ViewerStateKeys$View, undefined);
|
|
285
|
-
/**
|
|
286
|
-
* Render mode. Valid values are "volumetric", "maxproject", and "pathtrace".
|
|
287
|
-
* Defaults to "volumetric".
|
|
288
|
-
*/
|
|
289
|
-
_defineProperty(this, _ViewerStateKeys$Mode, undefined);
|
|
290
|
-
/** The opacity of the mask channel, an integer in the range [0, 100]. Defaults to 50. */
|
|
291
|
-
_defineProperty(this, _ViewerStateKeys$Mask, undefined);
|
|
292
|
-
/** The type of image to display. Valid values are "cell" and "fov". Defaults to "cell". */
|
|
293
|
-
_defineProperty(this, _ViewerStateKeys$Imag, undefined);
|
|
294
|
-
/** Whether to show the axes helper. "1" is enabled. Disabled by default. */
|
|
295
|
-
_defineProperty(this, _ViewerStateKeys$Axes, undefined);
|
|
296
|
-
/** Whether to show the bounding box. "1" is enabled. Disabled by default. */
|
|
297
|
-
_defineProperty(this, _ViewerStateKeys$Boun, undefined);
|
|
298
|
-
/** Whether single-channel mode is active. "1" is active. Inactive by default. */
|
|
299
|
-
_defineProperty(this, _ViewerStateKeys$Sing, undefined);
|
|
300
|
-
/** If single-channel mode is active, which channel index is shown. Defaults to 0. */
|
|
301
|
-
_defineProperty(this, _ViewerStateKeys$Sing2, undefined);
|
|
302
|
-
/** The color of the bounding box, as a 6-digit hex color. */
|
|
303
|
-
_defineProperty(this, _ViewerStateKeys$Boun2, undefined);
|
|
304
|
-
/** The background color, as a 6-digit hex color. */
|
|
305
|
-
_defineProperty(this, _ViewerStateKeys$Back, undefined);
|
|
306
|
-
/** Whether to autorotate the view. "1" is enabled. Disabled by default. */
|
|
307
|
-
_defineProperty(this, _ViewerStateKeys$Auto, undefined);
|
|
308
|
-
/** The brightness of the image, an float in the range [0, 100]. Defaults to 70. */
|
|
309
|
-
_defineProperty(this, _ViewerStateKeys$Brig, undefined);
|
|
310
|
-
/** Density, a float in the range [0, 100]. Defaults to 50. */
|
|
311
|
-
_defineProperty(this, _ViewerStateKeys$Dens, undefined);
|
|
312
|
-
/**
|
|
313
|
-
* Levels for image intensity adjustment. Should be three numeric values separated
|
|
314
|
-
* by commas, representing the low, middle, and high values in a [0, 255] range.
|
|
315
|
-
* Values will be sorted in ascending order; empty values will be parsed as 0.
|
|
316
|
-
*/
|
|
317
|
-
_defineProperty(this, _ViewerStateKeys$Leve, undefined);
|
|
318
|
-
/** Whether to enable interpolation. "1" is enabled. Enabled by default. */
|
|
319
|
-
_defineProperty(this, _ViewerStateKeys$Inte, undefined);
|
|
320
|
-
/** Subregions per axis, as min:max pairs separated by commas.
|
|
321
|
-
* Defaults to full range (`0:1`) for each axis.
|
|
322
|
-
*/
|
|
323
|
-
_defineProperty(this, _ViewerStateKeys$Regi, undefined);
|
|
324
|
-
/** Slice position per X, Y, and Z axes, as a list of comma-separated floats.
|
|
325
|
-
* 0.5 for all axes by default (e.g. `0.5,0.5,0.5`)
|
|
326
|
-
*/
|
|
327
|
-
_defineProperty(this, _ViewerStateKeys$Slic, undefined);
|
|
328
|
-
/** Frame number, for time-series volumes. 0 by default. */
|
|
329
|
-
_defineProperty(this, _ViewerStateKeys$Time, undefined);
|
|
330
|
-
/** Scene number, for multiscene images. 0 by default. */
|
|
331
|
-
_defineProperty(this, _ViewerStateKeys$Scen, undefined);
|
|
332
|
-
/** Whether to use an exact scale level index. 0 by default. */
|
|
333
|
-
_defineProperty(this, _ViewerStateKeys$UseE, undefined);
|
|
334
|
-
/** The exact scale level index to use, if `UseExactScaleLevel` is 1. 0 by default. */
|
|
335
|
-
_defineProperty(this, _ViewerStateKeys$Scal, undefined);
|
|
336
|
-
/**
|
|
337
|
-
* Camera transform settings, as a list of `key:value` pairs separated by commas.
|
|
338
|
-
* Valid keys are defined in `CameraTransformKeys`:
|
|
339
|
-
* - `pos`: position
|
|
340
|
-
* - `tar`: target
|
|
341
|
-
* - `up`: up
|
|
342
|
-
* - `rot`: rotation
|
|
343
|
-
* - `ort`: orthographic scales
|
|
344
|
-
*
|
|
345
|
-
* All values are an array of three floats, separated by commas and
|
|
346
|
-
* encoded using `encodeURIComponent`.
|
|
347
|
-
*/
|
|
348
|
-
_defineProperty(this, _ViewerStateKeys$Came, undefined);
|
|
349
|
-
});
|
|
350
|
-
|
|
351
45
|
/** URL parameters that define data sources when loading volumes. */
|
|
352
46
|
var DataParams = /*#__PURE__*/_createClass(function DataParams() {
|
|
353
47
|
_classCallCheck(this, DataParams);
|
|
@@ -496,516 +190,8 @@ export var parseImageURLParam = function parseImageURLParam(urlParam) {
|
|
|
496
190
|
});
|
|
497
191
|
};
|
|
498
192
|
|
|
499
|
-
//// DATA PARSING //////////////////////
|
|
500
|
-
|
|
501
|
-
/**
|
|
502
|
-
* Parse a string list of comma-separated key:value pairs into
|
|
503
|
-
* a key-value object.
|
|
504
|
-
*
|
|
505
|
-
* @param data The string to parse. Expected to be in the format
|
|
506
|
-
* "key1:value1,key2:value2,...". Commas in keys or values
|
|
507
|
-
* must be encoded using `encodeURIComponent`.
|
|
508
|
-
* @returns An object with the parsed key-value pairs. Key and value strings
|
|
509
|
-
* will be decoded using `decodeURIComponent`.
|
|
510
|
-
*/
|
|
511
|
-
export function parseKeyValueList(data) {
|
|
512
|
-
if (data === "") {
|
|
513
|
-
return {};
|
|
514
|
-
}
|
|
515
|
-
var result = {};
|
|
516
|
-
var keyValuePairs = data.split(",");
|
|
517
|
-
var _iterator2 = _createForOfIteratorHelper(keyValuePairs),
|
|
518
|
-
_step2;
|
|
519
|
-
try {
|
|
520
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
521
|
-
var pair = _step2.value;
|
|
522
|
-
var splitIndex = pair.indexOf(":");
|
|
523
|
-
var key = pair.slice(0, splitIndex);
|
|
524
|
-
var value = pair.slice(splitIndex + 1);
|
|
525
|
-
result[decodeURIComponent(key).trim()] = decodeURIComponent(value).trim();
|
|
526
|
-
}
|
|
527
|
-
} catch (err) {
|
|
528
|
-
_iterator2.e(err);
|
|
529
|
-
} finally {
|
|
530
|
-
_iterator2.f();
|
|
531
|
-
}
|
|
532
|
-
return result;
|
|
533
|
-
}
|
|
534
|
-
function decodeColons(str) {
|
|
535
|
-
return str.replace(ENCODED_COLON_REGEX, ":");
|
|
536
|
-
}
|
|
537
|
-
export function objectToKeyValueList(obj) {
|
|
538
|
-
var keyValuePairs = [];
|
|
539
|
-
for (var key in obj) {
|
|
540
|
-
var value = obj[key];
|
|
541
|
-
if (value === undefined) {
|
|
542
|
-
continue;
|
|
543
|
-
}
|
|
544
|
-
// Allow colon separators to remain unencoded to save URL character length.
|
|
545
|
-
var escapedValue = decodeColons(encodeURIComponent(value.trim()));
|
|
546
|
-
keyValuePairs.push("".concat(encodeURIComponent(key.trim()), ":").concat(escapedValue));
|
|
547
|
-
}
|
|
548
|
-
return keyValuePairs.join(",");
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
/**
|
|
552
|
-
* Parses a string to a float and clamps the result to the [min, max] range.
|
|
553
|
-
* Returns `undefined` if the string is undefined or NaN.
|
|
554
|
-
* @param value String to parse as a float. Will be parsed with `Number.parseFloat`.
|
|
555
|
-
* @param min Minimum value, inclusive.
|
|
556
|
-
* @param max Maximum value, inclusive.
|
|
557
|
-
* @returns
|
|
558
|
-
* - The parsed number, clamped to the [min, max] range.
|
|
559
|
-
* - `undefined` if the string is undefined or NaN.
|
|
560
|
-
*/
|
|
561
|
-
export function parseStringFloat(value, min, max) {
|
|
562
|
-
if (value === undefined) {
|
|
563
|
-
return undefined;
|
|
564
|
-
}
|
|
565
|
-
var number = Number.parseFloat(value);
|
|
566
|
-
return Number.isNaN(number) ? undefined : clamp(number, min, max);
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
/**
|
|
570
|
-
* Parses a string to an integer and clamps the result to the [min, max] range.
|
|
571
|
-
* @param value String to parse as a float. Assumes base 10, parses with `Number.parseInt(value, 10)`.
|
|
572
|
-
* @param min Minimum value, inclusive.
|
|
573
|
-
* @param max Maximum value, inclusive.
|
|
574
|
-
* @returns
|
|
575
|
-
* - The parsed number, clamped to the [min, max] range.
|
|
576
|
-
* - `undefined` if the string is undefined or NaN.
|
|
577
|
-
*/
|
|
578
|
-
export function parseStringInt(value, min, max) {
|
|
579
|
-
if (value === undefined) {
|
|
580
|
-
return undefined;
|
|
581
|
-
}
|
|
582
|
-
var number = Number.parseInt(value, 10);
|
|
583
|
-
if (Number.isNaN(number)) {
|
|
584
|
-
return undefined;
|
|
585
|
-
}
|
|
586
|
-
return clamp(number, min, max);
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
/**
|
|
590
|
-
* Parses a string to an enum value; if the string is not in the enum, returns the default value.
|
|
591
|
-
* @param value String to parse.
|
|
592
|
-
* @param enumValues Enum. Cannot be a `const enum`, as these are removed at compile time.
|
|
593
|
-
* @param defaultValue Default value to return if the string is not in the enum.
|
|
594
|
-
* @returns A value from the enum or the default value. Note that the return type includes `undefined`
|
|
595
|
-
* if the `defaultValue` is `undefined`.
|
|
596
|
-
*/
|
|
597
|
-
export function parseStringEnum(value, enumValues) {
|
|
598
|
-
var defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
599
|
-
if (value === undefined || !Object.values(enumValues).includes(value)) {
|
|
600
|
-
return defaultValue;
|
|
601
|
-
}
|
|
602
|
-
return value;
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
/**
|
|
606
|
-
* Parses a string boolean value ("1" as true, "0" as false), and returns `undefined` if the value is `undefined`.
|
|
607
|
-
*/
|
|
608
|
-
function parseStringBoolean(value) {
|
|
609
|
-
if (value === undefined) {
|
|
610
|
-
return undefined;
|
|
611
|
-
}
|
|
612
|
-
return value === "1";
|
|
613
|
-
}
|
|
614
|
-
export function parseHexColorAsColorArray(hexColor) {
|
|
615
|
-
if (!hexColor || !HEX_COLOR_STR_REGEX.test(hexColor)) {
|
|
616
|
-
return undefined;
|
|
617
|
-
}
|
|
618
|
-
// if (hexColor in COLOR_CODES) {
|
|
619
|
-
// return COLOR_CODES[hexColor];
|
|
620
|
-
// }
|
|
621
|
-
if (hexColor === DEFAULT_CONTROL_POINT_COLOR_CODE) {
|
|
622
|
-
return DEFAULT_CONTROL_POINT_COLOR;
|
|
623
|
-
}
|
|
624
|
-
var r = Number.parseInt(hexColor.slice(0, 2), 16);
|
|
625
|
-
var g = Number.parseInt(hexColor.slice(2, 4), 16);
|
|
626
|
-
var b = Number.parseInt(hexColor.slice(4, 6), 16);
|
|
627
|
-
return [r, g, b];
|
|
628
|
-
}
|
|
629
|
-
function colorArrayToHex(color) {
|
|
630
|
-
return color.map(function (c) {
|
|
631
|
-
return c.toString(16).padStart(2, "0");
|
|
632
|
-
}).join("").toLowerCase();
|
|
633
|
-
}
|
|
634
|
-
function parseStringSlice(region) {
|
|
635
|
-
if (!region || !SLICE_REGEX.test(region)) {
|
|
636
|
-
return undefined;
|
|
637
|
-
}
|
|
638
|
-
var _region$split$map = region.split(",").map(function (val) {
|
|
639
|
-
return parseStringFloat(val, 0, 1);
|
|
640
|
-
}),
|
|
641
|
-
_region$split$map2 = _slicedToArray(_region$split$map, 3),
|
|
642
|
-
x = _region$split$map2[0],
|
|
643
|
-
y = _region$split$map2[1],
|
|
644
|
-
z = _region$split$map2[2];
|
|
645
|
-
if (x === undefined || y === undefined || z === undefined) {
|
|
646
|
-
return undefined;
|
|
647
|
-
}
|
|
648
|
-
return {
|
|
649
|
-
x: x,
|
|
650
|
-
y: y,
|
|
651
|
-
z: z
|
|
652
|
-
};
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
* Parses an array of three numbers from a string.
|
|
657
|
-
* @param stringArr The string to parse. Should be three numbers separated by a separator.
|
|
658
|
-
* @param options Optional parameters for parsing:
|
|
659
|
-
* - `min`: Minimum value for each number. Default is negative infinity.
|
|
660
|
-
* - `max`: Maximum value for each number. Default is positive infinity.
|
|
661
|
-
* - `separator`: Separator between numbers. Default is `,`.
|
|
662
|
-
* @returns
|
|
663
|
-
* - undefined if the string is undefined or could not be parsed.
|
|
664
|
-
* - An array of three numbers, clamped to the [min, max] range.
|
|
665
|
-
*/
|
|
666
|
-
function parseThreeNumberArray(stringArr, options) {
|
|
667
|
-
var _options$min, _options$max, _options$separator;
|
|
668
|
-
if (!stringArr) {
|
|
669
|
-
return undefined;
|
|
670
|
-
}
|
|
671
|
-
var min = (_options$min = options === null || options === void 0 ? void 0 : options.min) !== null && _options$min !== void 0 ? _options$min : Number.NEGATIVE_INFINITY;
|
|
672
|
-
var max = (_options$max = options === null || options === void 0 ? void 0 : options.max) !== null && _options$max !== void 0 ? _options$max : Number.POSITIVE_INFINITY;
|
|
673
|
-
var separator = (_options$separator = options === null || options === void 0 ? void 0 : options.separator) !== null && _options$separator !== void 0 ? _options$separator : ",";
|
|
674
|
-
var _stringArr$split$map = stringArr.split(separator).map(function (val) {
|
|
675
|
-
return parseStringFloat(val, min, max);
|
|
676
|
-
}),
|
|
677
|
-
_stringArr$split$map2 = _slicedToArray(_stringArr$split$map, 3),
|
|
678
|
-
x = _stringArr$split$map2[0],
|
|
679
|
-
y = _stringArr$split$map2[1],
|
|
680
|
-
z = _stringArr$split$map2[2];
|
|
681
|
-
if (x === undefined || y === undefined || z === undefined) {
|
|
682
|
-
return undefined;
|
|
683
|
-
}
|
|
684
|
-
return [x, y, z];
|
|
685
|
-
}
|
|
686
|
-
function parseStringRegion(region) {
|
|
687
|
-
if (!region || !REGION_REGEX.test(region)) {
|
|
688
|
-
return undefined;
|
|
689
|
-
}
|
|
690
|
-
var _region$split$map3 = region.split(",").map(function (axis) {
|
|
691
|
-
// each is a min/max pair
|
|
692
|
-
var _axis$split$map = axis.split(":").map(function (val) {
|
|
693
|
-
return parseStringFloat(val, 0, 1);
|
|
694
|
-
}),
|
|
695
|
-
_axis$split$map2 = _slicedToArray(_axis$split$map, 2),
|
|
696
|
-
min = _axis$split$map2[0],
|
|
697
|
-
max = _axis$split$map2[1];
|
|
698
|
-
if (min === undefined || max === undefined) {
|
|
699
|
-
return undefined;
|
|
700
|
-
}
|
|
701
|
-
// Ensure sorted order
|
|
702
|
-
return min < max ? [min, max] : [max, min];
|
|
703
|
-
}),
|
|
704
|
-
_region$split$map4 = _slicedToArray(_region$split$map3, 3),
|
|
705
|
-
x = _region$split$map4[0],
|
|
706
|
-
y = _region$split$map4[1],
|
|
707
|
-
z = _region$split$map4[2];
|
|
708
|
-
// Check for undefined values
|
|
709
|
-
if (x === undefined || y === undefined || z === undefined) {
|
|
710
|
-
return undefined;
|
|
711
|
-
}
|
|
712
|
-
return {
|
|
713
|
-
x: x,
|
|
714
|
-
y: y,
|
|
715
|
-
z: z
|
|
716
|
-
};
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
/**
|
|
720
|
-
* Formats a float or integer value to a string with a maximum precision for float values.
|
|
721
|
-
* @param value The number to format.
|
|
722
|
-
* @param maxPrecision The maximum number of significant digits to display for float values.
|
|
723
|
-
* Default is 7.
|
|
724
|
-
* @returns
|
|
725
|
-
* - For integers, the integer value as a string.
|
|
726
|
-
* - For floats, the float value as a string with a maximum of `maxPrecision` significant digits
|
|
727
|
-
* and any trailing zeroes removed.
|
|
728
|
-
*
|
|
729
|
-
* @example
|
|
730
|
-
* ```
|
|
731
|
-
* formatFloat(1.23456, 3) // "1.23"
|
|
732
|
-
* formatFloat(123456, 3) // "123456"
|
|
733
|
-
* formatFloat(1.3999999999999999, 3) // "1.4"
|
|
734
|
-
* ```
|
|
735
|
-
*/
|
|
736
|
-
function formatFloat(value) {
|
|
737
|
-
var maxPrecision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 7;
|
|
738
|
-
if (Number.isInteger(value)) {
|
|
739
|
-
return value.toString();
|
|
740
|
-
}
|
|
741
|
-
return Number(value.toPrecision(maxPrecision)).toString();
|
|
742
|
-
}
|
|
743
|
-
function perAxisToArray(perAxis) {
|
|
744
|
-
return [perAxis.x, perAxis.y, perAxis.z];
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
/** Serializes a region into a `x1:x2,y1:y2,z1:z2` string format. */
|
|
748
|
-
function serializeRegion(region) {
|
|
749
|
-
return perAxisToArray(region).map(function (axis) {
|
|
750
|
-
return axis.map(function (val) {
|
|
751
|
-
return formatFloat(val);
|
|
752
|
-
}).join(":");
|
|
753
|
-
}).join(",");
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
/** Serializes a slice parameter into a `x,y,z` string format. */
|
|
757
|
-
function serializeSlice(slice) {
|
|
758
|
-
return perAxisToArray(slice).map(function (val) {
|
|
759
|
-
return formatFloat(val);
|
|
760
|
-
}).join(",");
|
|
761
|
-
}
|
|
762
|
-
function serializeBoolean(value) {
|
|
763
|
-
if (value === undefined) {
|
|
764
|
-
return undefined;
|
|
765
|
-
}
|
|
766
|
-
return value ? "1" : "0";
|
|
767
|
-
}
|
|
768
|
-
function parseCameraState(cameraSettings) {
|
|
769
|
-
if (!cameraSettings) {
|
|
770
|
-
return undefined;
|
|
771
|
-
}
|
|
772
|
-
var parsedCameraSettings = parseKeyValueList(cameraSettings);
|
|
773
|
-
var result = {
|
|
774
|
-
position: parseThreeNumberArray(parsedCameraSettings[CameraTransformKeys.Position], {
|
|
775
|
-
separator: ":"
|
|
776
|
-
}),
|
|
777
|
-
target: parseThreeNumberArray(parsedCameraSettings[CameraTransformKeys.Target], {
|
|
778
|
-
separator: ":"
|
|
779
|
-
}),
|
|
780
|
-
up: parseThreeNumberArray(parsedCameraSettings[CameraTransformKeys.Up], {
|
|
781
|
-
separator: ":"
|
|
782
|
-
}),
|
|
783
|
-
// Orthographic scales cannot be negative
|
|
784
|
-
orthoScale: parseStringFloat(parsedCameraSettings[CameraTransformKeys.OrthoScale], 0, Infinity),
|
|
785
|
-
fov: parseStringFloat(parsedCameraSettings[CameraTransformKeys.Fov], 0, 180)
|
|
786
|
-
};
|
|
787
|
-
return removeUndefinedProperties(result);
|
|
788
|
-
}
|
|
789
|
-
export function serializeCameraState(cameraState, removeDefaults) {
|
|
790
|
-
var viewMode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ViewMode.threeD;
|
|
791
|
-
if (removeDefaults) {
|
|
792
|
-
// Note that we use the `getDefaultCameraState()` to get the defaults here,
|
|
793
|
-
// instead of `getDefaultViewerState().cameraState`. The latter is undefined, which signals
|
|
794
|
-
// that the camera should not be modified for URLs that don't specify it.
|
|
795
|
-
cameraState = removeMatchingProperties(cameraState, getDefaultCameraState(viewMode));
|
|
796
|
-
if (Object.keys(cameraState).length === 0) {
|
|
797
|
-
return undefined;
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
var cameraString = objectToKeyValueList(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, CameraTransformKeys.Position, cameraState.position && cameraState.position.map(function (value) {
|
|
801
|
-
return formatFloat(value);
|
|
802
|
-
}).join(":")), CameraTransformKeys.Target, cameraState.target && cameraState.target.map(function (value) {
|
|
803
|
-
return formatFloat(value);
|
|
804
|
-
}).join(":")), CameraTransformKeys.Up, cameraState.up && cameraState.up.map(function (value) {
|
|
805
|
-
return formatFloat(value);
|
|
806
|
-
}).join(":")), CameraTransformKeys.OrthoScale, cameraState.orthoScale === undefined ? undefined : formatFloat(cameraState.orthoScale)), CameraTransformKeys.Fov, cameraState.fov === undefined ? undefined : formatFloat(cameraState.fov)));
|
|
807
|
-
return cameraString === "" ? undefined : cameraString;
|
|
808
|
-
}
|
|
809
|
-
function serializeControlPoints(controlPoints) {
|
|
810
|
-
return controlPoints.map(function (cp) {
|
|
811
|
-
var x = formatFloat(cp.x);
|
|
812
|
-
var opacity = formatFloat(cp.opacity);
|
|
813
|
-
// Default color is empty string
|
|
814
|
-
// TODO: Substitute
|
|
815
|
-
var color = isEqual(cp.color, DEFAULT_CONTROL_POINT_COLOR) ? DEFAULT_CONTROL_POINT_COLOR_CODE : colorArrayToHex(cp.color);
|
|
816
|
-
return "".concat(x, ":").concat(opacity, ":").concat(color);
|
|
817
|
-
}).join(":");
|
|
818
|
-
}
|
|
819
|
-
function parseControlPoints(controlPoints) {
|
|
820
|
-
if (!(controlPoints && (CONTROL_POINTS_REGEX.test(controlPoints) || LEGACY_CONTROL_POINTS_REGEX.test(controlPoints)))) {
|
|
821
|
-
return undefined;
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
// Parse raw control point data from the string into an array of [x, opacity, color] triplets.
|
|
825
|
-
var controlPointStrings;
|
|
826
|
-
if (LEGACY_CONTROL_POINTS_REGEX.test(controlPoints)) {
|
|
827
|
-
// Legacy format uses commas to separate control points.
|
|
828
|
-
controlPointStrings = controlPoints.split(",").map(function (cp) {
|
|
829
|
-
return cp.split(":");
|
|
830
|
-
});
|
|
831
|
-
} else {
|
|
832
|
-
// New format is all colon-separated, where every three elements represent a control point.
|
|
833
|
-
controlPointStrings = controlPoints.split(":").reduce(function (acc, _val, i, array) {
|
|
834
|
-
if ((i + 1) % 3 === 0) {
|
|
835
|
-
acc.push([array[i - 2], array[i - 1], array[i]]);
|
|
836
|
-
}
|
|
837
|
-
return acc;
|
|
838
|
-
}, []);
|
|
839
|
-
}
|
|
840
|
-
var newControlPoints = controlPointStrings.map(function (cp) {
|
|
841
|
-
var _parseStringFloat, _parseStringFloat2, _parseHexColorAsColor;
|
|
842
|
-
var _cp = _slicedToArray(cp, 3),
|
|
843
|
-
x = _cp[0],
|
|
844
|
-
opacity = _cp[1],
|
|
845
|
-
color = _cp[2];
|
|
846
|
-
return {
|
|
847
|
-
x: (_parseStringFloat = parseStringFloat(x, -Infinity, Infinity)) !== null && _parseStringFloat !== void 0 ? _parseStringFloat : 0,
|
|
848
|
-
opacity: (_parseStringFloat2 = parseStringFloat(opacity, 0, 1)) !== null && _parseStringFloat2 !== void 0 ? _parseStringFloat2 : 1.0,
|
|
849
|
-
color: (_parseHexColorAsColor = parseHexColorAsColorArray(color)) !== null && _parseHexColorAsColor !== void 0 ? _parseHexColorAsColor : DEFAULT_CONTROL_POINT_COLOR
|
|
850
|
-
};
|
|
851
|
-
});
|
|
852
|
-
// Sort control points by x value
|
|
853
|
-
return newControlPoints.sort(function (a, b) {
|
|
854
|
-
return a.x - b.x;
|
|
855
|
-
});
|
|
856
|
-
}
|
|
857
|
-
|
|
858
193
|
//// DATA SERIALIZATION //////////////////////
|
|
859
194
|
|
|
860
|
-
/**
|
|
861
|
-
* Parses a ViewerChannelSetting from a JSON object.
|
|
862
|
-
* @param channelIndex Index of the channel, to be turned into a `match` value.
|
|
863
|
-
* @param jsonState The serialized ViewerChannelSetting to parse, as an object.
|
|
864
|
-
* @returns A ViewerChannelSetting object.
|
|
865
|
-
*/
|
|
866
|
-
export function deserializeViewerChannelSetting(channelIndex, jsonState) {
|
|
867
|
-
// Missing/undefined fields should be handled downstream.
|
|
868
|
-
var result = {
|
|
869
|
-
match: channelIndex,
|
|
870
|
-
enabled: parseStringBoolean(jsonState[ViewerChannelSettingKeys.VolumeEnabled]),
|
|
871
|
-
surfaceEnabled: parseStringBoolean(jsonState[ViewerChannelSettingKeys.SurfaceEnabled]),
|
|
872
|
-
isovalue: parseStringFloat(jsonState[ViewerChannelSettingKeys.IsosurfaceValue], -Infinity, Infinity),
|
|
873
|
-
keepIntensityRange: parseStringBoolean(jsonState[ViewerChannelSettingKeys.KeepRange]),
|
|
874
|
-
surfaceOpacity: parseStringFloat(jsonState[ViewerChannelSettingKeys.IsosurfaceAlpha], 0, 1),
|
|
875
|
-
colorizeEnabled: parseStringBoolean(jsonState[ViewerChannelSettingKeys.Colorize]),
|
|
876
|
-
colorizeAlpha: parseStringFloat(jsonState[ViewerChannelSettingKeys.ColorizeAlpha], 0, 1),
|
|
877
|
-
controlPointsEnabled: parseStringBoolean(jsonState[ViewerChannelSettingKeys.ControlPointsEnabled])
|
|
878
|
-
};
|
|
879
|
-
if (jsonState[ViewerChannelSettingKeys.Color] && HEX_COLOR_REGEX.test(jsonState.col)) {
|
|
880
|
-
result.color = jsonState[ViewerChannelSettingKeys.Color];
|
|
881
|
-
}
|
|
882
|
-
if (jsonState[ViewerChannelSettingKeys.Lut] && LUT_REGEX.test(jsonState.lut)) {
|
|
883
|
-
var _jsonState$ViewerChan = jsonState[ViewerChannelSettingKeys.Lut].split(":"),
|
|
884
|
-
_jsonState$ViewerChan2 = _slicedToArray(_jsonState$ViewerChan, 2),
|
|
885
|
-
min = _jsonState$ViewerChan2[0],
|
|
886
|
-
max = _jsonState$ViewerChan2[1];
|
|
887
|
-
result.intensity = _objectSpread(_objectSpread({}, result.intensity), {}, {
|
|
888
|
-
lut: [min.trim(), max.trim()]
|
|
889
|
-
});
|
|
890
|
-
}
|
|
891
|
-
if (jsonState[ViewerChannelSettingKeys.Ramp]) {
|
|
892
|
-
if (RAMP_REGEX.test(jsonState[ViewerChannelSettingKeys.Ramp])) {
|
|
893
|
-
var _jsonState$ViewerChan3 = jsonState[ViewerChannelSettingKeys.Ramp].split(":"),
|
|
894
|
-
_jsonState$ViewerChan4 = _slicedToArray(_jsonState$ViewerChan3, 2),
|
|
895
|
-
_min = _jsonState$ViewerChan4[0],
|
|
896
|
-
_max = _jsonState$ViewerChan4[1];
|
|
897
|
-
result.intensity = _objectSpread(_objectSpread({}, result.intensity), {}, {
|
|
898
|
-
ramp: [Number.parseFloat(_min), Number.parseFloat(_max)]
|
|
899
|
-
});
|
|
900
|
-
}
|
|
901
|
-
} else if (jsonState[ViewerChannelSettingKeys.RampLegacy]) {
|
|
902
|
-
if (RAMP_REGEX.test(jsonState[ViewerChannelSettingKeys.RampLegacy])) {
|
|
903
|
-
var _jsonState$ViewerChan5 = jsonState[ViewerChannelSettingKeys.RampLegacy].split(":"),
|
|
904
|
-
_jsonState$ViewerChan6 = _slicedToArray(_jsonState$ViewerChan5, 2),
|
|
905
|
-
_min2 = _jsonState$ViewerChan6[0],
|
|
906
|
-
_max2 = _jsonState$ViewerChan6[1];
|
|
907
|
-
result.ramp = [Number.parseFloat(_min2), Number.parseFloat(_max2)];
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
if (jsonState[ViewerChannelSettingKeys.ControlPoints]) {
|
|
911
|
-
var parsedResult = parseControlPoints(jsonState[ViewerChannelSettingKeys.ControlPoints]);
|
|
912
|
-
if (parsedResult) {
|
|
913
|
-
result.intensity = _objectSpread(_objectSpread({}, result.intensity), {}, {
|
|
914
|
-
controlPoints: parsedResult
|
|
915
|
-
});
|
|
916
|
-
}
|
|
917
|
-
} else if (jsonState[ViewerChannelSettingKeys.ControlPointsLegacy]) {
|
|
918
|
-
var _parsedResult = parseControlPoints(jsonState[ViewerChannelSettingKeys.ControlPointsLegacy]);
|
|
919
|
-
if (_parsedResult) {
|
|
920
|
-
result.controlPoints = _parsedResult;
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
return result;
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
/**
|
|
927
|
-
* Serializes a single viewer channel setting into a dictionary of URL parameters
|
|
928
|
-
* (`ViewerChannelSettingParams`).
|
|
929
|
-
* @param channelSetting The channel state object to serialize.
|
|
930
|
-
* @param removeDefaults Whether to remove properties that match the output of `GET_DEFAULT_CHANNEL_STATE`.
|
|
931
|
-
* @returns A `ViewerChannelSettingParams` object with the serialized parameters. Undefined values are removed.
|
|
932
|
-
*/
|
|
933
|
-
export function serializeViewerChannelSetting(channelSetting, removeDefaults) {
|
|
934
|
-
var _channelSetting$isova, _channelSetting$opaci, _channelSetting$color, _channelSetting$ramp, _removeUndefinedPrope;
|
|
935
|
-
if (removeDefaults) {
|
|
936
|
-
channelSetting = removeMatchingProperties(channelSetting, getDefaultChannelState());
|
|
937
|
-
}
|
|
938
|
-
return removeUndefinedProperties((_removeUndefinedPrope = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_removeUndefinedPrope, ViewerChannelSettingKeys.VolumeEnabled, serializeBoolean(channelSetting.volumeEnabled)), ViewerChannelSettingKeys.SurfaceEnabled, serializeBoolean(channelSetting.isosurfaceEnabled)), ViewerChannelSettingKeys.IsosurfaceValue, (_channelSetting$isova = channelSetting.isovalue) === null || _channelSetting$isova === void 0 ? void 0 : _channelSetting$isova.toString()), ViewerChannelSettingKeys.IsosurfaceAlpha, (_channelSetting$opaci = channelSetting.opacity) === null || _channelSetting$opaci === void 0 ? void 0 : _channelSetting$opaci.toString()), ViewerChannelSettingKeys.Colorize, serializeBoolean(channelSetting.colorizeEnabled)), ViewerChannelSettingKeys.ColorizeAlpha, (_channelSetting$color = channelSetting.colorizeAlpha) === null || _channelSetting$color === void 0 ? void 0 : _channelSetting$color.toString()), ViewerChannelSettingKeys.Color, channelSetting.color && colorArrayToHex(channelSetting.color)), ViewerChannelSettingKeys.ControlPoints, channelSetting.controlPoints && serializeControlPoints(channelSetting.controlPoints)), ViewerChannelSettingKeys.ControlPointsEnabled, serializeBoolean(channelSetting.useControlPoints)), ViewerChannelSettingKeys.Ramp, (_channelSetting$ramp = channelSetting.ramp) === null || _channelSetting$ramp === void 0 ? void 0 : _channelSetting$ramp.join(":")), _defineProperty(_removeUndefinedPrope, ViewerChannelSettingKeys.KeepRange, serializeBoolean(channelSetting.keepIntensityRange))));
|
|
939
|
-
}
|
|
940
|
-
export function deserializeViewerState(params) {
|
|
941
|
-
var result = {
|
|
942
|
-
maskAlpha: parseStringInt(params[ViewerStateKeys.Mask], 0, 100),
|
|
943
|
-
imageType: parseStringEnum(params[ViewerStateKeys.Image], ImageType),
|
|
944
|
-
showAxes: parseStringBoolean(params[ViewerStateKeys.Axes]),
|
|
945
|
-
showBoundingBox: parseStringBoolean(params[ViewerStateKeys.BoundingBox]),
|
|
946
|
-
boundingBoxColor: parseHexColorAsColorArray(params[ViewerStateKeys.BoundingBoxColor]),
|
|
947
|
-
backgroundColor: parseHexColorAsColorArray(params[ViewerStateKeys.BackgroundColor]),
|
|
948
|
-
autorotate: parseStringBoolean(params[ViewerStateKeys.Autorotate]),
|
|
949
|
-
brightness: parseStringFloat(params[ViewerStateKeys.Brightness], 0, 100),
|
|
950
|
-
density: parseStringFloat(params[ViewerStateKeys.Density], 0, 100),
|
|
951
|
-
levels: parseThreeNumberArray(params[ViewerStateKeys.Levels], {
|
|
952
|
-
min: 0,
|
|
953
|
-
max: 255
|
|
954
|
-
}),
|
|
955
|
-
interpolationEnabled: parseStringBoolean(params[ViewerStateKeys.Interpolation]),
|
|
956
|
-
region: parseStringRegion(params[ViewerStateKeys.Region]),
|
|
957
|
-
slice: parseStringSlice(params[ViewerStateKeys.Slice]),
|
|
958
|
-
time: parseStringInt(params[ViewerStateKeys.Time], 0, Number.POSITIVE_INFINITY),
|
|
959
|
-
scene: parseStringInt(params[ViewerStateKeys.Scene], 0, Number.POSITIVE_INFINITY),
|
|
960
|
-
renderMode: parseStringEnum(params[ViewerStateKeys.Mode], RenderMode),
|
|
961
|
-
singleChannelMode: parseStringBoolean(params[ViewerStateKeys.SingleChannelMode]),
|
|
962
|
-
singleChannelIndex: parseStringInt(params[ViewerStateKeys.SingleChannelIndex], 0, Number.POSITIVE_INFINITY),
|
|
963
|
-
useExactScaleLevel: parseStringBoolean(params[ViewerStateKeys.UseExactScaleLevel]),
|
|
964
|
-
scaleLevelIndex: parseStringInt(params[ViewerStateKeys.ScaleLevelIndex], 0, Number.MAX_SAFE_INTEGER),
|
|
965
|
-
cameraState: parseCameraState(params[ViewerStateKeys.CameraState])
|
|
966
|
-
};
|
|
967
|
-
|
|
968
|
-
// Handle viewmode, since they use different mappings
|
|
969
|
-
// TODO: Allow lowercase
|
|
970
|
-
if (params.view) {
|
|
971
|
-
var viewParamToViewMode = {
|
|
972
|
-
"3D": ViewMode.threeD,
|
|
973
|
-
Z: ViewMode.xy,
|
|
974
|
-
Y: ViewMode.xz,
|
|
975
|
-
X: ViewMode.yz
|
|
976
|
-
};
|
|
977
|
-
var allowedViews = Object.keys(viewParamToViewMode);
|
|
978
|
-
var view;
|
|
979
|
-
if (allowedViews.includes(params.view.toUpperCase())) {
|
|
980
|
-
view = params.view.toUpperCase();
|
|
981
|
-
} else {
|
|
982
|
-
view = "3D";
|
|
983
|
-
}
|
|
984
|
-
result.viewMode = viewParamToViewMode[view];
|
|
985
|
-
}
|
|
986
|
-
return removeUndefinedProperties(result);
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
/**
|
|
990
|
-
* Serializes a ViewerState object into a dictionary of URL parameters.
|
|
991
|
-
* @param state The ViewerState to serialize.
|
|
992
|
-
* @param removeDefaults If true, remove properties that match the output of `GET_DEFAULT_VIEWER_STATE`.
|
|
993
|
-
* @returns A `ViewerStateParams` object with the serialized parameters. Undefined values are removed.
|
|
994
|
-
*/
|
|
995
|
-
export function serializeViewerState(state, removeDefaults) {
|
|
996
|
-
var _state$maskAlpha, _state$brightness, _state$density, _state$levels, _state$time, _state$scene, _state$singleChannelI, _state$scaleLevelInde, _result;
|
|
997
|
-
if (removeDefaults) {
|
|
998
|
-
state = removeMatchingProperties(state, getDefaultViewerState());
|
|
999
|
-
// special case: if there's an explicit scale level but it's not being used, no reason to include it
|
|
1000
|
-
if (state.scaleLevelIndex !== undefined && state.useExactScaleLevel === undefined) {
|
|
1001
|
-
delete state.scaleLevelIndex;
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
var result = (_result = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_result, ViewerStateKeys.Mode, state.renderMode), ViewerStateKeys.Mask, (_state$maskAlpha = state.maskAlpha) === null || _state$maskAlpha === void 0 ? void 0 : _state$maskAlpha.toString()), ViewerStateKeys.Image, state.imageType), ViewerStateKeys.Axes, serializeBoolean(state.showAxes)), ViewerStateKeys.BoundingBox, serializeBoolean(state.showBoundingBox)), ViewerStateKeys.BoundingBoxColor, state.boundingBoxColor && colorArrayToHex(state.boundingBoxColor)), ViewerStateKeys.BackgroundColor, state.backgroundColor && colorArrayToHex(state.backgroundColor)), ViewerStateKeys.Autorotate, serializeBoolean(state.autorotate)), ViewerStateKeys.Brightness, (_state$brightness = state.brightness) === null || _state$brightness === void 0 ? void 0 : _state$brightness.toString()), ViewerStateKeys.Density, (_state$density = state.density) === null || _state$density === void 0 ? void 0 : _state$density.toString()), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_result, ViewerStateKeys.Interpolation, serializeBoolean(state.interpolationEnabled)), ViewerStateKeys.Region, state.region && serializeRegion(state.region)), ViewerStateKeys.Slice, state.slice && serializeSlice(state.slice)), ViewerStateKeys.Levels, (_state$levels = state.levels) === null || _state$levels === void 0 ? void 0 : _state$levels.join(",")), ViewerStateKeys.Time, (_state$time = state.time) === null || _state$time === void 0 ? void 0 : _state$time.toString()), ViewerStateKeys.Scene, (_state$scene = state.scene) === null || _state$scene === void 0 ? void 0 : _state$scene.toString()), ViewerStateKeys.SingleChannelMode, serializeBoolean(state.singleChannelMode)), ViewerStateKeys.SingleChannelIndex, (_state$singleChannelI = state.singleChannelIndex) === null || _state$singleChannelI === void 0 ? void 0 : _state$singleChannelI.toString()), ViewerStateKeys.UseExactScaleLevel, serializeBoolean(state.useExactScaleLevel)), ViewerStateKeys.ScaleLevelIndex, (_state$scaleLevelInde = state.scaleLevelIndex) === null || _state$scaleLevelInde === void 0 ? void 0 : _state$scaleLevelInde.toString()), _defineProperty(_result, ViewerStateKeys.CameraState, state.cameraState && serializeCameraState(state.cameraState, removeDefaults, state.viewMode)));
|
|
1005
|
-
var viewModeToViewParam = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ViewMode.threeD, "3D"), ViewMode.xy, "Z"), ViewMode.xz, "Y"), ViewMode.yz, "X");
|
|
1006
|
-
result[ViewerStateKeys.View] = state.viewMode && viewModeToViewParam[state.viewMode];
|
|
1007
|
-
return removeUndefinedProperties(result);
|
|
1008
|
-
}
|
|
1009
195
|
function parseDeprecatedChannelSettings(params) {
|
|
1010
196
|
// old, deprecated channels model
|
|
1011
197
|
if (params.ch) {
|
|
@@ -1087,7 +273,7 @@ function loadDataset(_x, _x2, _x3) {
|
|
|
1087
273
|
}
|
|
1088
274
|
function _loadDataset() {
|
|
1089
275
|
_loadDataset = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(firestore, dataset, id) {
|
|
1090
|
-
var db, args, datasets, datasetMeta,
|
|
276
|
+
var db, args, datasets, datasetMeta, _iterator2, _step2, d, innerDatasets, names, matchingName, datasetData, baseUrl, fileInfo;
|
|
1091
277
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1092
278
|
while (1) switch (_context.prev = _context.next) {
|
|
1093
279
|
case 0:
|
|
@@ -1098,15 +284,15 @@ function _loadDataset() {
|
|
|
1098
284
|
case 4:
|
|
1099
285
|
datasets = _context.sent;
|
|
1100
286
|
datasetMeta = undefined;
|
|
1101
|
-
|
|
287
|
+
_iterator2 = _createForOfIteratorHelper(datasets);
|
|
1102
288
|
_context.prev = 7;
|
|
1103
|
-
|
|
289
|
+
_iterator2.s();
|
|
1104
290
|
case 9:
|
|
1105
|
-
if ((
|
|
291
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
1106
292
|
_context.next = 19;
|
|
1107
293
|
break;
|
|
1108
294
|
}
|
|
1109
|
-
d =
|
|
295
|
+
d = _step2.value;
|
|
1110
296
|
innerDatasets = d.datasets;
|
|
1111
297
|
names = Object.keys(innerDatasets);
|
|
1112
298
|
matchingName = names.find(function (name) {
|
|
@@ -1127,10 +313,10 @@ function _loadDataset() {
|
|
|
1127
313
|
case 21:
|
|
1128
314
|
_context.prev = 21;
|
|
1129
315
|
_context.t0 = _context["catch"](7);
|
|
1130
|
-
|
|
316
|
+
_iterator2.e(_context.t0);
|
|
1131
317
|
case 24:
|
|
1132
318
|
_context.prev = 24;
|
|
1133
|
-
|
|
319
|
+
_iterator2.f();
|
|
1134
320
|
return _context.finish(24);
|
|
1135
321
|
case 27:
|
|
1136
322
|
if (!(datasetMeta === undefined)) {
|