Skip to content

Commit e998ce5

Browse files
committed
Small bits and pieces
1 parent eac9c87 commit e998ce5

File tree

4 files changed

+64
-53
lines changed

4 files changed

+64
-53
lines changed

src/App.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ function App() {
107107
]}
108108
>
109109
<FixedTargetPanels />
110-
<Footer color={theme.palette.primary.main}>
111-
{/* <Footer logo={theme.logos.normal} color={theme.palette.primary.main}> */}
110+
<Footer logo={theme.logos?.normal} color={theme.palette.primary.main}>
112111
<FooterLinks>
113112
<ColourSchemeButton sx={{ marginLeft: "1px", marginTop: "2px" }} />
114113
</FooterLinks>

src/CustomTheme.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const I24DiamondTheme: Theme = createTheme({
5656

5757
// To be improved and extended to light mode once
5858
// https://github.com/DiamondLightSource/sci-react-ui/pull/70
59-
// is merged and released (v0.2.0)
59+
// is merged and released (v0.2.0+)
6060

6161
/** Set up a customisable theme derived from the common DiamondTheme
6262
* This way it should be possible to easily add settings if required

src/components/OavVideoStream.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
import { Box } from "@mui/material";
2-
import { PvComponent, PvItem, PvDescription, useParsedPvConnection } from "../pv/PvComponent";
2+
import {
3+
PvComponent,
4+
PvItem,
5+
PvDescription,
6+
useParsedPvConnection,
7+
} from "../pv/PvComponent";
38
import { parseNumericPv, pvIntArrayToString } from "../pv/util";
49
import React from "react";
510

6-
export const useContainerDimensions = (ref: React.MutableRefObject<HTMLHeadingElement | null>) => {
11+
const useContainerDimensions = (
12+
ref: React.MutableRefObject<HTMLHeadingElement | null>
13+
) => {
714
const [dimensions, setDimensions] = React.useState({ width: 0, height: 0 });
815
React.useEffect(() => {
916
const getDimensions = () => ({
@@ -62,7 +69,10 @@ export function OavVideoStream(
6269
label: props.label,
6370
render: (props: PvItem) => {
6471
const value = props.value ? props.value : "undefined";
65-
if (!streamUrl.startsWith("http") && value.toString().startsWith("http")) {
72+
if (
73+
!streamUrl.startsWith("http") &&
74+
value.toString().startsWith("http")
75+
) {
6676
setStreamUrl(value.toString());
6777
}
6878
return (
@@ -148,8 +158,12 @@ function VideoBoxWithOverlay(props: {
148158
// x and y relative to the crosshair
149159
const [relX, relY] = [x - props.crosshairX, y - props.crosshairY];
150160
// fraction of the image in x/y * original dimension in pixels
151-
const scaledX = props.originalDims ? (relX / width) * props.originalDims.width : x;
152-
const scaledY = props.originalDims ? (relY / height) * props.originalDims.height : y;
161+
const scaledX = props.originalDims
162+
? (relX / width) * props.originalDims.width
163+
: x;
164+
const scaledY = props.originalDims
165+
? (relY / height) * props.originalDims.height
166+
: y;
153167
props.onCoordClick(scaledX, scaledY);
154168
}
155169
}

src/screens/OavMover.tsx

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -182,52 +182,50 @@ export function OavMover() {
182182
const theme = useTheme();
183183
const bgColor = theme.palette.background.paper;
184184
return (
185-
<div>
186-
<Grid2 container spacing={2} columns={12}>
187-
<Grid2 size={9} sx={{ bgcolor: bgColor }}>
188-
<Box width={"100%"}>
189-
<OavVideoStream
190-
pv="ca://BL24I-DI-OAV-01:"
191-
label="I24 OAV image stream"
192-
crosshairX={crosshairX}
193-
crosshairY={crosshairY}
194-
onCoordClick={(x: number, y: number) => {
195-
const [x_um, y_um] = [x / pixelsPerMicron, y / pixelsPerMicron];
196-
console.log(
197-
`Clicked on position (${x}, ${y}) (px relative to beam centre) in original stream. Relative position in um (${x_um}, ${y_um}). Submitting to BlueAPI...`
198-
);
199-
const [x_int, y_int] = [Math.round(x), Math.round(y)];
200-
if (Number.isNaN(x_um) || Number.isNaN(y_um)) {
201-
console.log(
202-
"Not submitting plan while disconnected from PVs!"
203-
);
204-
} else {
205-
submitAndRunPlanImmediately("gui_gonio_move_on_click", {
206-
position_px: [x_int, y_int],
207-
});
208-
}
209-
}}
210-
/>
211-
</Box>
212-
</Grid2>
213-
<Grid2 size={3} height={3}>
214-
<MoveArrows />
215-
<Grid2 size={3} padding={1} />
216-
<BeamCentre
217-
setCrosshairX={setCrosshairX}
218-
setCrosshairY={setCrosshairY}
219-
/>
220-
<PixelsToMicrons setPixelsPerMicron={setPixelsPerMicron} />
221-
<BacklightControl
222-
label="backlight-pos"
223-
pv="ca://BL24I-MO-BL-01:MP:SELECT"
224-
/>
225-
<ZoomControl
226-
label="zoom-level"
227-
pv="ca://BL24I-EA-OAV-01:FZOOM:MP:SELECT"
185+
// <div>
186+
<Grid2 container spacing={2} columns={12}>
187+
<Grid2 size={9} sx={{ bgcolor: bgColor }}>
188+
<Box width={"100%"}>
189+
<OavVideoStream
190+
pv="ca://BL24I-DI-OAV-01:"
191+
label="I24 OAV image stream"
192+
crosshairX={crosshairX}
193+
crosshairY={crosshairY}
194+
onCoordClick={(x: number, y: number) => {
195+
const [x_um, y_um] = [x / pixelsPerMicron, y / pixelsPerMicron];
196+
console.log(
197+
`Clicked on position (${x}, ${y}) (px relative to beam centre) in original stream. Relative position in um (${x_um}, ${y_um}). Submitting to BlueAPI...`
198+
);
199+
const [x_int, y_int] = [Math.round(x), Math.round(y)];
200+
if (Number.isNaN(x_um) || Number.isNaN(y_um)) {
201+
console.log("Not submitting plan while disconnected from PVs!");
202+
} else {
203+
submitAndRunPlanImmediately("gui_gonio_move_on_click", {
204+
position_px: [x_int, y_int],
205+
});
206+
}
207+
}}
228208
/>
229-
</Grid2>
209+
</Box>
210+
</Grid2>
211+
<Grid2 size={3} height={3}>
212+
<MoveArrows />
213+
<Grid2 size={3} padding={1} />
214+
<BeamCentre
215+
setCrosshairX={setCrosshairX}
216+
setCrosshairY={setCrosshairY}
217+
/>
218+
<PixelsToMicrons setPixelsPerMicron={setPixelsPerMicron} />
219+
<BacklightControl
220+
label="backlight-pos"
221+
pv="ca://BL24I-MO-BL-01:MP:SELECT"
222+
/>
223+
<ZoomControl
224+
label="zoom-level"
225+
pv="ca://BL24I-EA-OAV-01:FZOOM:MP:SELECT"
226+
/>
230227
</Grid2>
231-
</div>
228+
</Grid2>
229+
// </div>
232230
);
233231
}

0 commit comments

Comments
 (0)