change preview.maxspeed to preview.speeds and emit an object with min/max
This commit is contained in:
parent
c42fc7ee73
commit
abe27001ca
5 changed files with 32 additions and 13 deletions
|
|
@ -209,7 +209,7 @@ KIRI.work = {
|
|||
update(reply.progress, reply.message, reply.layer);
|
||||
}
|
||||
if (reply.done) {
|
||||
done(reply.output, reply.maxSpeed);
|
||||
done(reply.output, reply.maxSpeed, reply.minSpeed);
|
||||
}
|
||||
if (reply.error) {
|
||||
done(reply);
|
||||
|
|
@ -260,7 +260,7 @@ KIRI.work = {
|
|||
progress(reply.progress);
|
||||
}
|
||||
if (reply.parsed) {
|
||||
done(KIRI.codec.decode(reply.parsed), reply.maxSpeed);
|
||||
done(KIRI.codec.decode(reply.parsed), reply.maxSpeed, reply.minSpeed);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -953,7 +953,7 @@
|
|||
UI.speeds.style.display = 'none';
|
||||
}
|
||||
|
||||
function updateSpeeds(maxSpeed) {
|
||||
function updateSpeeds(maxSpeed, minSpeed) {
|
||||
UI.speeds.style.display =
|
||||
settings.mode !== 'SLA' &&
|
||||
settings.mode !== 'LASER' &&
|
||||
|
|
@ -977,7 +977,7 @@
|
|||
});
|
||||
UI.speedbar.innerHTML = list.join('');
|
||||
});
|
||||
API.event.emit('preview.maxspeed', maxSpeed);
|
||||
API.event.emit('preview.speeds', {min: minSpeed, max: maxSpeed});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1177,7 +1177,7 @@
|
|||
startTime = mark;
|
||||
}
|
||||
API.show.progress(offset + progress * scale, message);
|
||||
}, function (reply, maxSpeed) {
|
||||
}, function (reply, maxSpeed, minSpeed) {
|
||||
// handle worker errors
|
||||
if (reply && reply.error) {
|
||||
alert2(reply.error, 5);
|
||||
|
|
@ -1224,7 +1224,7 @@
|
|||
SPACE.update();
|
||||
updateSliderMax(true);
|
||||
setVisibleLayer(-1, 0);
|
||||
updateSpeeds(maxSpeed);
|
||||
updateSpeeds(maxSpeed, minSpeed);
|
||||
updateStackLabelState();
|
||||
|
||||
// mark preview complete for export
|
||||
|
|
@ -1267,13 +1267,13 @@
|
|||
setOpacity(0);
|
||||
KIRI.client.parse({code, type, settings}, progress => {
|
||||
API.show.progress(progress, "parsing");
|
||||
}, (layers, maxSpeed) => {
|
||||
}, (layers, maxSpeed, minSpeed) => {
|
||||
API.show.progress(0);
|
||||
STACKS.clear();
|
||||
const stack = STACKS.create('parse', SPACE.platform.world);
|
||||
layers.forEach(layer => stack.add(layer));
|
||||
updateSliderMax(true);
|
||||
updateSpeeds(maxSpeed);
|
||||
updateSpeeds(maxSpeed, minSpeed);
|
||||
showSlices();
|
||||
updateStackLabelState();
|
||||
SPACE.update();
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@
|
|||
height = 0,
|
||||
factor = 1,
|
||||
tool = 0,
|
||||
minf = Infinity,
|
||||
maxf = 0,
|
||||
seq = [],
|
||||
autolayer = true,
|
||||
|
|
@ -252,6 +253,7 @@
|
|||
if (!moving && point.z) bounds.max.z = Math.max(bounds.max.z, point.z);
|
||||
|
||||
// update max speed
|
||||
if (pos.F) minf = Math.min(minf, pos.F);
|
||||
maxf = Math.max(maxf, pos.F);
|
||||
|
||||
// always add moves to the current sequence
|
||||
|
|
@ -392,6 +394,7 @@
|
|||
scope.imported = gcode;
|
||||
scope.lines = lines.length;
|
||||
scope.bytes = gcode.length;
|
||||
scope.minSpeed = Math.floor(minf / 60);
|
||||
scope.maxSpeed = Math.floor(maxf / 60);
|
||||
scope.belt = belt;
|
||||
|
||||
|
|
|
|||
|
|
@ -220,6 +220,7 @@ KIRI.worker = {
|
|||
|
||||
const unitScale = settings.controller.units === 'in' ? (1 / 25.4) : 1;
|
||||
const print = current.print || {};
|
||||
const minSpeed = (print.minSpeed || 0) * unitScale;
|
||||
const maxSpeed = (print.maxSpeed || 0) * unitScale;
|
||||
const state = { zeros: [] };
|
||||
|
||||
|
|
@ -228,6 +229,7 @@ KIRI.worker = {
|
|||
send.done({
|
||||
done: true,
|
||||
// output: KIRI.codec.encode(layers, state),
|
||||
minSpeed,
|
||||
maxSpeed
|
||||
}, state.zeros);
|
||||
},
|
||||
|
|
@ -282,11 +284,12 @@ KIRI.worker = {
|
|||
const parsed = print.parseGCode(code, offset, progress => {
|
||||
send.data({ progress: progress * 0.25 });
|
||||
}, done => {
|
||||
const minSpeed = print.minSpeed;
|
||||
const maxSpeed = print.maxSpeed;
|
||||
const layers = KIRI.driver.FDM.prepareRender(done.output, progress => {
|
||||
send.data({ progress: 0.25 + progress * 0.75 });
|
||||
}, { thin: thin || print.belt, flat, tools });
|
||||
send.done({parsed: KIRI.codec.encode(layers), maxSpeed});
|
||||
send.done({parsed: KIRI.codec.encode(layers), maxSpeed, minSpeed});
|
||||
}, {
|
||||
fdm: mode === 'FDM',
|
||||
belt: device.bedBelt
|
||||
|
|
|
|||
|
|
@ -629,12 +629,25 @@
|
|||
opacity: flat ? 0.5 : 1
|
||||
};
|
||||
|
||||
const maxspd = levels.map(level => {
|
||||
return level.map(o => o.speed || 0).reduce((a, v) => Math.max(a,v));
|
||||
}).reduce((a, v) => Math.max(a, v)) + 1;
|
||||
let minspd = Infinity;
|
||||
let maxspd = 0;
|
||||
|
||||
for (let level of levels) {
|
||||
for (let o of level) {
|
||||
if (o.speed) {
|
||||
minspd = Math.min(minspd, o.speed);
|
||||
maxspd = Math.max(maxspd, o.speed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// const maxspd = levels.map(level => {
|
||||
// return level.map(o => o.speed || 0).reduce((a, v) => Math.max(a,v));
|
||||
// }).reduce((a, v) => Math.max(a, v)) + 1;
|
||||
|
||||
// for reporting
|
||||
self.worker.print.maxSpeed = maxspd - 1;
|
||||
self.worker.print.minSpeed = minspd;
|
||||
self.worker.print.maxSpeed = maxspd;
|
||||
self.worker.print.thinColor = thin;
|
||||
self.worker.print.flatColor = flat;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue