show colors for parsed gcode

This commit is contained in:
Stewart Allen 2020-11-13 09:27:42 -05:00
commit bcab6f15c3
5 changed files with 31 additions and 26 deletions

View file

@ -2,6 +2,8 @@
NEXT
- contour tabs support
- flat color gradient
- fix line colors
- cap path ends
- path arrows
- help dialog

View file

@ -205,18 +205,13 @@ KIRI.work = {
}
});
return;
// const layers = KIRI.driver.FDM.prepareRender(output, progress => {
// send.data({ progress: 0.5 + progress * 0.5 });
// }, { thin: true });
// send.done({parsed: layers});
// return;
}
send("parse", args, function(reply) {
if (reply.progress) {
progress(reply);
}
if (reply.parsed) {
done(KIRI.codec.decode(reply.parsed));
done(KIRI.codec.decode(reply.parsed), reply.maxSpeed);
}
});
}

View file

@ -637,23 +637,6 @@
SPACE.update();
}
function loadCode(code, type) {
setViewMode(VIEWS.PREVIEW);
setOpacity(0);
KIRI.client.parse({code, type, settings}, progress => {
API.show.progress(progress, "parsing");
}, layers => {
API.show.progress(0);
STACKS.clear();
const stack = STACKS.create('parse', SPACE.platform.world);
layers.forEach(layer => stack.add(layer));
updateSliderMax(true);
showSlices();
SPACE.update();
});
}
function cancelWorker() {
if (KIRI.work.isSlicing()) KIRI.work.restart();
}
@ -865,6 +848,24 @@
});
}
function loadCode(code, type) {
setViewMode(VIEWS.PREVIEW);
setOpacity(0);
KIRI.client.parse({code, type, settings}, progress => {
API.show.progress(progress, "parsing");
}, (layers, maxSpeed) => {
API.show.progress(0);
STACKS.clear();
const stack = STACKS.create('parse', SPACE.platform.world);
layers.forEach(layer => stack.add(layer));
updateSliderMax(true);
updateSpeeds(maxSpeed);
showSlices();
SPACE.update();
});
}
/** ******************************************************************
* Selection Functions
******************************************************************* */
@ -1584,7 +1585,8 @@
let loaded = files.length;
platform.group();
for (let i=0; i<files.length; i++) {
let reader = new FileReader(),
const file = files[i],
reader = new FileReader(),
lower = files[i].name.toLowerCase(),
israw = lower.indexOf(".raw") > 0 || lower.indexOf('.') < 0,
isstl = lower.indexOf(".stl") > 0,
@ -1599,7 +1601,7 @@
);
if (isstl) {
if (API.feature.on_add_stl) {
API.feature.on_add_stl(e.target.result);
API.feature.on_add_stl(e.target.result, file);
} else {
platform.add(
newWidget(undefined,group)

View file

@ -125,6 +125,7 @@
height = 0,
factor = 1,
tool = 0,
maxf = 0,
seq = [];
const output = scope.output = [ seq ];
@ -159,6 +160,9 @@
const moving = g0 || (fdm && pos.E <= 0);
// update max speed
maxf = Math.max(maxf, pos.F);
// always add moves to the current sequence
if (moving) {
addOutput(seq, point, false, pos.F, tool);
@ -230,6 +234,7 @@
scope.imported = gcode;
scope.lines = lines.length;
scope.bytes = gcode.length;
scope.maxSpeed = Math.floor(maxf / 60);
done({ output: scope.output });
};

View file

@ -185,10 +185,11 @@ KIRI.worker = {
const parsed = print.parseGCode(code, offset, progress => {
send.data({ progress: progress * 0.5 });
}, done => {
const maxSpeed = print.maxSpeed;
const layers = KIRI.driver.FDM.prepareRender(done.output, progress => {
send.data({ progress: 0.5 + progress * 0.5 });
}, { thin, flat, tools });
send.done({parsed: KIRI.codec.encode(layers)});
send.done({parsed: KIRI.codec.encode(layers), maxSpeed});
}, { fdm : mode === 'FDM' });
},