import { usePileCapStore } from '../../store/pileCapStore'; import { DraggableLabel } from './DraggableLabel'; export const ConstructionDiagram = () => { const geometry = usePileCapStore(state => state.geometry); const reinforcement = usePileCapStore(state => state.reinforcement); // Global Diagram State const isLocked = usePileCapStore(state => state.diagramState.isLocked); const labelPositions = usePileCapStore(state => state.diagramState.labelPositions); const setDiagramLocked = usePileCapStore(state => state.setDiagramLocked); const updateLabelPosition = usePileCapStore(state => state.updateLabelPosition); const getLabelPos = (id: string, defaultX: number, defaultY: number) => { return labelPositions[id] || { x: defaultX, y: defaultY }; }; // --- Drawing Logic --- const scale = 25; const padding = 80; // Increased padding // Dimensions const capWidthPx = geometry.length * scale; const capHeightPx = geometry.width * scale; // Plan view height const capDepthPx = (geometry.depth / 12) * scale; // Corrected: geometry.depth const colWidthPx = (geometry.columnLength / 12) * scale; const colDepthPx = (geometry.columnWidth / 12) * scale; // Plan view column depth // Layout const elevationY = padding + 60; // More space at top const planY = elevationY + capDepthPx + padding + 40; const centerX = padding + capWidthPx / 2; const svgWidth = capWidthPx + 2 * padding + 100; // Extra space for side labels const svgHeight = planY + capHeightPx + padding + 40; // Extra space at bottom // --- Elevation View --- // Cap const capRect = { x: padding, y: elevationY, w: capWidthPx, h: capDepthPx }; // Column Stub const colStubH = 40; const colStubRect = { x: centerX - colWidthPx / 2, y: elevationY - colStubH, w: colWidthPx, h: colStubH }; const pileDepth = 60; const pileWidth = (geometry.pileSize / 12) * scale; // --- Plan View --- const planRect = { x: padding, y: planY, w: capWidthPx, h: capHeightPx }; const colPlanRect = { x: centerX - colWidthPx / 2, y: planY + capHeightPx / 2 - colDepthPx / 2, w: colWidthPx, h: colDepthPx }; return (