cloudmr-ux 4.3.1 → 4.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,91 @@
1
+ import React from "react";
2
+ export interface NiivueContrastAdjustmentsProps {
3
+ /** The Niivue instance. */
4
+ nv: any;
5
+ /**
6
+ * Current window minimum in real space (mirrors `volumes[0].cal_min`).
7
+ * Controlled by the parent — updated via `setMin`.
8
+ */
9
+ min: number;
10
+ /**
11
+ * Current window maximum in real space (mirrors `volumes[0].cal_max`).
12
+ * Controlled by the parent — updated via `setMax`.
13
+ */
14
+ max: number;
15
+ /** Called with the new real-space minimum when the user moves the low thumb. */
16
+ setMin: (min: number) => void;
17
+ /** Called with the new real-space maximum when the user moves the high thumb. */
18
+ setMax: (max: number) => void;
19
+ /**
20
+ * Scaling factors used to convert between real space and the display (render)
21
+ * space shown in the dual-range input boxes.
22
+ *
23
+ * Transform: `renderValue = a * realValue - a * b`
24
+ * Inverse: `realValue = renderValue / a + b`
25
+ *
26
+ * Pass `{ a: 1, b: 0 }` for a 1-to-1 mapping (no scientific-notation scaling).
27
+ */
28
+ transformFactors: {
29
+ a: number;
30
+ b: number;
31
+ };
32
+ /** Current gamma value. Controlled by the parent — updated via `setGamma`. */
33
+ gamma: number;
34
+ /**
35
+ * React key forwarded to the gamma slider to force a remount when gamma is
36
+ * externally reset (e.g. from the Toolbar reset button).
37
+ */
38
+ gammaKey: number;
39
+ /** Called with the new gamma value when the user moves the gamma slider. */
40
+ setGamma: (val: number) => void;
41
+ /**
42
+ * Optional list of layer controls rendered below the gamma slider (e.g.
43
+ * per-layer color-map pickers). Pass an empty array or omit to render nothing.
44
+ */
45
+ layerList?: React.ReactNode[];
46
+ /**
47
+ * Heading displayed above the card.
48
+ * @default "Contrast Adjustments"
49
+ */
50
+ title?: string;
51
+ /**
52
+ * Accent color used on the dual-range slider and the gamma slider.
53
+ * @default "#580f8b"
54
+ */
55
+ accentColor?: string;
56
+ style?: React.CSSProperties;
57
+ className?: string;
58
+ }
59
+ /**
60
+ * **NiivueContrastAdjustments**
61
+ *
62
+ * A reusable "Contrast Adjustments" control panel for a Niivue viewer. Renders:
63
+ *
64
+ * 1. A dark **title strip** (`.title` class, same visual style as Slice Position).
65
+ * 2. An outlined **Card** + **CardContent** containing:
66
+ * - A `TKDualRange` for window min/max with optional real→render-space transform.
67
+ * - A gamma range slider.
68
+ * - An optional `layerList` slot for per-layer controls.
69
+ *
70
+ * ### Wiring
71
+ *
72
+ * ```tsx
73
+ * <NiivueContrastAdjustments
74
+ * nv={nv}
75
+ * min={min}
76
+ * max={max}
77
+ * setMin={setMin}
78
+ * setMax={setMax}
79
+ * transformFactors={transformFactors}
80
+ * gamma={gamma}
81
+ * gammaKey={gammaKey}
82
+ * setGamma={setGamma}
83
+ * layerList={layerList}
84
+ * />
85
+ * ```
86
+ *
87
+ * Pass `title=""` to suppress the heading strip, or `title="Window / Level"` to
88
+ * rename it for a different application.
89
+ */
90
+ export declare function NiivueContrastAdjustments({ nv, min, max, setMin, setMax, transformFactors, gamma, gammaKey, setGamma, layerList, title, accentColor, style, className, }: NiivueContrastAdjustmentsProps): import("react/jsx-runtime").JSX.Element;
91
+ export default NiivueContrastAdjustments;
@@ -0,0 +1,74 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { Card, CardContent, Box } from "@mui/material";
14
+ import TKDualRange from "../tk-dualrange/TKDualRange";
15
+ import CmrLabel from "../label/Label";
16
+ // ─── Component ────────────────────────────────────────────────────────────────
17
+ /**
18
+ * **NiivueContrastAdjustments**
19
+ *
20
+ * A reusable "Contrast Adjustments" control panel for a Niivue viewer. Renders:
21
+ *
22
+ * 1. A dark **title strip** (`.title` class, same visual style as Slice Position).
23
+ * 2. An outlined **Card** + **CardContent** containing:
24
+ * - A `TKDualRange` for window min/max with optional real→render-space transform.
25
+ * - A gamma range slider.
26
+ * - An optional `layerList` slot for per-layer controls.
27
+ *
28
+ * ### Wiring
29
+ *
30
+ * ```tsx
31
+ * <NiivueContrastAdjustments
32
+ * nv={nv}
33
+ * min={min}
34
+ * max={max}
35
+ * setMin={setMin}
36
+ * setMax={setMax}
37
+ * transformFactors={transformFactors}
38
+ * gamma={gamma}
39
+ * gammaKey={gammaKey}
40
+ * setGamma={setGamma}
41
+ * layerList={layerList}
42
+ * />
43
+ * ```
44
+ *
45
+ * Pass `title=""` to suppress the heading strip, or `title="Window / Level"` to
46
+ * rename it for a different application.
47
+ */
48
+ export function NiivueContrastAdjustments(_a) {
49
+ var _b, _c, _d, _e;
50
+ var nv = _a.nv, min = _a.min, max = _a.max, setMin = _a.setMin, setMax = _a.setMax, transformFactors = _a.transformFactors, gamma = _a.gamma, gammaKey = _a.gammaKey, setGamma = _a.setGamma, _f = _a.layerList, layerList = _f === void 0 ? [] : _f, _g = _a.title, title = _g === void 0 ? "Contrast Adjustments" : _g, _h = _a.accentColor, accentColor = _h === void 0 ? "#580f8b" : _h, style = _a.style, className = _a.className;
51
+ var a = transformFactors.a, b = transformFactors.b;
52
+ return (_jsxs("div", __assign({ style: style, className: className }, { children: [title !== "" && (_jsx("div", __assign({ className: "title", style: { width: "100%" } }, { children: title }))), _jsx(Card, __assign({ variant: "outlined", sx: { mb: 2, borderTopLeftRadius: 0, borderTopRightRadius: 0 } }, { children: _jsx(CardContent, { children: _jsxs(Box, __assign({ style: { display: "flex", flex: 1, minWidth: "245px", flexDirection: "column" } }, { children: [_jsx(TKDualRange, { name: "Values:", minDomain: (_c = (_b = nv.volumes[0]) === null || _b === void 0 ? void 0 : _b.robust_min) !== null && _c !== void 0 ? _c : 0, maxDomain: (_e = (_d = nv.volumes[0]) === null || _d === void 0 ? void 0 : _d.robust_max) !== null && _e !== void 0 ? _e : 1, valueLow: min, valueHigh: max, onChangeLow: function (newMin) {
53
+ var v = nv.volumes[0];
54
+ if (!v)
55
+ return;
56
+ v.cal_min = newMin;
57
+ nv.refreshLayers(v, 0, nv.volumes.length);
58
+ nv.drawScene();
59
+ setMin(newMin);
60
+ }, onChangeHigh: function (newMax) {
61
+ var v = nv.volumes[0];
62
+ if (!v)
63
+ return;
64
+ v.cal_max = newMax;
65
+ nv.refreshLayers(v, 0, nv.volumes.length);
66
+ nv.drawScene();
67
+ setMax(newMax);
68
+ }, transform: function (x) { return a * x - a * b; }, inverse: function (y) { return y / a + b; }, step: 0.001, precision: 3, accentColor: accentColor }), _jsxs("div", __assign({ style: { marginTop: 20, marginBottom: 15 } }, { children: [_jsxs(CmrLabel, __assign({ style: { display: "block", marginBottom: 6 } }, { children: ["Gamma: ", gamma.toFixed(2)] })), _jsx("input", { id: "gamma", type: "range", min: 0.1, max: 3.0, step: 0.05, value: gamma, onChange: function (e) {
69
+ var val = Number(e.target.value);
70
+ setGamma(val);
71
+ nv.setGamma(val);
72
+ }, style: { width: "100%", accentColor: accentColor } }, gammaKey)] })), layerList.length > 0 && (_jsx(Box, __assign({ style: { height: "100%" } }, { children: layerList })))] })) }) }))] })));
73
+ }
74
+ export default NiivueContrastAdjustments;
package/dist/index.d.ts CHANGED
@@ -23,6 +23,8 @@ export { InvertibleDualSlider } from "./CmrComponents/double-slider/InvertibleDu
23
23
  export type { LambdaFile } from "./CmrComponents/upload/Upload";
