@aics/vole-app 2.11.0
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/LICENSE +33 -0
- package/LICENSE.txt +26 -0
- package/README.md +45 -0
- package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-500.eot +0 -0
- package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-500.js +2337 -0
- package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-500.svg +604 -0
- package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-500.ttf +0 -0
- package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-500.woff +0 -0
- package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-500.woff2 +0 -0
- package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-700.eot +0 -0
- package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-700.js +2336 -0
- package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-700.svg +604 -0
- package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-700.ttf +0 -0
- package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-700.woff +0 -0
- package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-700.woff2 +0 -0
- package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-regular.eot +0 -0
- package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-regular.js +2337 -0
- package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-regular.svg +604 -0
- package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-regular.ttf +0 -0
- package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-regular.woff +0 -0
- package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-regular.woff2 +0 -0
- package/es/aics-image-viewer/assets/icons/axes.js +20 -0
- package/es/aics-image-viewer/assets/icons/boundingBox.js +18 -0
- package/es/aics-image-viewer/assets/icons/camera.js +15 -0
- package/es/aics-image-viewer/assets/icons/channels.js +15 -0
- package/es/aics-image-viewer/assets/icons/closePanel.js +18 -0
- package/es/aics-image-viewer/assets/icons/download.js +17 -0
- package/es/aics-image-viewer/assets/icons/dropdownArrow.js +15 -0
- package/es/aics-image-viewer/assets/icons/index.js +24 -0
- package/es/aics-image-viewer/assets/icons/metadata.js +15 -0
- package/es/aics-image-viewer/assets/icons/preferences.js +15 -0
- package/es/aics-image-viewer/assets/icons/resetView.js +16 -0
- package/es/aics-image-viewer/assets/icons/svg.d.js +0 -0
- package/es/aics-image-viewer/assets/icons/turnTable.js +18 -0
- package/es/aics-image-viewer/assets/styles/animatedEllipsis.css +21 -0
- package/es/aics-image-viewer/assets/styles/globals.css +35 -0
- package/es/aics-image-viewer/assets/styles/noui-slider-override.css +1 -0
- package/es/aics-image-viewer/assets/styles/variables.css +1 -0
- package/es/aics-image-viewer/components/App/ChannelUpdater.js +96 -0
- package/es/aics-image-viewer/components/App/index.js +849 -0
- package/es/aics-image-viewer/components/App/styles.css +60 -0
- package/es/aics-image-viewer/components/App/types.js +1 -0
- package/es/aics-image-viewer/components/AxisClipSliders/index.js +285 -0
- package/es/aics-image-viewer/components/AxisClipSliders/styles.css +257 -0
- package/es/aics-image-viewer/components/BottomPanel/index.js +70 -0
- package/es/aics-image-viewer/components/BottomPanel/styles.css +85 -0
- package/es/aics-image-viewer/components/CellViewerCanvasWrapper/index.js +113 -0
- package/es/aics-image-viewer/components/CellViewerCanvasWrapper/styles.css +12 -0
- package/es/aics-image-viewer/components/ChannelsWidget.js +100 -0
- package/es/aics-image-viewer/components/ChannelsWidgetRow/index.js +158 -0
- package/es/aics-image-viewer/components/ChannelsWidgetRow/styles.css +38 -0
- package/es/aics-image-viewer/components/ColorPicker.js +120 -0
- package/es/aics-image-viewer/components/ControlPanel/index.js +180 -0
- package/es/aics-image-viewer/components/ControlPanel/styles.css +169 -0
- package/es/aics-image-viewer/components/CustomizeWidget.js +46 -0
- package/es/aics-image-viewer/components/ErrorAlert/index.js +144 -0
- package/es/aics-image-viewer/components/ErrorAlert/styles.css +22 -0
- package/es/aics-image-viewer/components/GlobalVolumeControls.js +38 -0
- package/es/aics-image-viewer/components/MetadataViewer/index.js +99 -0
- package/es/aics-image-viewer/components/MetadataViewer/styles.css +81 -0
- package/es/aics-image-viewer/components/StyleProvider/index.js +210 -0
- package/es/aics-image-viewer/components/TfEditor/index.js +584 -0
- package/es/aics-image-viewer/components/TfEditor/styles.css +88 -0
- package/es/aics-image-viewer/components/Toolbar/DownloadButton.js +55 -0
- package/es/aics-image-viewer/components/Toolbar/ViewModeRadioButtons.js +22 -0
- package/es/aics-image-viewer/components/Toolbar/index.js +274 -0
- package/es/aics-image-viewer/components/Toolbar/styles.css +241 -0
- package/es/aics-image-viewer/components/ViewerStateProvider/ResetStateProvider.js +160 -0
- package/es/aics-image-viewer/components/ViewerStateProvider/index.js +261 -0
- package/es/aics-image-viewer/components/ViewerStateProvider/types.js +1 -0
- package/es/aics-image-viewer/components/shared/NumericInput/index.js +147 -0
- package/es/aics-image-viewer/components/shared/NumericInput/styles.css +64 -0
- package/es/aics-image-viewer/components/shared/SharedCheckBox.js +17 -0
- package/es/aics-image-viewer/components/shared/SliderRow/index.js +31 -0
- package/es/aics-image-viewer/components/shared/SliderRow/styles.css +19 -0
- package/es/aics-image-viewer/components/shared/SmarterSlider.js +40 -0
- package/es/aics-image-viewer/components/shared/ViewerIcon.js +22 -0
- package/es/aics-image-viewer/shared/colorPalette.js +19 -0
- package/es/aics-image-viewer/shared/constants.js +164 -0
- package/es/aics-image-viewer/shared/enums.js +18 -0
- package/es/aics-image-viewer/shared/types.js +6 -0
- package/es/aics-image-viewer/shared/utils/colorRepresentations.js +16 -0
- package/es/aics-image-viewer/shared/utils/controlPointsToLut.js +182 -0
- package/es/aics-image-viewer/shared/utils/hooks.js +51 -0
- package/es/aics-image-viewer/shared/utils/httpClient.js +57 -0
- package/es/aics-image-viewer/shared/utils/playControls.js +97 -0
- package/es/aics-image-viewer/shared/utils/sceneStore.js +140 -0
- package/es/aics-image-viewer/shared/utils/sliderValuesToImageValues.js +36 -0
- package/es/aics-image-viewer/shared/utils/test/viewerChannelSettings.test.js +132 -0
- package/es/aics-image-viewer/shared/utils/utilsService.js +54 -0
- package/es/aics-image-viewer/shared/utils/viewerChannelSettings.js +152 -0
- package/es/aics-image-viewer/shared/utils/viewerState.js +69 -0
- package/es/aics-image-viewer/shared/utils/webgl-debug.js +1103 -0
- package/es/index.js +4 -0
- package/package.json +130 -0
- package/type-declarations/aics-image-viewer/assets/icons/index.d.ts +14 -0
- package/type-declarations/aics-image-viewer/components/App/ChannelUpdater.d.ts +16 -0
- package/type-declarations/aics-image-viewer/components/App/index.d.ts +6 -0
- package/type-declarations/aics-image-viewer/components/App/types.d.ts +45 -0
- package/type-declarations/aics-image-viewer/components/AxisClipSliders/index.d.ts +24 -0
- package/type-declarations/aics-image-viewer/components/BottomPanel/index.d.ts +11 -0
- package/type-declarations/aics-image-viewer/components/CellViewerCanvasWrapper/index.d.ts +33 -0
- package/type-declarations/aics-image-viewer/components/ChannelsWidget.d.ts +19 -0
- package/type-declarations/aics-image-viewer/components/ChannelsWidgetRow/index.d.ts +17 -0
- package/type-declarations/aics-image-viewer/components/ColorPicker.d.ts +13 -0
- package/type-declarations/aics-image-viewer/components/ControlPanel/index.d.ts +20 -0
- package/type-declarations/aics-image-viewer/components/CustomizeWidget.d.ts +15 -0
- package/type-declarations/aics-image-viewer/components/ErrorAlert/index.d.ts +12 -0
- package/type-declarations/aics-image-viewer/components/GlobalVolumeControls.d.ts +21 -0
- package/type-declarations/aics-image-viewer/components/MetadataViewer/index.d.ts +7 -0
- package/type-declarations/aics-image-viewer/components/StyleProvider/index.d.ts +5 -0
- package/type-declarations/aics-image-viewer/components/TfEditor/index.d.ts +19 -0
- package/type-declarations/aics-image-viewer/components/Toolbar/DownloadButton.d.ts +8 -0
- package/type-declarations/aics-image-viewer/components/Toolbar/ViewModeRadioButtons.d.ts +8 -0
- package/type-declarations/aics-image-viewer/components/Toolbar/index.d.ts +31 -0
- package/type-declarations/aics-image-viewer/components/ViewerStateProvider/ResetStateProvider.d.ts +34 -0
- package/type-declarations/aics-image-viewer/components/ViewerStateProvider/index.d.ts +33 -0
- package/type-declarations/aics-image-viewer/components/ViewerStateProvider/types.d.ts +105 -0
- package/type-declarations/aics-image-viewer/components/shared/NumericInput/index.d.ts +19 -0
- package/type-declarations/aics-image-viewer/components/shared/SharedCheckBox.d.ts +9 -0
- package/type-declarations/aics-image-viewer/components/shared/SliderRow/index.d.ts +17 -0
- package/type-declarations/aics-image-viewer/components/shared/SmarterSlider.d.ts +5 -0
- package/type-declarations/aics-image-viewer/components/shared/ViewerIcon.d.ts +9 -0
- package/type-declarations/aics-image-viewer/shared/constants.d.ts +40 -0
- package/type-declarations/aics-image-viewer/shared/enums.d.ts +15 -0
- package/type-declarations/aics-image-viewer/shared/types.d.ts +15 -0
- package/type-declarations/aics-image-viewer/shared/utils/colorRepresentations.d.ts +10 -0
- package/type-declarations/aics-image-viewer/shared/utils/controlPointsToLut.d.ts +53 -0
- package/type-declarations/aics-image-viewer/shared/utils/hooks.d.ts +14 -0
- package/type-declarations/aics-image-viewer/shared/utils/playControls.d.ts +27 -0
- package/type-declarations/aics-image-viewer/shared/utils/sceneStore.d.ts +17 -0
- package/type-declarations/aics-image-viewer/shared/utils/sliderValuesToImageValues.d.ts +10 -0
- package/type-declarations/aics-image-viewer/shared/utils/viewerChannelSettings.d.ts +46 -0
- package/type-declarations/aics-image-viewer/shared/utils/viewerState.d.ts +10 -0
- package/type-declarations/index.d.ts +7 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import SmarterSlider from "../SmarterSlider";
|
|
3
|
+
import "./styles.css";
|
|
4
|
+
var INTEGER_FORMATTER = {
|
|
5
|
+
to: Math.round,
|
|
6
|
+
from: Number
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/** A component to ensure a single unified style across the many labeled slider rows in the control panel */
|
|
10
|
+
var SliderRow = function SliderRow(props) {
|
|
11
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
12
|
+
className: "viewer-control-row"
|
|
13
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
14
|
+
className: "control-name"
|
|
15
|
+
}, props.label), /*#__PURE__*/React.createElement("div", {
|
|
16
|
+
className: "control"
|
|
17
|
+
}, props.start === undefined ? props.children : !props.hideSlider && /*#__PURE__*/React.createElement(SmarterSlider, {
|
|
18
|
+
range: {
|
|
19
|
+
min: 0,
|
|
20
|
+
max: props.max
|
|
21
|
+
},
|
|
22
|
+
start: props.start,
|
|
23
|
+
connect: true,
|
|
24
|
+
tooltips: true,
|
|
25
|
+
behaviour: "drag",
|
|
26
|
+
format: props.formatInteger ? INTEGER_FORMATTER : undefined,
|
|
27
|
+
onUpdate: props.onUpdate,
|
|
28
|
+
onChange: props.onChange
|
|
29
|
+
})));
|
|
30
|
+
};
|
|
31
|
+
export default SliderRow;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.viewer-control-row{
|
|
2
|
+
display:flex;
|
|
3
|
+
align-items:center;
|
|
4
|
+
margin-right:10px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.viewer-control-row:not(:last-child){
|
|
8
|
+
margin-bottom:20px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.viewer-control-row .control-name{
|
|
12
|
+
color:var(--color-controlpanel-text);
|
|
13
|
+
flex:2;
|
|
14
|
+
white-space:nowrap;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.viewer-control-row .control{
|
|
18
|
+
flex:5;
|
|
19
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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 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; }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
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); }
|
|
7
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
9
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
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
|
+
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
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
13
|
+
import React from "react";
|
|
14
|
+
import Nouislider from "nouislider-react";
|
|
15
|
+
var MemoedNouislider = /*#__PURE__*/React.memo(Nouislider, function (_prevProps, _ref) {
|
|
16
|
+
var noUpdate = _ref.noUpdate;
|
|
17
|
+
return noUpdate;
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/** A wrapper around `Nouislider` that prevents updates while the slider is being dragged. */
|
|
21
|
+
var SmarterSlider = function SmarterSlider(props) {
|
|
22
|
+
var _React$useState = React.useState(false),
|
|
23
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
24
|
+
noUpdate = _React$useState2[0],
|
|
25
|
+
setNoUpdate = _React$useState2[1];
|
|
26
|
+
var wrapEventHandler = function wrapEventHandler(shouldNotUpdate, handler) {
|
|
27
|
+
return function () {
|
|
28
|
+
setNoUpdate(shouldNotUpdate);
|
|
29
|
+
if (handler) handler.apply(void 0, arguments);
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
var onStart = wrapEventHandler(true, props.onStart);
|
|
33
|
+
var onEnd = wrapEventHandler(false, props.onEnd);
|
|
34
|
+
return /*#__PURE__*/React.createElement(MemoedNouislider, _objectSpread(_objectSpread({}, props), {}, {
|
|
35
|
+
noUpdate: noUpdate,
|
|
36
|
+
onStart: onStart,
|
|
37
|
+
onEnd: onEnd
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
40
|
+
export default SmarterSlider;
|
|
@@ -0,0 +1,22 @@
|
|
|
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 _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
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
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
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
|
+
import Icon from "@ant-design/icons";
|
|
10
|
+
import ICONS from "../../assets/icons";
|
|
11
|
+
var STYLE = {
|
|
12
|
+
fontSize: "19px"
|
|
13
|
+
};
|
|
14
|
+
/** Wrapper component for easy inclusion of our own custom icons. */
|
|
15
|
+
var ViewerIcon = function ViewerIcon(props) {
|
|
16
|
+
var newProps = _objectSpread({}, props);
|
|
17
|
+
newProps.style = _objectSpread(_objectSpread({}, STYLE), props.style);
|
|
18
|
+
return /*#__PURE__*/React.createElement(Icon, _extends({
|
|
19
|
+
component: ICONS[props.type]
|
|
20
|
+
}, newProps));
|
|
21
|
+
};
|
|
22
|
+
export default ViewerIcon;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
primary1Color: "#0B9AAB",
|
|
3
|
+
// bright blue
|
|
4
|
+
primary2Color: "#827AA3",
|
|
5
|
+
// aics purple
|
|
6
|
+
primary3Color: "#d8e0e2",
|
|
7
|
+
// light blue gray
|
|
8
|
+
accent1Color: "#B8D637",
|
|
9
|
+
// aics lime green light
|
|
10
|
+
accent2Color: "#C1F448",
|
|
11
|
+
// aics lime green bright
|
|
12
|
+
accent3Color: "#d8e0e2",
|
|
13
|
+
// light blue gray
|
|
14
|
+
textColor: "#003057",
|
|
15
|
+
// dark blue
|
|
16
|
+
disabledColor: "#D1D1D1",
|
|
17
|
+
// dull gray
|
|
18
|
+
pickerHeaderColor: "#316773" // cool blue green
|
|
19
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
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 _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; }
|
|
3
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
4
|
+
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); }
|
|
5
|
+
import { ImageType, RenderMode, ViewMode } from "./enums";
|
|
6
|
+
// Add all exported constants here to prevent circular dependencies
|
|
7
|
+
export var
|
|
8
|
+
// Control panel will automatically close if viewport is less than this width
|
|
9
|
+
CONTROL_PANEL_CLOSE_WIDTH = 970,
|
|
10
|
+
CLIPPING_PANEL_HEIGHT_DEFAULT = 200,
|
|
11
|
+
CLIPPING_PANEL_HEIGHT_TALL = 235,
|
|
12
|
+
BACKGROUND_COLOR_DEFAULT = [0, 0, 0],
|
|
13
|
+
BOUNDING_BOX_COLOR_DEFAULT = [255, 255, 255],
|
|
14
|
+
AXIS_MARGIN_DEFAULT = [16, 16],
|
|
15
|
+
SCALE_BAR_MARGIN_DEFAULT = [120, 12],
|
|
16
|
+
// These settings were chosen to work well with most AICS microscopy pipeline images.
|
|
17
|
+
// These numbers mean: remap the bottom LUT_MIN_PERCENTILE fraction of pixels to zero intensity,
|
|
18
|
+
// and linearly increase intensity up to the LUT_MAX_PERCENTILE fraction of pixels.
|
|
19
|
+
LUT_MIN_PERCENTILE = 0.5,
|
|
20
|
+
LUT_MAX_PERCENTILE = 0.983,
|
|
21
|
+
ISOSURFACE_OPACITY_SLIDER_MAX = 255.0,
|
|
22
|
+
ALPHA_MASK_SLIDER_DEFAULT = 0,
|
|
23
|
+
BRIGHTNESS_SLIDER_LEVEL_DEFAULT = 70,
|
|
24
|
+
DENSITY_SLIDER_LEVEL_DEFAULT = 50,
|
|
25
|
+
LEVELS_SLIDER_DEFAULT = [35.0, 140.0, 255.0],
|
|
26
|
+
INTERPOLATION_ENABLED_DEFAULT = true,
|
|
27
|
+
OTHER_CHANNEL_KEY = "Other",
|
|
28
|
+
SINGLE_GROUP_CHANNEL_KEY = "Channels";
|
|
29
|
+
export var TFEDITOR_DEFAULT_COLOR = [255, 255, 255];
|
|
30
|
+
export var TFEDITOR_MAX_BIN = 255;
|
|
31
|
+
export var CACHE_MAX_SIZE = 1000000000;
|
|
32
|
+
export var QUEUE_MAX_SIZE = 10;
|
|
33
|
+
export var QUEUE_MAX_LOW_PRIORITY_SIZE = 4;
|
|
34
|
+
export var PRESET_COLORS_1 = [[190, 68, 171], [189, 211, 75], [61, 155, 169], [128, 128, 128], [255, 255, 255], [239, 27, 45], [238, 77, 245], [96, 255, 255]];
|
|
35
|
+
export var PRESET_COLORS_2 = [[128, 0, 0], [0, 128, 0], [0, 0, 128], [32, 32, 32], [255, 255, 0], [255, 0, 255], [0, 255, 0], [0, 0, 255]];
|
|
36
|
+
export var PRESET_COLORS_3 = [[128, 0, 128], [128, 128, 128], [0, 128, 128], [128, 128, 0], [255, 255, 255], [255, 0, 0], [255, 0, 255], [0, 255, 255]];
|
|
37
|
+
export var PRESET_COLORS_0 = [[226, 205, 179], [111, 186, 17], [141, 163, 192], [245, 241, 203], [224, 227, 209], [221, 155, 245], [227, 244, 245], [255, 98, 0], [247, 219, 120]];
|
|
38
|
+
export var PRESET_COLOR_MAP = Object.freeze([{
|
|
39
|
+
colors: PRESET_COLORS_0,
|
|
40
|
+
name: "Default"
|
|
41
|
+
}, {
|
|
42
|
+
colors: PRESET_COLORS_1,
|
|
43
|
+
name: "Thumbnail colors"
|
|
44
|
+
}, {
|
|
45
|
+
colors: PRESET_COLORS_2,
|
|
46
|
+
name: "RGB colors"
|
|
47
|
+
}, {
|
|
48
|
+
colors: PRESET_COLORS_3,
|
|
49
|
+
name: "White structure"
|
|
50
|
+
}]);
|
|
51
|
+
|
|
52
|
+
/** Allows the 3D viewer to apply the default camera settings for the view mode. */
|
|
53
|
+
var USE_VIEW_MODE_DEFAULT_CAMERA = undefined;
|
|
54
|
+
var viewModeToDefaultCameraPosition = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ViewMode.threeD, [0, 0, 5]), ViewMode.xy, [0, 0, 2]), ViewMode.xz, [0, 2, 0]), ViewMode.yz, [2, 0, 0]);
|
|
55
|
+
var viewModeToDefaultCameraUp = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ViewMode.threeD, [0, 1, 0]), ViewMode.xy, [0, 1, 0]), ViewMode.xz, [0, 0, 1]), ViewMode.yz, [0, 0, 1]);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Reflects the default camera settings the 3D viewer uses on volume load.
|
|
59
|
+
* These SHOULD NOT be changed; otherwise, existing shared links that don't specify the
|
|
60
|
+
* camera settings will use the new defaults and may be in unexpected orientations or positions.
|
|
61
|
+
*/
|
|
62
|
+
export var getDefaultCameraState = function getDefaultCameraState() {
|
|
63
|
+
var viewMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ViewMode.threeD;
|
|
64
|
+
return {
|
|
65
|
+
// Default position varies by view mode
|
|
66
|
+
position: viewModeToDefaultCameraPosition[viewMode],
|
|
67
|
+
target: [0, 0, 0],
|
|
68
|
+
up: viewModeToDefaultCameraUp[viewMode],
|
|
69
|
+
fov: 20,
|
|
70
|
+
orthoScale: 0.5
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export var getDefaultViewerChannelSettings = function getDefaultViewerChannelSettings() {
|
|
74
|
+
return {
|
|
75
|
+
groups: [{
|
|
76
|
+
name: "Channels",
|
|
77
|
+
channels: [{
|
|
78
|
+
match: [0, 1, 2],
|
|
79
|
+
enabled: true
|
|
80
|
+
}, {
|
|
81
|
+
match: "(.+)",
|
|
82
|
+
enabled: false
|
|
83
|
+
}]
|
|
84
|
+
}]
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Returns the default viewer state as a new object.
|
|
90
|
+
*/
|
|
91
|
+
export var getDefaultViewerState = function getDefaultViewerState() {
|
|
92
|
+
return {
|
|
93
|
+
viewMode: ViewMode.threeD,
|
|
94
|
+
// "XY", "XZ", "YZ"
|
|
95
|
+
renderMode: RenderMode.volumetric,
|
|
96
|
+
// "pathtrace", "maxproject"
|
|
97
|
+
imageType: ImageType.segmentedCell,
|
|
98
|
+
showAxes: false,
|
|
99
|
+
showBoundingBox: false,
|
|
100
|
+
backgroundColor: BACKGROUND_COLOR_DEFAULT,
|
|
101
|
+
boundingBoxColor: BOUNDING_BOX_COLOR_DEFAULT,
|
|
102
|
+
autorotate: false,
|
|
103
|
+
maskAlpha: ALPHA_MASK_SLIDER_DEFAULT,
|
|
104
|
+
brightness: BRIGHTNESS_SLIDER_LEVEL_DEFAULT,
|
|
105
|
+
density: DENSITY_SLIDER_LEVEL_DEFAULT,
|
|
106
|
+
levels: LEVELS_SLIDER_DEFAULT,
|
|
107
|
+
interpolationEnabled: INTERPOLATION_ENABLED_DEFAULT,
|
|
108
|
+
region: {
|
|
109
|
+
x: [0, 1],
|
|
110
|
+
y: [0, 1],
|
|
111
|
+
z: [0, 1]
|
|
112
|
+
},
|
|
113
|
+
slice: {
|
|
114
|
+
x: 0.5,
|
|
115
|
+
y: 0.5,
|
|
116
|
+
z: 0.5
|
|
117
|
+
},
|
|
118
|
+
time: 0,
|
|
119
|
+
scene: 0,
|
|
120
|
+
// Do not override camera position, target, etc. by default;
|
|
121
|
+
// instead, let the viewer apply default camera settings based on the view mode.
|
|
122
|
+
// This prevents a bug where the camera's position and view mode are set to
|
|
123
|
+
// incompatible states and the viewport becomes blank.
|
|
124
|
+
cameraState: USE_VIEW_MODE_DEFAULT_CAMERA
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
var INIT_COLORS = PRESET_COLORS_0;
|
|
128
|
+
|
|
129
|
+
/** Returns the default color for a channel, by its index. */
|
|
130
|
+
export function getDefaultChannelColor(channelIndex) {
|
|
131
|
+
return INIT_COLORS[channelIndex % INIT_COLORS.length];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Returns the default channel state as a new object. If an index is provided, uses the default
|
|
136
|
+
* color preset for that index.
|
|
137
|
+
* @param index Optional channel index to use for the color preset.
|
|
138
|
+
* @returns a default ChannelState object.
|
|
139
|
+
*/
|
|
140
|
+
export var getDefaultChannelState = function getDefaultChannelState() {
|
|
141
|
+
var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
142
|
+
return {
|
|
143
|
+
name: "",
|
|
144
|
+
displayName: "",
|
|
145
|
+
volumeEnabled: false,
|
|
146
|
+
isosurfaceEnabled: false,
|
|
147
|
+
colorizeEnabled: false,
|
|
148
|
+
colorizeAlpha: 1.0,
|
|
149
|
+
isovalue: 128,
|
|
150
|
+
opacity: 1.0,
|
|
151
|
+
color: getDefaultChannelColor(index),
|
|
152
|
+
useControlPoints: false,
|
|
153
|
+
ramp: [0, TFEDITOR_MAX_BIN],
|
|
154
|
+
controlPoints: [{
|
|
155
|
+
x: 0,
|
|
156
|
+
opacity: 0,
|
|
157
|
+
color: [255, 255, 255]
|
|
158
|
+
}, {
|
|
159
|
+
x: 255,
|
|
160
|
+
opacity: 1,
|
|
161
|
+
color: [255, 255, 255]
|
|
162
|
+
}]
|
|
163
|
+
};
|
|
164
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export var ViewMode = /*#__PURE__*/function (ViewMode) {
|
|
2
|
+
ViewMode["threeD"] = "3D";
|
|
3
|
+
ViewMode["xy"] = "XY";
|
|
4
|
+
ViewMode["xz"] = "XZ";
|
|
5
|
+
ViewMode["yz"] = "YZ";
|
|
6
|
+
return ViewMode;
|
|
7
|
+
}({});
|
|
8
|
+
export var RenderMode = /*#__PURE__*/function (RenderMode) {
|
|
9
|
+
RenderMode["volumetric"] = "volumetric";
|
|
10
|
+
RenderMode["maxProject"] = "maxproject";
|
|
11
|
+
RenderMode["pathTrace"] = "pathtrace";
|
|
12
|
+
return RenderMode;
|
|
13
|
+
}({});
|
|
14
|
+
export var ImageType = /*#__PURE__*/function (ImageType) {
|
|
15
|
+
ImageType["segmentedCell"] = "cell";
|
|
16
|
+
ImageType["fullField"] = "fov";
|
|
17
|
+
return ImageType;
|
|
18
|
+
}({});
|
|
@@ -0,0 +1,6 @@
|
|
|
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 _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; }
|
|
3
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
4
|
+
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); }
|
|
5
|
+
import { ViewMode } from "./enums";
|
|
6
|
+
export var activeAxisMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ViewMode.yz, "x"), ViewMode.xz, "y"), ViewMode.xy, "z"), ViewMode.threeD, null);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export var colorObjectToArray = function colorObjectToArray(obj) {
|
|
2
|
+
return [obj.r, obj.g, obj.b];
|
|
3
|
+
};
|
|
4
|
+
export var colorArrayToObject = function colorArrayToObject(arr) {
|
|
5
|
+
return {
|
|
6
|
+
r: arr[0],
|
|
7
|
+
g: arr[1],
|
|
8
|
+
b: arr[2]
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export var colorArrayToFloats = function colorArrayToFloats(arr) {
|
|
12
|
+
return [arr[0] / 255, arr[1] / 255, arr[2] / 255];
|
|
13
|
+
};
|
|
14
|
+
export var colorArrayToString = function colorArrayToString(arr) {
|
|
15
|
+
return "rgb(".concat(arr[0], ", ").concat(arr[1], ", ").concat(arr[2], ")");
|
|
16
|
+
};
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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; } }
|
|
4
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
5
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
6
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
8
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
9
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
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
|
+
import { Lut, remapControlPoints } from "@aics/vole-core";
|
|
12
|
+
import { LUT_MAX_PERCENTILE, LUT_MIN_PERCENTILE, TFEDITOR_DEFAULT_COLOR, TFEDITOR_MAX_BIN } from "../constants";
|
|
13
|
+
import { findFirstChannelMatch } from "./viewerChannelSettings";
|
|
14
|
+
|
|
15
|
+
// @param {Object[]} controlPoints - array of {x:number, opacity:number, color:string}
|
|
16
|
+
// @return {Uint8Array} array of length 256*4 representing the rgba values of the gradient
|
|
17
|
+
export function controlPointsToLut(controlPoints) {
|
|
18
|
+
var lut = new Lut().createFromControlPoints(controlPoints);
|
|
19
|
+
return lut;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Returns a default lookup table based on a min/max percentile of the current volume's data. */
|
|
23
|
+
export function getDefaultLut(histogram) {
|
|
24
|
+
var hmin = histogram.findBinOfPercentile(LUT_MIN_PERCENTILE);
|
|
25
|
+
var hmax = histogram.findBinOfPercentile(LUT_MAX_PERCENTILE);
|
|
26
|
+
return new Lut().createFromMinMax(hmin, hmax);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Parses a single LUT value from a string, where the value is either a number, a percentile, or a median multiplier.
|
|
31
|
+
*/
|
|
32
|
+
function parseLutValue(value, histogram) {
|
|
33
|
+
// look at first char of string.
|
|
34
|
+
var firstChar = value.charAt(0);
|
|
35
|
+
if (firstChar === "m") {
|
|
36
|
+
// median
|
|
37
|
+
var parsedValue = parseFloat(value.substring(1)) / 100.0;
|
|
38
|
+
return histogram.maxBin * parsedValue;
|
|
39
|
+
} else if (firstChar === "p") {
|
|
40
|
+
// percentile
|
|
41
|
+
var _parsedValue = parseFloat(value.substring(1)) / 100.0;
|
|
42
|
+
return histogram.findBinOfPercentile(_parsedValue);
|
|
43
|
+
} else {
|
|
44
|
+
// plain number
|
|
45
|
+
return parseFloat(value);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Parses a lookup table (LUT) from a `ViewerChannelSetting` object, where the `lut` field is an
|
|
51
|
+
* array of two alphanumeric strings.
|
|
52
|
+
*
|
|
53
|
+
* @returns a Lut object if the `lut` field is valid; otherwise, returns undefined.
|
|
54
|
+
*
|
|
55
|
+
* Min and max values are determined as following:
|
|
56
|
+
* - Plain numbers are direct intensity values.
|
|
57
|
+
* - `p{n}` represents a percentile, where `n` is a percentile in the [0, 100] range.
|
|
58
|
+
* - `m{n}` represents the median multiplied by `n / 100`.
|
|
59
|
+
* - `autoij` in either the min or max fields will use the "auto" algorithm
|
|
60
|
+
* from ImageJ to select the min AND max.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```
|
|
64
|
+
* "0:255" // min: intensity 0, max: intensity 255.
|
|
65
|
+
* "p50:p90" // min: 50th percentile, max: 90th percentile.
|
|
66
|
+
* "m1:p75" // min: median, max: 75th percentile.
|
|
67
|
+
* "autoij:0" // use Auto-IJ to calculate min and max.
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export function parseLutFromSettings(histogram, initSettings) {
|
|
71
|
+
if (initSettings.lut === undefined || initSettings.lut.length !== 2) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
var lutValues;
|
|
75
|
+
if (initSettings.lut[0] === "autoij" || initSettings.lut[1] === "autoij") {
|
|
76
|
+
lutValues = histogram.findAutoIJBins();
|
|
77
|
+
} else {
|
|
78
|
+
lutValues = [parseLutValue(initSettings.lut[0], histogram), parseLutValue(initSettings.lut[1], histogram)];
|
|
79
|
+
}
|
|
80
|
+
return new Lut().createFromMinMax(Math.min(lutValues[0], lutValues[1]), Math.max(lutValues[0], lutValues[1]));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Initializes the lookup table (LUT) that maps from volume intensity values to color + opacity and applies the LUT to the volume.
|
|
85
|
+
*
|
|
86
|
+
* @param aimg The loaded volume data.
|
|
87
|
+
* @param channelIndex The index of the channel to initialize the LUT for.
|
|
88
|
+
* @param channelSettings The ViewerChannelSettings object that may contain settings for this channel. If relevant
|
|
89
|
+
* settings are not found, a default LUT will be used.
|
|
90
|
+
* @returns an object containing the retrieved ramp control points and "advanced mode" control points.
|
|
91
|
+
*
|
|
92
|
+
* LUT values will be determined using the following rules:
|
|
93
|
+
* - If no `lut` is provided in the `channelSettings`, a default LUT is calculated using min/max percentiles of the data.
|
|
94
|
+
* - Otherwise, `lut` will be parsed as described in `ViewerChannelSettingParams.lut`.
|
|
95
|
+
* - The `controlPoints` and `ramp` fields in the `channelSettings` will be used to override the returned "advanced mode"
|
|
96
|
+
* control points and ramp, respectively.
|
|
97
|
+
*
|
|
98
|
+
* If `controlPointsEnabled` is set to true in the `channelSettings`, the "advanced mode" control points will be applied
|
|
99
|
+
* to the volume; otherwise, the ramp will be applied.
|
|
100
|
+
*/
|
|
101
|
+
export function initializeLut(aimg, channelIndex, channelSettings) {
|
|
102
|
+
var _initSettings$control;
|
|
103
|
+
var histogram = aimg.getHistogram(channelIndex);
|
|
104
|
+
var defaultLut = getDefaultLut(histogram);
|
|
105
|
+
var ramp = [];
|
|
106
|
+
var controlPoints = [];
|
|
107
|
+
var lut = defaultLut;
|
|
108
|
+
var name = aimg.channelNames[channelIndex];
|
|
109
|
+
var initSettings = channelSettings && findFirstChannelMatch(name, channelIndex, channelSettings);
|
|
110
|
+
|
|
111
|
+
// Attempt to load a LUT from the settings, which will be used to initialize the control points and ramp
|
|
112
|
+
if (initSettings && initSettings.lut) {
|
|
113
|
+
var _parseLutFromSettings;
|
|
114
|
+
lut = (_parseLutFromSettings = parseLutFromSettings(histogram, initSettings)) !== null && _parseLutFromSettings !== void 0 ? _parseLutFromSettings : defaultLut;
|
|
115
|
+
}
|
|
116
|
+
// Initialize the control points + ramp using the LUT.
|
|
117
|
+
// Optionally, override the LUT's control points with the provided control points and/or ramp.
|
|
118
|
+
controlPoints = (_initSettings$control = initSettings === null || initSettings === void 0 ? void 0 : initSettings.controlPoints) !== null && _initSettings$control !== void 0 ? _initSettings$control : _toConsumableArray(lut.controlPoints);
|
|
119
|
+
ramp = initSettings !== null && initSettings !== void 0 && initSettings.ramp ? rampToControlPoints(initSettings.ramp) : _toConsumableArray(lut.controlPoints);
|
|
120
|
+
|
|
121
|
+
// Apply whatever lut is currently visible
|
|
122
|
+
var visibleLut;
|
|
123
|
+
if (initSettings !== null && initSettings !== void 0 && initSettings.controlPointsEnabled) {
|
|
124
|
+
visibleLut = new Lut().createFromControlPoints(controlPoints);
|
|
125
|
+
} else {
|
|
126
|
+
visibleLut = new Lut().createFromControlPoints(ramp);
|
|
127
|
+
}
|
|
128
|
+
aimg.setLut(channelIndex, visibleLut);
|
|
129
|
+
return {
|
|
130
|
+
ramp: ramp,
|
|
131
|
+
controlPoints: controlPoints
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
export function controlPointsToRamp(controlPoints) {
|
|
135
|
+
if (controlPoints.length <= 1) {
|
|
136
|
+
return [0, TFEDITOR_MAX_BIN];
|
|
137
|
+
} else if (controlPoints.length === 2) {
|
|
138
|
+
return [controlPoints[0].x, controlPoints[1].x];
|
|
139
|
+
} else if (controlPoints.length === 3) {
|
|
140
|
+
if (controlPoints[0].opacity !== controlPoints[1].opacity && controlPoints[0].opacity !== controlPoints[2].opacity && controlPoints[1].opacity !== controlPoints[2].opacity) {
|
|
141
|
+
// if all 3 are unequal, assume a ramp from first to last
|
|
142
|
+
return [controlPoints[0].x, controlPoints[2].x];
|
|
143
|
+
} else if (controlPoints[0].opacity !== controlPoints[1].opacity) {
|
|
144
|
+
return [controlPoints[0].x, controlPoints[1].x];
|
|
145
|
+
} else if (controlPoints[1].opacity !== controlPoints[2].opacity) {
|
|
146
|
+
return [controlPoints[1].x, controlPoints[2].x];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return [controlPoints[1].x, controlPoints[controlPoints.length - 2].x];
|
|
150
|
+
}
|
|
151
|
+
export function rampToControlPoints(_ref) {
|
|
152
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
153
|
+
min = _ref2[0],
|
|
154
|
+
max = _ref2[1];
|
|
155
|
+
return [{
|
|
156
|
+
x: Math.min(min - 1, 0),
|
|
157
|
+
opacity: 0,
|
|
158
|
+
color: TFEDITOR_DEFAULT_COLOR
|
|
159
|
+
}, {
|
|
160
|
+
x: min,
|
|
161
|
+
opacity: 0,
|
|
162
|
+
color: TFEDITOR_DEFAULT_COLOR
|
|
163
|
+
}, {
|
|
164
|
+
x: max,
|
|
165
|
+
opacity: 1,
|
|
166
|
+
color: TFEDITOR_DEFAULT_COLOR
|
|
167
|
+
}, {
|
|
168
|
+
x: Math.max(max + 1, TFEDITOR_MAX_BIN),
|
|
169
|
+
opacity: 1,
|
|
170
|
+
color: TFEDITOR_DEFAULT_COLOR
|
|
171
|
+
}];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** Remaps an array of control points from an old range (as a 2-tuple) to a new one (extracted from a `Channel`) */
|
|
175
|
+
export function remapControlPointsForChannel(controlPoints, oldRange, _ref3) {
|
|
176
|
+
var rawMin = _ref3.rawMin,
|
|
177
|
+
rawMax = _ref3.rawMax;
|
|
178
|
+
if (oldRange === undefined) {
|
|
179
|
+
return controlPoints;
|
|
180
|
+
}
|
|
181
|
+
return remapControlPoints(controlPoints, oldRange[0], oldRange[1], rawMin, rawMax);
|
|
182
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
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; }
|
|
5
|
+
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; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
import { useState, useRef, useCallback } from "react";
|
|
8
|
+
|
|
9
|
+
/** A `useState` that also creates a getter function for breaking through closures. */
|
|
10
|
+
export function useStateWithGetter(initialState) {
|
|
11
|
+
var _useState = useState(initialState),
|
|
12
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
13
|
+
state = _useState2[0],
|
|
14
|
+
setState = _useState2[1];
|
|
15
|
+
var stateRef = useRef(state);
|
|
16
|
+
var wrappedSetState = useCallback(function (value) {
|
|
17
|
+
stateRef.current = value;
|
|
18
|
+
setState(value);
|
|
19
|
+
}, []);
|
|
20
|
+
var getState = useCallback(function () {
|
|
21
|
+
return stateRef.current;
|
|
22
|
+
}, []);
|
|
23
|
+
return [state, wrappedSetState, getState];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Wraps a setter function and keeps a ref updated to follow the set value. Useful for making the most up-to-date value
|
|
28
|
+
* of some state accessible to a closure that might be called after the value is updated.
|
|
29
|
+
*/
|
|
30
|
+
// TODO should this replace `useStateWithGetter`?
|
|
31
|
+
|
|
32
|
+
export function useRefWithSetter(setter, init) {
|
|
33
|
+
var value = init === undefined ? useRef() : useRef(init);
|
|
34
|
+
var wrappedSetter = useCallback(function (newValue) {
|
|
35
|
+
value.current = newValue;
|
|
36
|
+
setter(newValue);
|
|
37
|
+
}, [setter]);
|
|
38
|
+
return [value, wrappedSetter];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* For objects which are persistent for the lifetime of the component, not
|
|
43
|
+
* a member of state, and require a constructor to create. Wraps `useRef`.
|
|
44
|
+
*/
|
|
45
|
+
export function useConstructor(constructor) {
|
|
46
|
+
var value = useRef(null);
|
|
47
|
+
if (value.current === null) {
|
|
48
|
+
value.current = constructor();
|
|
49
|
+
}
|
|
50
|
+
return value.current;
|
|
51
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
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 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; }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
6
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
7
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
9
|
+
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); }
|
|
10
|
+
var HttpClient = /*#__PURE__*/function () {
|
|
11
|
+
function HttpClient() {
|
|
12
|
+
_classCallCheck(this, HttpClient);
|
|
13
|
+
}
|
|
14
|
+
return _createClass(HttpClient, [{
|
|
15
|
+
key: "parseJSON",
|
|
16
|
+
value:
|
|
17
|
+
// fetch response.json() is a promise but we want return the json itself
|
|
18
|
+
function parseJSON(response, _options) {
|
|
19
|
+
return response.json().then(function (json) {
|
|
20
|
+
return _objectSpread(_objectSpread({}, response), {}, {
|
|
21
|
+
locationHeader: response.headers.get("Location"),
|
|
22
|
+
data: json || {
|
|
23
|
+
data: [],
|
|
24
|
+
total_count: 0
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
})["catch"](function () {
|
|
28
|
+
return _objectSpread(_objectSpread({}, response), {}, {
|
|
29
|
+
data: {
|
|
30
|
+
error: "unknown_error",
|
|
31
|
+
message: "error in parsing response json",
|
|
32
|
+
host: response.headers.get("Location"),
|
|
33
|
+
time: new Date().toISOString()
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}, {
|
|
39
|
+
key: "getJSON",
|
|
40
|
+
value: function getJSON(url, options) {
|
|
41
|
+
var _this = this;
|
|
42
|
+
return fetch(url, options).then(function (response) {
|
|
43
|
+
return _this.parseJSON(response, options);
|
|
44
|
+
}).then(function (response) {
|
|
45
|
+
if (response.ok) {
|
|
46
|
+
return response;
|
|
47
|
+
} else {
|
|
48
|
+
// fetch will not automatically reject error status codes
|
|
49
|
+
// however, we want to treat error status codes as failures
|
|
50
|
+
// so we reject here
|
|
51
|
+
return Promise.reject(response);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}]);
|
|
56
|
+
}();
|
|
57
|
+
export { HttpClient as default };
|