move gerber render to worker to free up UI thread

This commit is contained in:
Stewart Allen 2024-07-01 21:17:18 -04:00
commit edf7a53d4c
5 changed files with 45 additions and 10 deletions

View file

@ -297,6 +297,17 @@ const client = exports({
}, [ data.png ]);
},
gerber2mesh(data, progress, output) {
send('gerber2mesh', data, reply => {
if (reply.progress) {
progress(reply.progress);
}
if (reply.vertices) {
output(reply.vertices);
}
});
},
zip(files, progress, output) {
send("zip", {files}, reply => {
if (reply.percent !== undefined) {

View file

@ -815,13 +815,17 @@ function platformLoadFiles(files, group) {
if (api.conf.get().controller.devel) {
api.event.emit('cam.parse.gerber', { data: text });
} else {
let mesh = load.GBR.toMesh(text);
let wid = platformLoadWidget(group, mesh, name);
if (api.mode.is_cam()) {
// attach raw illustration
api.event.emit('cam.parse.gerber', { data: text, mesh: wid.mesh });
}
}
kiri.client.gerber2mesh(text, progress => {
api.show.progress(progress, "converting");
}, vertices => {
api.show.progress(0);
let wid = platformLoadWidget(group, vertices, name);
if (api.mode.is_cam()) {
// attach raw illustration
api.event.emit('cam.parse.gerber', { data: text, mesh: wid.mesh });
}
});
}
} else if (is3mf) {
let odon = function(models) {
let msg = api.show.alert('Adding Objects');