improve progress bars

This commit is contained in:
Stewart Allen 2020-04-18 23:39:17 -04:00
commit 2977b1da7e
3 changed files with 50 additions and 19 deletions

View file

@ -265,8 +265,11 @@ let gs_kiri_sla = exports;
output = print.output; output = print.output;
print.images.forEach((image,index) => { print.images.forEach((image,index) => {
// online(image.data, [image.data.buffer]); online({
online({progress: (index/print.images.length)/2, data: image.data}); progress: (index / print.images.length) * 0.25,
message: "image_xfer",
data: image.data
});
}); });
let exp_func; let exp_func;
@ -286,14 +289,13 @@ let gs_kiri_sla = exports;
lines: print.images.map(i => i.data), lines: print.images.map(i => i.data),
small: previewSmall.data, small: previewSmall.data,
large: previewLarge.data large: previewLarge.data
}, progress => { }, (progress, message) => {
online({progress: progress/2 + 0.5}); online({progress: progress * 0.75 + 0.25, message});
}); });
ondone({ ondone({
width:2560, width: 2560,
height:1440, height: 1440,
file:file file: file
},[file]); },[file]);
}; };
@ -413,13 +415,18 @@ let gs_kiri_sla = exports;
layerBytes = width * height, layerBytes = width * height,
small = conf.small, small = conf.small,
large = conf.large, large = conf.large,
subcount = process.slaAntiAlias ? 2 : 1, subcount = process.slaAntiAlias || 1,
masks = [ ]; // move = [0,0,0,0],
move = {1:0,2:4,4:2,8:1},
masks = [];
for (let l=0; l < subcount; l++) { for (let l=0; l<subcount; l++) {
masks.push((Math.pow(2,8/subcount)-1) << (l * (8/subcount))); let o = 8/subcount;
masks.push((Math.pow(2,o)-1) << (move[subcount] * l));
} }
let ccl = 0;
let tcl = conf.lines.length * subcount;
let converted = conf.lines.map((line, index) => { let converted = conf.lines.map((line, index) => {
let count = line.length / 4; let count = line.length / 4;
let lineDV = new DataView(line.buffer); let lineDV = new DataView(line.buffer);
@ -434,17 +441,19 @@ let gs_kiri_sla = exports;
// use R from RGB since that was painted on the canvas // use R from RGB since that was painted on the canvas
for (let s=0; s<subcount; s++) { for (let s=0; s<subcount; s++) {
let view = subs[s].view; let view = subs[s].view;
let mask = masks[s]; let mask = masks[subcount-s-1];
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
let dv = lineDV.getUint8(i * 4) & mask; let dv = lineDV.getUint8(i * 4) & mask;
view.setUint8(i, dv > 0 ? 1 : 0); view.setUint8(i, dv > 0 ? 1 : 0);
} }
progress((ccl++/tcl) * 0.4, "layer_convert");
} }
progress(index / conf.lines.length);
return { subs }; return { subs };
}); });
let coded = encodeLayers(converted, "photon"); let coded = encodeLayers(converted, "photon", (pro => {
progress(pro * 0.4 + 0.4, "layer_encode");
}));
let buflen = 3000 + coded.length + (layerCount * subcount * 28) + small.byteLength + large.byteLength; let buflen = 3000 + coded.length + (layerCount * subcount * 28) + small.byteLength + large.byteLength;
let filebuf = new ArrayBuffer(buflen); let filebuf = new ArrayBuffer(buflen);
let filedat = new DataWriter(new DataView(filebuf)); let filedat = new DataWriter(new DataView(filebuf));
@ -511,7 +520,10 @@ let gs_kiri_sla = exports;
filedat.writeU32(layer.length, true); filedat.writeU32(layer.length, true);
filedat.skip(16); // padding filedat.skip(16); // padding
} }
// write layer data // write layer data
let clo = 0;
let tlo = layers.length * subcount;
for (let sc=0; sc<subcount; sc++) for (let sc=0; sc<subcount; sc++)
for (let l=0; l<layers.length; l++) { for (let l=0; l<layers.length; l++) {
let layer = layers[l].sublayers[sc]; let layer = layers[l].sublayers[sc];
@ -519,7 +531,7 @@ let gs_kiri_sla = exports;
for (let j=0; j<layer.length; j++) { for (let j=0; j<layer.length; j++) {
filedat.writeU8(layer[j], false); filedat.writeU8(layer[j], false);
} }
progress((l / layers.length) / 2 + 0.5); progress(((clo++/tlo) * 0.1) + 0.9, "layer_write");
} }
filedat.view.setUint32(hirez, filedat.pos, true); filedat.view.setUint32(hirez, filedat.pos, true);
@ -612,8 +624,11 @@ let gs_kiri_sla = exports;
return filebuf; return filebuf;
} }
function encodeLayers(input, type) { function encodeLayers(input, type, progress) {
let layers = [], length = 0; let layers = [], length = 0, total = 0, count = 0;
input.forEach(layer => {
layer.subs.forEach(sub => total++);
});
for (let index = 0; index < input.length; index++) { for (let index = 0; index < input.length; index++) {
let subs = input[index].subs, let subs = input[index].subs,
sublayers = [], sublayers = [],
@ -623,6 +638,7 @@ let gs_kiri_sla = exports;
let encoded = rleEncode(data, type); let encoded = rleEncode(data, type);
sublength += encoded.length; sublength += encoded.length;
sublayers.push(encoded); sublayers.push(encoded);
if (progress) progress(count++/total);
if (type == "photons") break; if (type == "photons") break;
} }
length += sublength; length += sublength;

View file

@ -39,10 +39,24 @@ let gs_kiri_export = exports;
function exportPrintSLA(currentPrint) { function exportPrintSLA(currentPrint) {
if (currentPrint) { if (currentPrint) {
let lines = []; let lines = [];
let times = {};
let mark = Date.now();
let seq = 1;
let segment;
currentPrint.export(true, function(line) { currentPrint.export(true, function(line) {
if (line.message) {
if (segment && segment !== line.message) {
let now = Date.now();
times[`${seq++}_${segment}`] = now - mark;
mark = now;
}
segment = line.message;
}
if (line.progress) API.show.progress(line.progress, "exporting"); if (line.progress) API.show.progress(line.progress, "exporting");
if (line.data) lines.push(line.data); if (line.data) lines.push(line.data);
}, function(done) { }, function(done) {
times[`${seq++}_${segment}`] = Date.now() - mark;
console.log({export: times});
API.show.progress(0); API.show.progress(0);
currentPrint.sla = { lines, done, API }; currentPrint.sla = { lines, done, API };
KIRI.driver.SLA.printDownload(currentPrint); KIRI.driver.SLA.printDownload(currentPrint);

View file

@ -162,6 +162,7 @@ input[type=range]::-moz-focus-outer {
color: white; color: white;
padding: 5px; padding: 5px;
margin: 5px; margin: 5px;
white-space: nowrap;
} }
#modal { #modal {
z-index: 20000; z-index: 20000;