stock is now always on in CAM mode

This commit is contained in:
Stewart Allen 2023-02-14 13:25:56 -05:00
commit 6c67c93988
10 changed files with 40 additions and 50 deletions

View file

@ -68,6 +68,7 @@
# CAM # CAM
* `B` in indexed stock mode, stock should rotate with indexing
* `B` feed rate for next tool set before tool change (push/pop feed rates?) * `B` feed rate for next tool set before tool change (push/pop feed rates?)
* `B` tab cuts cause loss of direction, parenting, depth, and it's hard to fix * `B` tab cuts cause loss of direction, parenting, depth, and it's hard to fix
* `B` tabs do not properly track widget mirror events * `B` tabs do not properly track widget mirror events
@ -76,6 +77,7 @@
* `B` need to force cut line at synthetic z bottom (midlines, etc) * `B` need to force cut line at synthetic z bottom (midlines, etc)
* `B` contour does not honor clip to stock * `B` contour does not honor clip to stock
* `F` allow import, rotation, scaling of stock
* `F` get gcode coordinates off a part with point/click or hover? * `F` get gcode coordinates off a part with point/click or hover?
* `F` include tools in default devices (Carvera) * `F` include tools in default devices (Carvera)
* `F` add `match faces` option in `outline` operation * `F` add `match faces` option in `outline` operation

View file

@ -10,10 +10,10 @@ Full docs @ https://docs.grid.space/projects/kiri-moto
* CAM clearly delineate ops reachable or not on timeline * CAM clearly delineate ops reachable or not on timeline
* CAM add 4th axis lathe operation for debug and testing (can be optimized) * CAM add 4th axis lathe operation for debug and testing (can be optimized)
* CAM add rough all stock to aid lathe mode * CAM add rough all stock to aid lathe mode
* CAM stock is now always on, whether offset or absolute
- add auto-disable for ops mismatched to axis indexed state - add auto-disable for ops mismatched to axis indexed state
- remove clear top (always on) - remove clear top (always on)
- add z top (like z bottom) - add z top (like z bottom)
- stock always on
- add "common" overrides in ops (z top/bottom/thru, direction) - add "common" overrides in ops (z top/bottom/thru, direction)

View file

