From 23f33083c9d2eef076310d26423317569f7bf2d0 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Wed, 18 Nov 2020 09:11:29 -0500 Subject: [PATCH] add workspace auto-save. add path line caps --- notes.md | 3 +-- src/kiri/conf.js | 1 + src/kiri/init.js | 17 ++++++++++------- src/kiri/main.js | 30 +++++++++++++++++++++++------- src/kiri/render.js | 17 +++++++++++++++++ src/moto/ctrl.js | 4 ++-- web/kiri/lang/en.js | 7 ++++--- 7 files changed, 58 insertions(+), 21 deletions(-) diff --git a/notes.md b/notes.md index e56a12f8..cff03edc 100644 --- a/notes.md +++ b/notes.md @@ -1,9 +1,7 @@ # Kiri:Moto todo ## 2.3 remaining -* cap path ends * fix ruler axis name label -* onshape mouse mapping option ## 2.4 tenative list * cnc @@ -33,6 +31,7 @@ * `P` duplicate objects should share same slice data unless rotated or scaled * `P` worker state cache cleanup and organization * `P` client/worker interface normalization and cleanup +* `C` improve path line caps # FDM diff --git a/src/kiri/conf.js b/src/kiri/conf.js index ae70c8c0..96a3a2e4 100644 --- a/src/kiri/conf.js +++ b/src/kiri/conf.js @@ -593,6 +593,7 @@ hoverPop: false, zoomSpeed: 1.0, lineType: "path", + autoSave: true, reverseZoom: true, showOrigin: false, showRulers: false, diff --git a/src/kiri/init.js b/src/kiri/init.js index 2ae567d1..e92d4c00 100644 --- a/src/kiri/init.js +++ b/src/kiri/init.js @@ -72,7 +72,7 @@ CATALOG.putFile("sample cube.stl", vert); platform.compute_max_z(); SPACE.view.home(); - setTimeout(API.space.save,500); + setTimeout(() => { API.space.save(true) },500); then(); API.help.show(); }); @@ -129,6 +129,7 @@ control.autoLayout = UI.autoLayout.checked; control.freeLayout = UI.freeLayout.checked; control.alignTop = UI.alignTop.checked; + control.autoSave = UI.autoSave.checked; control.reverseZoom = UI.reverseZoom.checked; control.dark = UI.dark.checked; control.exportOcto = UI.exportOcto.checked; @@ -243,27 +244,27 @@ case 37: // left arrow if (inputHasFocus()) return false; if (deg) API.selection.rotate(0, 0, -deg); - if (move > 0) moveSelection(-move, 0, 0); + if (move > 0) API.selection.move(-move, 0, 0); evt.preventDefault(); break; case 39: // right arrow if (inputHasFocus()) return false; if (deg) API.selection.rotate(0, 0, deg); - if (move > 0) moveSelection(move, 0, 0); + if (move > 0) API.selection.move(move, 0, 0); evt.preventDefault(); break; case 38: // up arrow if (inputHasFocus()) return false; if (evt.metaKey) return API.show.layer(API.var.layer_at+1); if (deg) API.selection.rotate(deg, 0, 0); - if (move > 0) moveSelection(0, move, 0); + if (move > 0) API.selection.move(0, move, 0); evt.preventDefault(); break; case 40: // down arrow if (inputHasFocus()) return false; if (evt.metaKey) return API.show.layer(API.var.layer_at-1); if (deg) API.selection.rotate(-deg, 0, 0); - if (move > 0) moveSelection(0, -move, 0); + if (move > 0) API.selection.move(0, -move, 0); evt.preventDefault(); break; case 65: // 'a' for select all @@ -1383,12 +1384,13 @@ ], {modes:GCODE, class:"ext-buttons f-row"}), lprefs: UC.newGroup(LANG.op_menu, $('prefs-gen1'), {inline: true}), - expert: UC.newBoolean(LANG.op_xprt_s, booleanSave, {title:LANG.op_xprt_l}), + autoSave: UC.newBoolean(LANG.op_auto_s, booleanSave, {title:LANG.op_auto_l}), hoverPop: UC.newBoolean(LANG.op_hopo_s, booleanSave, {title:LANG.op_hopo_l}), dark: UC.newBoolean(LANG.op_dark_s, booleanSave, {title:LANG.op_dark_l}), reverseZoom: UC.newBoolean(LANG.op_invr_s, booleanSave, {title:LANG.op_invr_l}), + expert: UC.newBoolean(LANG.op_xprt_s, booleanSave, {title:LANG.op_xprt_l}), - lprefs: UC.newGroup(LANG.op_menu, $('prefs-gen2'), {inline: true}), + lprefs: UC.newGroup(LANG.op_disp, $('prefs-gen2'), {inline: true}), showOrigin: UC.newBoolean(LANG.op_shor_s, booleanSave, {title:LANG.op_shor_l}), showRulers: UC.newBoolean(LANG.op_shru_s, booleanSave, {title:LANG.op_shru_l}), showSpeeds: UC.newBoolean(LANG.op_sped_s, speedSave, {title:LANG.op_sped_l}), @@ -1983,6 +1985,7 @@ UI.autoLayout.checked = control.autoLayout; UI.alignTop.checked = control.alignTop; UI.reverseZoom.checked = control.reverseZoom; + UI.autoSave.checked = control.autoSave; UI.decimate.checked = control.decimate; lineTypeSave(); detailSave(); diff --git a/src/kiri/main.js b/src/kiri/main.js index 5e0f04a7..405a9d71 100644 --- a/src/kiri/main.js +++ b/src/kiri/main.js @@ -54,7 +54,8 @@ busy = 0, showFavorites = SDB.getItem('dev-favorites') === 'true', alerts = [], - grouping = false; + grouping = false, + saveTimer = null; DBUG.enable(); @@ -108,7 +109,7 @@ set_axes: SPACE.platform.setAxes, set_volume: SPACE.platform.setVolume, top_z: () => { return topZ }, - clear: () => { platform.delete(WIDGETS.slice()) } + clear: () => { clearWorkspace(); saveWorkspace(true) } }; const color = { @@ -327,6 +328,16 @@ }, time || 100); } + function auto_save() { + if (!settings.controller.autoSave) { + return; + } + clearTimeout(saveTimer); + saveTimer = setTimeout(() => { + API.space.save(true); + }, 1000); + } + /** ****************************************************************** * Stats accumulator ******************************************************************* */ @@ -924,8 +935,8 @@ w.move(x, y, z, abs); }); API.event.emit('selection.move', {x, y, z, abs}); - // platform.update_stock(); SPACE.update(); + auto_save(); } function scaleSelection() { @@ -940,8 +951,8 @@ return; } updateSelectedInfo(); - // platform.update_stock(true); SPACE.update(); + auto_save(); } function rotateSelection(x, y, z) { @@ -951,8 +962,8 @@ platform.compute_max_z(); API.event.emit('selection.rotate', {x, y, z}); updateSelectedInfo(); - // platform.update_stock(true); SPACE.update(); + auto_save(); } /** ****************************************************************** @@ -1204,6 +1215,7 @@ platform.select(widget, shift); platform.compute_max_z(); API.event.emit('widget.add', widget); + auto_save(); if (nolayout) { return; } @@ -1240,6 +1252,7 @@ platformUpdateSelected(); if (feature.drop_layout) platform.layout(); API.event.emit('widget.delete', widget); + auto_save(); } function platformSelectAll() { @@ -1267,6 +1280,7 @@ setViewMode(VIEWS.ARRANGE); hideSlices(); + auto_save(); // only auto-layout when in arrange mode if (oldmode !== VIEWS.ARRANGE) { @@ -1622,7 +1636,7 @@ // alert2("drag/drop STL files onto platform to import\nreload page to return to last saved state"); } - function saveWorkspace() { + function saveWorkspace(quiet) { API.conf.save(); let newWidgets = [], oldWidgets = js2o(SDB.getItem('ws-widgets'), []); @@ -1643,7 +1657,9 @@ } }) }, "ws-save-" ,"ws-savf"); - alert2("workspace saved", 1); + if (!quiet) { + alert2("workspace saved", 1); + } } function restoreSettings(save) { diff --git a/src/kiri/render.js b/src/kiri/render.js index 3fbc6104..e2be43d2 100644 --- a/src/kiri/render.js +++ b/src/kiri/render.js @@ -311,6 +311,23 @@ } } + if (!contourClosed) { + // cheating because we know the profile length is 4 (for now) + const p1 = 0 + profile.count * 0; + const p2 = 1 + profile.count * 0; + const p3 = 2 + profile.count * 0; + const p4 = 3 + profile.count * 0; + index.push(p1, p2, p3); + index.push(p1, p3, p4); + const lc = lastCorner; + const p5 = 0 + profile.count * lc; + const p6 = 1 + profile.count * lc; + const p7 = 2 + profile.count * lc; + const p8 = 3 + profile.count * lc; + index.push(p7, p6, p5); + index.push(p8, p7, p5); + } + return {index, faces}; } diff --git a/src/moto/ctrl.js b/src/moto/ctrl.js index 2e34cce7..0155dad6 100644 --- a/src/moto/ctrl.js +++ b/src/moto/ctrl.js @@ -65,14 +65,14 @@ MOTO.CTRL = function (object, domElement, notify, slider) { // default mouse buttons this.mouseDefault = { ORBIT: THREE.MOUSE.LEFT, - // ZOOM: THREE.MOUSE.MIDDLE, + ZOOM: THREE.MOUSE.MIDDLE, PAN: THREE.MOUSE.RIGHT }; // Onshape this.mouseOnshape = { ORBIT: THREE.MOUSE.RIGHT, - // ZOOM: THREE.MOUSE.MIDDLE, + ZOOM: THREE.MOUSE.LEFT, PAN: THREE.MOUSE.MIDDLE }; diff --git a/web/kiri/lang/en.js b/web/kiri/lang/en.js index 4784771b..6be65321 100644 --- a/web/kiri/lang/en.js +++ b/web/kiri/lang/en.js @@ -115,8 +115,9 @@ kiri.lang['en-us'] = { // OPTIONS op_menu: "interface", + op_disp: "display", op_xprt_s: "expert", - op_xprt_l: "enable expert options", + op_xprt_l: "show more settings options", op_hopo_s: "hover pop", op_hopo_l: "enable menu hover\nto activate", op_dark_s: "dark mode", @@ -137,8 +138,8 @@ kiri.lang['en-us'] = { op_free_l: "permit dragable layout\nno effect in laser mode", op_invr_s: "invert zoom", op_invr_l: "invert mouse wheel\nscroll zoom", - op_thin_s: "thin lines", - op_thin_l: "faster part visualization\nsacrificing visual quality", + op_auto_s: "auto save", + op_auto_l: "preserve objects in workspace\nbetween application reloads", op_line_s: "line type", op_line_l: "line style for path rendering\nimpacts 3d performance\npath: 3d best\nflat: 2d good\nline = 1d fast", op_unit_s: "units",