From 5a93a817841f23302352c4eba95ebd70c20f06ed Mon Sep 17 00:00:00 2001 From: kim Date: Sun, 4 Oct 2026 14:12:39 +0900 Subject: [PATCH] =?UTF-8?q?feat(pcb):=20G-code=20=EB=AF=B8=EB=A6=AC?= =?UTF-8?q?=EB=B3=B4=EA=B8=B0=EC=97=90=20=EC=8B=A4=ED=81=AC(=EC=B2=AD?= =?UTF-8?q?=EB=A1=9D)=20=ED=91=9C=EC=8B=9C=20=E2=80=94=20=EB=B6=80?= =?UTF-8?q?=ED=92=88=EB=A9=B4=20=EB=B0=A9=ED=96=A5,=20silk=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EA=B3=B5=EA=B5=AC=20=EC=95=88=EB=82=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- src/tools/pcb/gcode.ts | 6 ++++-- web-ui/html/pcb-app.html | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tools/pcb/gcode.ts b/src/tools/pcb/gcode.ts index 58f64cf..1e2329a 100644 --- a/src/tools/pcb/gcode.ts +++ b/src/tools/pcb/gcode.ts @@ -95,7 +95,7 @@ function orderPaths(paths: IP[][]): IP[][] { export interface GcodeResult { files: Record; - preview: { isolation: Record; drills: { x: number; y: number; d: number }[]; outline: Pt[] }; + preview: { isolation: Record; drills: { x: number; y: number; d: number }[]; outline: Pt[]; silk: Pt[][]; silkSide: 'top' | 'copper' | null }; stats: { holes: number; drillSizes: number[]; isolationLengthMm: number; estMinutes: number }; warnings: string[]; } @@ -125,6 +125,7 @@ export function buildGcode(p: PcbProject, routed: Routed): GcodeResult { const files: Record = {}; const isolation: Record = {}; + let silkPreview: Pt[][] = [], silkSideUsed: 'top' | 'copper' | null = null; let isoLen = 0, plunges = 0; for (const layer of layers) { @@ -204,6 +205,7 @@ export function buildGcode(p: PcbProject, routed: Routed): GcodeResult { const diff = orderPaths(clipSilk([...shapes, ...labels])); const inBoard = diff; if (inBoard.length) { + silkPreview = inBoard.map(pp => pp.map(toMm)); silkSideUsed = topSide ? 'top' : 'copper'; const z = m.silkZ ?? -0.05; const L = head(`실크(부품 윤곽) 새기기 — ${topSide ? '부품면(동박 반대면): 보드를 뒤집어 부품면이 위로 오게 놓고, 같은 원점·고정으로 가공' : '동박면'} (Ø${m.toolDia}mm 비트, 깊이 ${z}mm)`); for (const pp of inBoard) { @@ -240,7 +242,7 @@ export function buildGcode(p: PcbProject, routed: Routed): GcodeResult { return { files, - preview: { isolation, drills: holes, outline }, + preview: { isolation, drills: holes, outline, silk: silkPreview, silkSide: silkSideUsed }, stats: { holes: holes.length, drillSizes: sizes, isolationLengthMm: Math.round(isoLen), estMinutes: Math.round(((isoLen / Math.max(m.feed, 1)) + plunges * 0.02 + holes.length * 0.03) * 10) / 10, diff --git a/web-ui/html/pcb-app.html b/web-ui/html/pcb-app.html index 3ed1ab2..5793dc0 100644 --- a/web-ui/html/pcb-app.html +++ b/web-ui/html/pcb-app.html @@ -319,6 +319,7 @@ function draw(){ ctx.lineWidth=1;ctx.strokeStyle='#ffd54a'; for(const layer of Object.keys(gres.preview.isolation)) for(const loop of gres.preview.isolation[layer]){ctx.beginPath();loop.forEach((q,i)=>i?ctx.lineTo(sx(q[0]),sy(q[1])):ctx.moveTo(sx(q[0]),sy(q[1])));ctx.stroke();} ctx.strokeStyle='#ff6b6b';ctx.setLineDash([6,4]);ctx.beginPath();gres.preview.outline.forEach((q,i)=>i?ctx.lineTo(sx(q[0]),sy(q[1])):ctx.moveTo(sx(q[0]),sy(q[1])));ctx.closePath();ctx.stroke();ctx.setLineDash([]); + if(gres.preview.silk&&gres.preview.silk.length){ctx.strokeStyle='#80deea';ctx.lineWidth=1;for(const l of gres.preview.silk){ctx.beginPath();l.forEach((q,i)=>i?ctx.lineTo(sx(q[0]),sy(q[1])):ctx.moveTo(sx(q[0]),sy(q[1])));ctx.stroke();}} } // 트레이스·비아 if(routed){ @@ -707,7 +708,7 @@ function renderMill(){ if(running) h+=`
`; } if(gres){ const names=Object.keys(gres.files).filter(n=>/\.nc$/.test(n)); - const tool=n=>/copper/.test(n)?`공구: 가공 폭 ${P.mill.toolDia}mm 비트(V비트/엔드밀)`:/drill/.test(n)?`공구: 드릴 ${gres.stats.drillSizes.join(', ')||'-'}mm — 크기마다 M0에서 멈추니 공구 교체 후 ▶ 재개`:`공구: 엔드밀 Ø${P.mill.outlineDia}mm`; + const tool=n=>/copper/.test(n)?`공구: 가공 폭 ${P.mill.toolDia}mm 비트(V비트/엔드밀)`:/silk/.test(n)?`공구: 얕게 긋는 Ø${P.mill.toolDia}mm 비트(깊이 ${P.mill.silkZ}mm)${/top/.test(n)?' — 보드를 뒤집어 부품면이 위로':''}`:/drill/.test(n)?`공구: 드릴 ${gres.stats.drillSizes.join(', ')||'-'}mm — 크기마다 M0에서 멈추니 공구 교체 후 ▶ 재개`:`공구: 엔드밀 Ø${P.mill.outlineDia}mm`; h+=names.map(n=>`
${esc(n)}${millPaths[n]?' · 업로드됨':''}
${esc(tool(n))}
`).join(''); } else h+='
G-code 를 생성하면 파일별로 올리고 시작할 수 있습니다.
';