match render width to tool in fdm preview

This commit is contained in:
Stewart Allen 2020-06-09 20:22:11 -04:00
commit 80dd0d83dc
4 changed files with 39 additions and 28 deletions

View file

@ -288,17 +288,8 @@
case cca('C'): // refresh catalog case cca('C'): // refresh catalog
CATALOG.refresh(); CATALOG.refresh();
break; break;
case cca('i'): // single settings edit case cca('i'): // file import
let v = prompt('edit "'+current.process.processName+'"', JSON.stringify(current.process)); API.event.import();
if (v) {
try {
current.process = JSON.parse(v);
API.view.update_fields();
} catch (e) {
console.log(e);
API.show.alert("invalid settings format");
}
}
break; break;
case cca('U'): // full settings url case cca('U'): // full settings url
storeSettingsToServer(true); storeSettingsToServer(true);
@ -327,7 +318,11 @@
case cca('x'): // export print case cca('x'): // export print
API.function.export(); API.function.export();
break; break;
case cca('e'): // devices case cca('q'): // preferences
API.modal.show('prefs');
break;
case cca('d'): // device
case cca('e'): // device
showDevices(); showDevices();
break; break;
case cca('o'): // tools case cca('o'): // tools
@ -1023,6 +1018,7 @@
del = DOC.createElement('button'), del = DOC.createElement('button'),
file = list[i], file = list[i],
name = file.n, name = file.n,
date = new Date(file.t),
split = name.split('.'), split = name.split('.'),
short = split[0], short = split[0],
ext = split[1] ? `.${split[1]}` : ''; ext = split[1] ? `.${split[1]}` : '';
@ -1040,7 +1036,7 @@
}; };
load.setAttribute('load', name); load.setAttribute('load', name);
load.setAttribute('title', 'file: '+name+'\nvertices: '+file.v); load.setAttribute('title', `file: ${name}\nvertices: ${file.v}\ndate: ${date}`);
load.onclick = loadCatalogFile; load.onclick = loadCatalogFile;
load.appendChild(DOC.createTextNode(short)); load.appendChild(DOC.createTextNode(short));
@ -1200,7 +1196,7 @@
bedWidth: UC.newInput(LANG.dv_bedw_s, {title:LANG.dv_bedw_l, convert:UC.toFloat, size:6}), bedWidth: UC.newInput(LANG.dv_bedw_s, {title:LANG.dv_bedw_l, convert:UC.toFloat, size:6}),
bedDepth: UC.newInput(LANG.dv_bedd_s, {title:LANG.dv_bedd_l, convert:UC.toFloat, size:6}), bedDepth: UC.newInput(LANG.dv_bedd_s, {title:LANG.dv_bedd_l, convert:UC.toFloat, size:6}),
maxHeight: UC.newInput(LANG.dv_bedh_s, {title:LANG.dv_bedh_l, convert:UC.toFloat, size:6, modes:FDM_SLA}), maxHeight: UC.newInput(LANG.dv_bedh_s, {title:LANG.dv_bedh_l, convert:UC.toFloat, size:6, modes:FDM_SLA}),
spindleMax: UC.newInput(LANG.dv_spmx_s, {title:LANG.dv_spmx_l, convert:UC.toInt, modes:CAM}), spindleMax: UC.newInput(LANG.dv_spmx_s, {title:LANG.dv_spmx_l, convert:UC.toInt, size: 6, modes:CAM}),
deviceOrigin: UC.newBoolean(LANG.dv_orgc_s, onBooleanClick, {title:LANG.dv_orgc_l, modes:GCODE}), deviceOrigin: UC.newBoolean(LANG.dv_orgc_s, onBooleanClick, {title:LANG.dv_orgc_l, modes:GCODE}),
deviceOriginTop: UC.newBoolean(LANG.dv_orgt_s, onBooleanClick, {title:LANG.dv_orgt_l, modes:CAM}), deviceOriginTop: UC.newBoolean(LANG.dv_orgt_s, onBooleanClick, {title:LANG.dv_orgt_l, modes:CAM}),
deviceRound: UC.newBoolean(LANG.dv_bedc_s, onBooleanClick, {title:LANG.dv_bedc_l, modes:FDM}), deviceRound: UC.newBoolean(LANG.dv_bedc_s, onBooleanClick, {title:LANG.dv_bedc_l, modes:FDM}),

View file

@ -1812,7 +1812,9 @@
} }
ajax(local, function(html) { ajax(local, function(html) {
UI.help.innerHTML = html; UI.help.innerHTML = html;
$('kiri-version').innerHTML = `${LANG.version} ${KIRI.version}`; try {
$('kiri-version').innerHTML = `${LANG.version} ${KIRI.version}`;
} catch (e) { }
showModal('help'); showModal('help');
}); });
API.event.emit('help.show', local); API.event.emit('help.show', local);

View file

