diff --git a/apps/visr/src/components/tomography/SliceViewer.tsx b/apps/visr/src/components/tomography/SliceViewer.tsx index 0ed5f855..99041244 100644 --- a/apps/visr/src/components/tomography/SliceViewer.tsx +++ b/apps/visr/src/components/tomography/SliceViewer.tsx @@ -9,6 +9,7 @@ interface Props { volumeShape: [number, number, number]; plane: Plane; slice: number; + threshold?: number; // raw 0–255; values at or below render as the bottom of the colormap resizeKey?: string; //if this depends on a value, the plot will remount every time that value changes. If no need for it to remound, leave as undefined } export default function SliceViewer({ @@ -16,6 +17,7 @@ export default function SliceViewer({ volumeShape, plane, slice, + threshold = 0, resizeKey, }: Props) { if (volumeData == undefined || volumeShape == undefined) { @@ -46,7 +48,7 @@ export default function SliceViewer({ aspect={"equal"} plotConfig={{}} values={sliceNdarray} - domain={[0, 255]} + domain={[threshold, 255]} customToolbarChildren={null} /> ); diff --git a/apps/visr/src/components/tomography/TomographyControls.tsx b/apps/visr/src/components/tomography/TomographyControls.tsx index e4bb73dc..30f32c62 100644 --- a/apps/visr/src/components/tomography/TomographyControls.tsx +++ b/apps/visr/src/components/tomography/TomographyControls.tsx @@ -11,16 +11,20 @@ import { Plane } from "./PlaneEnum"; interface Props { onSlide: (event: Event, newValue: number | number[]) => void; onSetDirection: (event: React.ChangeEvent) => void; + onThreshold: (event: Event, newValue: number | number[]) => void; plane: Plane; slice: number; + threshold: number; volumeShape: [number, number, number]; } export default function Controls({ onSlide, onSetDirection, + onThreshold, plane, slice, + threshold, volumeShape, }: Props) { const maxSlice: Record = { @@ -38,6 +42,21 @@ export default function Controls({ p: 3, }} > + + + Threshold + + + + Slice View diff --git a/apps/visr/src/components/tomography/TomographyPlots.tsx b/apps/visr/src/components/tomography/TomographyPlots.tsx index 25e24d1c..598d0f3b 100644 --- a/apps/visr/src/components/tomography/TomographyPlots.tsx +++ b/apps/visr/src/components/tomography/TomographyPlots.tsx @@ -16,6 +16,7 @@ interface Props { volumeVisible: boolean; slice: number; plane: Plane; + threshold: number; } // --------------------------------------------------------------------------- @@ -47,6 +48,7 @@ function TomographyPlots({ volumeShape, plane, slice, + threshold, drawerOpen, }: Props) { const { width, containerRef, mounted } = useContainerWidth(); @@ -96,12 +98,17 @@ function TomographyPlots({ // ------------------------------------------------------------------------- const views = [ , - , + , , ]; diff --git a/apps/visr/src/components/tomography/TomographyView.tsx b/apps/visr/src/components/tomography/TomographyView.tsx index 68927cfe..64c832fa 100644 --- a/apps/visr/src/components/tomography/TomographyView.tsx +++ b/apps/visr/src/components/tomography/TomographyView.tsx @@ -25,6 +25,7 @@ function TomographyView() { // const [revolve, setRevolve] = useState(false); const [slice, setSlice] = useState(0); const [plane, setPlane] = useState(Plane.Z); + const [threshold, setThreshold] = useState(38); // 38/255 ≈ 0.15, the renderer's old default const [drawerOpen, setDrawerOpen] = useState(true); // ------------------------------------------------------------------------- @@ -95,6 +96,10 @@ function TomographyView() { setPlane(radioValue); }; + const handleThreshold = (event: Event, newValue: number | number[]) => { + setThreshold(typeof newValue == "number" ? newValue : newValue[0]); + }; + // revolve to be implemented if (!volume) return ; @@ -116,6 +121,7 @@ function TomographyView() { volumeVisible={volumeVisible} plane={plane} slice={slice} + threshold={threshold} volumeShape={volume.volumeShape} drawerOpen={drawerOpen} /> @@ -127,8 +133,10 @@ function TomographyView() { , ]} diff --git a/apps/visr/src/components/tomography/VolumeRenderer.tsx b/apps/visr/src/components/tomography/VolumeRenderer.tsx index 5ed6b9c9..35aa04cb 100644 --- a/apps/visr/src/components/tomography/VolumeRenderer.tsx +++ b/apps/visr/src/components/tomography/VolumeRenderer.tsx @@ -41,12 +41,15 @@ function VolumeMesh({ // Sync scalar uniforms when props change useEffect(() => { uniforms.threshold.value = threshold; + invalidate(); }, [threshold, uniforms]); useEffect(() => { uniforms.opacityScale.value = opacityScale; + invalidate(); }, [opacityScale, uniforms]); useEffect(() => { uniforms.steps.value = steps; + invalidate(); }, [steps, uniforms]); // Upload volume data to GPU texture