show colors for parsed gcode
This commit is contained in:
parent
268a470a4f
commit
bcab6f15c3
5 changed files with 31 additions and 26 deletions
2
notes.md
2
notes.md
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
NEXT
|
NEXT
|
||||||
- contour tabs support
|
- contour tabs support
|
||||||
|
- flat color gradient
|
||||||
|
- fix line colors
|
||||||
- cap path ends
|
- cap path ends
|
||||||
- path arrows
|
- path arrows
|
||||||
- help dialog
|
- help dialog
|
||||||
|
|
|
||||||
|
|
@ -205,18 +205,13 @@ KIRI.work = {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
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) {
|
send("parse", args, function(reply) {
|
||||||
if (reply.progress) {
|
if (reply.progress) {
|
||||||
progress(reply);
|
progress(reply);
|
||||||
}
|
}
|
||||||
if (reply.parsed) {
|
if (reply.parsed) {
|
||||||
done(KIRI.codec.decode(reply.parsed));
|
done(KIRI.codec.decode(reply.parsed), reply.maxSpeed);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -637,23 +637,6 @@
|
||||||
SPACE.update();
|
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() {
|
function cancelWorker() {
|
||||||
if (KIRI.work.isSlicing()) KIRI.work.restart();
|
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
|
* Selection Functions
|
||||||
******************************************************************* */
|
******************************************************************* */
|
||||||
|
|
@ -1584,7 +1585,8 @@
|
||||||
let loaded = files.length;
|
let loaded = files.length;
|
||||||
platform.group();
|
platform.group();
|
||||||
for (let i=0; i<files.length; i++) {
|
for (let i=0; i<files.length; i++) {
|
||||||
let reader = new FileReader(),
|
const file = files[i],
|
||||||
|
reader = new FileReader(),
|
||||||
lower = files[i].name.toLowerCase(),
|
lower = files[i].name.toLowerCase(),
|
||||||
israw = lower.indexOf(".raw") > 0 || lower.indexOf('.') < 0,
|
israw = lower.indexOf(".raw") > 0 || lower.indexOf('.') < 0,
|
||||||
isstl = lower.indexOf(".stl") > 0,
|
isstl = lower.indexOf(".stl") > 0,
|
||||||
|
|
@ -1599,7 +1601,7 @@
|
||||||
);
|
);
|
||||||
if (isstl) {
|
if (isstl) {
|
||||||
if (API.feature.on_add_stl) {
|
if (API.feature.on_add_stl) {
|
||||||
API.feature.on_add_stl(e.target.result);
|
API.feature.on_add_stl(e.target.result, file);
|
||||||
} else {
|
} else {
|
||||||
platform.add(
|
platform.add(
|
||||||
newWidget(undefined,group)
|
newWidget(undefined,group)
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,7 @@
|
||||||
height = 0,
|
height = 0,
|
||||||
factor = 1,
|
factor = 1,
|
||||||
tool = 0,
|
tool = 0,
|
||||||
|
maxf = 0,
|
||||||
seq = [];
|
seq = [];
|
||||||
|
|
||||||
const output = scope.output = [ seq ];
|
const output = scope.output = [ seq ];
|
||||||
|
|
@ -159,6 +160,9 @@
|
||||||
|
|
||||||
const moving = g0 || (fdm && pos.E <= 0);
|
const moving = g0 || (fdm && pos.E <= 0);
|
||||||
|
|
||||||
|
// update max speed
|
||||||
|
maxf = Math.max(maxf, pos.F);
|
||||||
|
|
||||||
// always add moves to the current sequence
|
// always add moves to the current sequence
|
||||||
if (moving) {
|
if (moving) {
|
||||||
addOutput(seq, point, false, pos.F, tool);
|
addOutput(seq, point, false, pos.F, tool);
|
||||||
|
|
@ -230,6 +234,7 @@
|
||||||
scope.imported = gcode;
|
scope.imported = gcode;
|
||||||
scope.lines = lines.length;
|
scope.lines = lines.length;
|
||||||
scope.bytes = gcode.length;
|
scope.bytes = gcode.length;
|
||||||
|
scope.maxSpeed = Math.floor(maxf / 60);
|
||||||
|
|
||||||
done({ output: scope.output });
|
done({ output: scope.output });
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -185,10 +185,11 @@ KIRI.worker = {
|
||||||
const parsed = print.parseGCode(code, offset, progress => {
|
const parsed = print.parseGCode(code, offset, progress => {
|
||||||
send.data({ progress: progress * 0.5 });
|
send.data({ progress: progress * 0.5 });
|
||||||
}, done => {
|
}, done => {
|
||||||
|
const maxSpeed = print.maxSpeed;
|
||||||
const layers = KIRI.driver.FDM.prepareRender(done.output, progress => {
|
const layers = KIRI.driver.FDM.prepareRender(done.output, progress => {
|
||||||
send.data({ progress: 0.5 + progress * 0.5 });
|
send.data({ progress: 0.5 + progress * 0.5 });
|
||||||
}, { thin, flat, tools });
|
}, { thin, flat, tools });
|
||||||
send.done({parsed: KIRI.codec.encode(layers)});
|
send.done({parsed: KIRI.codec.encode(layers), maxSpeed});
|
||||||
}, { fdm : mode === 'FDM' });
|
}, { fdm : mode === 'FDM' });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue