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
* `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` tab cuts cause loss of direction, parenting, depth, and it's hard to fix
* `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` 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` include tools in default devices (Carvera)
* `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 add 4th axis lathe operation for debug and testing (can be optimized)
* 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
- remove clear top (always on)
- add z top (like z bottom)
- stock always on
- add "common" overrides in ops (z top/bottom/thru, direction)

View file

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

View file

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

View file

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

View file

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

View file

@ -566,7 +566,7 @@ const conf = exports({
camDepthFirst: false,
camEaseDown: false,
camOriginTop: true,
camZAnchor: "top",
camZAnchor: "middle",
camZOffset: 0,
camZBottom: 0,
camZClearance: 1,
@ -578,14 +578,13 @@ const conf = exports({
camContourBridge: 0,
camStockX: 5,
camStockY: 5,
camStockZ: 0,
camStockZ: 5,
camStockOffset: true,
camStockClipTo: false,
camStockIndexed: false,
camStockIndexGrid: false,
camIndexAxis: 0,
camIndexAbs: true,
camStockOn: true,
camConventional: false, // outputClockwise
camOriginCenter: false,
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>'}))
], {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}),
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}),
@ -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}),
camStockClipTo: uc.newBoolean(LANG.cs_clip_s, onBooleanClick, {title:LANG.cs_clip_l, modes:CAM}),
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}),
camStockIndexed: uc.newBoolean(LANG.cs_indx_s, onBooleanClick, {title:LANG.cs_indx_l, modes:CAM, show:() => ui.camStockOn.checked}),
camStockOn: uc.newBoolean(LANG.cs_offe_s, onBooleanClick, {title:LANG.cs_offe_l, modes:CAM}),
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}),
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"),
camSep: uc.newBlank({class:"pop-sep", show:() => ui.camStockOn.checked && !ui.camStockIndexed.checked}),
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.camStockIndexed.checked}),
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}),
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 stockCenter = stock.center || { x: 0, y: 0, z: 0 };
let hasStock = stock.x && stock.y && stock.z;
let isIndexed = process.camStockIndexed && process.camStockOn;
let isIndexed = process.camStockIndexed;
let isBelt = device.bedBelt;
let origin = settings.origin = { x: 0, y: 0, z: 0 };
let center = MODE === MODES.FDM ? device.originCenter || device.bedRound :
@ -55,11 +54,11 @@ function platformUpdateOrigin(update_bounds = true) {
device.originCenter || process.outputOriginCenter;
if (MODE === MODES.CAM && process.camOriginTop) {
origin.z = (hasStock ? stock.z : topZ) + 0.01;
origin.z = stock.z + 0.01;
}
if (!center) {
if (hasStock) {
if (MODE === MODES.CAM) {
origin.x = (-stock.x / 2) + stockCenter.x;
origin.y = (stock.y / 2) - stockCenter.y;
} else {
@ -72,7 +71,7 @@ function platformUpdateOrigin(update_bounds = true) {
origin.y = device.bedDepth / 2;
}
}
} else if (hasStock) {
} else if (MODE === MODES.CAM) {
origin.x = stockCenter.x;
origin.y = -stockCenter.y;
} 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');
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) {
space.platform.setOrigin(x, y, oz, true);
} else {
@ -150,10 +149,9 @@ function platformUpdateMidZ() {
function platformUpdateTopZ(zdelta) {
const { process, stock } = current();
const hasStock = stock.x && stock.y && stock.z;
const MODE = get_mode();
api.widgets.each(widget => {
if (MODE === MODES.CAM && hasStock) {
if (MODE === MODES.CAM) {
const bounds = widget.getBoundingBox();
const wzmax = bounds.max.z;
const zdelta = process.camZOffset || 0;
@ -177,14 +175,15 @@ function platformUpdateTopZ(zdelta) {
function platformUpdateStock() {
const settings = current();
const { bounds, process, mode } = settings;
const { camStockOn, camStockX, camStockY, camStockZ, camStockOffset, camStockIndexed } = process;
if (mode === 'CAM' && camStockOn) {
const { camStockX, camStockY, camStockZ, camStockOffset, camStockIndexed } = process;
if (mode === 'CAM') {
let stock = settings.stock = {
x: camStockX,
y: camStockY,
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.y += bounds.max.y - bounds.min.y;
stock.z += bounds.max.z - bounds.min.z;