feat(pcb): 원통형 부품(전해 콘덴서)은 기판에서 원으로 표시 + 극성 + 표시

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
kimandClaude Sonnet 5.5 committed 2026-10-04 13:51:34 +09:00
1 parent 52ed80e6da
commit 0cfef03824
3 files changed
+17 -2

No files matched your search

+1
View File
@@ -7,6 +7,7 @@ export interface Footprint {
id: string; name: string; group: string; smd: boolean;
pads: Pad[];
body: { x0: number; y0: number; x1: number; y1: number }; // 실크/외곽선 그리기용
circle?: { cx: number; cy: number; r: number }; // 원형 외형(전해 콘덴서 등) — 있으면 상자 대신 원으로 그린다
}
export interface PartInst { ref: string; fp: string; x: number; y: number; rot: number; value?: string }
export interface PlacedPad { ref: string; n: string; id: string; x: number; y: number; w: number; h: number; shape: Pad['shape']; drill: number; smd: boolean; npth: boolean }
+12 -1
View File
@@ -176,7 +176,18 @@ export function parseKicadMod(text: string, id: string, group: string, name: str
x0: r3(Math.min(...src.map(q => q[0]))), y0: r3(Math.min(...src.map(q => q[1]))),
x1: r3(Math.max(...src.map(q => q[0]))), y1: r3(Math.max(...src.map(q => q[1]))),
};
return { id, name, group, smd: pads.length > 0 && pads.every(p => p.smd), pads, body };
// 원형 외형: Fab → 실크 → 코트야드 순으로 가장 큰 원(전해 콘덴서·원통형 부품)
let circle: Footprint['circle'];
for (const layerName of ['F.Fab', 'F.SilkS', 'F.CrtYd']) {
for (const it of kids(root, 'fp_circle')) {
if (kids(it, 'layer')[0]?.[1] !== layerName) continue;
const c0 = kids(it, 'center')[0], e0 = kids(it, 'end')[0]; if (!c0 || !e0) continue;
const cx = num(c0[1]), cy = num(c0[2]), r = Math.hypot(num(e0[1]) - cx, num(e0[2]) - cy);
if (r > 0.3 && (!circle || r > circle.r)) circle = { cx: r3(cx), cy: r3(cy), r: r3(r) };
}
if (circle) break;
}
return { id, name, group, smd: pads.length > 0 && pads.every(p => p.smd), pads, body, ...(circle ? { circle } : {}) };
}
const mod = new Map<string, Footprint>();
+4 -1
View File
@@ -339,7 +339,10 @@ function draw(){
const b=bboxOf(part); if(!b) continue;
const isSel=sel===part.ref;
ctx.strokeStyle=isSel?'#fff176':'rgba(255,255,255,.55)'; ctx.lineWidth=isSel?2:1;
ctx.strokeRect(sx(b.x0),sy(b.y0),(b.x1-b.x0)*view.s,(b.y1-b.y0)*view.s);
const cf=FPM[part.fp]&&FPM[part.fp].circle;
if(cf){const cc=rotPoint(cf.cx,cf.cy,part.rot);ctx.beginPath();ctx.arc(sx(part.x+cc[0]),sy(part.y+cc[1]),cf.r*view.s,0,7);ctx.stroke();
if(/^kicad:Capacitor_THT:CP_/.test(part.fp)){const p1=padsOf(part).find(q=>q.id.endsWith('-1'));if(p1){const dx=p1.x-(part.x+cc[0]),dy=p1.y-(part.y+cc[1]),L=Math.hypot(dx,dy)||1;ctx.fillStyle=ctx.strokeStyle;ctx.font='bold 13px sans-serif';ctx.textAlign='center';ctx.fillText('+',sx(part.x+cc[0]+dx/L*cf.r*1.25),sy(part.y+cc[1]+dy/L*cf.r*1.25)+4);ctx.textAlign='left';}}}
else ctx.strokeRect(sx(b.x0),sy(b.y0),(b.x1-b.x0)*view.s,(b.y1-b.y0)*view.s);
ctx.fillStyle=isSel?'#fff176':'rgba(255,255,255,.8)'; ctx.font='11px sans-serif'; ctx.fillText(part.ref+(part.value?' '+part.value:''),sx(b.x0)+2,sy(b.y0)-3);
for(const pad of padsOf(part)){
const net=netOfPin(pad.id)>=0, cx=sx(pad.x), cy=sy(pad.y), w=pad.w*view.s, h=pad.h*view.s;