@ -229,6 +229,8 @@
} else { } else {
// executed from kiri-worker.js // executed from kiri-worker.js
// uses encodeOutput in this class to produce scope.output above
// this encoding could be made vastly more efficient
let driver = KIRI.driver[mode]; let driver = KIRI.driver[mode];
if (driver) driver.printSetup(scope, onupdate); if (driver) driver.printSetup(scope, onupdate);
else console.log({missing_print_driver: mode}); else console.log({missing_print_driver: mode});
@ -318,7 +320,8 @@
emit: out.emit, emit: out.emit,
speed: out.speed * 60, speed: out.speed * 60,
retract: out.retract, retract: out.retract,
point: {x: out.point.x, y: out.point.y, z: out.point.z} point: {x: out.point.x, y: out.point.y, z: out.point.z},
tool: out.tool
}); });
} }
}); });
@ -331,9 +334,14 @@
let settings = this.settings, let settings = this.settings,
origin = settings.origin, origin = settings.origin,
mode = settings.mode, mode = settings.mode,
tools = [],
driver = KIRI.driver[mode]; driver = KIRI.driver[mode];
driver.printRender(this); if (mode === 'FDM') {
tools = settings.device.extruders || [];
}
driver.printRender(this, {tools});
}; };
function pref(a,b) { function pref(a,b) {

View file

@ -397,7 +397,10 @@
function sliceRender(widget, mode) { function sliceRender(widget, mode) {
let slices = widget.slices; let slices = widget.slices;
let settings = widget.settings; let settings = widget.settings;
let extruder = widget.getExtruder(settings); let extnum = widget.getExtruder(settings);
let extarr = settings.device.extruders || [];
let extinfo = extarr[extnum || 0];
let extoff = (extinfo.extNozzle || 0.4) / 2;
if (!slices) return; if (!slices) return;
@ -440,29 +443,29 @@
// if (top.thinner) outline.poly(top.thinner, 0x559999, true, null); // if (top.thinner) outline.poly(top.thinner, 0x559999, true, null);
// shells // shells
shells.noodle(top.traces, 0.2, 0x88aadd, 0x77bbcc); shells.noodle(top.traces, extoff, 0x88aadd, 0x77bbcc);
if (top.polish) { if (top.polish) {
shells.poly(top.polish.x, 0x880000, true, null); shells.poly(top.polish.x, 0x880000, true, null);
shells.poly(top.polish.y, 0x880000, true, null); shells.poly(top.polish.y, 0x880000, true, null);
} }
// solid fill // solid fill
solids.noodle_lines(top.fill_lines, 0.2, 0x88aadd, 0x77bbcc, s.z); solids.noodle_lines(top.fill_lines, extoff, 0x88aadd, 0x77bbcc, s.z);
// sparse fill // sparse fill
if (top.fill_sparse) { if (top.fill_sparse) {
top.fill_sparse.forEach(function(poly) { top.fill_sparse.forEach(function(poly) {
// todo cull polys with single point before this // todo cull polys with single point before this
sparse.noodle_open(poly, 0.2, 0x88aadd, 0x77bbcc, s.z); sparse.noodle_open(poly, extoff, 0x88aadd, 0x77bbcc, s.z);
// poly.render(sparse, 0x0, false, true); // poly.render(sparse, 0x0, false, true);
}); });
} }
// support // support
if (s.supports) { if (s.supports) {
support.noodle(s.supports, 0.2, 0x88aadd, 0x77bbcc); support.noodle(s.supports, extoff, 0x88aadd, 0x77bbcc);
s.supports.forEach(function(poly) { s.supports.forEach(function(poly) {
support.noodle_lines(poly.fills, 0.2, 0x88aadd, 0x77bbcc, s.z); support.noodle_lines(poly.fills, extoff, 0x88aadd, 0x77bbcc, s.z);
}); });
} }
}); });
@ -1234,6 +1237,7 @@
let scope = print, emits, last, let scope = print, emits, last,
moves, moving = true, moves, moving = true,
opt = options || {}, opt = options || {},
tools = opt.tools || [],
showmoves = !opt.nomoves; showmoves = !opt.nomoves;
// render layered output // render layered output
scope.lines = 0; scope.lines = 0;
@ -1250,7 +1254,7 @@
if (moving) { if (moving) {
let spd = out.speed || 4000; let spd = out.speed || 4000;
cprint = base.newPolygon().setOpen(true).append(toPoint(last)); cprint = base.newPolygon().setOpen(true).append(toPoint(last));
print.push({speed: spd, poly: cprint}); print.push({speed: spd, poly: cprint, tool:tools[out.tool]});
} }
cprint.append(toPoint(point)); cprint.append(toPoint(point));
moving = false; moving = false;
@ -1284,16 +1288,17 @@
emits.setTransparent(false); emits.setTransparent(false);
// emit printing shapes // emit printing shapes
print.forEach(segment => { print.forEach(segment => {
let {poly, speed} = segment; let {poly, speed, tool} = segment;
let sint = Math.min(6000, parseInt(speed)); let off = tool ? (tool.extNozzle || 0.4) / 2 : 0.2;
let rgb = scope.hsv2rgb({h:sint/6000, s:1, v:1}); let sint = Math.min(9000, parseInt(speed));
let rgb = scope.hsv2rgb({h:sint/9000, s:1, v:1});
let color = ((rgb.r * 0xff) << 16) | let color = ((rgb.r * 0xff) << 16) |
((rgb.g * 0xff) << 8) | ((rgb.g * 0xff) << 8) |
((rgb.b * 0xff) << 0); ((rgb.b * 0xff) << 0);
if (opt.aslines) { if (opt.aslines) {
emits.poly(poly, color, false, true); emits.poly(poly, color, false, true);
} else { } else {
emits.noodle_open(poly, 0.2, color, 0x0, poly.getZ()); emits.noodle_open(poly, off, color, 0x0, poly.getZ());
} }
}); });
emits.renderAll(); emits.renderAll();