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
CATALOG.refresh();
break;
case cca('i'): // single settings edit
let v = prompt('edit "'+current.process.processName+'"', JSON.stringify(current.process));
if (v) {
try {
current.process = JSON.parse(v);
API.view.update_fields();
} catch (e) {
console.log(e);
API.show.alert("invalid settings format");
}
}
case cca('i'): // file import
API.event.import();
break;
case cca('U'): // full settings url
storeSettingsToServer(true);
@ -327,7 +318,11 @@
case cca('x'): // export print
API.function.export();
break;
case cca('e'): // devices
case cca('q'): // preferences
API.modal.show('prefs');
break;
case cca('d'): // device
case cca('e'): // device
showDevices();
break;
case cca('o'): // tools
@ -1023,6 +1018,7 @@
del = DOC.createElement('button'),
file = list[i],
name = file.n,
date = new Date(file.t),
split = name.split('.'),
short = split[0],
ext = split[1] ? `.${split[1]}` : '';
@ -1040,7 +1036,7 @@
};
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.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}),
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}),
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}),
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}),

View file

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

View file

@ -229,6 +229,8 @@
} else {
// 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];
if (driver) driver.printSetup(scope, onupdate);
else console.log({missing_print_driver: mode});
@ -318,7 +320,8 @@
emit: out.emit,
speed: out.speed * 60,
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,
origin = settings.origin,
mode = settings.mode,
tools = [],
driver = KIRI.driver[mode];
driver.printRender(this);
if (mode === 'FDM') {
tools = settings.device.extruders || [];
}
driver.printRender(this, {tools});
};
function pref(a,b) {

View file

@ -397,7 +397,10 @@
function sliceRender(widget, mode) {
let slices = widget.slices;
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;
@ -440,29 +443,29 @@
// if (top.thinner) outline.poly(top.thinner, 0x559999, true, null);
// shells
shells.noodle(top.traces, 0.2, 0x88aadd, 0x77bbcc);
shells.noodle(top.traces, extoff, 0x88aadd, 0x77bbcc);
if (top.polish) {
shells.poly(top.polish.x, 0x880000, true, null);
shells.poly(top.polish.y, 0x880000, true, null);
}
// 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
if (top.fill_sparse) {
top.fill_sparse.forEach(function(poly) {
// 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);
});
}
// support
if (s.supports) {
support.noodle(s.supports, 0.2, 0x88aadd, 0x77bbcc);
support.noodle(s.supports, extoff, 0x88aadd, 0x77bbcc);
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,
moves, moving = true,
opt = options || {},
tools = opt.tools || [],
showmoves = !opt.nomoves;
// render layered output
scope.lines = 0;
@ -1250,7 +1254,7 @@
if (moving) {
let spd = out.speed || 4000;
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));
moving = false;
@ -1284,16 +1288,17 @@
emits.setTransparent(false);
// emit printing shapes
print.forEach(segment => {
let {poly, speed} = segment;
let sint = Math.min(6000, parseInt(speed));
let rgb = scope.hsv2rgb({h:sint/6000, s:1, v:1});
let {poly, speed, tool} = segment;
let off = tool ? (tool.extNozzle || 0.4) / 2 : 0.2;
let sint = Math.min(9000, parseInt(speed));
let rgb = scope.hsv2rgb({h:sint/9000, s:1, v:1});
let color = ((rgb.r * 0xff) << 16) |
((rgb.g * 0xff) << 8) |
((rgb.b * 0xff) << 0);
if (opt.aslines) {
emits.poly(poly, color, false, true);
} else {
emits.noodle_open(poly, 0.2, color, 0x0, poly.getZ());
emits.noodle_open(poly, off, color, 0x0, poly.getZ());
}
});
emits.renderAll();