add slice layer naming using op notes. fixes #447

This commit is contained in:
Stewart Allen 2025-11-13 22:25:06 -05:00
commit 04da5abccb
6 changed files with 11 additions and 8 deletions

View file

@ -47,7 +47,7 @@ class OpDrill extends CamOp {
slice.camLines = [poly];
slice.output()
.setLayer("drill", { face: color, line: color })
.setLayer(state.layername, { face: color, line: color })
.addPolys(slice.camLines);
addSlices(slice);
sliceOut.push(slice);

View file

@ -212,7 +212,7 @@ class OpOutline extends CamOp {
.setLayer("slice", {line: 0xaaaa00}, false)
.addPolys(slice.topPolys())
slice.output()
.setLayer("outline", {face: color, line: color})
.setLayer(state.layername, {face: color, line: color})
.addPolys(slice.camLines);
}

View file

@ -135,7 +135,7 @@ class OpPocket extends CamOp {
});
}
slice.output()
.setLayer("pocket", {line: color}, false)
.setLayer(state.layername, {line: color}, false)
.addPolys(slice.camLines)
if (debug && shadow) slice.output()
.setLayer("pocket shadow", {line: 0xff8811}, false)

View file

@ -65,7 +65,7 @@ class OpRough extends CamOp {
}
slice.camLines = polys;
slice.output()
.setLayer("roughing", {face: color, line: color})
.setLayer(state.layername, {face: color, line: color})
.addPolys(slice.camLines);
addSlices(slice);
camFaces.push(slice);
@ -279,7 +279,7 @@ class OpRough extends CamOp {
slices.forEach(slice => {
slice.output()
.setLayer("roughing", {face: color, line: color})
.setLayer(state.layername, {face: color, line: color})
.addPolys(slice.camLines);
});
this.sliceOut = slices.filter(slice => slice.camLines);

View file

@ -92,7 +92,7 @@ class OpTrace extends CamOp {
}
POLY.setWinding(slice.camLines, offset === "outside" ? !cutdir : cutdir, false);
slice.output()
.setLayer("trace follow", {line: color}, false)
.setLayer(state.layername, {line: color}, false)
.addPolys(slice.camLines)
}
function clearZnew(polys, z, down) {
@ -154,7 +154,7 @@ class OpTrace extends CamOp {
.setLayer("trace poly", {line: 0x1188ff}, false)
.addPolys([ poly ])
slice.output()
.setLayer("trace", {line: color}, false)
.setLayer(state.layername, {line: color}, false)
.addPolys(slice.camLines)
progress(zpro, "trace");
zpro += zinc;

View file

@ -310,8 +310,11 @@ export async function cam_slice(settings, widget, onupdate, ondone) {
workover.bottom_z = isIndexed ? valz.ov_botz : bottom_stock + valz.ov_botz;
workover.bottom_cut = Math.max(workover.bottom_z, -zThru);
}
// state.workarea = workover;
let { note, type } = op.op;
let named = note ? note.split(' ').filter(v => v.charAt(0) === '#') : [];
let layername = named.length ? named : (note ? `${type} (${note})` : type);
Object.assign(state, {
layername,
zBottom,
zThru,
ztOff,