diff --git a/apps/visr/src/components/ControlsDrawer.tsx b/apps/visr/src/components/ControlsDrawer.tsx index da552d9e..40ff29c1 100644 --- a/apps/visr/src/components/ControlsDrawer.tsx +++ b/apps/visr/src/components/ControlsDrawer.tsx @@ -1,12 +1,13 @@ import { Drawer, Box, IconButton, Typography } from "@mui/material"; import UnfoldLessIcon from "@mui/icons-material/UnfoldLess"; import UnfoldMoreIcon from "@mui/icons-material/UnfoldMore"; +import { Children, Fragment, type ReactNode } from "react"; interface ControlsDrawerProps { open: boolean; collapsedHeight: number; onToggle: () => void; - controls: JSX.Element; + controls: ReactNode | ReactNode[]; } function ControlsDrawer({ @@ -15,6 +16,8 @@ function ControlsDrawer({ onToggle, controls, }: ControlsDrawerProps) { + const items = Children.toArray(controls); + return ( Controls - + {open ? : } + - {open ? controls : } + {items.map((control, index) => ( + + {index > 0 && ( + + )} + {control} + + ))} ); diff --git a/apps/visr/src/components/tomography/TomographyControls.tsx b/apps/visr/src/components/tomography/TomographyControls.tsx index 69a08e2c..e4bb73dc 100644 --- a/apps/visr/src/components/tomography/TomographyControls.tsx +++ b/apps/visr/src/components/tomography/TomographyControls.tsx @@ -1,118 +1,86 @@ import { Box, - Button, FormControlLabel, - LinearProgress, Radio, RadioGroup, Slider, - Stack, - TextField, Typography, } from "@mui/material"; import { Plane } from "./PlaneEnum"; interface Props { - onRun: () => void; - onReset: () => void; onSlide: (event: Event, newValue: number | number[]) => void; onSetDirection: (event: React.ChangeEvent) => void; plane: Plane; - progress: number; slice: number; volumeShape: [number, number, number]; } export default function Controls({ - onRun, - onReset, onSlide, onSetDirection, plane, - progress, slice, volumeShape, }: Props) { + const maxSlice: Record = { + [Plane.Z]: volumeShape[0] - 1, + [Plane.Y]: volumeShape[1] - 1, + [Plane.X]: volumeShape[2] - 1, + }; + return ( - - - - - Reconstruction - - - - - - - - - - - - Slice View - - - Slice - - - - Axis - - - } label="X" /> - } label="Y" /> - } label="Z" /> - - - - {/* */} + + Slice View + + + + + Slice + + + - {/* onRevolveChange(!revolve)} - color="secondary" - sx={{ textTransform: "none" }} - > - Revolve - */} + + + Axis + + + } label="X" /> + } label="Y" /> + } label="Z" /> + + ); } + +{ + /* onRevolveChange(!revolve)} + color="secondary" + sx={{ textTransform: "none" }} + > + Revolve + */ +} diff --git a/apps/visr/src/components/tomography/TomographyForm.tsx b/apps/visr/src/components/tomography/TomographyForm.tsx new file mode 100644 index 00000000..1f2528b5 --- /dev/null +++ b/apps/visr/src/components/tomography/TomographyForm.tsx @@ -0,0 +1,141 @@ +import { useInstrumentSession } from "../../context/instrumentSession/useInstrumentSession"; +import { RunPlanButton } from "@atlas/blueapi-ui"; +import AbortButton from "../AbortButton"; +import { useState } from "react"; +import { NumberInput } from "@diamondlightsource/sci-react-ui"; +import { + Box, + FormControl, + FormLabel, + ToggleButton, + ToggleButtonGroup, +} from "@mui/material"; +import { visitToText, VisitInput } from "@diamondlightsource/sci-react-ui"; +import { visitTextToVisit } from "../../utils/common"; + +enum LightSource { + LED = "led", + SR = "sr", + DARK = "dark", +} + +export type TomographyFormData = { + number_of_projections: number; + light_source: LightSource; +}; + +export function TomographyForm() { + const { instrumentSession, setInstrumentSession } = useInstrumentSession(); + const [formData, setFormData] = useState({ + number_of_projections: 360, + light_source: LightSource.LED, + }); + const minProjections = 30; + const maxProjections = 1440; + + return ( + + + { + setFormData({ + ...formData, + ["number_of_projections"]: parsedValue, + }); + }} + minValue={minProjections} + maxValue={maxProjections} + /> + setInstrumentSession(visitToText(visit))} + submitButton={false} + /> + + + Light Source + + + value && setFormData({ ...formData, light_source: value }) + } + > + LED + Synchrotron + Off + + + + + + + + + + + + + + + + ); +} diff --git a/apps/visr/src/components/tomography/TomographyView.tsx b/apps/visr/src/components/tomography/TomographyView.tsx index 8ecf05dd..ea6b1a99 100644 --- a/apps/visr/src/components/tomography/TomographyView.tsx +++ b/apps/visr/src/components/tomography/TomographyView.tsx @@ -1,6 +1,7 @@ import { Box } from "@mui/material"; -import { useEffect, useRef, useState } from "react"; -import Controls from "./TomographyControls"; +import { useEffect, useState } from "react"; +import TomographyControls from "./TomographyControls"; +import { TomographyForm } from "./TomographyForm"; import { Plane } from "./PlaneEnum"; import ControlsDrawer from "../ControlsDrawer"; import TomographyPlots from "./TomographyPlots"; @@ -10,13 +11,9 @@ interface Volume { volumeShape: [number, number, number]; } -const SCAN_DURATION_MS = 3000; - function TomographyView() { const [volume, setVolume] = useState(null); - const [volumeVisible, setVolumeVisible] = useState(false); - const [progress, setProgress] = useState(0); - const intervalRef = useRef | null>(null); + const [volumeVisible, setVolumeVisible] = useState(true); // const [revolve, setRevolve] = useState(false); const [slice, setSlice] = useState(0); const [plane, setPlane] = useState(Plane.Z); @@ -48,8 +45,7 @@ function TomographyView() { localStorage.setItem("plane", plane.toString()); localStorage.setItem("volumeVisible", volumeVisible.toString()); localStorage.setItem("slice", slice.toString()); - localStorage.setItem("progress", progress.toString()); - }, [plane, volumeVisible, slice, progress]); + }, [plane, volumeVisible, slice]); useEffect(() => { const onReceiveMessage = (e: StorageEvent) => { @@ -67,10 +63,6 @@ function TomographyView() { setSlice(Number(newValue)); break; } - case "progress": { - setProgress(Number(newValue)); - break; - } } }; window.addEventListener("storage", onReceiveMessage); @@ -79,31 +71,6 @@ function TomographyView() { }; }, []); - // run waits 3 seconds, updating progress bar then allows mock volume to be seen - const handleRun = () => { - if (intervalRef.current) clearInterval(intervalRef.current); - setVolumeVisible(false); - setProgress(0); - - const startTime = Date.now(); - intervalRef.current = setInterval(() => { - const elapsed = Date.now() - startTime; - const next = Math.min((elapsed / SCAN_DURATION_MS) * 100, 100); - setProgress(next); - if (next >= 100) { - clearInterval(intervalRef.current!); - setVolumeVisible(true); - } - }, 50); - }; - - // reset reverts progress bar and volume viewing - const handleReset = () => { - if (intervalRef.current) clearInterval(intervalRef.current); - setVolumeVisible(false); - setProgress(0); - }; - const handleSlider = (event: Event, newValue: number | number[]) => { const slice = typeof newValue == "number" ? newValue : newValue[0]; setSlice(slice); @@ -140,18 +107,16 @@ function TomographyView() { open={drawerOpen} collapsedHeight={DRAWER_COLLAPSED_HEIGHT} onToggle={() => setDrawerOpen(prev => !prev)} - controls={ - , + - } + />, + ]} /> );