24
24
  export { NiivueSlicePosition } from "./CmrComponents/niivue-slice-position/NiivueSlicePosition";
25
25
  export type { NiivueSlicePositionProps } from "./CmrComponents/niivue-slice-position/NiivueSlicePosition";
26
+ export { NiivueContrastAdjustments } from "./CmrComponents/niivue-contrast-adjustments/NiivueContrastAdjustments";
27
+ export type { NiivueContrastAdjustmentsProps } from "./CmrComponents/niivue-contrast-adjustments/NiivueContrastAdjustments";
26
28
  import type { FC } from "react";
27
29
  import type { CmrTableProps } from "./CmrTable/CmrTable";
28
30
  export declare const CmrTable: FC<CmrTableProps>;
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ export { DualSlider } from "./CmrComponents/double-slider/DualSlider";
23
23
  export { Slider } from "./CmrComponents/gui-slider/Slider";
24
24
  export { InvertibleDualSlider } from "./CmrComponents/double-slider/InvertibleDualSlider";
25
25
  export { NiivueSlicePosition } from "./CmrComponents/niivue-slice-position/NiivueSlicePosition";
26
+ export { NiivueContrastAdjustments } from "./CmrComponents/niivue-contrast-adjustments/NiivueContrastAdjustments";
26
27
  import CmrTableComponent from "./CmrTable/CmrTable";
27
28
  export var CmrTable = CmrTableComponent;
28
29
  export * from "./core";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudmr-ux",
3
- "version": "4.3.1",
3
+ "version": "4.3.2",
4
4
  "author": "erosmontin@gmail.com",
5
5
  "license": "MIT",
6
6
  "repository": "erosmontin/cloudmr-ux",