From 51e22faf64b14849590c09c512dcf3c12d338687 Mon Sep 17 00:00:00 2001 From: tizayi Date: Mon, 22 Apr 2024 14:30:24 +0100 Subject: [PATCH] add comments --- src/basicAppBar.tsx | 9 ----- src/data-entry/beamProperties.tsx | 4 +- src/data-entry/dataSideBar.tsx | 2 +- src/dialogs/presetDialog.tsx | 4 +- src/plot/centrePlot.tsx | 64 +++++++++++++++++-------------- src/results/rangeTable.tsx | 10 ++--- src/results/resultsStore.ts | 9 +++-- src/utils/units.ts | 4 +- 8 files changed, 54 insertions(+), 52 deletions(-) diff --git a/src/basicAppBar.tsx b/src/basicAppBar.tsx index 44389c5..3f93213 100644 --- a/src/basicAppBar.tsx +++ b/src/basicAppBar.tsx @@ -1,18 +1,9 @@ -import * as React from "react"; import AppBar from "@mui/material/AppBar"; import Box from "@mui/material/Box"; import Toolbar from "@mui/material/Toolbar"; import Typography from "@mui/material/Typography"; -import IconButton from "@mui/material/IconButton"; -import MenuIcon from "@mui/icons-material/Menu"; -import { Drawer } from "@mui/material"; export default function BasicAppBar(): JSX.Element { - const [state, setState] = React.useState({ menuOpen: false }); - const toggleDrawer = (open: boolean) => () => { - setState({ menuOpen: open }); - }; - return ( diff --git a/src/data-entry/beamProperties.tsx b/src/data-entry/beamProperties.tsx index 5c4d973..e4b2c2e 100644 --- a/src/data-entry/beamProperties.tsx +++ b/src/data-entry/beamProperties.tsx @@ -126,8 +126,8 @@ export default function BeampropertiesDataEntry() { value={beamlineConfig.wavelength.formatUnits() as WavelengthUnits} onChange={handleWavelengthUnits} > - - {WavelengthUnits.nanmometres} + + {WavelengthUnits.nanometres} {"\u212B"} diff --git a/src/data-entry/dataSideBar.tsx b/src/data-entry/dataSideBar.tsx index d039b0b..2ce08da 100644 --- a/src/data-entry/dataSideBar.tsx +++ b/src/data-entry/dataSideBar.tsx @@ -26,7 +26,7 @@ import React from "react"; import PresetDialog from "../dialogs/presetDialog"; /** - * React component which represents the whole side bar for data entry + * React component which represents the whole side bar for data entry. * @returns */ export default function DataSideBar(): JSX.Element { diff --git a/src/dialogs/presetDialog.tsx b/src/dialogs/presetDialog.tsx index f2e80d2..b0e1c16 100644 --- a/src/dialogs/presetDialog.tsx +++ b/src/dialogs/presetDialog.tsx @@ -15,7 +15,7 @@ import React from "react"; import BeamlineTable from "./BeamlineTable"; import { detectorList } from "../presets/presetManager"; -const GRID_ITEM_SIZE = 3; +const GRID_ITEM_SIZE = 4; export default function PresetDialog(props: { open: boolean; @@ -50,7 +50,7 @@ export default function PresetDialog(props: { - + ((state) => { - return { - resolution: state.resolution, - pixelSize: state.pixelSize, - }; - }); + const detector = useDetectorStore(); const beamstop = useBeamstopStore((state) => { return { @@ -65,31 +65,41 @@ export default function CentrePlot(): JSX.Element { const scaleFactor: mathjs.Unit | null = getScaleFactor(beamlineConfig); + + +const { ptMin, ptMax, visibleQRange, fullQRange } = useMemo(()=> { + // todo this might need to be moved elsewhere - // evil :( :( :( :() - /* eslint-disable */ - // @ts-ignore - if (mathjs.Unit.UNITS.xpixel) { + /* eslint-disable */ // @ts-ignore - delete mathjs.Unit.UNITS.xpixel; - } - // @ts-ignore - if (mathjs.Unit.UNITS.ypixel) { + if (mathjs.Unit.UNITS.xpixel) { + // @ts-ignore + delete mathjs.Unit.UNITS.xpixel; + } // @ts-ignore - delete mathjs.Unit.UNITS.ypixel; - } - /* eslint-enable */ - // evil :( :( :( :() + if (mathjs.Unit.UNITS.ypixel) { + // @ts-ignore + delete mathjs.Unit.UNITS.ypixel; + } + /* eslint-enable */ + + + mathjs.createUnit("xpixel", detector.pixelSize.width.toString()); + mathjs.createUnit("ypixel", detector.pixelSize.height.toString()); + + console.log("calculating qrange"); + + return computeQrange( + detector, + beamstop, + cameraTube, + beamlineConfig, + ); + }, [detector, beamstop, cameraTube, beamlineConfig]); + + - mathjs.createUnit("xpixel", detector.pixelSize.width.toString()); - mathjs.createUnit("ypixel", detector.pixelSize.height.toString()); - const { ptMin, ptMax, visibleQRange, fullQRange } = computeQrange( - detector, - beamstop, - cameraTube, - beamlineConfig, - ); // todo move these 2 statements into the ResultsBar component // as that's the only place that uses these @@ -146,8 +156,6 @@ export default function CentrePlot(): JSX.Element { ); } - console.log(plotDetector); - const domains = getDomains(plotDetector); return ( diff --git a/src/results/rangeTable.tsx b/src/results/rangeTable.tsx index f061996..4da66ac 100644 --- a/src/results/rangeTable.tsx +++ b/src/results/rangeTable.tsx @@ -86,7 +86,7 @@ export default function RangeTable(props: { qRange: UnitRange }): JSX.Element { value={resultsStore.qUnits} onChange={handleQunits} > - + {"1 / nm"} @@ -120,8 +120,8 @@ export default function RangeTable(props: { qRange: UnitRange }): JSX.Element { value={resultsStore.sUnits} onChange={handleSunits} > - - {WavelengthUnits.nanmometres} + + {WavelengthUnits.nanometres} {"\u212B"} @@ -154,8 +154,8 @@ export default function RangeTable(props: { qRange: UnitRange }): JSX.Element { value={resultsStore.dUnits} onChange={handleDunits} > - - {WavelengthUnits.nanmometres} + + {WavelengthUnits.nanometres} {"\u212B"} diff --git a/src/results/resultsStore.ts b/src/results/resultsStore.ts index dcae1b6..e8c3411 100644 --- a/src/results/resultsStore.ts +++ b/src/results/resultsStore.ts @@ -28,11 +28,14 @@ export interface ResultStore { updateDUnits: (newunits: WavelengthUnits) => void; } +/** + * Zustand store for the results + */ export const useResultStore = create((set) => ({ requested: ScatteringOptions.q, - qUnits: ReciprocalWavelengthUnits.nanmometres, - sUnits: WavelengthUnits.nanmometres, - dUnits: WavelengthUnits.nanmometres, + qUnits: ReciprocalWavelengthUnits.nanometres, + sUnits: WavelengthUnits.nanometres, + dUnits: WavelengthUnits.nanometres, requestedMin: null, requestedMax: null, updateRequested: (quantity: ScatteringOptions) => { diff --git a/src/utils/units.ts b/src/utils/units.ts index b605c66..57753de 100644 --- a/src/utils/units.ts +++ b/src/utils/units.ts @@ -15,12 +15,12 @@ export enum EnergyUnits { export enum WavelengthUnits { // todo is this a typo for nanometers? - nanmometres = "nm", + nanometres = "nm", angstroms = "angstrom", } export enum ReciprocalWavelengthUnits { - nanmometres = "nm^-1", + nanometres = "nm^-1", angstroms = `angstrom^-1`, }