add flip operation for double-sided work

This commit is contained in:
Stewart Allen 2020-12-27 22:51:32 -05:00
commit 8627f54a98
8 changed files with 79 additions and 8 deletions

View file

@ -5,7 +5,6 @@
# - revisit ease down
# - split gcode output
# - redo path planning
# - double-sided assistance
# `fdm`
# - bind process to z ranges or boxed regions

View file

@ -456,6 +456,8 @@
camDrillDwell: 250,
camDrillLift: 2,
camDrillingOn: false,
camFlipAxis: "X",
camFlipOther: "",
// camDrillReg: "none",
camTabsWidth: 5,
camTabsHeight: 5,
@ -480,7 +482,8 @@
outputOriginCenter: false,
outputInvertX: false,
outputInvertY: false,
ops: []
ops: [], // current ops
op2: [] // flip ops
}
},
laser: {

View file

@ -1640,7 +1640,7 @@
******************************************************************* */
// given a settings region, update values of matching bound UI fields
function updateFieldsFromSettings(setrec, uirec = UI) {
function updateFieldsFromSettings(setrec, uirec = UI, trace) {
if (!setrec) {
return console.trace("missing scope");
}
@ -1664,7 +1664,7 @@
} else if (typ === 'select-one') {
uie.innerHTML = '';
let source = uie.parentNode.getAttribute('source'),
list = settings[source] || lists[source],
list = uie._source || settings[source] || lists[source],
chosen = null;
if (list) list.forEach(function(el, index) {
let id = el.id || el.name;

View file

@ -733,7 +733,11 @@
row.appendChild(newLabel(label));
row.appendChild(ip);
if (Array.isArray(source)) {
ip._source = source;
} else {
row.setAttribute("source", source || "tools");
}
row.setAttribute("class", "var-row");
row.style.display = hide ? 'none' : '';
if (options) {

View file

@ -22,7 +22,8 @@
let zaxis = { x: 0, y: 0, z: 1 },
popOp = {},
func = {};
func = {},
flipping;
CAM.restoreTabs = restoreTabs;
@ -156,6 +157,14 @@
case "register": return func.opAddRegister('X', 2);
case "drill": return func.opAddDrill();
case "trace": return func.opAddTrace();
case "flip":
// only one flip op permitted
for (let op of current.process.ops) {
if (op.type === 'flip') {
return;
}
}
return func.opAddFlip();
}
};
@ -194,6 +203,10 @@
func.opAdd(rec);
};
func.opAddFlip = () => {
func.opAdd(popOp.flip.new());
};
// TAB/TRACE BUTTON HANDLERS
api.event.on("button.click", target => {
let process = API.conf.get().process;
@ -345,6 +358,41 @@
}
});
func.opFlip = () => {
let { process } = current;
let { ops, op2 } = process;
let add2 = op2.length === 0; // add flip singleton to b-side
let axis = poppedRec.axis;
flipping = true;
switch (axis) {
case 'X':
API.selection.rotate(Math.PI, 0, 0);
// API.widgets.all().forEach(widget => {
// widget.rotate(Math.PI, 0, 0);
// });
break;
case 'Y':
API.selection.rotate(0, Math.PI, 0);
// API.widgets.all().forEach(widget => {
// widget.rotate(0, Math.PI, 0);
// });
break;
}
flipping = false;
process.ops = op2;
process.op2 = ops;
for (let op of op2) {
if (op.type === 'flip') {
op.axis = poppedRec.axis;
}
}
if (add2) {
func.opAdd(poppedRec);
} else {
func.opRender();
}
};
// TAB FUNCS
let showTab, lastTab, tab, iw, ic;
api.event.on("cam.tabs.add", func.tabAdd = () => {
@ -628,6 +676,9 @@
func.traceDone();
}
unselectTraces(widget);
if (flipping) {
return;
}
if (x || y) {
clearTabs(widget);
} else {
@ -817,6 +868,16 @@
dwell: UC.newInput(LANG.cd_dwll_s, {title:LANG.cd_dwll_l, convert:UC.toFloat}),
lift: UC.newInput(LANG.cd_lift_s, {title:LANG.cd_lift_l, convert:UC.toFloat, units:true})
};
createPopOp('flip', {
axis: 'camFlipAxis'
}).inputs = {
axis: UC.newSelect(LANG.cd_axis, {}, "regaxis"),
sep: UC.newBlank({class:"pop-sep"}),
action: UC.newRow([
UC.newButton(LANG.cc_flip, func.opFlip)
], {class:"ext-buttons f-row"})
};
};
function createPopOp(type, map) {

View file

@ -967,7 +967,8 @@
"contour": OpContour,
"trace": OpTrace,
"drill": OpDrill,
"register": OpRegister
"register": OpRegister,
"flip": CamOp
};
})();

View file

@ -422,9 +422,11 @@
<div title="remove an area of material&#13;inside a defined boundary&#13;sometimes called pocketing">rough</div>
<div title="clean up after roughing&#13;or perform a part cutout">outline</div>
<div title="2.5D tracing along X or Y axis&#13;used for complex part features">contour</div>
<div title="drill registration holes&#13;along the X or Y axis for&#13;double-sided milling">register</div>
<div title="follow selected features with&#13;a specified tool. often used&#13;for lettering and engraving">trace</div>
<div title="drill any holes matching&#13;selected tool diameter">drill</div>
<hr width="100%">
<div title="drill registration holes&#13;along the X or Y axis&#13;for double-sided work">register</div>
<div title="flip part and load&#13;profile for other side&#13;for double-sided work">flip</div>
</div>
</div>
</div>

View file

@ -273,6 +273,7 @@ kiri.lang['en-us'] = {
// CNC COMMON
cc_menu: "limits",
cc_flip: "flip",
cc_rapd_s: "xy feed",
cc_rapd_l: "max xy moves feedrate\nin workspace units / minute",
cc_rzpd_s: "z feed",