add tweaks api for output line precision and gcode decimal places

This commit is contained in:
Stewart Allen 2020-09-14 09:43:34 -04:00
commit f108dfd701
8 changed files with 58 additions and 9 deletions

View file

@ -1351,7 +1351,7 @@
sliceSupportOffset: UC.newInput(LANG.sp_offs_s, {title:LANG.sp_offs_l, bound:UC.bound(0.0,200.0), convert:UC.toFloat, modes:FDM}),
sliceSupportGap: UC.newInput(LANG.sp_gaps_s, {title:LANG.sp_gaps_l, bound:UC.bound(0,5), convert:UC.toInt, modes:FDM, expert:true}),
sliceSupportSpan: UC.newInput(LANG.sp_span_s, {title:LANG.sp_span_l, bound:UC.bound(0.0,200.0), convert:UC.toFloat, modes:FDM}),
sliceSupportArea: UC.newInput(LANG.sp_area_s, {title:LANG.sp_area_l, bound:UC.bound(0.1,200.0), convert:UC.toFloat, modes:FDM}),
sliceSupportArea: UC.newInput(LANG.sp_area_s, {title:LANG.sp_area_l, bound:UC.bound(0.0,200.0), convert:UC.toFloat, modes:FDM}),
sliceSupportExtra: UC.newInput(LANG.sp_xpnd_s, {title:LANG.sp_xpnd_l, bound:UC.bound(0.0,200.0), convert:UC.toFloat, modes:FDM, expert:true}),
sliceSupportNozzle: UC.newSelect(LANG.sp_nozl_s, {title:LANG.sp_nozl_l, modes:FDM, expert:true}, "extruders"),
sliceSupportEnable: UC.newBoolean(LANG.enable, onBooleanClick, {modes:FDM}),

View file

@ -150,6 +150,11 @@
]
};
const tweak = {
line_precision: (v) => { API.work.config({base:{clipperClean: v}}) },
gcode_decimals: (v) => { API.work.config({base:{gcode_decimals: v}}) }
};
const API = KIRI.api = {
ui: UI,
uc: UC,
@ -261,6 +266,7 @@
clear: clearWorkspace,
save: saveWorkspace,
},
tweak,
util: {
isSecure
},

View file

@ -847,8 +847,8 @@
* @param {number} gap layers between supports and part
*/
PRO.doSupport = function(minOffset, maxBridge, expand, minArea, pillarSize, offset, gap) {
let min = minArea || 0.1,
size = (pillarSize || 2),
let min = minArea || 0.01,
size = (pillarSize || 1),
slice = this,
mergeDist = size * 3, // pillar merge dist
tops = slice.gatherTopPolys([]),
@ -879,7 +879,9 @@
let supported = point.isInPolygonOnly(down_tops);
if (!supported) down_traces.forEach(function(trace) {
trace.forEachSegment(function(p1, p2) {
if (point.distToLine(p1, p2) <= minOffset) return supported = true;
if (point.distToLine(p1, p2) <= minOffset) {
return supported = true;
}
});
return supported;
});

View file

@ -87,6 +87,12 @@ KIRI.work = {
});
},
config : function(obj) {
send("config", obj, function(reply) {
// console.log({config:reply});
});
},
clear : function(widget) {
send("clear", widget ? {id:widget.id} : {}, function(reply) {
// console.log({clear:reply});

View file

@ -52,6 +52,28 @@ let dispatch = {
state.rotate = new THREE.Matrix4().makeRotationY(-rotation);
}
// let buf = new THREE.BufferGeometry();
// buf.setAttribute('position', new THREE.BufferAttribute(vertices, 3));
// let geo = new THREE.Geometry().fromBufferGeometry(buf);
// geo.computeFaceNormals();
// console.log(geo);
// let z0 = new THREE.Vector3(0,0,1);
// let ve = geo.vertices;
// geo.faces.forEach((face,ind) => {
// let n = face.normal;
// let v3 = new THREE.Vector3(n.x, n.y, n.z);
// if (n.z >= 0) {
// console.log({skip:ind});
// return;
// }
// let va = v3.angleTo(z0) / Math.PI;
// let i3 = ind * 3;
// let v = [
// ve[i3], ve[i3+1], ve[i3+2]
// ];
// console.log({ind, va, v});
// });
send.data({update:0.05, updateStatus:"slicing"});
let widget = kiri.newWidget(data.id).setPoints(points),
@ -166,6 +188,17 @@ let dispatch = {
has: cache[data.id] !== undefined
});
},
config: function(data, send) {
const update = {};
if (data.base) {
update.base = data.base;
Object.assign(self.base.config, data.base);
} else {
console.log({invalid:data});
}
send.done({config: update});
}
};
self.onmessage = function(e) {