add ability for ui components to enable/disable based on arbitrary functions. add laser slice min height when auto detect enabled

This commit is contained in:
Stewart Allen 2020-10-10 13:36:20 -04:00
commit 9238a68257
6 changed files with 29 additions and 5 deletions

View file

@ -479,6 +479,7 @@
processName: "default", processName: "default",
laserOffset: 0.25, laserOffset: 0.25,
laserSliceHeight: 1, laserSliceHeight: 1,
laserSliceHeightMin: 0,
laserSliceSingle: false, laserSliceSingle: false,
outputTileSpacing: 1, outputTileSpacing: 1,
outputTileScaling: 1, outputTileScaling: 1,

View file

@ -1352,7 +1352,8 @@
sliceBottomLayers: UC.newInput(LANG.sl_lbot_s, {title:LANG.sl_lbot_l, convert:UC.toInt, modes:FDM}), sliceBottomLayers: UC.newInput(LANG.sl_lbot_s, {title:LANG.sl_lbot_l, convert:UC.toInt, modes:FDM}),
laserOffset: UC.newInput(LANG.ls_offs_s, {title:LANG.ls_offs_l, convert:UC.toFloat, modes:LASER}), laserOffset: UC.newInput(LANG.ls_offs_s, {title:LANG.ls_offs_l, convert:UC.toFloat, modes:LASER}),
laserSliceHeight: UC.newInput(LANG.ls_lahi_s, {title:LANG.ls_lahi_l, convert:UC.toFloat, modes:LASER}), laserSliceHeight: UC.newInput(LANG.ls_lahi_s, {title:LANG.ls_lahi_l, convert:UC.toFloat, modes:LASER, trigger: true}),
laserSliceHeightMin: UC.newInput(LANG.ls_lahm_s, {title:LANG.ls_lahm_l, convert:UC.toFloat, modes:LASER, show:() => { return UI.laserSliceHeight.value == 0 }}),
laserSliceSingle: UC.newBoolean(LANG.ls_sngl_s, onBooleanClick, {title:LANG.ls_sngl_l, modes:LASER}), laserSliceSingle: UC.newBoolean(LANG.ls_sngl_s, onBooleanClick, {title:LANG.ls_sngl_l, modes:LASER}),
fdmInfill: UC.newGroup(LANG.fi_menu, $('settings'), {modes:FDM, marker:true}), fdmInfill: UC.newGroup(LANG.fi_menu, $('settings'), {modes:FDM, marker:true}),

View file

@ -241,6 +241,18 @@
// use Z indices in auto slice mode for laser // use Z indices in auto slice mode for laser
// find unique z-index offsets for slicing // find unique z-index offsets for slicing
let zl = zOrdered let zl = zOrdered
// if zIncMin also present, then merge adjacent
// slices less than that value
if (zIncMin) {
let last = undefined;
zl = zl.filter(v => {
if (last !== undefined && v - last < zIncMin) {
return false;
}
last = v;
return true;
});
}
for (i = 0; i < zl.length - 1; i++) { for (i = 0; i < zl.length - 1; i++) {
zIndexes.push((zl[i] + zl[i+1]) / 2); zIndexes.push((zl[i] + zl[i+1]) / 2);
} }

View file

@ -122,7 +122,7 @@
}); });
} }
function setMode(mode) { function setMode(mode, nohide) {
Object.keys(groupShow).forEach(group => { Object.keys(groupShow).forEach(group => {
updateGroupShow(group); updateGroupShow(group);
}); });
@ -130,7 +130,9 @@
hasModes.forEach(function(div) { hasModes.forEach(function(div) {
div.setMode(div._group && !groupShow[div._group] ? NOMODE : mode); div.setMode(div._group && !groupShow[div._group] ? NOMODE : mode);
}); });
hidePoppers(); if (!nohide) {
hidePoppers();
}
} }
function setExpert(bool) { function setExpert(bool) {
@ -326,8 +328,9 @@
}; };
el.setMode = function(mode) { el.setMode = function(mode) {
let show = opt.expert === undefined || (opt.expert === letExpert); let show = opt.expert === undefined || (opt.expert === letExpert);
let test = !opt.show || (opt.show && opt.show());
let disp = opt.visible ? opt.visible() : true; let disp = opt.visible ? opt.visible() : true;
el.setVisible(el.hasMode(mode) && show && disp); el.setVisible(el.hasMode(mode) && test && show && disp);
} }
el.hasMode = function(mode) { el.hasMode = function(mode) {
if (mode === NOMODE) return false; if (mode === NOMODE) return false;
@ -569,6 +572,9 @@
}); });
ip.addEventListener('blur', function(event) { ip.addEventListener('blur', function(event) {
action(event); action(event);
if (opt.trigger) {
setMode(letMode, true);
}
}); });
} }
if (!ip.convert) ip.convert = raw.bind(ip); if (!ip.convert) ip.convert = raw.bind(ip);

View file

@ -40,7 +40,9 @@
} }
SLICER.sliceWidget(widget, { SLICER.sliceWidget(widget, {
height: proc.laserSliceHeight, single: proc.laserSliceSingle single: proc.laserSliceSingle,
height: proc.laserSliceHeight,
minHeight: proc.laserSliceHeight === 0 ? proc.laserSliceHeightMin : 0
}, function(slices) { }, function(slices) {
widget.slices = slices; widget.slices = slices;
slices.forEach(function(slice, index) { slices.forEach(function(slice, index) {

View file

@ -224,6 +224,8 @@ kiri.lang['en-us'] = {
ls_offs_l: "adjust for beam width\nin millimeters", ls_offs_l: "adjust for beam width\nin millimeters",
ls_lahi_s: "height", ls_lahi_s: "height",
ls_lahi_l: "layer height\nin millimeters\n0 = auto/detect", ls_lahi_l: "layer height\nin millimeters\n0 = auto/detect",
ls_lahm_s: "min",
ls_lahm_l: "layer height minimum\nwill merge auto slices\nunder this thickness\nin millimeters",
ls_sngl_s: "single", ls_sngl_s: "single",
ls_sngl_l: "perform only one slice\nat specified layer height", ls_sngl_l: "perform only one slice\nat specified layer height",