@ -366,7 +366,7 @@ kiri.load(() => {
const { process } = settings; const { process } = settings;
const print = worker.print; const print = worker.print;
const density = parseInt(settings.controller.animesh) * 1000; const density = parseInt(settings.controller.animesh) * 1000;
const isIndexed = process.camStockOn && process.camStockIndexed; const isIndexed = process.camStockIndexed;
pathIndex = 0; pathIndex = 0;
path = print.output.flat(); path = print.output.flat();

View file

@ -66,8 +66,8 @@ CAM.init = function(kiri, api) {
API = api; API = api;
function updateAxisMode(refresh) { function updateAxisMode(refresh) {
const { camStockIndexGrid, camStockIndexed, camStockOn } = current.process; const { camStockIndexGrid, camStockIndexed } = current.process;
let newIndexed = camStockIndexed && camStockOn; let newIndexed = camStockIndexed;
let changed = refresh || isIndexed !== newIndexed; let changed = refresh || isIndexed !== newIndexed;
isIndexed = newIndexed; isIndexed = newIndexed;
if (!isIndexed || !isCamMode) { if (!isIndexed || !isCamMode) {
@ -94,7 +94,7 @@ CAM.init = function(kiri, api) {
return; return;
} }
for (let widget of api.widgets.all()) { for (let widget of api.widgets.all()) {
widget.setIndexed(camStock && isIndexed ? true : false); widget.setIndexed(isIndexed ? true : false);
} }
api.platform.update_bounds(); api.platform.update_bounds();
// add or remove clock op depending on indexing // add or remove clock op depending on indexing
@ -116,7 +116,7 @@ CAM.init = function(kiri, api) {
api.event.on("widget.add", widget => { api.event.on("widget.add", widget => {
if (isCamMode && !Array.isArray(widget)) { if (isCamMode && !Array.isArray(widget)) {
updateAxisMode(true); updateAxisMode(true);
widget.setIndexed(camStock && isIndexed ? true : false); widget.setIndexed(isIndexed ? true : false);
api.platform.update_bounds(); api.platform.update_bounds();
} }
}); });
@ -126,11 +126,8 @@ CAM.init = function(kiri, api) {
if (isAnimate) { if (isAnimate) {
return; return;
} }
if (isCamMode && !camStock) {
return api.show.alert("animation requires stock to be enabled");
}
api.function.prepare(() => { api.function.prepare(() => {
if (isCamMode && camStock) { if (isCamMode) {
animate(); animate();
} }
}); });
@ -193,7 +190,6 @@ CAM.init = function(kiri, api) {
} }
// show/hide dots in enabled process pop buttons // show/hide dots in enabled process pop buttons
api.ui.camTabs.marker.style.display = hasTabs ? 'flex' : 'none'; api.ui.camTabs.marker.style.display = hasTabs ? 'flex' : 'none';
api.ui.camStock.marker.style.display = proc.camStockOn ? 'flex' : 'none';
api.platform.update_bounds(); api.platform.update_bounds();
updateIndex(); updateIndex();
updateStock(); updateStock();
@ -1653,8 +1649,8 @@ function createTabBox(iw, ic, n) {
const { track } = iw; const { track } = iw;
const { stock, bounds, process } = API.conf.get(); const { stock, bounds, process } = API.conf.get();
const { camTabsWidth, camTabsHeight, camTabsDepth, camTabsMidline } = process; const { camTabsWidth, camTabsHeight, camTabsDepth, camTabsMidline } = process;
const { camZBottom, camStockOn, camStockIndexed } = process; const { camZBottom, camStockIndexed } = process;
const isIndexed = camStockOn && camStockIndexed; const isIndexed = camStockIndexed;
const sz = stock.z || bounds.max.z; const sz = stock.z || bounds.max.z;
const zto = sz - iw.track.top; const zto = sz - iw.track.top;
const zp = (camZBottom || isIndexed ? camZBottom : sz - track.box.d - zto) + (camTabsMidline ? 0 : camTabsHeight / 2); const zp = (camZBottom || isIndexed ? camZBottom : sz - track.box.d - zto) + (camTabsMidline ? 0 : camTabsHeight / 2);

View file

@ -60,10 +60,9 @@ CAM.export = function(print, online) {
lasering = false, lasering = false,
laserOp, laserOp,
stock = settings.stock || { }, stock = settings.stock || { },
hasStock = spro.camStockOn && stock.x && stock.y && stock.z, ztOff = stock.z - widget.track.top,
ztOff = hasStock ? stock.z - widget.track.top : 0,
bounds = widget.getBoundingBox(), bounds = widget.getBoundingBox(),
zmax = hasStock ? stock.z : bounds.max.z, zmax = stock.z,
runbox = { runbox = {
max: { x:-Infinity, y:-Infinity, z:-Infinity}, max: { x:-Infinity, y:-Infinity, z:-Infinity},
min: { x:Infinity, y:Infinity, z:Infinity} min: { x:Infinity, y:Infinity, z:Infinity}
@ -372,9 +371,7 @@ CAM.export = function(print, online) {
append(`; Generated by Kiri:Moto ${kiri.version}`); append(`; Generated by Kiri:Moto ${kiri.version}`);
append(`; ${new Date().toString()}`); append(`; ${new Date().toString()}`);
filterEmit(["; Bed left:{left} right:{right} top:{top} bottom:{bottom}"], consts); filterEmit(["; Bed left:{left} right:{right} top:{top} bottom:{bottom}"], consts);
if (hasStock) { append(`; Stock X:${stock.x.round(2)} Y:${stock.y.round(2)} Z:${stock.z.round(2)}`);
append(`; Stock X:${stock.x.round(2)} Y:${stock.y.round(2)} Z:${stock.z.round(2)}`);
}
append(`; Target: ${settings.filter[settings.mode]}`); append(`; Target: ${settings.filter[settings.mode]}`);
append("; --- process ---"); append("; --- process ---");
for (let pk in spro) { for (let pk in spro) {

View file

@ -68,24 +68,23 @@ function prepEach(widget, settings, print, firstPoint, update) {
outer = settings.bounds || widget.getPositionBox(), outer = settings.bounds || widget.getPositionBox(),
outerz = outer.max.z, outerz = outer.max.z,
slices = widget.slices, slices = widget.slices,
hasStock = stock.x && stock.y && stock.z && process.camStockOn, isIndexed = process.camStockIndexed,
isIndexed = hasStock && process.camStockIndexed,
startCenter = process.camOriginCenter, startCenter = process.camOriginCenter,
alignTop = settings.controller.alignTop, alignTop = settings.controller.alignTop,
zclear = (process.camZClearance || 1), zclear = (process.camZClearance || 1),
zmax_force = process.camForceZMax || false, zmax_force = process.camForceZMax || false,
zmax_outer = hasStock ? stock.z + zclear : outerz + zclear, zmax_outer = stock.z + zclear,
wztop = widget.track.top, wztop = widget.track.top,
ztOff = hasStock ? stock.z - wztop : 0, ztOff = stock.z - wztop,
bounds = widget.getBoundingBox(), bounds = widget.getBoundingBox(),
boundsz = bounds.max.z + ztOff, boundsz = bounds.max.z + ztOff,
zadd = hasStock && !isIndexed ? stock.z - boundsz : alignTop ? outerz - boundsz : 0, zadd = !isIndexed ? stock.z - boundsz : alignTop ? outerz - boundsz : 0,
zmax = outerz + zclear + process.camOriginOffZ, zmax = outerz + zclear + process.camOriginOffZ,
wmpos = widget.track.pos, wmpos = widget.track.pos,
wmx = wmpos.x, wmx = wmpos.x,
wmy = wmpos.y, wmy = wmpos.y,
originx = (startCenter ? 0 : hasStock ? -stock.x / 2 : bounds.min.x) + process.camOriginOffX, originx = (startCenter ? 0 : -stock.x / 2) + process.camOriginOffX,
originy = (startCenter ? 0 : hasStock ? -stock.y / 2 : bounds.min.y) + process.camOriginOffY, originy = (startCenter ? 0 : -stock.y / 2) + process.camOriginOffY,
origin = newPoint(originx + wmx, originy + wmy, zmax), origin = newPoint(originx + wmx, originy + wmy, zmax),
output = print.output, output = print.output,
easeDown = process.camEaseDown, easeDown = process.camEaseDown,

View file

@ -31,8 +31,7 @@ CAM.slice = async function(settings, widget, onupdate, ondone) {
let mesh = widget.mesh, let mesh = widget.mesh,
proc = settings.process, proc = settings.process,
stock = settings.stock || {}, stock = settings.stock || {},
hasStock = stock.x && stock.y && stock.z && proc.camStockOn, isIndexed = proc.camStockIndexed,
isIndexed = hasStock && proc.camStockIndexed,
camOps = widget.camops = [], camOps = widget.camops = [],
sliceAll = widget.slices = [], sliceAll = widget.slices = [],
bounds = widget.getBoundingBox(), bounds = widget.getBoundingBox(),
@ -40,9 +39,9 @@ CAM.slice = async function(settings, widget, onupdate, ondone) {
// widget top z as defined by setTopz() // widget top z as defined by setTopz()
wztop = track.top, wztop = track.top,
// distance between top of part and top of stock // distance between top of part and top of stock
ztOff = isIndexed ? 0 : (hasStock ? stock.z - wztop : 0), ztOff = isIndexed ? 0 : (stock.z - wztop),
// distance between bottom of part and bottom of stock // distance between bottom of part and bottom of stock
zbOff = isIndexed ? 0 : (hasStock ? wztop - track.box.d : 0), zbOff = isIndexed ? 0 : (wztop - track.box.d),
// defined z bottom offset by distance to stock bottom // defined z bottom offset by distance to stock bottom
// keeps the z bottom relative to the part when z align changes // keeps the z bottom relative to the part when z align changes
zBottom = isIndexed ? proc.camZBottom : proc.camZBottom - zbOff, zBottom = isIndexed ? proc.camZBottom : proc.camZBottom - zbOff,

View file

@ -566,7 +566,7 @@ const conf = exports({
camDepthFirst: false, camDepthFirst: false,
camEaseDown: false, camEaseDown: false,
camOriginTop: true, camOriginTop: true,
camZAnchor: "top", camZAnchor: "middle",
camZOffset: 0, camZOffset: 0,
camZBottom: 0, camZBottom: 0,
camZClearance: 1, camZClearance: 1,
@ -578,14 +578,13 @@ const conf = exports({
camContourBridge: 0, camContourBridge: 0,
camStockX: 5, camStockX: 5,
camStockY: 5, camStockY: 5,
camStockZ: 0, camStockZ: 5,
camStockOffset: true, camStockOffset: true,
camStockClipTo: false, camStockClipTo: false,
camStockIndexed: false, camStockIndexed: false,
camStockIndexGrid: false, camStockIndexGrid: false,
camIndexAxis: 0, camIndexAxis: 0,
camIndexAbs: true, camIndexAbs: true,
camStockOn: true,
camConventional: false, // outputClockwise camConventional: false, // outputClockwise
camOriginCenter: false, camOriginCenter: false,
camOriginOffX: 0, camOriginOffX: 0,

View file

@ -1912,7 +1912,7 @@ gapp.register("kiri.init", [], (root, exports) => {
(ui.tabClr = uc.newButton(undefined, onButtonClick, {icon:'<i class="fas fa-trash-alt"></i>'})) (ui.tabClr = uc.newButton(undefined, onButtonClick, {icon:'<i class="fas fa-trash-alt"></i>'}))
], {modes:CAM, class:"ext-buttons f-row"}), ], {modes:CAM, class:"ext-buttons f-row"}),
camStock: uc.newGroup(LANG.cs_menu, null, {modes:CAM, marker: true}), camStock: uc.newGroup(LANG.cs_menu, null, {modes:CAM}),
camStockX: uc.newInput(LANG.cs_wdth_s, {title:LANG.cs_wdth_l, convert:uc.toFloat, bound:uc.bound(0,9999), modes:CAM, units:true}), camStockX: uc.newInput(LANG.cs_wdth_s, {title:LANG.cs_wdth_l, convert:uc.toFloat, bound:uc.bound(0,9999), modes:CAM, units:true}),
camStockY: uc.newInput(LANG.cs_dpth_s, {title:LANG.cs_dpth_l, convert:uc.toFloat, bound:uc.bound(0,9999), modes:CAM, units:true}), camStockY: uc.newInput(LANG.cs_dpth_s, {title:LANG.cs_dpth_l, convert:uc.toFloat, bound:uc.bound(0,9999), modes:CAM, units:true}),
camStockZ: uc.newInput(LANG.cs_hght_s, {title:LANG.cs_hght_l, convert:uc.toFloat, bound:uc.bound(0,9999), modes:CAM, units:true}), camStockZ: uc.newInput(LANG.cs_hght_s, {title:LANG.cs_hght_l, convert:uc.toFloat, bound:uc.bound(0,9999), modes:CAM, units:true}),
@ -1920,13 +1920,12 @@ gapp.register("kiri.init", [], (root, exports) => {
camStockOffset: uc.newBoolean(LANG.cs_offs_s, onBooleanClick, {title:LANG.cs_offs_l, modes:CAM}), camStockOffset: uc.newBoolean(LANG.cs_offs_s, onBooleanClick, {title:LANG.cs_offs_l, modes:CAM}),
camStockClipTo: uc.newBoolean(LANG.cs_clip_s, onBooleanClick, {title:LANG.cs_clip_l, modes:CAM}), camStockClipTo: uc.newBoolean(LANG.cs_clip_s, onBooleanClick, {title:LANG.cs_clip_l, modes:CAM}),
camSep: uc.newBlank({class:"pop-sep"}), camSep: uc.newBlank({class:"pop-sep"}),
camStockIndexGrid: uc.newBoolean(LANG.cs_ishg_s, onBooleanClick, {title:LANG.cs_ishg_l, modes:CAM, show:() => ui.camStockOn.checked && ui.camStockIndexed.checked}), camStockIndexGrid: uc.newBoolean(LANG.cs_ishg_s, onBooleanClick, {title:LANG.cs_ishg_l, modes:CAM, show:() => ui.camStockIndexed.checked}),
camStockIndexed: uc.newBoolean(LANG.cs_indx_s, onBooleanClick, {title:LANG.cs_indx_l, modes:CAM, show:() => ui.camStockOn.checked}), camStockIndexed: uc.newBoolean(LANG.cs_indx_s, onBooleanClick, {title:LANG.cs_indx_l, modes:CAM}),
camStockOn: uc.newBoolean(LANG.cs_offe_s, onBooleanClick, {title:LANG.cs_offe_l, modes:CAM}),
camCommon: uc.newGroup(LANG.cc_menu, null, {modes:CAM}), camCommon: uc.newGroup(LANG.cc_menu, null, {modes:CAM}),
camZAnchor: uc.newSelect(LANG.ou_zanc_s, {title: LANG.ou_zanc_l, action:zAnchorSave, modes:CAM, trace:true, show:() => ui.camStockOn.checked && !ui.camStockIndexed.checked}, "zanchor"), camZAnchor: uc.newSelect(LANG.ou_zanc_s, {title: LANG.ou_zanc_l, action:zAnchorSave, modes:CAM, trace:true, show:() => !ui.camStockIndexed.checked}, "zanchor"),
camSep: uc.newBlank({class:"pop-sep", show:() => ui.camStockOn.checked && !ui.camStockIndexed.checked}), camSep: uc.newBlank({class:"pop-sep", show:() => !ui.camStockIndexed.checked}),
camZOffset: uc.newInput(LANG.ou_ztof_s, {title:LANG.ou_ztof_l, convert:uc.toFloat, modes:CAM, units:true}), camZOffset: uc.newInput(LANG.ou_ztof_s, {title:LANG.ou_ztof_l, convert:uc.toFloat, modes:CAM, units:true}),
camZBottom: uc.newInput(LANG.ou_zbot_s, {title:LANG.ou_zbot_l, convert:uc.toFloat, modes:CAM, units:true, trigger: true}), camZBottom: uc.newInput(LANG.ou_zbot_s, {title:LANG.ou_zbot_l, convert:uc.toFloat, modes:CAM, units:true, trigger: true}),
camZThru: uc.newInput(LANG.ou_ztru_s, {title:LANG.ou_ztru_l, convert:uc.toFloat, bound:uc.bound(0.0,100), modes:CAM, units:true, show:() => { return ui.camZBottom.value == 0 }}), camZThru: uc.newInput(LANG.ou_ztru_s, {title:LANG.ou_ztru_l, convert:uc.toFloat, bound:uc.bound(0.0,100), modes:CAM, units:true, show:() => { return ui.camZBottom.value == 0 }}),

View file

@ -45,8 +45,7 @@ function platformUpdateOrigin(update_bounds = true) {
let ruler = controller.showRulers; let ruler = controller.showRulers;
let stockCenter = stock.center || { x: 0, y: 0, z: 0 }; let stockCenter = stock.center || { x: 0, y: 0, z: 0 };
let hasStock = stock.x && stock.y && stock.z; let isIndexed = process.camStockIndexed;
let isIndexed = process.camStockIndexed && process.camStockOn;
let isBelt = device.bedBelt; let isBelt = device.bedBelt;
let origin = settings.origin = { x: 0, y: 0, z: 0 }; let origin = settings.origin = { x: 0, y: 0, z: 0 };
let center = MODE === MODES.FDM ? device.originCenter || device.bedRound : let center = MODE === MODES.FDM ? device.originCenter || device.bedRound :
@ -55,11 +54,11 @@ function platformUpdateOrigin(update_bounds = true) {
device.originCenter || process.outputOriginCenter; device.originCenter || process.outputOriginCenter;
if (MODE === MODES.CAM && process.camOriginTop) { if (MODE === MODES.CAM && process.camOriginTop) {
origin.z = (hasStock ? stock.z : topZ) + 0.01; origin.z = stock.z + 0.01;
} }
if (!center) { if (!center) {
if (hasStock) { if (MODE === MODES.CAM) {
origin.x = (-stock.x / 2) + stockCenter.x; origin.x = (-stock.x / 2) + stockCenter.x;
origin.y = (stock.y / 2) - stockCenter.y; origin.y = (stock.y / 2) - stockCenter.y;
} else { } else {
@ -72,7 +71,7 @@ function platformUpdateOrigin(update_bounds = true) {
origin.y = device.bedDepth / 2; origin.y = device.bedDepth / 2;
} }
} }
} else if (hasStock) { } else if (MODE === MODES.CAM) {
origin.x = stockCenter.x; origin.x = stockCenter.x;
origin.y = -stockCenter.y; origin.y = -stockCenter.y;
} else if (isBelt) { } else if (isBelt) {
@ -92,7 +91,7 @@ function platformUpdateOrigin(update_bounds = true) {
space.platform.setRulers(ruler, ruler, 1 / api.view.unit_scale(), 'X', isBelt ? 'Z' : 'Y'); space.platform.setRulers(ruler, ruler, 1 / api.view.unit_scale(), 'X', isBelt ? 'Z' : 'Y');
let { x, y, z } = origin; let { x, y, z } = origin;
let oz = process.camStockIndexed && process.camStockOn ? z / 2 : z; let oz = process.camStockIndexed ? z / 2 : z;
if (controller.showOrigin && MODE !== MODES.SLA) { if (controller.showOrigin && MODE !== MODES.SLA) {
space.platform.setOrigin(x, y, oz, true); space.platform.setOrigin(x, y, oz, true);
} else { } else {
@ -150,10 +149,9 @@ function platformUpdateMidZ() {
function platformUpdateTopZ(zdelta) { function platformUpdateTopZ(zdelta) {
const { process, stock } = current(); const { process, stock } = current();
const hasStock = stock.x && stock.y && stock.z;
const MODE = get_mode(); const MODE = get_mode();
api.widgets.each(widget => { api.widgets.each(widget => {
if (MODE === MODES.CAM && hasStock) { if (MODE === MODES.CAM) {
const bounds = widget.getBoundingBox(); const bounds = widget.getBoundingBox();
const wzmax = bounds.max.z; const wzmax = bounds.max.z;
const zdelta = process.camZOffset || 0; const zdelta = process.camZOffset || 0;
@ -177,14 +175,15 @@ function platformUpdateTopZ(zdelta) {
function platformUpdateStock() { function platformUpdateStock() {
const settings = current(); const settings = current();
const { bounds, process, mode } = settings; const { bounds, process, mode } = settings;
const { camStockOn, camStockX, camStockY, camStockZ, camStockOffset, camStockIndexed } = process; const { camStockX, camStockY, camStockZ, camStockOffset, camStockIndexed } = process;
if (mode === 'CAM' && camStockOn) { if (mode === 'CAM') {
let stock = settings.stock = { let stock = settings.stock = {
x: camStockX, x: camStockX,
y: camStockY, y: camStockY,
z: camStockZ z: camStockZ
}; };
if (camStockOffset) { // drop back to offset mode if any stock dimension is 0
if (camStockOffset || (stock.x * stock.y * stock.z === 0)) {
stock.x += bounds.max.x - bounds.min.x; stock.x += bounds.max.x - bounds.min.x;
stock.y += bounds.max.y - bounds.min.y; stock.y += bounds.max.y - bounds.min.y;
stock.z += bounds.max.z - bounds.min.z; stock.z += bounds.max.z - bounds.min.z;