feat(pcb): G-code 미리보기에 실크(청록) 표시 — 부품면 방향, silk 파일 공구 안내
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3eca4d60fc
commit
5a93a81784
2 files changed
+6
-3
No files matched your search
@@ -95,7 +95,7 @@ function orderPaths(paths: IP[][]): IP[][] {
|
||||
|
||||
export interface GcodeResult {
|
||||
files: Record<string, string>;
|
||||
preview: { isolation: Record<string, Pt[][]>; drills: { x: number; y: number; d: number }[]; outline: Pt[] };
|
||||
preview: { isolation: Record<string, Pt[][]>; 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<string, string> = {};
|
||||
const isolation: Record<string, Pt[][]> = {};
|
||||
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,
|
||||
|
||||
@@ -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+=`<div style="display:flex;gap:4px;margin-top:4px"><button class="btn" onclick="millJob('pause')">⏸ 일시정지</button><button class="btn" onclick="millJob('resume')">▶ 재개</button><button class="btn" onclick="millJob('cancel')" style="border-color:var(--red);color:var(--red)">■ 취소</button></div>`; }
|
||||
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=>`<div class="net" style="margin-top:6px"><b>${esc(n)}</b>${millPaths[n]?' <span class="ok">· 업로드됨</span>':''}<div class="note">${esc(tool(n))}</div>
|
||||
<div style="display:flex;gap:4px;margin-top:4px"><button class="btn" onclick="millUpload('${esc(n)}')">⬆ 업로드</button><button class="btn pri" ${/operational/i.test(state)?'':'disabled'} onclick="millStart('${esc(n)}')">▶ 시작</button></div></div>`).join('');
|
||||
} else h+='<div class="note" style="margin-top:6px">G-code 를 생성하면 파일별로 올리고 시작할 수 있습니다.</div>';
|
||||
|
||||
Reference in new issue
Block a user