import { usePileCapStore } from '../../store/pileCapStore'; import { DraggableLabel } from './DraggableLabel'; export const ReinforcementDiagram = () => { const { geometry, reinforcement } = usePileCapStore(); // 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 }; }; const scale = 25; const padding = 40; // Dimensions const width = geometry.length * scale; const height = (geometry.depth / 12) * scale; const colW = (geometry.columnWidth / 12) * scale; const colH = (geometry.columnLength / 12) * scale; // For plan view const svgWidth = width + padding * 2; const svgHeight = height + padding * 2 + 150; // Extra space for plan view // Bar properties const topCover = (reinforcement.topConcreteCover / 12) * scale; const bottomCover = (reinforcement.bottomConcreteCover / 12) * scale; return (
Reinforcement Schematic
{/* Controls */}
{/* --- SECTION VIEW (Top) --- */} {/* Concrete Body */} {/* Column Stub */} {/* Top Reinforcement */} {reinforcement.hasTopMat && ( {/* Longitudinal (Dots) */} {Array.from({ length: reinforcement.topXBarCount }).map((_, i) => ( ))} {/* Transverse (Line) */} )} {/* Bottom Reinforcement */} {reinforcement.hasBottomMat && ( {/* Longitudinal (Dots) */} {Array.from({ length: reinforcement.bottomXBarCount }).map((_, i) => ( ))} {/* Transverse (Line) */} )} {/* Piles (Schematic) */} {Array.from({ length: geometry.pileColumns }).map((_, i) => { const spacing = (width - 40) / (Math.max(1, geometry.pileColumns - 1)); const x = 20 + i * spacing; return ( ); })} {/* --- PLAN VIEW (Bottom) --- */} {/* Cap Outline */} {/* Column */} {/* Bottom Bars (X-Direction) - Horizontal Lines */} {reinforcement.hasBottomMat && Array.from({ length: reinforcement.bottomZBarCount }).map((_, i) => { const y = 10 + i * (((geometry.width / 12) * scale - 20) / (Math.max(1, reinforcement.bottomZBarCount - 1))); return ( ); })} {/* Bottom Bars (Z-Direction) - Vertical Lines */} {reinforcement.hasBottomMat && Array.from({ length: reinforcement.bottomXBarCount }).map((_, i) => { const x = 10 + i * ((width - 20) / (Math.max(1, reinforcement.bottomXBarCount - 1))); return ( ); })} {/* Labels */}
); };