diff --git a/src/components/OavVideoStream.tsx b/src/components/OavVideoStream.tsx index 82defa4..585d71f 100644 --- a/src/components/OavVideoStream.tsx +++ b/src/components/OavVideoStream.tsx @@ -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); } } }} diff --git a/src/screens/OavMover/OAVStageController.tsx b/src/screens/OavMover/OAVStageController.tsx index e55204c..29a4fcd 100644 --- a/src/screens/OavMover/OAVStageController.tsx +++ b/src/screens/OavMover/OAVStageController.tsx @@ -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({ @@ -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 (
@@ -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} />