From 799e1e15ecd5c4cfedf9afe970647424f4f9304d Mon Sep 17 00:00:00 2001 From: leonarski_f Date: Fri, 17 Jul 2026 19:25:16 +0200 Subject: [PATCH] frontend: configurable decimal precision, 5 places for azint Q fields NumberTextField quantized every float input to 3 decimals, so the finest q_spacing reachable through the UI was 0.001 - capping the azimuthal-integration q-bin count around 200 regardless of the CPU/FPGA backend. Add an optional `decimals` prop (default 3, unchanged elsewhere) and set it to 5 on the Q spacing / Low Q / High Q fields, matching the q_spacing minimum of 1e-5. Co-Authored-By: Claude Opus 4.8 --- frontend/src/components/AzIntSettings.tsx | 3 +++ frontend/src/components/NumberTextField.tsx | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/AzIntSettings.tsx b/frontend/src/components/AzIntSettings.tsx index 83a29157..c84ca9fb 100644 --- a/frontend/src/components/AzIntSettings.tsx +++ b/frontend/src/components/AzIntSettings.tsx @@ -56,6 +56,7 @@ function AzIntSettings({s: serverS}: MyProps) { min={1e-5} units={"A-1"} float={true} + decimals={5} counter={downloadCounter} callback={(val: number, err: boolean) => { setS(prev => ({...prev, q_spacing: val})); @@ -71,6 +72,7 @@ function AzIntSettings({s: serverS}: MyProps) { max={10.0} units={"A-1"} float={true} + decimals={5} counter={downloadCounter} callback={(val: number, err: boolean) => { setS(prev => ({...prev, low_q_recipA: val})); @@ -86,6 +88,7 @@ function AzIntSettings({s: serverS}: MyProps) { max={10.0} units={"A-1"} float={true} + decimals={5} counter={downloadCounter} callback={(val: number, err: boolean) => { setS(prev => ({...prev, high_q_recipA: val})); diff --git a/frontend/src/components/NumberTextField.tsx b/frontend/src/components/NumberTextField.tsx index 663ac939..8535206a 100644 --- a/frontend/src/components/NumberTextField.tsx +++ b/frontend/src/components/NumberTextField.tsx @@ -17,7 +17,8 @@ type MyProps = { units?: string, disabled?: boolean, fullWidth?: boolean, - float?: boolean + float?: boolean, + decimals?: number } function unitsNode(str: string | undefined): ReactNode | null { @@ -33,7 +34,7 @@ function unitsNode(str: string | undefined): ReactNode | null { return {str}; } -function NumberTextField({start_val, default: defaultValue, label, callback, counter, min, max, sx, units, disabled, float}: MyProps) { +function NumberTextField({start_val, default: defaultValue, label, callback, counter, min, max, sx, units, disabled, float, decimals = 3}: MyProps) { const [text, setText] = useState("."); const [err, setErr] = useState(true); const [val, setVal] = useState(0); @@ -51,7 +52,7 @@ function NumberTextField({start_val, default: defaultValue, label, callback, cou if (float !== true) v = Math.round(v); else - v = Math.round(v * 1000.0) / 1000.0 + v = Number(v.toFixed(decimals)); setErr(false); setVal(v);