add wire-edm origin offsets to setup a lead-in
This commit is contained in:
parent
8d66083409
commit
3a48b319d7
6 changed files with 53 additions and 43 deletions
|
|
@ -768,6 +768,8 @@ const conf = exports({
|
|||
ctOutMerged: false,
|
||||
ctOriginCenter: false,
|
||||
ctOriginBounds: true,
|
||||
ctOriginOffX: 0,
|
||||
ctOriginOffY: -10,
|
||||
outputInvertX: false,
|
||||
outputInvertY: false,
|
||||
ctOutKnifeDepth: 1,
|
||||
|
|
|
|||
|
|
@ -1970,6 +1970,9 @@ gapp.register("kiri.init", [], (root, exports) => {
|
|||
separator: newBlank({ class:"set-sep", driven }),
|
||||
ctOriginBounds: newBoolean(LANG.or_bnds_s, onBooleanClick, {title:LANG.or_bnds_l}),
|
||||
ctOriginCenter: newBoolean(LANG.or_cntr_s, onBooleanClick, {title:LANG.or_cntr_l}),
|
||||
separator: newBlank({ class:"set-sep", driven, modes:WEDM }),
|
||||
ctOriginOffX: newInput(LANG.or_offx_s, {title:LANG.or_offx_l, convert:toFloat, modes:WEDM}),
|
||||
ctOriginOffY: newInput(LANG.or_offy_s, {title:LANG.or_offy_l, convert:toFloat, modes:WEDM}),
|
||||
separator: newBlank({ class:"set-sep", driven, modes:TWONED }),
|
||||
ctOutZColor: newBoolean(LANG.ou_layo_s, onBooleanClick, {title:LANG.ou_layo_l, modes:TWONED, show:() => { return ui.ctOutMerged.checked === false }}),
|
||||
ctOutLayer: newBoolean(LANG.ou_layr_s, onBooleanClick, {title:LANG.ou_layr_l, modes:TWONED}),
|
||||
|
|
|
|||
|
|
@ -12,28 +12,33 @@ gapp.register("kiri.pack", [], (root, exports) => {
|
|||
const { kiri } = root;
|
||||
|
||||
class Packer {
|
||||
constructor(w, h, spacing) {
|
||||
constructor(w, h, spacing, inv) {
|
||||
this.root = { x: 0, y: 0, w: w, h: h };
|
||||
this.max = { w: 0, h: 0 };
|
||||
this.packed = false;
|
||||
this.spacing = typeof(spacing) === 'number' ? spacing : 1;
|
||||
this.inv = inv;
|
||||
this.pad = this.spacing / 2;
|
||||
}
|
||||
|
||||
simple(blocks) {
|
||||
let n = 0, block, x = 0, y = 0, mh = 0;
|
||||
let spacing = blocks.length > 1 ? this.spacing : 0;
|
||||
while (n < blocks.length) {
|
||||
block = blocks[n++];
|
||||
block.fit = { x, y };
|
||||
this.max.w = Math.max(this.max.w, x + block.w);
|
||||
this.max.h = Math.max(this.max.h, y + block.h);
|
||||
mh = Math.max(mh, block.h);
|
||||
x += block.w + this.spacing;
|
||||
x += block.w + spacing;
|
||||
if (x > this.root.w) {
|
||||
x = 0;
|
||||
y += mh + this.spacing;
|
||||
y += ((mh + spacing) * (this.inv ? -1 : 1));
|
||||
mh = 0;
|
||||
}
|
||||
if (this.inv && (y < -this.root.h)) {
|
||||
return this;
|
||||
}
|
||||
if (y > this.root.h) {
|
||||
return this;
|
||||
}
|
||||
|
|
@ -47,10 +52,11 @@ class Packer {
|
|||
return this.simple(blocks);
|
||||
}
|
||||
let n = 0, node, block, w, h;
|
||||
let spacing = blocks.length > 1 ? this.spacing : 0;
|
||||
while (n < blocks.length) {
|
||||
block = blocks[n++];
|
||||
w = block.w + this.spacing;
|
||||
h = block.h + this.spacing;
|
||||
w = block.w + spacing;
|
||||
h = block.h + spacing;
|
||||
if (node = this.findNode(this.root, w, h)) {
|
||||
block.fit = this.splitNode(node, w, h);
|
||||
} else {
|
||||
|
|
@ -81,16 +87,6 @@ class Packer {
|
|||
}
|
||||
}
|
||||
|
||||
// kiri.Sort = function (a, b) {
|
||||
// let aa = (a.w * a.h);
|
||||
// let ab = (b.w * b.h);
|
||||
// if (Math.abs(aa - ab) < 1) {
|
||||
// return (b.w / b.h) - (a.w / a.h);
|
||||
// } else {
|
||||
// return ab - aa;
|
||||
// }
|
||||
// };
|
||||
|
||||
kiri.Pack = Packer;
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -88,12 +88,19 @@ function platformUpdateOrigin(update_bounds = true) {
|
|||
origin.y = device.bedDepth / 2;
|
||||
}
|
||||
|
||||
// CNC origin offsets
|
||||
if (MODE === MODES.CAM) {
|
||||
origin.x += process.camOriginOffX;
|
||||
origin.y += process.camOriginOffY;
|
||||
origin.z += process.camOriginOffZ;
|
||||
}
|
||||
|
||||
// WireEDM origin offsets
|
||||
if (MODE === MODES.WEDM) {
|
||||
origin.x -= process.ctOriginOffX;
|
||||
origin.y -= process.ctOriginOffY;
|
||||
}
|
||||
|
||||
if (isIndexed) {
|
||||
origin.y = 0;
|
||||
}
|
||||
|
|
@ -711,7 +718,7 @@ function platformLayout() {
|
|||
let i, m, sz = space.platform.size(),
|
||||
mp = [sz.x, sz.y],
|
||||
ms = [mp[0] / 2, mp[1] / 2],
|
||||
c = Widget.Groups.blocks().sort(moto.Sort),
|
||||
c = Widget.Groups.blocks().sort(),
|
||||
p = new kiri.Pack(ms[0], ms[1], gap).fit(c);
|
||||
|
||||
while (!p.packed) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue