add CAM z bottom inversion option to flip operator

This commit is contained in:
Stewart Allen 2022-10-05 14:05:21 -04:00
commit 94dfc15768
4 changed files with 24 additions and 10 deletions

View file

@ -19,6 +19,7 @@ Full docs @ https://docs.grid.space/projects/kiri-moto
* add option to ignore z bottom in CAM contouring * add option to ignore z bottom in CAM contouring
* add CAM pocket option to ignore interior features (outline only) * add CAM pocket option to ignore interior features (outline only)
* add CAM Z bottom visualization, make it relative to stock instead of part * add CAM Z bottom visualization, make it relative to stock instead of part
* add CAM z bottom inversion option to flip operator
* extend url loading of workspaces to all formats * extend url loading of workspaces to all formats
* alert when healing is enabled and non-manifold geometries are detected * alert when healing is enabled and non-manifold geometries are detected
* fix thin output start and end point tracking which broke retraction * fix thin output start and end point tracking which broke retraction

View file

@ -473,14 +473,18 @@ CAM.init = function(kiri, api) {
flipping = false; flipping = false;
process.ops = op2; process.ops = op2;
process.op2 = ops; process.op2 = ops;
// special case, auto-adjust camZBottom // flip camZBottom
if (process.camZBottom && widgets.length === 1) { if (poppedRec.invert && process.camZBottom && camZBottom) {
process.camZBottom = widgets[0].bounds.max.z - process.camZBottom; const maxZ = camZBottom._max.z
process.camZBottom = maxZ - process.camZBottom;
API.util.rec2ui(process); API.util.rec2ui(process);
updateStock();
} }
// keep flip operations in sync
for (let op of op2) { for (let op of op2) {
if (op.type === 'flip') { if (op.type === 'flip') {
op.axis = poppedRec.axis; op.axis = poppedRec.axis;
op.invert = poppedRec.invert;
} }
} }
if (add2) { if (add2) {
@ -1128,12 +1132,15 @@ CAM.init = function(kiri, api) {
}; };
createPopOp('flip', { createPopOp('flip', {
axis: 'camFlipAxis' axis: 'camFlipAxis',
invert: 'camFlipInvert'
}).inputs = { }).inputs = {
axis: UC.newSelect(LANG.cd_axis, {}, "regaxis"), axis: UC.newSelect(LANG.cd_axis, {}, "regaxis"),
sep: UC.newBlank({class:"pop-sep", show:(op,conf) => conf.process.camZBottom}),
invert: UC.newBoolean(LANG.cf_nvrt_s, undefined, {title:LANG.cf_nvrt_l, show:(op,conf) => conf.process.camZBottom}),
sep: UC.newBlank({class:"pop-sep"}), sep: UC.newBlank({class:"pop-sep"}),
action: UC.newRow([ action: UC.newRow([
UC.newButton(LANG.cc_flip, func.opFlip) UC.newButton(LANG.cf_menu, func.opFlip)
], {class:"ext-buttons f-row"}) ], {class:"ext-buttons f-row"})
}; };
}; };
@ -1408,10 +1415,11 @@ function updateStock(args, event) {
SPACE.world.remove(camZBottom); SPACE.world.remove(camZBottom);
if (proc.camZBottom) { if (proc.camZBottom) {
let max = { x: csx, y: csy }; let max = { x: csx, y: csy, z: csz };
for (let w of widgets) { for (let w of widgets) {
max.x = Math.max(max.x, w.track.box.w); max.x = Math.max(max.x, w.track.box.w);
max.y = Math.max(max.y, w.track.box.h); max.y = Math.max(max.y, w.track.box.h);
max.z = Math.max(max.z, w.track.box.d);
} }
let geo = new THREE.PlaneGeometry(max.x, max.y); let geo = new THREE.PlaneGeometry(max.x, max.y);
let mat = new THREE.MeshBasicMaterial({ let mat = new THREE.MeshBasicMaterial({
@ -1423,6 +1431,7 @@ function updateStock(args, event) {
camZBottom = new THREE.Mesh(geo, mat); camZBottom = new THREE.Mesh(geo, mat);
camZBottom.renderOrder = 1; camZBottom.renderOrder = 1;
camZBottom.position.z = proc.camZBottom; camZBottom.position.z = proc.camZBottom;
camZBottom._max = max;
SPACE.world.add(camZBottom); SPACE.world.add(camZBottom);
} else { } else {
camZBottom = undefined; camZBottom = undefined;

View file

@ -532,12 +532,12 @@ gapp.register("kiri.main", [], (root, exports) => {
} }
function loadFile() { function loadFile() {
$('load-file').onchange = function(event) { const button = $('load-file');
button.onchange = function(event) {
console.log(event); console.log(event);
api.platform.load_files(event.target.files); api.platform.load_files(event.target.files);
}; };
$('load-file').click(); button.click();
// api.show.alert("drag/drop STL files onto platform to import\nreload page to return to last saved state");
} }
function saveWorkspace(quiet) { function saveWorkspace(quiet) {

View file

@ -448,7 +448,6 @@ self.kiri.lang['en-us'] = {
// CNC COMMON // CNC COMMON
cc_menu: "limits", cc_menu: "limits",
cc_flip: "flip",
cc_rapd_s: "xy feed", cc_rapd_s: "xy feed",
cc_rapd_l: ["max xy moves feedrate","in workspace units / minute"], cc_rapd_l: ["max xy moves feedrate","in workspace units / minute"],
cc_rzpd_s: "z feed", cc_rzpd_s: "z feed",
@ -530,6 +529,11 @@ self.kiri.lang['en-us'] = {
cd_mark_s: "marking", cd_mark_s: "marking",
cd_mark_l: ["only mark holes, do not drill out","the step down setting is used","to determine how deep to mark"], cd_mark_l: ["only mark holes, do not drill out","the step down setting is used","to determine how deep to mark"],
// CNC FLIP
cf_menu: "flip",
cf_nvrt_s: "z bottom",
cf_nvrt_l: "invert z bottom setting to follow stock",
// CNC CUTOUT TABS // CNC CUTOUT TABS
ct_menu: "tabs", ct_menu: "tabs",
ct_angl_s: "angle", ct_angl_s: "angle",