From 9b404bc4b56e87c9bf81ee0574f5b1125c79a837 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Sat, 14 Nov 2026 07:55:26 +0100 Subject: [PATCH 1/3] rugnux live page, alternative layout: image and model across the middle, four plots along the bottom The stage's right column goes: the diffraction image and the model (the run's step until there is one) take the whole middle, side by side, the image square with the row's height. The bottom row holds four plots - the collection image by image on the left, wide, a point an image; the merge by resolution on the right, completeness and CC1/2 side by side and square, a point a shell - and the checks sit under the merge numbers in the rail. For comparison with the layout before it. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01UqXYdJDrM65gxsCn2PrbfK --- .../src/components/RugnuxCollectionPlots.tsx | 6 +- frontend/src/components/RugnuxPage.tsx | 75 +++++++++++-------- frontend/src/components/RugnuxShellPlots.tsx | 19 +++-- 3 files changed, 58 insertions(+), 42 deletions(-) diff --git a/frontend/src/components/RugnuxCollectionPlots.tsx b/frontend/src/components/RugnuxCollectionPlots.tsx index 38f284c8d..26aa9918a 100644 --- a/frontend/src/components/RugnuxCollectionPlots.tsx +++ b/frontend/src/components/RugnuxCollectionPlots.tsx @@ -11,7 +11,7 @@ import {livePalette} from "../livePalette"; // rejected (red) as bands over both panels, each with the reason it saw; serial: the indexing rate. The // second panel is empty until there is a merge. -const PLOT_MARGIN = {t: 6, b: 22, l: 42, r: 42}; +const PLOT_MARGIN = {t: 6, b: 26, l: 46, r: 46}; // Points of one receiver plot, polled while the run is on; coarser bins on a long serial collection function useCollectionPlot(type: plot_type, s: rugnux_live_status) { @@ -31,8 +31,8 @@ function Empty({text}: { text: string }) { function RugnuxCollectionPlots({s, height}: { s: rugnux_live_status, height: number }) { const theme = useTheme(); const pal = livePalette(theme.palette.mode); - // type that grows with the strip, so a 4k screen does not get 11 px labels - const size = Math.round(Math.min(16, Math.max(10, height / 15))); + // type that grows with the strip, so a 4k screen does not get 11 px labels, within the margins' room + const size = Math.round(Math.min(13, Math.max(10, height / 15))); const font = {color: theme.palette.text.secondary, size}; const axis = {gridcolor: pal.grid, zerolinecolor: pal.grid, tickfont: {size: size - 1}}; const title = (text: string, color: string) => ({text, standoff: 4, font: {size: size - 1, color}}); diff --git a/frontend/src/components/RugnuxPage.tsx b/frontend/src/components/RugnuxPage.tsx index 0baa22270..a58be1df9 100644 --- a/frontend/src/components/RugnuxPage.tsx +++ b/frontend/src/components/RugnuxPage.tsx @@ -28,10 +28,11 @@ import {lazy, Suspense, useEffect, useRef, useState} from "react"; // The live page as one control-room screen, in the app's own light or dark: a stage the height of the window, // edged in the colour of the run's phase, that shows everything at once - images, structure, statistics. // Across the top, the phase, the two progress bars (the detector's and rugnux's) and the clock the run is -// judged by. Below, left to right: the hero numbers of the merge as a rail, the diffraction image the broker -// is on, the placed model in Mol* (the run's step until there is one), and the triage badges over the merging -// statistics by shell. Under the image and the model, the collection image by image: spots and background, -// and the per-image scale with the frames the merge left out. Everything else - the timeline, step notes, +// judged by. Below, left to right: the hero numbers of the merge as a rail with the triage badges under them, +// the diffraction image the broker is on, and the placed model in Mol* (the run's step until there is one). +// Under the image and the model, four plots: the collection image by image - spots and background, and the +// per-image scale with the frames the merge left out - and the merge by resolution shell - completeness and +// CC1/2. Everything else - the timeline, step notes, // summary rows, warnings, the serial pre-pass geometry - sits under a "Details" fold below the stage, and the // settings under that. @@ -197,20 +198,20 @@ function useHeight() { return [ref, height] as const; } -// The height of the collection strip and the side of the image window, from the window's height so the -// stage holds everything without scrolling: the image takes what the header and the strip leave. -const STRIP = "clamp(150px, 11vh, 260px)"; -const IMAGE = "clamp(240px, min(calc(88vh - 430px), 30vw), 1500px)"; +// The height of the bottom row of plots, from the window's height so the stage holds everything without +// scrolling: the image and the model take what the header and the plots leave. +const PLOTS = "clamp(190px, 23vh, 440px)"; const RAIL = "clamp(200px, 12vw, 420px)"; function Dashboard({s, name, givenCell, deadline_s, modelLoaded, measuring, pal}: { s: rugnux_live_status, name?: string, givenCell?: string, deadline_s: number, modelLoaded: boolean, measuring: boolean, pal: LivePalette }) { - // Only on the fixed-height stage (xl) do the plots take their height from their box; below it the - // stage flows and the boxes take their height from the plots, so a measured height would feed back. + // Only on the fixed-height stage (xl) do the plots and the image take their height from their box; below it + // the stage flows and the boxes take their height from their content, so a measured height would feed back. const stage = useMediaQuery(useTheme().breakpoints.up("xl")); const [plotsRef, plotsHeight] = useHeight(); - const [stripRef, stripHeight] = useHeight(); + const [imageRef, imageHeight] = useHeight(); + const plotHeight = stage ? Math.max(150, plotsHeight) : 220; const later = s.stills ? "after the first merge" : "after scaling"; // Spots and predictions are drawn on an image only where the broker analysed it: a serial run's images after // the pre-pass. A rotation run's images are analysed by rugnux's own passes and carry neither. @@ -220,41 +221,51 @@ function Dashboard({s, name, givenCell, deadline_s, modelLoaded, measuring, pal}
+ gridTemplateColumns: {xs: "1fr", md: `${RAIL} minmax(0, 1fr)`, xl: `${RAIL} auto minmax(0, 1fr)`}, + gridTemplateRows: {xs: "auto", xl: `minmax(0, 1fr) ${PLOTS}`}}}> + {/* the merge's numbers, and under them what the checks made of it */} - - - - - {/* below the stage the model takes the whole width under the image, only as tall as Mol* needs, and - nothing when there is no model to show */} - - - - - *": {flexShrink: 0}}}> + {s.triage && s.triage.length > 0 ? : s.state === "Failed" ? {s.message} : } + + + {/* the image, square with the row's height, in a column of its own width; the model takes the rest */} + + + + + + + + {/* below the stage the model takes the whole width under the image, only as tall as Mol* needs, and + nothing when there is no model to show */} + + + + {/* four plots across the bottom: the collection image by image, wide - a point an image - and the + merge by resolution, square - a point a shell - each as wide as the row is high */} + + + + + - By resolution{s.stills && s.shells_merge && ` · ${s.shells_merge}`}}> - + By resolution{s.stills && s.shells_merge && ` · ${s.shells_merge}`}} + sx={{...hairline, minHeight: {xs: 200, xl: 0}}}> + {s.shells && s.shells.length > 0 ? + row height={plotHeight}/> : } - - - - - ); diff --git a/frontend/src/components/RugnuxShellPlots.tsx b/frontend/src/components/RugnuxShellPlots.tsx index 6cd9d207c..0d6ccea2a 100644 --- a/frontend/src/components/RugnuxShellPlots.tsx +++ b/frontend/src/components/RugnuxShellPlots.tsx @@ -2,9 +2,11 @@ import {useEffect, useRef, useState} from "react"; import {Box, Typography, useTheme} from "@mui/material"; import {rugnux_live_shell} from "../client"; import Plot from "./Plot"; +import {livePalette} from "../livePalette"; // Completeness and CC1/2 by resolution shell, the two columns of rugnux's shell table read first, one panel each, -// one under the other on one axis: labelled once, under the lower panel. Each shell is drawn at 1/d^2 of its +// one under the other on one axis: labelled once, under the lower panel - or side by side (row), each on its own +// axis, as panels like the collection's. Each shell is drawn at 1/d^2 of its // d_min, the axis labelled in d at round values - as many as the panel's width holds - and the resolution of the // merge is a dashed line, named once, on the upper panel: where the CC1/2 fall-off is fitted, which the written // range (the end of the axis) deliberately reaches a shell beyond; without a fit, the written limit itself. @@ -49,26 +51,29 @@ function dTicks(x0: number, x1: number, widthPx: number) { } // height: of each panel in px; d_min: the written limit of the merge; fit: where its CC1/2 fall-off is fitted -function RugnuxShellPlots({shells, d_min, fit, merge, height = 300}: - { shells: rugnux_live_shell[], d_min?: number, fit?: number, merge?: string, height?: number }) { +function RugnuxShellPlots({shells, d_min, fit, merge, row, height = 300}: + { shells: rugnux_live_shell[], d_min?: number, fit?: number, merge?: string, row?: boolean, height?: number }) { const theme = useTheme(); const grid = theme.palette.mode === "dark" ? "rgba(255,255,255,.12)" : "#eee"; const [ref, width] = useWidth(); + const panelWidth = row ? (width - 12) / 2 : width; const x = shells.map(sh => 1 / (sh.d_min * sh.d_min)); const limit = fit ?? d_min; const cut = limit !== undefined ? 1 / (limit * limit) : undefined; const x0 = 0; const x1 = 1.03 * Math.max(x[x.length - 1], d_min !== undefined ? 1 / (d_min * d_min) : 0, cut ?? 0); - const ticks = dTicks(x0, x1, Math.max(width - MARGIN.l - MARGIN.r, 100)); + const ticks = dTicks(x0, x1, Math.max(panelWidth - MARGIN.l - MARGIN.r, 100)); return ( - + *": {bgcolor: livePalette(theme.palette.mode).panel, borderRadius: 1}} : undefined}> {merge && Merge of {merge}} {PANELS.map((panel, i) => { if (!shells.some(sh => panel.value(sh) !== undefined)) return null; - const lower = i === PANELS.length - 1; - const panelHeight = lower ? height + AXIS_TITLE : height; + // the axis is named under the lower panel; side by side, under each, within the panel's height + const lower = row || i === PANELS.length - 1; + const panelHeight = lower && !row ? height + AXIS_TITLE : height; return ( Date: Sat, 14 Nov 2026 08:24:06 +0100 Subject: [PATCH 2/3] rugnux live page: a flow for narrow windows, and the model fitted to its panel Below the wide stage the page now flows for the common case of a browser beside other windows: the merge's numbers as a row of tiles under the header, the image and the model side by side as large as the width allows (one above the other under 1000 px), the collection plots wide, then the shell plots square with the checks beside them (under them where the row is too narrow). Mol*'s camera reset frames the structure's bounding sphere within the panel's shorter side, which left a compact molecule small in a wide panel: the model is now fitted by the atoms' extent across and up the view (fitCamera.ts), on the first load, on "whole model" and whenever the panel changes shape. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01UqXYdJDrM65gxsCn2PrbfK --- frontend/src/components/RugnuxHero.tsx | 4 +- frontend/src/components/RugnuxPage.tsx | 124 ++++++++++++------ .../src/components/RugnuxStructureViewer.tsx | 28 +++- .../src/components/structure/fitCamera.ts | 39 ++++++ 4 files changed, 149 insertions(+), 46 deletions(-) create mode 100644 frontend/src/components/structure/fitCamera.ts diff --git a/frontend/src/components/RugnuxHero.tsx b/frontend/src/components/RugnuxHero.tsx index 274515a21..d27d9c266 100644 --- a/frontend/src/components/RugnuxHero.tsx +++ b/frontend/src/components/RugnuxHero.tsx @@ -157,7 +157,7 @@ function ModelTile({s, modelLoaded}: { s: rugnux_live_status, modelLoaded: boole } // column: the tiles as a rail, top to bottom, sharing the rail's height (two or three to a row on a phone, -// where the rail is the width of the screen) +// where the rail is the width of the screen); else a row of tiles, five to a row, ten on a wide screen // givenCell: the unit cell the collection was started with, if any function RugnuxHero({s, modelLoaded, givenCell, column}: { s: rugnux_live_status, modelLoaded: boolean, givenCell?: string, column?: boolean }) { @@ -176,7 +176,7 @@ function RugnuxHero({s, modelLoaded, givenCell, column}: *": {display: "flex", flexDirection: "column", justifyContent: "center"}} - : {gridTemplateColumns: {xs: "repeat(3, minmax(0, 1fr))", md: "repeat(10, minmax(0, 1fr))"}})}}> + : {gridTemplateColumns: {xs: "repeat(3, minmax(0, 1fr))", sm: "repeat(5, minmax(0, 1fr))", xl: "repeat(10, minmax(0, 1fr))"}})}}> `${x.toFixed(2)} Å`)} caption="Resolution" tone={pending} tip={o.fit !== undefined ? `Where the CC½ fall-off is fitted: the resolution to quote. The reflections are written to ${o.d_min?.toFixed(2)} Å, a shell beyond, on purpose.` diff --git a/frontend/src/components/RugnuxPage.tsx b/frontend/src/components/RugnuxPage.tsx index a58be1df9..76fc04397 100644 --- a/frontend/src/components/RugnuxPage.tsx +++ b/frontend/src/components/RugnuxPage.tsx @@ -25,8 +25,9 @@ import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; import ClearAllIcon from "@mui/icons-material/ClearAll"; import {lazy, Suspense, useEffect, useRef, useState} from "react"; -// The live page as one control-room screen, in the app's own light or dark: a stage the height of the window, -// edged in the colour of the run's phase, that shows everything at once - images, structure, statistics. +// The live page as one control-room screen, in the app's own light or dark: on a wide window a stage the height +// of the window, edged in the colour of the run's phase, that shows everything at once - images, structure, +// statistics; in a narrower one the same pieces flow down the page (FlowDashboard). // Across the top, the phase, the two progress bars (the detector's and rugnux's) and the clock the run is // judged by. Below, left to right: the hero numbers of the merge as a rail with the triage badges under them, // the diffraction image the broker is on, and the placed model in Mol* (the run's step until there is one). @@ -198,71 +199,72 @@ function useHeight() { return [ref, height] as const; } +// The checks: what the pathology checklist made of the merge, a failed run's message, or what is still to come +function Checks({s, pal}: { s: rugnux_live_status, pal: LivePalette }) { + if (s.triage && s.triage.length > 0) + return ; + if (s.state === "Failed") + return {s.message}; + return ; +} + +function ShellPlotsOrLater({s, height}: { s: rugnux_live_status, height: number }) { + if (!s.shells || s.shells.length === 0) + return ; + return ; +} + +type DashboardProps = { s: rugnux_live_status, name?: string, givenCell?: string, deadline_s: number, modelLoaded: boolean, + measuring: boolean, pal: LivePalette }; + +// Spots and predictions are drawn on an image only where the broker analysed it: a serial run's images after +// the pre-pass. A rotation run's images are analysed by rugnux's own passes and carry neither. +const overlaysOn = (s: rugnux_live_status) => s.stills !== undefined && s.stills.images_analysed > 0; + // The height of the bottom row of plots, from the window's height so the stage holds everything without // scrolling: the image and the model take what the header and the plots leave. const PLOTS = "clamp(190px, 23vh, 440px)"; const RAIL = "clamp(200px, 12vw, 420px)"; -function Dashboard({s, name, givenCell, deadline_s, modelLoaded, measuring, pal}: - { s: rugnux_live_status, name?: string, givenCell?: string, deadline_s: number, modelLoaded: boolean, - measuring: boolean, pal: LivePalette }) { - // Only on the fixed-height stage (xl) do the plots and the image take their height from their box; below it - // the stage flows and the boxes take their height from their content, so a measured height would feed back. - const stage = useMediaQuery(useTheme().breakpoints.up("xl")); +// The stage of a wide window (xl): the height of the window, nothing scrolls. +function StageDashboard({s, name, givenCell, deadline_s, modelLoaded, measuring, pal}: DashboardProps) { const [plotsRef, plotsHeight] = useHeight(); const [imageRef, imageHeight] = useHeight(); - const plotHeight = stage ? Math.max(150, plotsHeight) : 220; - const later = s.stills ? "after the first merge" : "after scaling"; - // Spots and predictions are drawn on an image only where the broker analysed it: a serial run's images after - // the pre-pass. A rotation run's images are analysed by rugnux's own passes and carry neither. - const overlays = s.stills !== undefined && s.stills.images_analysed > 0; - const hairline = {borderLeft: {xl: "1px solid"}, borderColor: {xl: "divider"}, pl: {xl: 2.5}}; + const plotHeight = Math.max(150, plotsHeight); + const hairline = {borderLeft: "1px solid", borderColor: "divider", pl: 2.5}; return (
- + {/* the merge's numbers, and under them what the checks made of it */} - + - - {s.triage && s.triage.length > 0 ? - : s.state === "Failed" ? {s.message} - : } - + {/* the image, square with the row's height, in a column of its own width; the model takes the rest */} - + - - + + - {/* below the stage the model takes the whole width under the image, only as tall as Mol* needs, and - nothing when there is no model to show */} - + {/* four plots across the bottom: the collection image by image, wide - a point an image - and the merge by resolution, square - a point a shell - each as wide as the row is high */} - - + + - By resolution{s.stills && s.shells_merge && ` · ${s.shells_merge}`}} - sx={{...hairline, minHeight: {xs: 200, xl: 0}}}> - - {s.shells && s.shells.length > 0 - ? - - - : } + By resolution{s.stills && s.shells_merge && ` · ${s.shells_merge}`}} sx={hairline}> + *": {width: "100%"}}}> + @@ -271,6 +273,46 @@ function Dashboard({s, name, givenCell, deadline_s, modelLoaded, measuring, pal} ); } +// The side of the square shell plots and the height of the collection strip, below the stage +const FLOW_SQUARE = 240; +const FLOW_STRIP = 200; + +// A narrower window (the common case: a browser beside other windows), where the page scrolls: the merge's +// numbers as a row of tiles under the header, then the image and the model side by side, as large as the width +// allows - one above the other where that would leave them under 360 px - then the collection plots, wide, and +// the shell plots, square, with the checks beside them. +function FlowDashboard({s, name, givenCell, deadline_s, modelLoaded, measuring, pal}: DashboardProps) { + const twoUp = useMediaQuery("(min-width: 1000px)"); + return ( + +
+ + + + {/* beside the image the model is as tall as the image; under it, as tall as Mol* needs */} + + + + + + + By resolution{s.stills && s.shells_merge && ` · ${s.shells_merge}`}} + sx={{width: 2 * FLOW_SQUARE + 12, maxWidth: "100%", minHeight: {xs: 120, sm: FLOW_SQUARE}}}> + *": {width: "100%"}}}> + + + + + + + ); +} + +function Dashboard(props: DashboardProps) { + const stage = useMediaQuery(useTheme().breakpoints.up("xl")); + return stage ? : ; +} + // What the stage leaves out, below it: the timeline, the steps with their notes, the summary rows // and warnings, the model's scores, and the serial pre-pass geometry. function Details({s, deadline_s}: { s: rugnux_live_status, deadline_s: number }) { diff --git a/frontend/src/components/RugnuxStructureViewer.tsx b/frontend/src/components/RugnuxStructureViewer.tsx index ba8ebc6d5..b241778b7 100644 --- a/frontend/src/components/RugnuxStructureViewer.tsx +++ b/frontend/src/components/RugnuxStructureViewer.tsx @@ -12,6 +12,7 @@ import {applyModelDisplay, clearScene, getStructureAtoms, getStructureBox, Loade import {loadMapLayer, MAP_COLORS, MapLayer, removeMapLayer, setLayerVisible} from "./structure/loadMaps"; import {FullCellMap, fullCellFromCcp4, prepareMap} from "./structure/densityCrop"; import {revealCamera} from "./structure/reveal"; +import {fitCamera} from "./structure/fitCamera"; import {PEAK_MAP_RADIUS_A, viewPeak} from "./structure/peakView"; @@ -19,7 +20,8 @@ import {PEAK_MAP_RADIUS_A, viewPeak} from "./structure/peakView"; // 2mFo-DFc at 1 sigma, mFo-DFc at +-3 sigma and (where the data carry anomalous signal) the anomalous difference // map at 4 sigma, in Mol*. Set up as aaredb's structure viewer (gitea.psi.ch/mx/aaredb, pages/StructureView.tsx // and components/Structure/, the PSI MX group's own code): its plugin, Coot mouse controls, model presets, map -// meshes, crop and carve - on a black stage. It is not a viewer to work in: what it shows is gone with the next +// meshes, crop and carve - on a black stage, the model fitted to the panel (fitCamera.ts), and again whenever the +// panel changes shape. It is not a viewer to work in: what it shows is gone with the next // collection, so the controls are a toggle for the difference map and arrows through the refined model's // difference-map peaks (the blobs of the live result, highest first), in a bar over the stage. Every map is carved // within the same radius of the atoms (aaredb carves 2Fo-Fc only); at a peak the maps are drawn uncarved within @@ -88,6 +90,7 @@ function RugnuxStructureViewer({resultKey, anomalous, anomalousSignal, fill, pea const [hasMap, setHasMap] = useState>({twofofc: false, fofc: false, anom: false}); // The stage stays dark until the first model and its maps are in, then fades up as the camera eases in. const [revealed, setRevealed] = useState(false); + const stageRef = useRef(null); // aaredb factory defaults (state/viewerDefaults.ts:16-23); anomalous as a difference map, +4 sigma const SIGMA: Record = {twofofc: 1.0, fofc: 3.0, anom: 4.0}; @@ -159,6 +162,7 @@ function RugnuxStructureViewer({resultKey, anomalous, anomalousSignal, fill, pea } if (firstScene && !abort.signal.aborted) { await nextFrames(); // the camera reset loadModel asked for is applied on a draw + fitCamera(plugin, atoms, 0); if (!reducedMotion()) revealCamera(plugin, REVEAL_MS); } @@ -176,6 +180,22 @@ function RugnuxStructureViewer({resultKey, anomalous, anomalousSignal, fill, pea return () => abort.abort(); }, [pluginReady, resultKey, anomalous]); + // The panel changed shape: the whole model is fitted to it again (a peak keeps its own view) + useEffect(() => { + const stage = stageRef.current; + if (!stage) + return; + const observer = new ResizeObserver(() => { + const plugin = pluginRef.current; + if (plugin && sceneLoadedRef.current && peakRef.current === null) { + plugin.handleResize(); + fitCamera(plugin, atomsRef.current, 0); + } + }); + observer.observe(stage); + return () => observer.disconnect(); + }, []); + const toggleLayer = useCallback((kind: Kind, visible: boolean) => { setShow(s => ({...s, [kind]: visible})); const plugin = pluginRef.current; @@ -198,7 +218,9 @@ function RugnuxStructureViewer({resultKey, anomalous, anomalousSignal, fill, pea // at a peak the side chains about it matter: sticks over the cartoon applyModelDisplay(plugin, modelRefsRef.current, i === null ? REPR : 'both', false); if (i === null) { - plugin.managers.camera.reset(undefined, reducedMotion() ? 0 : 400); + plugin.managers.camera.reset(undefined, 0); + await nextFrames(); // the reset is applied on a draw; the fit starts from it + fitCamera(plugin, atomsRef.current, reducedMotion() ? 0 : 400); return; } const p = sortedRef.current[i]; @@ -270,7 +292,7 @@ function RugnuxStructureViewer({resultKey, anomalous, anomalousSignal, fill, pea )} - + diff --git a/frontend/src/components/structure/fitCamera.ts b/frontend/src/components/structure/fitCamera.ts new file mode 100644 index 000000000..ed0e7e937 --- /dev/null +++ b/frontend/src/components/structure/fitCamera.ts @@ -0,0 +1,39 @@ +import { PluginContext } from 'molstar/lib/mol-plugin/context'; +import { Vec3 } from 'molstar/lib/mol-math/linear-algebra'; + +// The camera moved along its line of sight until the atoms fill the panel: Mol*'s own reset frames the +// structure's bounding sphere within the panel's shorter side, which leaves a compact molecule small in a +// wide or tall panel. Here the atoms' extent across and up the view is what has to fit, with a little air, +// so the model is as large as the panel lets it be, whatever the panel's shape; the view direction and the +// focus radius (the clipping) are left as they are. +const AIR = 1.08; + +export function fitCamera(plugin: PluginContext, atoms: Float32Array, durationMs: number): void { + const camera = plugin.canvas3d?.camera; + if (!camera || atoms.length < 3) + return; + const s = camera.getSnapshot(); + const dir = Vec3.normalize(Vec3(), Vec3.sub(Vec3(), s.position, s.target)); + const up = Vec3.normalize(Vec3(), Vec3.sub(Vec3(), s.up, Vec3.scale(Vec3(), dir, Vec3.dot(s.up, dir)))); + const right = Vec3.cross(Vec3(), up, dir); + const n = atoms.length / 3; + const centre = Vec3(); + for (let i = 0; i < atoms.length; i += 3) + Vec3.add(centre, centre, Vec3.create(atoms[i], atoms[i + 1], atoms[i + 2])); + Vec3.scale(centre, centre, 1 / n); + let hx = 0, hy = 0, hz = 0; + const d = Vec3(); + for (let i = 0; i < atoms.length; i += 3) { + Vec3.sub(d, Vec3.create(atoms[i], atoms[i + 1], atoms[i + 2]), centre); + hx = Math.max(hx, Math.abs(Vec3.dot(d, right))); + hy = Math.max(hy, Math.abs(Vec3.dot(d, up))); + hz = Math.max(hz, Math.abs(Vec3.dot(d, dir))); + } + const { width, height } = camera.viewport; + const t = Math.tan(s.fov / 2); + // the extent across the view fits the width, the one up the view the height; the nearest atoms sit hz + // in front of the centre + const distance = Math.max(hy / t, hx / (t * Math.max(width / Math.max(height, 1), 1e-3))) * AIR + hz; + camera.setState({ ...s, target: centre, position: Vec3.add(Vec3(), centre, Vec3.scale(Vec3(), dir, distance)) }, + durationMs, { easing: 'cubic-out' }); +} From b351bbb32b0982883f3136cb09e40f9aff0293dd Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Sat, 14 Nov 2026 08:25:57 +0100 Subject: [PATCH 3/3] rugnux live page, variant C: the checks over small square shell plots in a right panel, collection plots along the bottom The shape of the first layout - rail, image, model, a right panel, the collection plots along the bottom - with the right panel's two tall shell plots made small and square, one above the other under the checks. Below the stage the right panel stands beside the image and the model from 1200 px; narrower than that the shell plots follow the collection plots as in the layout before. For comparison with it. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01UqXYdJDrM65gxsCn2PrbfK --- frontend/src/components/RugnuxPage.tsx | 116 +++++++++++++++---------- 1 file changed, 70 insertions(+), 46 deletions(-) diff --git a/frontend/src/components/RugnuxPage.tsx b/frontend/src/components/RugnuxPage.tsx index 76fc04397..4dbb400f8 100644 --- a/frontend/src/components/RugnuxPage.tsx +++ b/frontend/src/components/RugnuxPage.tsx @@ -29,11 +29,11 @@ import {lazy, Suspense, useEffect, useRef, useState} from "react"; // of the window, edged in the colour of the run's phase, that shows everything at once - images, structure, // statistics; in a narrower one the same pieces flow down the page (FlowDashboard). // Across the top, the phase, the two progress bars (the detector's and rugnux's) and the clock the run is -// judged by. Below, left to right: the hero numbers of the merge as a rail with the triage badges under them, -// the diffraction image the broker is on, and the placed model in Mol* (the run's step until there is one). -// Under the image and the model, four plots: the collection image by image - spots and background, and the -// per-image scale with the frames the merge left out - and the merge by resolution shell - completeness and -// CC1/2. Everything else - the timeline, step notes, +// judged by. Below, left to right: the hero numbers of the merge as a rail, the diffraction image the broker +// is on, the placed model in Mol* (the run's step until there is one), and the triage badges over the merge by +// resolution shell - completeness and CC1/2, small and square. Under the image and the model, the collection +// image by image: spots and background, and the per-image scale with the frames the merge left out. Everything +// else - the timeline, step notes, // summary rows, warnings, the serial pre-pass geometry - sits under a "Details" fold below the stage, and the // settings under that. @@ -185,18 +185,18 @@ function Centre({s, pal}: { s: rugnux_live_status, pal: LivePalette }) { return ; } -// Height of an element in px, kept up to date as the page resizes: the plots need theirs in pixels. -function useHeight() { +// Size of an element in px, kept up to date as the page resizes: the plots need theirs in pixels. +function useSize() { const ref = useRef(null); - const [height, setHeight] = useState(0); + const [size, setSize] = useState({width: 0, height: 0}); useEffect(() => { if (!ref.current) return; - const observer = new ResizeObserver(entries => setHeight(entries[0].contentRect.height)); + const observer = new ResizeObserver(entries => setSize({width: entries[0].contentRect.width, height: entries[0].contentRect.height})); observer.observe(ref.current); return () => observer.disconnect(); }, []); - return [ref, height] as const; + return [ref, size.width, size.height] as const; } // The checks: what the pathology checklist made of the merge, a failed run's message, or what is still to come @@ -208,10 +208,28 @@ function Checks({s, pal}: { s: rugnux_live_status, pal: LivePalette }) { return ; } -function ShellPlotsOrLater({s, height}: { s: rugnux_live_status, height: number }) { +// row: the two plots side by side; else one above the other +function ShellPlotsOrLater({s, height, row}: { s: rugnux_live_status, height: number, row?: boolean }) { if (!s.shells || s.shells.length === 0) return ; - return ; + return ; +} + +// The right panel: the checks, and under them the shell plots, small and square, one above the other +// (side: their side in px; sx: how the plots' division takes its height - on the stage, what the checks leave) +function RightPanel({s, pal, side, sx}: { s: rugnux_live_status, pal: LivePalette, side: number, sx?: object }) { + return ( + <> + *": {flexShrink: 0}}}> + + + By resolution{s.stills && s.shells_merge && ` · ${s.shells_merge}`}} sx={sx}> + + + + + + ); } type DashboardProps = { s: rugnux_live_status, name?: string, givenCell?: string, deadline_s: number, modelLoaded: boolean, @@ -221,89 +239,95 @@ type DashboardProps = { s: rugnux_live_status, name?: string, givenCell?: string // the pre-pass. A rotation run's images are analysed by rugnux's own passes and carry neither. const overlaysOn = (s: rugnux_live_status) => s.stills !== undefined && s.stills.images_analysed > 0; -// The height of the bottom row of plots, from the window's height so the stage holds everything without -// scrolling: the image and the model take what the header and the plots leave. -const PLOTS = "clamp(190px, 23vh, 440px)"; +// The height of the collection strip along the bottom and the width of the rail and the right panel, from the +// window so the stage holds everything without scrolling: the image and the model take what is left. +const STRIP = "clamp(150px, 14vh, 260px)"; const RAIL = "clamp(200px, 12vw, 420px)"; +const RIGHT = "clamp(220px, 15vw, 360px)"; +const AXIS_TITLE = 18; // what the lower of two stacked shell plots adds for the axis title (RugnuxShellPlots) // The stage of a wide window (xl): the height of the window, nothing scrolls. function StageDashboard({s, name, givenCell, deadline_s, modelLoaded, measuring, pal}: DashboardProps) { - const [plotsRef, plotsHeight] = useHeight(); - const [imageRef, imageHeight] = useHeight(); - const plotHeight = Math.max(150, plotsHeight); + const [stripRef, , stripHeight] = useSize(); + const [imageRef, , imageHeight] = useSize(); + const [rightRef, rightWidth, rightHeight] = useSize(); + // the shell plots, square, one above the other in the right panel: as large as its width or height allows + const side = Math.max(120, Math.min(rightWidth, (rightHeight - AXIS_TITLE) / 2)); const hairline = {borderLeft: "1px solid", borderColor: "divider", pl: 2.5}; return (
- - {/* the merge's numbers, and under them what the checks made of it */} - + + - {/* the image, square with the row's height, in a column of its own width; the model takes the rest */} - + - + - {/* four plots across the bottom: the collection image by image, wide - a point an image - and the - merge by resolution, square - a point a shell - each as wide as the row is high */} - - - - - - - By resolution{s.stills && s.shells_merge && ` · ${s.shells_merge}`}} sx={hairline}> - *": {width: "100%"}}}> - - - + {/* the checks over the shell plots, small and square - a point a shell */} + + + {/* the collection image by image along the bottom, wide - a point an image */} + + + + + ); } -// The side of the square shell plots and the height of the collection strip, below the stage +// The side of the square shell plots, the height of the collection strip and the width of the right panel, +// below the stage const FLOW_SQUARE = 240; const FLOW_STRIP = 200; +const FLOW_RIGHT = 220; // A narrower window (the common case: a browser beside other windows), where the page scrolls: the merge's // numbers as a row of tiles under the header, then the image and the model side by side, as large as the width -// allows - one above the other where that would leave them under 360 px - then the collection plots, wide, and -// the shell plots, square, with the checks beside them. +// allows - one above the other where that would leave them under 360 px - with the right panel (the checks over +// the shell plots, small and square) beside them from 1200 px, then the collection plots, wide. Narrower than +// that, the shell plots come after the collection, with the checks beside them. function FlowDashboard({s, name, givenCell, deadline_s, modelLoaded, measuring, pal}: DashboardProps) { const twoUp = useMediaQuery("(min-width: 1000px)"); + const wide = useMediaQuery("(min-width: 1200px)"); return (
- + {/* beside the image the model is as tall as the image; under it, as tall as Mol* needs */} + {/* the row grows to the panel where it is taller than the image: the model fills it */} + {wide && + + } - + {!wide && By resolution{s.stills && s.shells_merge && ` · ${s.shells_merge}`}} sx={{width: 2 * FLOW_SQUARE + 12, maxWidth: "100%", minHeight: {xs: 120, sm: FLOW_SQUARE}}}> - *": {width: "100%"}}}> + *": {width: "100%"}}}> - + } ); }