import type { Ref } from 'react' import type { Geometry, Point } from '@faunosteo/core-wasm/types' import type { Correction } from '@/editor/annotations/correction' import type { Frame } from '@/editor/annotations/frame' import { isEditable } from '@/editor/annotations/geometryEdit' export interface OverlayProps { svgRef: Ref /** The composed root's own attributes: the overlay shares its coordinates. */ viewBox: string ratio: string frame: Frame | null selected: Geometry | null dragged: Geometry | null pending: Geometry | null tracing: Point[] | null correction: Correction | null } const STROKE = { fill: 'none', vectorEffect: 'non-scaling-stroke' } as const function Outline({ geometry, dashed, colour, }: { geometry: Geometry dashed: boolean colour: string }) { const style = { ...STROKE, stroke: colour, strokeWidth: 2, strokeDasharray: dashed ? '6 4' : undefined, } if (geometry.type === 'circle') { return ( ) } if (geometry.type === 'polygon') { return } return null } function Vertices({ geometry, size }: { geometry: Geometry; size: number }) { if (geometry.type !== 'polygon') return null return ( <> {geometry.points.map(([x, y], index) => ( ))} ) } /** The hollow cross of the position the user chose, drawn apart from the proposal. */ function HollowCross({ at, size, }: { at: { x: number; y: number } size: number }) { const style = { ...STROKE, stroke: 'var(--color-ink)', strokeWidth: 2 } return ( ) } function TracingPath({ points, size }: { points: Point[]; size: number }) { if (points.length === 0) return null const shape: Geometry = { type: 'polygon', points } return ( <> ) } /** * The page-drawn overlay (docs/ANNOTATION-RENDERING.md « Editor overlay »): numbers only, * no annotation. Selection outline, vertex circles, the tracing in progress, the pending * or dragged outline, a corrected position with the click marked apart. It never takes * the pointer: the canvas box does. */ export default function AnnotationOverlay(props: OverlayProps) { const { frame, selected, dragged, pending, tracing, correction } = props const size = frame ? Math.max(frame.w, frame.h) / 200 : 1 const shown = dragged ?? selected return ( ) }