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,12 +19,7 @@
|
|||
|
||||
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) {
|
||||
if (isPrepared()) {
|
||||
const mode = API.mode.get();
|
||||
API.event.emit('export', mode);
|
||||
switch (mode) {
|
||||
|
|
@ -33,11 +28,6 @@
|
|||
case 'CAM': return callExport(options, mode);
|
||||
case 'SLA': return callExportSLA(options);
|
||||
}
|
||||
} else {
|
||||
API.function.prepare(function() {
|
||||
exportFile(options)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function callExport(callback, mode) {
|
||||
|
|
|
|||
|
|
@ -154,7 +154,10 @@
|
|||
UI.fps.style.display = on ? 'block' : '';
|
||||
if (on) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
MODE = MODES.FDM,
|
||||
STACKS = KIRI.stacks,
|
||||
DRIVER = undefined,
|
||||
complete = {},
|
||||
onEvent = {},
|
||||
selectedMeshes = [],
|
||||
localFilterKey ='kiri-gcode-filters',
|
||||
|
|
@ -239,7 +240,7 @@
|
|||
slice: prepareSlices,
|
||||
print: preparePreview,
|
||||
prepare: preparePreview,
|
||||
export: function() { KIRI.export(...arguments) },
|
||||
export: prepareExport,
|
||||
cancel: cancelWorker,
|
||||
clear: KIRI.client.clear
|
||||
},
|
||||
|
|
@ -696,6 +697,9 @@
|
|||
callback = preparePreview;
|
||||
}
|
||||
|
||||
// clear completion marks
|
||||
complete = {};
|
||||
|
||||
hideSlider(true);
|
||||
platform.deselect();
|
||||
setViewMode(VIEWS.SLICE);
|
||||
|
|
@ -752,6 +756,8 @@
|
|||
API.event.emit('slice.end', getMode());
|
||||
// print stats
|
||||
DBUG.log(segtimes);
|
||||
// mark slicing complete for prep/preview
|
||||
complete.slice = true;
|
||||
if (callback && typeof callback === 'function') {
|
||||
callback();
|
||||
}
|
||||
|
|
@ -783,11 +789,14 @@
|
|||
}
|
||||
|
||||
function preparePreview(callback) {
|
||||
if (viewMode === VIEWS.PREVIEW) return;
|
||||
if (viewMode === VIEWS.ARRANGE) {
|
||||
if (complete.preview) {
|
||||
return;
|
||||
}
|
||||
if (!complete.slice) {
|
||||
prepareSlices(() => {
|
||||
preparePreview(callback);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
hideSlider(true);
|
||||
|
|
@ -834,12 +843,27 @@
|
|||
updateSpeeds(maxSpeed);
|
||||
}
|
||||
|
||||
// mark preview complete for export
|
||||
complete.preview = true;
|
||||
|
||||
if (typeof(callback) === 'function') {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function prepareExport() {
|
||||
const argsave = arguments;
|
||||
if (!complete.preview) {
|
||||
preparePreview(() => {
|
||||
prepareExport(...argsave);
|
||||
});
|
||||
return;
|
||||
}
|
||||
complete.export = true;
|
||||
KIRI.export(...argsave);
|
||||
}
|
||||
|
||||
function loadCode(code, type) {
|
||||
setViewMode(VIEWS.PREVIEW);
|
||||
setOpacity(0);
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@
|
|||
|
||||
function push_point(x,y,z) {
|
||||
const newP = newPoint(x,y,z);
|
||||
// todo: merge co-linear, not just co-planar
|
||||
if (lastP && lastP.z === z) {
|
||||
if (curvesOnly) {
|
||||
end_poly();
|
||||
|
|
@ -189,7 +190,6 @@
|
|||
// eliminate if points "under" other lines
|
||||
for (let j=0; j<len; j++) {
|
||||
// skip self and adjacent
|
||||
// if (j === i) continue;
|
||||
if (j >= i-1 && j <= i+1) continue;
|
||||
let l2 = lines[j], p3 = l2.p1, p4 = l2.p2;
|
||||
// sort p3,p4 by y for comparison
|
||||
|
|
@ -211,7 +211,7 @@
|
|||
.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++) {
|
||||
const slice = slices[j];
|
||||
const points = slice.points;
|
||||
|
|
|
|||
Loading…
Reference in a new issue