restore laser slice, preview, export

This commit is contained in:
Stewart Allen 2020-11-08 20:19:50 -05:00
commit 9842a0e43c
5 changed files with 71 additions and 149 deletions

View file

@ -212,105 +212,6 @@
scope.bytes = gcode.length;
};
// more generic. only used by SLA at the moment
PRO.export = function(remote, online, ondone) {
let mode = this.settings.mode;
let driver = KIRI.driver[mode];
if (KIRI.client) {
// executed from kiri.js
KIRI.client.export(this.settings, online, ondone);
} else {
if (!(driver && driver.export)) {
console.log({missing_export_driver: mode});
ondone(null);
return;
}
// executed from kiri-worker.js
driver.printExport(this, online, ondone);
}
};
PRO.exportGCode = function(remote, ondone, online) {
let scope = this,
settings = scope.settings,
mode = settings.mode;
if (scope.imported) {
return ondone(scope.imported);
}
if (KIRI.client) {
// executed from kiri.js
KIRI.client.printGCode(function(reply) {
scope.lines = reply.lines;
scope.bytes = reply.bytes;
scope.bounds = reply.bounds;
scope.distance = reply.distance;
scope.time = reply.time;
ondone(reply.gcode);
});
} else {
// executed from kiri-worker.js
let driver = KIRI.driver[mode];
if (driver && driver.printExport) {
ondone(driver.printExport(scope, online));
} else {
console.log({missing_export_driver: mode});
ondone(null);
}
}
};
PRO.exportLaserGCode = function() {
return KIRI.driver.LASER.exportGCode(this);
};
PRO.exportSVG = function(cut_color) {
return KIRI.driver.LASER.exportSVG(this, cut_color);
};
PRO.exportDXF = function() {
return KIRI.driver.LASER.exportDXF(this);
};
PRO.encodeOutput = function() {
let newout = [], newlayer;
this.output.forEach(function(layerout) {
newlayer = [];
newout.push(newlayer);
layerout.forEach(function(out) {
if (out.point) {
// used for renderMoves client side. can drop non-essential
// data to speed up worker -> browser transfer. perhaps a
// more compact encoding (arrays, etc)
let push = { };
if (out.emit !== undefined) push.emit = out.emit;
if (out.speed !== undefined) push.speed = out.speed * 60;
if (out.retract !== undefined) push.retract = out.retract;
if (out.point !== undefined) push.point = {
x: out.point.x, y: out.point.y, z: out.point.z
};
if (out.tool !== undefined) push.tool = out.tool;
if (layerout.thick !== undefined) push.thick = layerout.thick;
newlayer.push(push);
// newlayer.push({
// emit: out.emit,
// speed: out.speed * 60,
// retract: out.retract,
// point: {x: out.point.x, y: out.point.y, z: out.point.z},
// tool: out.tool,
// thick: layerout.thick
// });
}
});
});
return newout;
};
function pref(a,b) {
return a !== undefined ? a : b;
}