'use client' import type { GridCell, ImageRegionWithState } from './ground-truth-types' interface ReconstructionPanelProps { cells: GridCell[] aspect: number zoom: number reconWidth: number imageRegions: ImageRegionWithState[] drawingRegion: boolean dragStart: { x: number; y: number } | null dragEnd: { x: number; y: number } | null panelRef: React.RefObject reconRef: React.RefObject onScroll: () => void onToggleDrawing: () => void onMouseDown: (e: React.MouseEvent) => void onMouseMove: (e: React.MouseEvent) => void onMouseUp: () => void } export function ReconstructionPanel({ cells, aspect, zoom, reconWidth, imageRegions, drawingRegion, dragStart, dragEnd, panelRef, reconRef, onScroll, onToggleDrawing, onMouseDown, onMouseMove, onMouseUp, }: ReconstructionPanelProps) { return (
Rekonstruktion
{/* Reconstruction container */}
{/* Row separator lines -- derive from cells */} {/* Cell texts -- black on white, font size derived from cell height */} {cells.map(cell => { if (!cell.bbox_pct || !cell.text) return null const containerH = reconWidth * aspect const cellHeightPx = containerH * (cell.bbox_pct.h / 100) const fontSize = Math.max(6, cellHeightPx * 0.7) return ( {cell.text} ) })} {/* Generated images at region positions */} {imageRegions.map((region, i) => (
{region.image_b64 ? ( {region.description} ) : (
{region.generating ? '...' : `Bild ${i + 1}`}
)}
))} {/* Drawing rectangle */} {dragStart && dragEnd && (
)}
) } /** Row separator lines derived from first-column cells */ function RowSeparators({ cells }: { cells: GridCell[] }) { const rowYs = new Set() for (const cell of cells) { if (cell.col_index === 0 && cell.bbox_pct) { rowYs.add(cell.bbox_pct.y) } } return ( <> {Array.from(rowYs).map((y, i) => (
))} ) }