add laser z index unique coloring option

This commit is contained in:
Stewart Allen 2020-10-21 22:27:55 -04:00
commit 28b95da2e8
7 changed files with 45 additions and 9 deletions

View file

@ -45,6 +45,7 @@
# CAM # CAM
* `B` excessive moves with tabs. allow reversing in open polys or do not nest them
* `B` fails in pancaking (clone) when there are no sliced layers (like z bottom too high) * `B` fails in pancaking (clone) when there are no sliced layers (like z bottom too high)
* `B` contouring should extend beyond part boundaries by tool radius * `B` contouring should extend beyond part boundaries by tool radius
* `B` outside cutting direction in roughing mode inverted * `B` outside cutting direction in roughing mode inverted

View file

@ -486,6 +486,7 @@
outputLaserPower: 100, outputLaserPower: 100,
outputLaserSpeed: 1000, outputLaserSpeed: 1000,
outputLaserGroup: true, outputLaserGroup: true,
outputLaserZColor: false,
outputLaserLayer: false, outputLaserLayer: false,
outputLaserMerged: false, outputLaserMerged: false,
outputOriginCenter: true, outputOriginCenter: true,

View file

@ -113,6 +113,7 @@
} }
function onBooleanClick() { function onBooleanClick() {
UC.refresh();
API.conf.update(); API.conf.update();
DOC.activeElement.blur(); DOC.activeElement.blur();
} }
@ -1456,6 +1457,7 @@
outputLaserSpeed: UC.newInput(LANG.ou_sped_s, {title:LANG.ou_sped_l, convert:UC.toInt, modes:LASER}), outputLaserSpeed: UC.newInput(LANG.ou_sped_s, {title:LANG.ou_sped_l, convert:UC.toInt, modes:LASER}),
outputLaserMerged: UC.newBoolean(LANG.ou_mrgd_s, onBooleanClick, {title:LANG.ou_mrgd_l, modes:LASER}), outputLaserMerged: UC.newBoolean(LANG.ou_mrgd_s, onBooleanClick, {title:LANG.ou_mrgd_l, modes:LASER}),
outputLaserGroup: UC.newBoolean(LANG.ou_grpd_s, onBooleanClick, {title:LANG.ou_grpd_l, modes:LASER}), outputLaserGroup: UC.newBoolean(LANG.ou_grpd_s, onBooleanClick, {title:LANG.ou_grpd_l, modes:LASER}),
outputLaserZColor: UC.newBoolean(LANG.ou_layo_s, onBooleanClick, {title:LANG.ou_layo_l, modes:LASER, show:() => { return UI.outputLaserMerged.checked === false }}),
outputLaserLayer: UC.newBoolean(LANG.ou_layr_s, onBooleanClick, {title:LANG.ou_layr_l, modes:LASER}), outputLaserLayer: UC.newBoolean(LANG.ou_layr_s, onBooleanClick, {title:LANG.ou_layr_l, modes:LASER}),
outputTemp: UC.newInput(LANG.ou_nozl_s, {title:LANG.ou_nozl_l, convert:UC.toInt, modes:FDM}), outputTemp: UC.newInput(LANG.ou_nozl_s, {title:LANG.ou_nozl_l, convert:UC.toInt, modes:FDM}),
outputBedTemp: UC.newInput(LANG.ou_bedd_s, {title:LANG.ou_bedd_l, convert:UC.toInt, modes:FDM}), outputBedTemp: UC.newInput(LANG.ou_bedd_s, {title:LANG.ou_bedd_l, convert:UC.toInt, modes:FDM}),

View file

@ -33,6 +33,7 @@
prefix: function(pre) { prefix = pre; return kiri.ui }, prefix: function(pre) { prefix = pre; return kiri.ui },
hideAction: function(fn) { hideAction = fn; return kiri.ui }, hideAction: function(fn) { hideAction = fn; return kiri.ui },
inputAction: function(fn) { inputAction = fn; return kiri.ui }, inputAction: function(fn) { inputAction = fn; return kiri.ui },
refresh: refresh,
setMode: setMode, setMode: setMode,
setExpert: setExpert, setExpert: setExpert,
bound: bound, bound: bound,
@ -122,6 +123,10 @@
}); });
} }
function refresh() {
setMode(letMode, true);
}
function setMode(mode, nohide) { function setMode(mode, nohide) {
Object.keys(groupShow).forEach(group => { Object.keys(groupShow).forEach(group => {
updateGroupShow(group); updateGroupShow(group);
@ -573,7 +578,7 @@
ip.addEventListener('blur', function(event) { ip.addEventListener('blur', function(event) {
action(event); action(event);
if (opt.trigger) { if (opt.trigger) {
setMode(letMode, true); refresh();
} }
}); });
} }

View file

@ -1296,6 +1296,9 @@
} }
}); });
}); });
if (maxspeed === 0) {
maxspeed = 4000;
}
maxspeed *= 1.001; maxspeed *= 1.001;
// render layered output // render layered output
scope.lines = 0; scope.lines = 0;

View file

@ -64,6 +64,7 @@
let process = print.settings.process; let process = print.settings.process;
let grouped = process.outputLaserGroup; let grouped = process.outputLaserGroup;
let group = []; let group = [];
let zcolor = print.settings.process.outputLaserZColor;
group.thick = slice.thick; group.thick = slice.thick;
@ -76,7 +77,9 @@
laserOut(pi, group); laserOut(pi, group);
}); });
} else { } else {
print.polyPrintPath(poly, start, group, {extrude: 1}); print.polyPrintPath(poly, start, group,
zcolor ? {extrude: slice.z, rate: slice.z} : {extrude: 1}
);
} }
} }
@ -212,9 +215,10 @@
/** /**
* *
*/ */
function exportElements(print, onpre, onpoly, onpost, onpoint) { function exportElements(print, onpre, onpoly, onpost, onpoint, onlayer) {
let process = print.settings.process, let process = print.settings.process,
output = print.output, output = print.output,
zcolor = process.outputLaserZColor,
last, last,
point, point,
poly = [], poly = [],
@ -267,12 +271,15 @@
onpre(min, max, process.outputLaserPower, process.outputLaserSpeed); onpre(min, max, process.outputLaserPower, process.outputLaserSpeed);
output.forEach(function(layer) { output.forEach(function(layer, index) {
let thick = 0; let thick = 0;
let color = 0; let color = 0;
layer.forEach(function(out) { layer.forEach(function(out, li) {
thick = out.thick; thick = out.thick;
point = out.point; point = out.point;
if (onlayer) {
onlayer(index, point.z, out.thick, output.length);
}
if (out.emit) { if (out.emit) {
color = out.emit; color = out.emit;
if (last && poly.length === 0) { if (last && poly.length === 0) {
@ -298,7 +305,7 @@
* *
*/ */
function exportGCode(print) { function exportGCode(print) {
let lines = [], dx = 0, dy = 0, feedrate; let lines = [], dx = 0, dy = 0, z = 0, feedrate;
let dev = print.settings.device; let dev = print.settings.device;
let space = dev.gcodeSpace ? ' ' : ''; let space = dev.gcodeSpace ? ' ' : '';
let power = 255; let power = 255;
@ -320,13 +327,17 @@
lines.push(line); lines.push(line);
}); });
}, },
function(poly, color) { function(poly, color, thick) {
poly.forEach(function(point, index) { poly.forEach(function(point, index) {
if (index === 0) { if (index === 0) {
lines.push(`G0${space}${point}`); lines.push(`G0${space}${point}`);
} else if (index === 1) { } else if (index === 1) {
laser_on.forEach(line => { laser_on.forEach(line => {
lines.push(line.replace('{power}', power)); line = line.replace('{power}', power);
line = line.replace('{color}', color);
line = line.replace('{thick}', thick);
line = line.replace('{z}', z);
lines.push(line);
}); });
lines.push(`G1${space}${point}${feedrate}`); lines.push(`G1${space}${point}${feedrate}`);
} else { } else {
@ -343,7 +354,11 @@
}); });
}, },
function(point) { function(point) {
z = point.z;
return `X${(point.x - dx).toFixed(3)}${space}Y${(point.y - dy).toFixed(3)}`; return `X${(point.x - dx).toFixed(3)}${space}Y${(point.y - dy).toFixed(3)}`;
},
function(layer, z, thick, layers) {
// ununsed
} }
); );
@ -354,6 +369,7 @@
* *
*/ */
function exportSVG(print, cut_color) { function exportSVG(print, cut_color) {
let zcolor = print.settings.process.outputLaserZColor ? 1 : 0;
let lines = [], dx = 0, dy = 0, my, z = 0; let lines = [], dx = 0, dy = 0, my, z = 0;
let colors = [ let colors = [
"black", "black",
@ -380,7 +396,7 @@
lines.push(`<svg width="${width}mm" height="${height}mm" viewBox="0 0 ${width} ${height}" xmlns="http://www.w3.org/2000/svg" version="1.1">`); lines.push(`<svg width="${width}mm" height="${height}mm" viewBox="0 0 ${width} ${height}" xmlns="http://www.w3.org/2000/svg" version="1.1">`);
}, },
function(poly, color, thick) { function(poly, color, thick) {
let cout = colors[((color-1) % colors.length)]; let cout = zcolor || colors[((color-1) % colors.length)];
let def = ["polyline"]; let def = ["polyline"];
if (z !== undefined) def.push(`z="${z}"`); if (z !== undefined) def.push(`z="${z}"`);
if (thick !== undefined) def.push(`h="${thick}"`); if (thick !== undefined) def.push(`h="${thick}"`);
@ -392,6 +408,12 @@
function(point) { function(point) {
z = point.z; z = point.z;
return UTIL.round(point.x - dx, 3) + "," + UTIL.round(my - point.y - dy, 3); return UTIL.round(point.x - dx, 3) + "," + UTIL.round(my - point.y - dy, 3);
},
function(layer, z, thick, layers) {
if (zcolor) {
zcolor = Math.round(((layer + 1) / layers) * 0xffffff).toString(16);
zcolor = `#${zcolor.padStart(6,0)}`;
}
} }
); );

View file

@ -329,6 +329,8 @@ kiri.lang['en-us'] = {
ou_grpd_l: "retain each layer as\na unified grouping\ninstead of separated\npolygons", ou_grpd_l: "retain each layer as\na unified grouping\ninstead of separated\npolygons",
ou_layr_s: "layer order", ou_layr_s: "layer order",
ou_layr_l: "output layer order\nfrom top right to\nbottom left", ou_layr_l: "output layer order\nfrom top right to\nbottom left",
ou_layo_s: "layer color",
ou_layo_l: "output layer colors\nfor each z index\noverridden by merged",
// OUTPUT FDM // OUTPUT FDM
ou_nozl_s: "nozzle temp", ou_nozl_s: "nozzle temp",