Merge branch 'master' of github.com:GridSpace/grid-apps

This commit is contained in:
Stewart Allen 2021-02-24 12:28:24 -05:00
commit 2fa1bccca8
8 changed files with 39 additions and 19 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "grid-apps", "name": "grid-apps",
"version": "2.7.11D", "version": "2.7.12D",
"description": "grid.space 3d slice & modeling tools", "description": "grid.space 3d slice & modeling tools",
"author": "Stewart Allen <sa@grid.space>", "author": "Stewart Allen <sa@grid.space>",
"license": "MIT", "license": "MIT",

View file

@ -6,7 +6,7 @@
if (!self.kiri) { if (!self.kiri) {
self.kiri = { self.kiri = {
beta: 2711, beta: 2712,
driver: {}, // driver modules driver: {}, // driver modules
loader: [] // module loading: array of functions loader: [] // module loading: array of functions
}; };

View file

@ -14,8 +14,8 @@ let KIRI = self.kiri = self.kiri || {},
seqid = 1, seqid = 1,
syncd = {}, syncd = {},
running = {}, running = {},
slicing = {}, worker = null,
worker = null restarting = false
// occ = new Worker("/kiri/ext/occ-worker.js", {type:"module"}), // occ = new Worker("/kiri/ext/occ-worker.js", {type:"module"}),
; ;
@ -57,25 +57,34 @@ KIRI.work = {
} }
}, },
isSlicing: function() { isBusy: function() {
let current = 0; let current = 0;
for (let key in slicing) { for (let rec of Object.values(running)) {
current++; if (rec.fn) current++;
} }
return current > 0; return current > 0;
}, },
restart: function() { restart: function() {
// prevent re-entry from cancel callback
if (restarting) {
return;
}
if (worker) { if (worker) {
worker.terminate(); worker.terminate();
} }
// for (let key in slicing) { restarting = true;
// slicing[key]({error: "cancelled slicing"});
// } for (let key in running) {
let rec = running[key];
if (rec.fn) {
rec.fn({error: "cancelled operation"});
}
}
syncd = {}; syncd = {};
slicing = {};
running = {}; running = {};
worker = KIRI.work.newWorker(); worker = KIRI.work.newWorker();
@ -95,6 +104,8 @@ KIRI.work = {
onreply(reply.data, reply); onreply(reply.data, reply);
}; };
restarting = false;
}, },
decimate: function(vertices, options, callback) { decimate: function(vertices, options, callback) {
@ -169,14 +180,12 @@ KIRI.work = {
}, },
slice: function(settings, widget, callback) { slice: function(settings, widget, callback) {
slicing[widget.id] = callback;
send("slice", { send("slice", {
id: widget.id, id: widget.id,
settings: settings settings: settings
}, function(reply) { }, function(reply) {
callback(reply); callback(reply);
if (reply.done || reply.error) { if (reply.done || reply.error) {
delete slicing[widget.id];
// in belt mode, slicing modifies a widget and requires re-sync // in belt mode, slicing modifies a widget and requires re-sync
if (settings.device.bedBelt) { if (settings.device.bedBelt) {
widget.modified = true; widget.modified = true;

View file

@ -242,7 +242,8 @@
// hide all dialogs // hide all dialogs
API.dialog.hide(); API.dialog.hide();
// cancel slicing // cancel slicing
if (KIRI.work.isSlicing()) KIRI.work.restart(); API.function.cancel();
// if (KIRI.work.isSlicing()) KIRI.work.restart();
// kill any poppers in compact mode // kill any poppers in compact mode
UC.hidePoppers(); UC.hidePoppers();
// and send an event (used by FDM client) // and send an event (used by FDM client)

View file

@ -918,7 +918,9 @@
} }
function cancelWorker() { function cancelWorker() {
if (KIRI.work.isSlicing()) KIRI.work.restart(); if (KIRI.work.isBusy()) {
KIRI.work.restart();
}
} }
function showSlider() { function showSlider() {

View file

@ -3,7 +3,7 @@
let terms = { let terms = {
COPYRIGHT: "Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved", COPYRIGHT: "Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved",
LICENSE: "See the license.md file included with the source distribution", LICENSE: "See the license.md file included with the source distribution",
VERSION: "2.7.D11" VERSION: "2.7.D12"
}; };
if (typeof(module) === 'object') { if (typeof(module) === 'object') {

View file

@ -109,6 +109,10 @@
let { tshadow, shadowTop, ztOff, zBottom, zMax } = state; let { tshadow, shadowTop, ztOff, zBottom, zMax } = state;
let { process, stock } = settings; let { process, stock } = settings;
if (op.down <= 0) {
throw `invalid step down "${op.down}"`;
}
let roughIn = op.inside; let roughIn = op.inside;
let roughTop = op.top; let roughTop = op.top;
let roughDown = op.down; let roughDown = op.down;
@ -390,6 +394,10 @@
let { updateToolDiams, zThru, zBottom, shadowTop, tabs, cutTabs, cutPolys } = state; let { updateToolDiams, zThru, zBottom, shadowTop, tabs, cutTabs, cutPolys } = state;
let { process, stock } = settings; let { process, stock } = settings;
if (op.down <= 0) {
throw `invalid step down "${op.down}"`;
}
let toolDiam = this.toolDiam = new CAM.Tool(settings, op.tool).fluteDiameter(); let toolDiam = this.toolDiam = new CAM.Tool(settings, op.tool).fluteDiameter();
updateToolDiams(toolDiam); updateToolDiams(toolDiam);
@ -453,7 +461,7 @@
tops = tshadow; tops = tshadow;
} }
if (op.omitthru) { if (op.outside && op.omitthru) {
// eliminate thru holes from shadow // eliminate thru holes from shadow
for (let hole of thruHoles) { for (let hole of thruHoles) {
for (let top of tops) { for (let top of tops) {

View file

@ -68,7 +68,7 @@
offset = process.outputBrimOffset || (process.outputRaft ? 4 : 0); offset = process.outputBrimOffset || (process.outputRaft ? 4 : 0);
// compute first brim // compute first brim
widgets.forEach(function(widget) { widgets.filter(w => w.slices.length).forEach(function(widget) {
let tops = []; let tops = [];
// collect top outer polygons // collect top outer polygons
widget.slices[0].tops.forEach(function(top) { widget.slices[0].tops.forEach(function(top) {
@ -267,7 +267,7 @@
// generate purge block for given nozzle // generate purge block for given nozzle
function purge(nozzle, track, layer, start, z, using) { function purge(nozzle, track, layer, start, z, using) {
if (extcount < 2) { if (extcount < 2 || isBelt) {
return start; return start;
} }
let rec = track[nozzle]; let rec = track[nozzle];