diff --git a/apps/visr/src/components/scanType.ts b/apps/visr/src/components/scanType.ts new file mode 100644 index 00000000..e805bfd7 --- /dev/null +++ b/apps/visr/src/components/scanType.ts @@ -0,0 +1,4 @@ +export enum ScanType { + STEP = "step", + FLY = "fly", +} diff --git a/apps/visr/src/components/spectroscopy/SpectroscopyForm.tsx b/apps/visr/src/components/spectroscopy/SpectroscopyForm.tsx index 19f61a2a..04d6b7ee 100644 --- a/apps/visr/src/components/spectroscopy/SpectroscopyForm.tsx +++ b/apps/visr/src/components/spectroscopy/SpectroscopyForm.tsx @@ -1,13 +1,13 @@ import { useInstrumentSession } from "@atlas/app-shell"; import { RunPlanButton } from "@atlas/blueapi-ui"; import AbortButton from "../AbortButton"; +import { ScanType } from "../scanType"; import { useState } from "react"; import { NumberInput } from "@diamondlightsource/sci-react-ui"; -import { Box } from "@mui/material"; -import { visitToText, VisitInput } from "@diamondlightsource/sci-react-ui"; -import { visitTextToVisit } from "../../utils/common"; +import { Box, ToggleButton, ToggleButtonGroup } from "@mui/material"; export type SpectroscopyFormData = { + scan_type: ScanType; total_number_of_scan_points: number; grid_size: number; grid_origin_x: number; @@ -16,8 +16,9 @@ export type SpectroscopyFormData = { }; export function SpectroscopyForm() { - const { instrumentSession, setInstrumentSession } = useInstrumentSession(); + const { instrumentSession } = useInstrumentSession(); const [formData, setFormData] = useState({ + scan_type: ScanType.STEP, total_number_of_scan_points: 25, grid_size: 5.0, grid_origin_x: 0.0, @@ -27,89 +28,105 @@ export function SpectroscopyForm() { const minValue = -14.5; const maxValue = 14.5; + const setField = ( + key: K, + value: (typeof formData)[K], + ) => setFormData(prev => ({ ...prev, [key]: value })); + + const sectionSx = { pt: 3, borderTop: 1, borderColor: "divider" }; + return ( - + + {/* Parameters */} - { - setFormData({ ...formData, ["grid_origin_x"]: parsedValue }); - }} - minValue={minValue} - maxValue={maxValue} - /> - { - setFormData({ ...formData, ["grid_origin_y"]: parsedValue }); - }} - minValue={minValue} - maxValue={maxValue} - /> + {/* x and y share one cell */} + + setField("grid_origin_x", v)} + minValue={minValue} + maxValue={maxValue} + /> + setField("grid_origin_y", v)} + minValue={minValue} + maxValue={maxValue} + /> + { - setFormData({ ...formData, ["grid_size"]: parsedValue }); - }} + defaultValue={formData.grid_size} + onCommit={v => setField("grid_size", v)} minValue={0.1} maxValue={15} /> { - setFormData({ - ...formData, - ["total_number_of_scan_points"]: parsedValue, - }); - }} + defaultValue={formData.total_number_of_scan_points} + onCommit={v => setField("total_number_of_scan_points", v)} minValue={1} /> { - setFormData({ ...formData, ["exposure_time"]: parsedValue }); - }} + defaultValue={formData.exposure_time} + onCommit={v => setField("exposure_time", v)} minValue={0.1} /> - setInstrumentSession(visitToText(visit))} - submitButton={false} - /> - + + {/* Scan controls */} + + v && setField("scan_type", v)} + > + Step + Fly + - - diff --git a/apps/visr/src/components/tomography/TomographyForm.tsx b/apps/visr/src/components/tomography/TomographyForm.tsx index 03425593..47f5e882 100644 --- a/apps/visr/src/components/tomography/TomographyForm.tsx +++ b/apps/visr/src/components/tomography/TomographyForm.tsx @@ -1,6 +1,7 @@ import { useInstrumentSession } from "@atlas/app-shell"; import { RunPlanButton } from "@atlas/blueapi-ui"; import AbortButton from "../AbortButton"; +import { ScanType } from "../scanType"; import { useState } from "react"; import { NumberInput } from "@diamondlightsource/sci-react-ui"; import { @@ -10,8 +11,6 @@ import { ToggleButton, ToggleButtonGroup, } from "@mui/material"; -import { visitToText, VisitInput } from "@diamondlightsource/sci-react-ui"; -import { visitTextToVisit } from "../../utils/common"; enum LightSource { LED = "led", @@ -20,19 +19,30 @@ enum LightSource { } export type TomographyFormData = { + scan_type: ScanType; number_of_projections: number; light_source: LightSource; + exposure_time: number; }; export function TomographyForm() { - const { instrumentSession, setInstrumentSession } = useInstrumentSession(); + const { instrumentSession } = useInstrumentSession(); const [formData, setFormData] = useState({ + scan_type: ScanType.STEP, number_of_projections: 360, light_source: LightSource.LED, + exposure_time: 0.1, }); const minProjections = 30; const maxProjections = 1440; + const setField = ( + key: K, + value: (typeof formData)[K], + ) => setFormData(prev => ({ ...prev, [key]: value })); + + const sectionSx = { pt: 3, borderTop: 1, borderColor: "divider" }; + return ( + {/* Parameters */} { - setFormData({ - ...formData, - ["number_of_projections"]: parsedValue, - }); - }} + defaultValue={formData.number_of_projections} + onCommit={v => setField("number_of_projections", v)} minValue={minProjections} maxValue={maxProjections} /> - setInstrumentSession(visitToText(visit))} - submitButton={false} + setField("exposure_time", v)} + minValue={0.1} /> - - + + Light Source - value && setFormData({ ...formData, light_source: value }) - } + onChange={(_, v) => v && setField("light_source", v)} > LED Synchrotron @@ -89,52 +113,50 @@ export function TomographyForm() { + + {/* Scan controls */} + v && setField("scan_type", v)} + > + Step + Fly + - - - - + + {/* Darks/flats */} - + );