fix preview feature and generally clean up view state progression
This commit is contained in:
parent
42dfa27e63
commit
76d2ad5530
4 changed files with 40 additions and 23 deletions
|
|
@ -19,24 +19,14 @@
|
||||||
|
|
||||||
let printSeq = parseInt(SDB['kiri-print-seq'] || SDB['print-seq'] || "0") + 1;
|
let printSeq = parseInt(SDB['kiri-print-seq'] || SDB['print-seq'] || "0") + 1;
|
||||||
|
|
||||||
function isPrepared() {
|
|
||||||
return API.view.get() === API.const.VIEWS.PREVIEW;
|
|
||||||
}
|
|
||||||
|
|
||||||
function exportFile(options) {
|
function exportFile(options) {
|
||||||
if (isPrepared()) {
|
const mode = API.mode.get();
|
||||||
const mode = API.mode.get();
|
API.event.emit('export', mode);
|
||||||
API.event.emit('export', mode);
|
switch (mode) {
|
||||||
switch (mode) {
|
case 'LASER': return callExportLaser(options);
|
||||||
case 'LASER': return callExportLaser(options);
|
case 'FDM': return callExport(options, mode);
|
||||||
case 'FDM': return callExport(options, mode);
|
case 'CAM': return callExport(options, mode);
|
||||||
case 'CAM': return callExport(options, mode);
|
case 'SLA': return callExportSLA(options);
|
||||||
case 'SLA': return callExportSLA(options);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
API.function.prepare(function() {
|
|
||||||
exportFile(options)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,10 @@
|
||||||
UI.fps.style.display = on ? 'block' : '';
|
UI.fps.style.display = on ? 'block' : '';
|
||||||
if (on) {
|
if (on) {
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
UI.fps.innerText = SPACE.view.getFPS().toFixed(2);
|
const nv = SPACE.view.getFPS().toFixed(2);
|
||||||
|
if (nv !== UI.fps.innerText) {
|
||||||
|
UI.fps.innerText = nv;
|
||||||
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@
|
||||||
MODE = MODES.FDM,
|
MODE = MODES.FDM,
|
||||||
STACKS = KIRI.stacks,
|
STACKS = KIRI.stacks,
|
||||||
DRIVER = undefined,
|
DRIVER = undefined,
|
||||||
|
complete = {},
|
||||||
onEvent = {},
|
onEvent = {},
|
||||||
selectedMeshes = [],
|
selectedMeshes = [],
|
||||||
localFilterKey ='kiri-gcode-filters',
|
localFilterKey ='kiri-gcode-filters',
|
||||||
|
|
@ -239,7 +240,7 @@
|
||||||
slice: prepareSlices,
|
slice: prepareSlices,
|
||||||
print: preparePreview,
|
print: preparePreview,
|
||||||
prepare: preparePreview,
|
prepare: preparePreview,
|
||||||
export: function() { KIRI.export(...arguments) },
|
export: prepareExport,
|
||||||
cancel: cancelWorker,
|
cancel: cancelWorker,
|
||||||
clear: KIRI.client.clear
|
clear: KIRI.client.clear
|
||||||
},
|
},
|
||||||
|
|
@ -696,6 +697,9 @@
|
||||||
callback = preparePreview;
|
callback = preparePreview;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clear completion marks
|
||||||
|
complete = {};
|
||||||
|
|
||||||
hideSlider(true);
|
hideSlider(true);
|
||||||
platform.deselect();
|
platform.deselect();
|
||||||
setViewMode(VIEWS.SLICE);
|
setViewMode(VIEWS.SLICE);
|
||||||
|
|
@ -752,6 +756,8 @@
|
||||||
API.event.emit('slice.end', getMode());
|
API.event.emit('slice.end', getMode());
|
||||||
// print stats
|
// print stats
|
||||||
DBUG.log(segtimes);
|
DBUG.log(segtimes);
|
||||||
|
// mark slicing complete for prep/preview
|
||||||
|
complete.slice = true;
|
||||||
if (callback && typeof callback === 'function') {
|
if (callback && typeof callback === 'function') {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
@ -783,11 +789,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function preparePreview(callback) {
|
function preparePreview(callback) {
|
||||||
if (viewMode === VIEWS.PREVIEW) return;
|
if (complete.preview) {
|
||||||
if (viewMode === VIEWS.ARRANGE) {
|
return;
|
||||||
|
}
|
||||||
|
if (!complete.slice) {
|
||||||
prepareSlices(() => {
|
prepareSlices(() => {
|
||||||
preparePreview(callback);
|
preparePreview(callback);
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hideSlider(true);
|
hideSlider(true);
|
||||||
|
|
@ -834,12 +843,27 @@
|
||||||
updateSpeeds(maxSpeed);
|
updateSpeeds(maxSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mark preview complete for export
|
||||||
|
complete.preview = true;
|
||||||
|
|
||||||
if (typeof(callback) === 'function') {
|
if (typeof(callback) === 'function') {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function prepareExport() {
|
||||||
|
const argsave = arguments;
|
||||||
|
if (!complete.preview) {
|
||||||
|
preparePreview(() => {
|
||||||
|
prepareExport(...argsave);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
complete.export = true;
|
||||||
|
KIRI.export(...argsave);
|
||||||
|
}
|
||||||
|
|
||||||
function loadCode(code, type) {
|
function loadCode(code, type) {
|
||||||
setViewMode(VIEWS.PREVIEW);
|
setViewMode(VIEWS.PREVIEW);
|
||||||
setOpacity(0);
|
setOpacity(0);
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,7 @@
|
||||||
|
|
||||||
function push_point(x,y,z) {
|
function push_point(x,y,z) {
|
||||||
const newP = newPoint(x,y,z);
|
const newP = newPoint(x,y,z);
|
||||||
|
// todo: merge co-linear, not just co-planar
|
||||||
if (lastP && lastP.z === z) {
|
if (lastP && lastP.z === z) {
|
||||||
if (curvesOnly) {
|
if (curvesOnly) {
|
||||||
end_poly();
|
end_poly();
|
||||||
|
|
@ -189,7 +190,6 @@
|
||||||
// eliminate if points "under" other lines
|
// eliminate if points "under" other lines
|
||||||
for (let j=0; j<len; j++) {
|
for (let j=0; j<len; j++) {
|
||||||
// skip self and adjacent
|
// skip self and adjacent
|
||||||
// if (j === i) continue;
|
|
||||||
if (j >= i-1 && j <= i+1) continue;
|
if (j >= i-1 && j <= i+1) continue;
|
||||||
let l2 = lines[j], p3 = l2.p1, p4 = l2.p2;
|
let l2 = lines[j], p3 = l2.p1, p4 = l2.p2;
|
||||||
// sort p3,p4 by y for comparison
|
// sort p3,p4 by y for comparison
|
||||||
|
|
@ -211,7 +211,7 @@
|
||||||
.addPolys(slice.topPolys());
|
.addPolys(slice.topPolys());
|
||||||
});
|
});
|
||||||
|
|
||||||
// for each Y slice, find z grid value (x/z swapped)
|
// raster grid: for each Y slice, find z grid value (x/z swapped)
|
||||||
for (j=0, jl=slices.length; j<jl; j++) {
|
for (j=0, jl=slices.length; j<jl; j++) {
|
||||||
const slice = slices[j];
|
const slice = slices[j];
|
||||||
const points = slice.points;
|
const points = slice.points;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue