From 7c7e5c2ed4d9c281b37accac88643b0baadb33b0 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Tue, 17 Mar 2020 16:32:43 -0400 Subject: [PATCH] fix moto bug --- js/kiri-init.js | 31 +++++++++++++++++++++---------- js/kiri.js | 29 ++++++++++++++--------------- js/moto-ctrl.js | 2 +- js/moto-space.js | 2 +- notes.md | 14 ++++++++------ web/moto/style.css | 2 ++ 6 files changed, 47 insertions(+), 33 deletions(-) diff --git a/js/kiri-init.js b/js/kiri-init.js index 351bb448..51938c2a 100644 --- a/js/kiri-init.js +++ b/js/kiri-init.js @@ -46,6 +46,10 @@ var gs_kiri_init = exports; editTools = null, maxTool = 0; + // extend KIRI API with local functions + API.show.devices = showDevices; + API.device.set = selectDevice; + function settings() { return API.conf.get(); } @@ -659,8 +663,9 @@ var gs_kiri_init = exports; API.conf.save(); } catch (e) { - console.log({error:e, device:code}); - // API.show.alert("invalid or deprecated device. please select a new device."); + console.log({error:e, device:code, devicename}); + API.show.alert(`invalid or deprecated device: "${devicename}"`, 10); + API.show.alert(`please select a new device`, 10); showDevices(); } API.function.clear(); @@ -1574,8 +1579,6 @@ var gs_kiri_init = exports; API.space.restore(init_two) || checkSeed(init_two) || init_two(); - // extend API - API.show.devices = showDevices; }; // SECOND STAGE INIT AFTER UI RESTORED @@ -1636,16 +1639,15 @@ var gs_kiri_init = exports; // optional set-and-lock device (hides device menu) let DEVNAME = SETUP.dev ? SETUP.dev[0] : null; + // setup default mode and enable mode locking, if set API.mode.set(SETMODE || STARTMODE || current.mode, SETMODE); - API.show.controls(true); + + // update everything dependent on the platform size platform.update_size(); + + // ensure hot keys work even in iframes API.focus(); - if (STATS.get('upgrade')) DBUG.log("kiri | version upgrade"); - STATS.del('upgrade'); - - if (!SETUP.s) console.log(`kiri | init main | ${KIRI.version}`); - // place version number a couple of places to help users UI.helpButton.title = `${LANG.version} ` + KIRI.version; @@ -1673,14 +1675,23 @@ var gs_kiri_init = exports; // clear alerts as they build up setInterval(API.event.alerts, 1000); + // add hide-alerts-on-alert-click UI.alert.dialog.onclick = function() { API.event.alerts(true); }; + // default to ARRANGE view mode API.view.set(VIEWS.ARRANGE); + // add ability to override + API.show.controls(true); + // show version on startup API.show.alert(`${LANG.version} ${KIRI.version}`); + + if (!SETUP.s) console.log(`kiri | init main | ${KIRI.version}`); + if (STATS.get('upgrade')) DBUG.log("kiri | version upgrade"); + STATS.del('upgrade'); } // schedule init_one to run after all page content is loaded diff --git a/js/kiri.js b/js/kiri.js index 29850a7f..183fd88b 100644 --- a/js/kiri.js +++ b/js/kiri.js @@ -65,7 +65,6 @@ self.kiri.license = exports.LICENSE; viewMode = VIEWS.ARRANGE, layoutOnAdd = true, local = SETUP.local, - // mouseMoved = false, camStock = null, camTopZ = 0, topZ = 0, @@ -156,7 +155,8 @@ self.kiri.license = exports.LICENSE; layer_range: 0 }, device: { - get: currentDeviceName + get: currentDeviceName, + set: undefined // set during init }, dialog: { show: showDialog, @@ -196,10 +196,6 @@ self.kiri.license = exports.LICENSE; set: setMode, switch: switchMode }, - // mouse : { - // moved : function() { return mouseMoved }, - // movedSet : function(b) { mouseMoved = b } - // }, opacity, print: { get: function() { return currentPrint }, @@ -213,6 +209,7 @@ self.kiri.license = exports.LICENSE; selection, show: { alert: alert2, + devices: undefined, // set during init progress: setProgress, controls: setControlsVisible, favorites: getShowFavorites, @@ -1426,7 +1423,7 @@ self.kiri.license = exports.LICENSE; alert2("workspace saved", 1); } - function restoreWorkspace(ondone, skipwidgets) { + function restoreWorkspace(ondone, skip_widget_load) { var loaded = 0, toload = ls2o('ws-widgets',[]), newset = ls2o('ws-settings'), @@ -1462,11 +1459,14 @@ self.kiri.license = exports.LICENSE; if (camera) SPACE.view.load(camera); else setTimeout(SPACE.view.home, 100); - if (skipwidgets) return; + if (skip_widget_load) return; + // remove any widgets from platform forAllWidgets(function(widget) { platform.delete(widget); }); + + // load any widget by name that was saved to the workspace toload.forEach(function(widgetid) { Widget.loadFromState(widgetid, function(widget) { if (widget) { @@ -1476,12 +1476,10 @@ self.kiri.license = exports.LICENSE; platform.deselect(); if (ondone) { ondone(); - // if ((newset || settings).mode != 'CAM') { - setTimeout(() => { - platform.update_top_z(); - SPACE.update(); - }, 1); - // }; + setTimeout(() => { + platform.update_top_z(); + SPACE.update(); + }, 1); } } }, position); @@ -1789,6 +1787,7 @@ self.kiri.license = exports.LICENSE; // update device stat for FDM/CAM STATS.set(`ud_${getModeLower()}`, settings.filter[mode] || 'default'); MODE = MODES[mode]; + // updates right-hand menu by enabling/disabling fields UC.setMode(MODE); loadNamedSetting(); saveSettings(); @@ -1802,7 +1801,7 @@ self.kiri.license = exports.LICENSE; if (camStock) { camStock.material.visible = settings.mode === 'CAM'; } - restoreWorkspace(null,true); + restoreWorkspace(null, true); // if (MODE !== MODES.FDM) platform.layout(); if (then) then(); triggerSettingsEvent(); diff --git a/js/moto-ctrl.js b/js/moto-ctrl.js index 8578a718..e97e5430 100644 --- a/js/moto-ctrl.js +++ b/js/moto-ctrl.js @@ -3,7 +3,7 @@ "use strict"; let gs_moto_ctrl = exports; -let MOTO = window.moto = window.moto || {}; +var MOTO = window.moto = window.moto || {}; /** * Adapted from THREE.OrbitControls diff --git a/js/moto-space.js b/js/moto-space.js index 00adbb99..0ff5de28 100644 --- a/js/moto-space.js +++ b/js/moto-space.js @@ -2,7 +2,7 @@ "use strict"; let gs_moto_space = exports; -let MOTO = window.moto = window.moto || {}; +var MOTO = window.moto = window.moto || {}; (function() { diff --git a/notes.md b/notes.md index 3f72410a..52ce7e49 100644 --- a/notes.md +++ b/notes.md @@ -2,7 +2,7 @@ ## `C` cosmetic, `F` functional, `P` performance, `B` bug fix -* `B` restore settings should restore all mode/device/settings +* `B` restore settings should restore all mode/device/settings (find corner cases) * `C` set page background color? or dark mode? * `C` better small screen support (on screen button for hiding side panels, compact selectors) * `F` implement an in-app bug reporting system @@ -11,10 +11,10 @@ * share raw data w/ dups, encode/decode * `F` remember object's original position/orientation for reset/multi-object import alignment * `P` bail on decimation if it's proving ineffective -* `P` improve decimation speed by avoiding in/out of Point +* `P` improve decimation speed by avoiding in/out of Point? * `P` server-side processing (determine protocol and storage) * `P` refactor / simplify POLY.expand (put onus on collector) -* `P` cloned objects should share same slice data unless rotated +* `P` cloned objects should share same slice data unless rotated or scaled # FDM @@ -40,9 +40,11 @@ # CAM -* `B` fix zooming, workspace thickness for larger workspaces * `B` fails in pancaking (clone) when there are no sliced layers (like z bottom too high) +* `B` linear finishing should extend beyond part boundaries by tool radius * `B` outside cutting direction in roughing mode inverted +* `F` do not rough areas that go all the way through the part + https://github.com/GridSpace/grid-apps/issues/20 * `F` send gcode to cncjs * `F` trapezoidal tabs (in the Z axis) * `F` lead-in milling @@ -50,13 +52,13 @@ * `F` implement z line-only follows for ball/taper * `F` add option to spiral in vs out (optimal tool life) vs mixed (optimal path) * `F` add endmill spiral direction to fully respect climb vs conventional -* `F` add tapered ball mills +* `F` add support for tapered ball mills * `F` warn when part > stock or cuts go outside bed * `F` add M03 tool feedrate support * `P` refactor slicing around flats w/ interpolation instead of culling * `P` optimize away topo generation (for z hop/move) when part is flat * `P` store tab and camshell polys in widget.topo to minimize z on edge moves -* `P` linear finishing going back to z top too often +* `P` linear finishing is going back to z top too often * `P` option to skip milling holes that would be drilled * `P` crossing open space check point is outside camshell before returning max z diff --git a/web/moto/style.css b/web/moto/style.css index 46281dd5..aef33ed4 100644 --- a/web/moto/style.css +++ b/web/moto/style.css @@ -221,6 +221,7 @@ button[del] { xoverflow: hidden; } #control-left { + display: none; position: fixed; z-index: 10000; color: black; @@ -242,6 +243,7 @@ button[del] { display: none; } #control-right { + display: none; position: fixed; z-index: 10000; top: 5px;