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",
laserOffset: 0.25,
laserSliceHeight: 1,
laserSliceHeightMin: 0,
laserSliceSingle: false,
outputTileSpacing: 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}),
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}),
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
// find unique z-index offsets for slicing
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++) {
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 => {
updateGroupShow(group);
});
@ -130,7 +130,9 @@
hasModes.forEach(function(div) {
div.setMode(div._group && !groupShow[div._group] ? NOMODE : mode);
});
hidePoppers();
if (!nohide) {
hidePoppers();
}
}
function setExpert(bool) {
@ -326,8 +328,9 @@
};
el.setMode = function(mode) {
let show = opt.expert === undefined || (opt.expert === letExpert);
let test = !opt.show || (opt.show && opt.show());
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) {
if (mode === NOMODE) return false;
@ -569,6 +572,9 @@
});
ip.addEventListener('blur', function(event) {
action(event);
if (opt.trigger) {
setMode(letMode, true);
}
});
}
if (!ip.convert) ip.convert = raw.bind(ip);

View file

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