Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions src/components/OavVideoStream.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,8 @@ function VideoBoxWithOverlay(props: {
const canvas = canvasRef.current;
if (canvas) {
const rect = canvas.getBoundingClientRect();
// x and y relative to the canvas
const [x, y] = [e.clientX - rect.left, e.clientY - rect.top];
// x and y relative to the crosshair
const [relX, relY] = [x - props.crosshairX, y - props.crosshairY];
// fraction of the image in x/y * original dimension in pixels
const scaledX = props.originalDims
? (relX / width) * props.originalDims.width
: x;
const scaledY = props.originalDims
? (relY / height) * props.originalDims.height
: y;
props.onCoordClick(scaledX, scaledY);
props.onCoordClick(x, y);
}
}
}}
Expand Down
40 changes: 14 additions & 26 deletions src/screens/OavMover/OAVStageController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useMemo } from "react";

export function OavMover() {
const DISPLAY_CONFIG_ENDPOINT =
"/dls_sw/i24/software/daq_configuration/display.configuration";
"/dls_sw/i24/software/daq_configuration/domain/display.configuration";
const beamCenterQuery = useConfigCall(DISPLAY_CONFIG_ENDPOINT);
const currentZoomValue = String(
useParsedPvConnection({
Expand Down Expand Up @@ -39,13 +39,23 @@ export function OavMover() {
return [Number(xLine.split(" ")[2]), Number(yLine.split(" ")[2])];
}, [beamCenterQuery.data, zoomIndex]);

// #Issue 86: Remove these constants - https://github.com/DiamondLightSource/mx-daq-ui/issues/86
const pixelsPerMicron = 1.25;
const theme = useTheme();
const bgColor = theme.palette.background.paper;

const fullVisit = readVisitFromPv();

function onCoordClick(x: number, y: number) {
submitAndRunPlanImmediately({
planName: "move_on_oav_view_click",
planParams: { position: [x, y] },
instrumentSession: parseInstrumentSession(fullVisit),
}).catch((error) => {
console.log(
`Failed to run plan , see console and logs for full error. Reason: ${error}`,
);
});
}

return (
<div>
<Grid2 container spacing={2} columns={12}>
Expand All @@ -56,29 +66,7 @@ export function OavMover() {
label="I24 OAV image stream"
crosshairX={crosshairX}
crosshairY={crosshairY}
onCoordClick={(x: number, y: number) => {
const [x_um, y_um] = [x / pixelsPerMicron, y / pixelsPerMicron];
console.log(
`Clicked on position (${x}, ${y}) (px relative to beam centre) in original stream. Relative position in um (${x_um}, ${y_um}). Submitting to BlueAPI...`,
);
const [x_int, y_int] = [Math.round(x), Math.round(y)];
if (Number.isNaN(x_um) || Number.isNaN(y_um)) {
console.log(
"Not submitting plan while disconnected from PVs!",
);
} else {
// This is an example but not useful for actual production use.
submitAndRunPlanImmediately({
planName: "gui_gonio_move_on_click",
planParams: { position_px: [x_int, y_int] },
instrumentSession: parseInstrumentSession(fullVisit),
}).catch((error) => {
console.log(
`Failed to run plan gui_gonio_move_on_click, see console and logs for full error. Reason: ${error}`,
);
});
}
}}
onCoordClick={onCoordClick}
/>
</Box>
</Grid2>
Expand Down
Loading