From d252b7d1f696001ebee60350df8246362b3fc9d8 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Wed, 2 Dec 2020 10:00:41 -0500 Subject: [PATCH] add 'animate' button when action is valid. trace info on hover. bump rev 2.4.D10 --- notes.md | 4 ++-- package.json | 2 +- src/kiri/init.js | 12 +++++++----- src/kiri/main.js | 10 ++++++---- src/kiri/ui.js | 12 +++++++----- src/license.js | 2 +- src/mode/cam/animate.js | 10 +++++----- src/mode/cam/client.js | 23 +++++++++++++++++++++-- src/mode/cam/prepare.js | 2 +- src/mode/cam/topo.js | 31 ++++++++++++++++++------------- web/kiri/index.css | 6 ++++-- web/kiri/index.html | 8 ++++++-- web/kiri/lang/en.js | 2 +- 13 files changed, 80 insertions(+), 44 deletions(-) diff --git a/notes.md b/notes.md index c6e3ce0d..a455cacb 100644 --- a/notes.md +++ b/notes.md @@ -1,8 +1,6 @@ # Kiri:Moto todo and notes ## 2.4 roadmap -* `cnc` -* - compute tolerance from animesh when set to 0 * `laser` * - drag knife support * `all` @@ -65,6 +63,8 @@ # CAM +* `B` crossing interior open spaces doesn't lift high enough +* https://forum.grid.space/t/g0-movement-hits-the-stock-using-custom-tabs-positioning/171/2 * `B` climb vs conventional not fully consistent after refactor * `B` outside cutting direction in roughing mode inverted * `B` top clearing operations should use linear, not offset, passes diff --git a/package.json b/package.json index 9d84e3ef..eaa1dc77 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grid-apps", - "version": "2.4.9D", + "version": "2.4.10D", "description": "grid.space 3d slice & modeling tools", "author": "Stewart Allen ", "license": "MIT", diff --git a/src/kiri/init.js b/src/kiri/init.js index 26fd1bf5..b77aa5a7 100644 --- a/src/kiri/init.js +++ b/src/kiri/init.js @@ -1332,6 +1332,7 @@ func: { slice: $('act-slice'), preview: $('act-preview'), + animate: $('act-animate'), export: $('act-export') }, @@ -1604,7 +1605,7 @@ camContourOver: UC.newInput(LANG.cc_sovr_s, {title:LANG.cc_sovr_l, convert:UC.toFloat, bound:UC.bound(0.05,1.0), modes:CAM}), camContourSpeed: UC.newInput(LANG.cc_feed_s, {title:LANG.cc_feed_l, convert:UC.toInt, modes:CAM, units:true}), camContourAngle: UC.newInput(LANG.cf_angl_s, {title:LANG.cf_angl_l, convert:UC.toFloat, bound:UC.bound(45,90), modes:CAM}), - camTolerance: UC.newInput(LANG.ou_toll_s, {title:LANG.ou_toll_l, convert:UC.toFloat, bound:UC.bound(0.001,1.0), modes:CAM, units:true}), + camTolerance: UC.newInput(LANG.ou_toll_s, {title:LANG.ou_toll_l, convert:UC.toFloat, bound:UC.bound(0,10.0), modes:CAM, units:true}), camContourCurves: UC.newBoolean(LANG.cf_curv_s, onBooleanClick, {title:LANG.cf_curv_l, modes:CAM}), camContourIn: UC.newBoolean(LANG.cf_olin_s, onBooleanClick, {title:LANG.cf_olin_l, modes:CAM}), camContourSep: UC.newBlank({class:"pop-sep"}), @@ -2000,15 +2001,15 @@ API.platform.update_size(); - SPACE.mouse.onHover((int, ev, ints) => { + SPACE.mouse.onHover((int, event, ints) => { if (!API.feature.hover) return; if (!int) return API.widgets.meshes(); - API.event.emit('mouse.hover', {int, ints, point: int.point, type: 'widget'}); + API.event.emit('mouse.hover', {int, event, point: int.point, type: 'widget'}); }); - SPACE.platform.onHover((int, ev) => { + SPACE.platform.onHover((int, event) => { if (!API.feature.hover) return; - if (int) API.event.emit('mouse.hover', {point: int, type: 'platform'}); + if (int) API.event.emit('mouse.hover', {point: int, event, type: 'platform'}); }); SPACE.mouse.downSelect((int,event) => { @@ -2255,6 +2256,7 @@ UI.trash.onclick = API.selection.delete; UI.func.slice.onclick = (ev) => { ev.stopPropagation(); API.function.slice() }; UI.func.preview.onclick = (ev) => { ev.stopPropagation(); API.function.print() }; + UI.func.animate.onclick = (ev) => { ev.stopPropagation(); API.function.animate() }; UI.func.export.onclick = (ev) => { ev.stopPropagation(); API.function.export() }; $('view-arrange').onclick = API.platform.layout; $('view-top').onclick = SPACE.view.top; diff --git a/src/kiri/main.js b/src/kiri/main.js index bd68d90e..7fbca0af 100644 --- a/src/kiri/main.js +++ b/src/kiri/main.js @@ -55,7 +55,8 @@ showFavorites = SDB.getItem('dev-favorites') === 'true', alerts = [], grouping = false, - saveTimer = null; + saveTimer = null, + noop = () => {}; DBUG.enable(); @@ -236,8 +237,8 @@ }, device: { get: currentDeviceName, - set: undefined, // set during init - clone: undefined // set during init + set: noop, // set during init + clone: noop // set during init }, dialog: { show: showModal, @@ -259,6 +260,7 @@ slice: prepareSlices, print: preparePreview, prepare: preparePreview, + animate: noop, export: prepareExport, cancel: cancelWorker, clear: KIRI.client.clear @@ -292,7 +294,7 @@ selection, show: { alert: alert2, - devices: undefined, // set during init + devices: noop, // set during init progress: setProgress, controls: setControlsVisible, favorites: getShowFavorites, diff --git a/src/kiri/ui.js b/src/kiri/ui.js index 68d6cfff..95f285f3 100644 --- a/src/kiri/ui.js +++ b/src/kiri/ui.js @@ -766,9 +766,8 @@ } // unlike other elements, does not auto-add to a row - function newButton(label, action, options) { - let opt = options || {}, - b = DOC.createElement('button'); + function newButton(label, action, opt = {}) { + let b = DOC.createElement('button'); b.onclick = function() { hidePoppers(); @@ -785,12 +784,15 @@ d.innerHTML = opt.icon; b.appendChild(d); } + if (opt.title) { + b.setAttribute('title', opt.title); + } if (label) { b.appendChild(DOC.createTextNode(label)); } - addModeControls(b, options); - addId(b, options); + addModeControls(b, opt); + addId(b, opt); return b; } diff --git a/src/license.js b/src/license.js index e8eba713..0b6f02e1 100644 --- a/src/license.js +++ b/src/license.js @@ -3,7 +3,7 @@ let terms = { COPYRIGHT: "Copyright (C) Stewart Allen - All Rights Reserved", LICENSE: "See the license.md file included with the source distribution", - VERSION: "2.4.D9" + VERSION: "2.4.D10" }; if (typeof(module) === 'object') { diff --git a/src/mode/cam/animate.js b/src/mode/cam/animate.js index 18a4b294..f692a5dd 100644 --- a/src/mode/cam/animate.js +++ b/src/mode/cam/animate.js @@ -42,11 +42,11 @@ self.kiri.loader.push(function() { layer.innerHTML = ''; UC.setGroup(layer); UC.newRow([ - UC.newButton(null,replay,{icon:''}), - UC.newButton(null,play,{icon:''}), - UC.newButton(null,step,{icon:''}), - UC.newButton(null,fast,{icon:''}), - UC.newButton(null,pause,{icon:''}), + UC.newButton(null,replay,{icon:'',title:"restart"}), + UC.newButton(null,play,{icon:'',title:"play"}), + UC.newButton(null,step,{icon:'',title:"step"}), + UC.newButton(null,fast,{icon:'',title:"faster"}), + UC.newButton(null,pause,{icon:'',title:"pause"}), speedLabel = UC.newLabel("speed") ]); updateSpeed(); diff --git a/src/mode/cam/client.js b/src/mode/cam/client.js index 9e35422e..2efb56b2 100644 --- a/src/mode/cam/client.js +++ b/src/mode/cam/client.js @@ -36,6 +36,15 @@ toolInfo = $('tool-info'); + // wire up animate button in ui + api.function.animate = () => { + api.function.prepare(() => { + if (isCamMode && camStock) { + animate(); + } + }); + }; + api.event.on("mode.set", (mode) => { isCamMode = mode === 'CAM'; $('set-tools').style.display = isCamMode ? '' : 'none'; @@ -44,6 +53,7 @@ if (!isCamMode) { func.tabClear(); func.traceDone(); + UI.func.animate.style.display = 'none'; } // do not persist traces across page reloads func.traceClear(); @@ -243,7 +253,6 @@ KIRI.api.widgets.opacity(0.5); KIRI.api.widgets.for(widget => { if (ids.indexOf(widget.id) >= 0) { - console.log('clear_traces', widget.id); clearTraces(widget); widget.trace_stack = null; } @@ -312,6 +321,12 @@ } lastTrace = data.int.object; if (lastTrace.selected) { + let event = data.event; + let target = event.target; + let { clientX, clientY } = event; + let { offsetWidth, offsetHeight } = target; + toolInfo.style.right = `${offsetWidth - clientX + 5}px`; + toolInfo.style.bottom = `${offsetHeight - clientY + 5}px`; let traceInfo = lastTrace.trace.poly.traceInfo; let tool = new CAM.Tool(current, traceInfo.tool); toolInfo.innerText = [ @@ -537,9 +552,13 @@ let csox = 0; let csoy = 0; let stock = settings.stock = { }; + let compute = enabled && stockSet && widgets.length; + + UI.func.animate.style.display = refresh ? '' : 'none'; // create/inject cam stock if stock size other than default - if (enabled && stockSet && widgets.length) { + if (compute) { + UI.func.animate.style.display = ''; let csx = proc.camStockX; let csy = proc.camStockY; let csz = proc.camStockZ; diff --git a/src/mode/cam/prepare.js b/src/mode/cam/prepare.js index b63c6b9f..95bc4b61 100644 --- a/src/mode/cam/prepare.js +++ b/src/mode/cam/prepare.js @@ -237,7 +237,7 @@ // drop points too close together if (deltaXY < 0.001 && point.z === lastPoint.z) { - console.trace(["drop dup",lastPoint,point]); + // console.trace(["drop dup",lastPoint,point]); return; } diff --git a/src/mode/cam/topo.js b/src/mode/cam/topo.js index 8e1944ce..d6de96c7 100644 --- a/src/mode/cam/topo.js +++ b/src/mode/cam/topo.js @@ -18,20 +18,13 @@ noop = function() {}; class Topo { - constructor(widget, settings, options) { - const opt = options || {}, - ondone = opt.ondone || noop, - onupdate = opt.onupdate || noop, - shadow = opt.shadow, + constructor(widget, settings, opt = {}) { + const density = parseInt(settings.controller.animesh) * 2500, proc = settings.process, - inside = proc.camContourIn, - resolution = proc.camTolerance, - tool = new CAM.Tool(settings, proc.camContourTool), - toolOffset = tool.generateProfile(resolution).profile, - toolDiameter = tool.fluteDiameter(), - toolStep = toolDiameter * proc.camContourOver, - traceJoin = toolDiameter / 2, - pocketOnly = proc.camOutlinePocket, + tolerance = proc.camTolerance, + onupdate = opt.onupdate || noop, + ondone = opt.ondone || noop, + shadow = opt.shadow, bounds = widget.getBoundingBox().clone(), minX = bounds.min.x, maxX = bounds.max.x, @@ -41,6 +34,14 @@ zMin = Math.max(bounds.min.z, zBottom) + 0.0001, boundsX = maxX - minX, boundsY = maxY - minY, + inside = proc.camContourIn, + resolution = tolerance ? tolerance : 1/Math.sqrt(density/(boundsX * boundsY)), + tool = new CAM.Tool(settings, proc.camContourTool), + toolOffset = tool.generateProfile(resolution).profile, + toolDiameter = tool.fluteDiameter(), + toolStep = toolDiameter * proc.camContourOver, + traceJoin = toolDiameter / 2, + pocketOnly = proc.camOutlinePocket, maxangle = proc.camContourAngle, curvesOnly = proc.camContourCurves, R2A = 180 / Math.PI, @@ -73,6 +74,10 @@ debug_topo_lines = debug && true, debug_topo_shells = debug && true; + if (tolerance == 0) { + console.log(`contour auto tolerance`,resolution.round(4)); + } + if (tabs) { clipTab.appendAll(tabs.map(tab => { let ctab = POLY.expand([tab.poly], toolDiameter/2); diff --git a/web/kiri/index.css b/web/kiri/index.css index fc66d2fd..36351167 100644 --- a/web/kiri/index.css +++ b/web/kiri/index.css @@ -1199,10 +1199,12 @@ th, tr, td, label { #tool-info { position: fixed; white-space: pre; + background-color: rgba(255,255,255,0.25); + border: 1px solid rgba(0,0,0,0.25); + border-radius: 4px; + padding: 4px; font-family: monospace; font-size: 12px; - bottom: 5px; - left: 5px; color: #000; } #winfo { diff --git a/web/kiri/index.html b/web/kiri/index.html index 92ff04b1..c93e1f57 100644 --- a/web/kiri/index.html +++ b/web/kiri/index.html @@ -131,11 +131,15 @@
-
+
-
+
+ + +
+
diff --git a/web/kiri/lang/en.js b/web/kiri/lang/en.js index fe09b8bb..7c5d2f4e 100644 --- a/web/kiri/lang/en.js +++ b/web/kiri/lang/en.js @@ -394,7 +394,7 @@ kiri.lang['en-us'] = { // OUTPUT CAM ou_toll_s: "tolerance", - ou_toll_l: "surface precision\nin workspace units\nlower is slower and\nuses more memory", + ou_toll_l: "surface precision\nin workspace units\nlower is slower and\nuses more memory\n0 = automatic based\non animate preference", ou_ztof_s: "z top offset", ou_ztof_l: "offset from stock surface\nto top face of part\nin workspace units", ou_zbot_s: "z bottom",