add 'animate' button when action is valid. trace info on hover. bump rev 2.4.D10

This commit is contained in:
Stewart Allen 2020-12-02 10:00:41 -05:00
commit d252b7d1f6
13 changed files with 79 additions and 43 deletions

View file

@ -1,8 +1,6 @@
# Kiri:Moto todo and notes # Kiri:Moto todo and notes
## 2.4 roadmap ## 2.4 roadmap
* `cnc`
* - compute tolerance from animesh when set to 0
* `laser` * `laser`
* - drag knife support * - drag knife support
* `all` * `all`
@ -65,6 +63,8 @@
# CAM # 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` climb vs conventional not fully consistent after refactor
* `B` outside cutting direction in roughing mode inverted * `B` outside cutting direction in roughing mode inverted
* `B` top clearing operations should use linear, not offset, passes * `B` top clearing operations should use linear, not offset, passes

View file

@ -1,6 +1,6 @@
{ {
"name": "grid-apps", "name": "grid-apps",
"version": "2.4.9D", "version": "2.4.10D",
"description": "grid.space 3d slice & modeling tools", "description": "grid.space 3d slice & modeling tools",
"author": "Stewart Allen <sa@grid.space>", "author": "Stewart Allen <sa@grid.space>",
"license": "MIT", "license": "MIT",

View file

@ -1332,6 +1332,7 @@
func: { func: {
slice: $('act-slice'), slice: $('act-slice'),
preview: $('act-preview'), preview: $('act-preview'),
animate: $('act-animate'),
export: $('act-export') 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}), 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}), 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}), 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}), 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}), camContourIn: UC.newBoolean(LANG.cf_olin_s, onBooleanClick, {title:LANG.cf_olin_l, modes:CAM}),
camContourSep: UC.newBlank({class:"pop-sep"}), camContourSep: UC.newBlank({class:"pop-sep"}),
@ -2000,15 +2001,15 @@
API.platform.update_size(); API.platform.update_size();
SPACE.mouse.onHover((int, ev, ints) => { SPACE.mouse.onHover((int, event, ints) => {
if (!API.feature.hover) return; if (!API.feature.hover) return;
if (!int) return API.widgets.meshes(); 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 (!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) => { SPACE.mouse.downSelect((int,event) => {
@ -2255,6 +2256,7 @@
UI.trash.onclick = API.selection.delete; UI.trash.onclick = API.selection.delete;
UI.func.slice.onclick = (ev) => { ev.stopPropagation(); API.function.slice() }; UI.func.slice.onclick = (ev) => { ev.stopPropagation(); API.function.slice() };
UI.func.preview.onclick = (ev) => { ev.stopPropagation(); API.function.print() }; 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() }; UI.func.export.onclick = (ev) => { ev.stopPropagation(); API.function.export() };
$('view-arrange').onclick = API.platform.layout; $('view-arrange').onclick = API.platform.layout;
$('view-top').onclick = SPACE.view.top; $('view-top').onclick = SPACE.view.top;

View file

@ -55,7 +55,8 @@
showFavorites = SDB.getItem('dev-favorites') === 'true', showFavorites = SDB.getItem('dev-favorites') === 'true',
alerts = [], alerts = [],
grouping = false, grouping = false,
saveTimer = null; saveTimer = null,
noop = () => {};
DBUG.enable(); DBUG.enable();
@ -236,8 +237,8 @@
}, },
device: { device: {
get: currentDeviceName, get: currentDeviceName,
set: undefined, // set during init set: noop, // set during init
clone: undefined // set during init clone: noop // set during init
}, },
dialog: { dialog: {
show: showModal, show: showModal,
@ -259,6 +260,7 @@
slice: prepareSlices, slice: prepareSlices,
print: preparePreview, print: preparePreview,
prepare: preparePreview, prepare: preparePreview,
animate: noop,
export: prepareExport, export: prepareExport,
cancel: cancelWorker, cancel: cancelWorker,
clear: KIRI.client.clear clear: KIRI.client.clear
@ -292,7 +294,7 @@
selection, selection,
show: { show: {
alert: alert2, alert: alert2,
devices: undefined, // set during init devices: noop, // set during init
progress: setProgress, progress: setProgress,
controls: setControlsVisible, controls: setControlsVisible,
favorites: getShowFavorites, favorites: getShowFavorites,

View file

@ -766,9 +766,8 @@
} }
// unlike other elements, does not auto-add to a row // unlike other elements, does not auto-add to a row
function newButton(label, action, options) { function newButton(label, action, opt = {}) {
let opt = options || {}, let b = DOC.createElement('button');
b = DOC.createElement('button');
b.onclick = function() { b.onclick = function() {
hidePoppers(); hidePoppers();
@ -785,12 +784,15 @@
d.innerHTML = opt.icon; d.innerHTML = opt.icon;
b.appendChild(d); b.appendChild(d);
} }
if (opt.title) {
b.setAttribute('title', opt.title);
}
if (label) { if (label) {
b.appendChild(DOC.createTextNode(label)); b.appendChild(DOC.createTextNode(label));
} }
addModeControls(b, options); addModeControls(b, opt);
addId(b, options); addId(b, opt);
return b; return b;
} }

View file

@ -3,7 +3,7 @@
let terms = { let terms = {
COPYRIGHT: "Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved", COPYRIGHT: "Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved",
LICENSE: "See the license.md file included with the source distribution", LICENSE: "See the license.md file included with the source distribution",
VERSION: "2.4.D9" VERSION: "2.4.D10"
}; };
if (typeof(module) === 'object') { if (typeof(module) === 'object') {

View file

@ -42,11 +42,11 @@ self.kiri.loader.push(function() {
layer.innerHTML = ''; layer.innerHTML = '';
UC.setGroup(layer); UC.setGroup(layer);
UC.newRow([ UC.newRow([
UC.newButton(null,replay,{icon:'<i class="fas fa-fast-backward"></i>'}), UC.newButton(null,replay,{icon:'<i class="fas fa-fast-backward"></i>',title:"restart"}),
UC.newButton(null,play,{icon:'<i class="fas fa-play"></i>'}), UC.newButton(null,play,{icon:'<i class="fas fa-play"></i>',title:"play"}),
UC.newButton(null,step,{icon:'<i class="fas fa-step-forward"></i>'}), UC.newButton(null,step,{icon:'<i class="fas fa-step-forward"></i>',title:"step"}),
UC.newButton(null,fast,{icon:'<i class="fas fa-fast-forward"></i>'}), UC.newButton(null,fast,{icon:'<i class="fas fa-forward"></i>',title:"faster"}),
UC.newButton(null,pause,{icon:'<i class="fas fa-pause"></i>'}), UC.newButton(null,pause,{icon:'<i class="fas fa-pause"></i>',title:"pause"}),
speedLabel = UC.newLabel("speed") speedLabel = UC.newLabel("speed")
]); ]);
updateSpeed(); updateSpeed();

View file

@ -36,6 +36,15 @@
toolInfo = $('tool-info'); 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) => { api.event.on("mode.set", (mode) => {
isCamMode = mode === 'CAM'; isCamMode = mode === 'CAM';
$('set-tools').style.display = isCamMode ? '' : 'none'; $('set-tools').style.display = isCamMode ? '' : 'none';
@ -44,6 +53,7 @@
if (!isCamMode) { if (!isCamMode) {
func.tabClear(); func.tabClear();
func.traceDone(); func.traceDone();
UI.func.animate.style.display = 'none';
} }
// do not persist traces across page reloads // do not persist traces across page reloads
func.traceClear(); func.traceClear();
@ -243,7 +253,6 @@
KIRI.api.widgets.opacity(0.5); KIRI.api.widgets.opacity(0.5);
KIRI.api.widgets.for(widget => { KIRI.api.widgets.for(widget => {
if (ids.indexOf(widget.id) >= 0) { if (ids.indexOf(widget.id) >= 0) {
console.log('clear_traces', widget.id);
clearTraces(widget); clearTraces(widget);
widget.trace_stack = null; widget.trace_stack = null;
} }
@ -312,6 +321,12 @@
} }
lastTrace = data.int.object; lastTrace = data.int.object;
if (lastTrace.selected) { 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 traceInfo = lastTrace.trace.poly.traceInfo;
let tool = new CAM.Tool(current, traceInfo.tool); let tool = new CAM.Tool(current, traceInfo.tool);
toolInfo.innerText = [ toolInfo.innerText = [
@ -537,9 +552,13 @@
let csox = 0; let csox = 0;
let csoy = 0; let csoy = 0;
let stock = settings.stock = { }; 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 // 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 csx = proc.camStockX;
let csy = proc.camStockY; let csy = proc.camStockY;
let csz = proc.camStockZ; let csz = proc.camStockZ;

View file

@ -237,7 +237,7 @@
// drop points too close together // drop points too close together
if (deltaXY < 0.001 && point.z === lastPoint.z) { if (deltaXY < 0.001 && point.z === lastPoint.z) {
console.trace(["drop dup",lastPoint,point]); // console.trace(["drop dup",lastPoint,point]);
return; return;
} }

View file

@ -18,20 +18,13 @@
noop = function() {}; noop = function() {};
class Topo { class Topo {
constructor(widget, settings, options) { constructor(widget, settings, opt = {}) {
const opt = options || {}, const density = parseInt(settings.controller.animesh) * 2500,
ondone = opt.ondone || noop,
onupdate = opt.onupdate || noop,
shadow = opt.shadow,
proc = settings.process, proc = settings.process,
inside = proc.camContourIn, tolerance = proc.camTolerance,
resolution = proc.camTolerance, onupdate = opt.onupdate || noop,
tool = new CAM.Tool(settings, proc.camContourTool), ondone = opt.ondone || noop,
toolOffset = tool.generateProfile(resolution).profile, shadow = opt.shadow,
toolDiameter = tool.fluteDiameter(),
toolStep = toolDiameter * proc.camContourOver,
traceJoin = toolDiameter / 2,
pocketOnly = proc.camOutlinePocket,
bounds = widget.getBoundingBox().clone(), bounds = widget.getBoundingBox().clone(),
minX = bounds.min.x, minX = bounds.min.x,
maxX = bounds.max.x, maxX = bounds.max.x,
@ -41,6 +34,14 @@
zMin = Math.max(bounds.min.z, zBottom) + 0.0001, zMin = Math.max(bounds.min.z, zBottom) + 0.0001,
boundsX = maxX - minX, boundsX = maxX - minX,
boundsY = maxY - minY, 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, maxangle = proc.camContourAngle,
curvesOnly = proc.camContourCurves, curvesOnly = proc.camContourCurves,
R2A = 180 / Math.PI, R2A = 180 / Math.PI,
@ -73,6 +74,10 @@
debug_topo_lines = debug && true, debug_topo_lines = debug && true,
debug_topo_shells = debug && true; debug_topo_shells = debug && true;
if (tolerance == 0) {
console.log(`contour auto tolerance`,resolution.round(4));
}
if (tabs) { if (tabs) {
clipTab.appendAll(tabs.map(tab => { clipTab.appendAll(tabs.map(tab => {
let ctab = POLY.expand([tab.poly], toolDiameter/2); let ctab = POLY.expand([tab.poly], toolDiameter/2);

View file

@ -1199,10 +1199,12 @@ th, tr, td, label {
#tool-info { #tool-info {
position: fixed; position: fixed;
white-space: pre; 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-family: monospace;
font-size: 12px; font-size: 12px;
bottom: 5px;
left: 5px;
color: #000; color: #000;
} }
#winfo { #winfo {

View file

@ -131,11 +131,15 @@
<i class="fas fa-bars"></i> <i class="fas fa-bars"></i>
<label>slice</label> <label>slice</label>
<div id="pop-slice" class="pop-lcol f-row"> <div id="pop-slice" class="pop-lcol f-row">
<div id="act-preview" xclass="lt-menu lt-enabled"> <div id="act-preview" xclass="lt-menu">
<i class="fas fa-cubes"></i> <i class="fas fa-cubes"></i>
<label>preview</label> <label>preview</label>
</div> </div>
<div id="act-export" xclass="lt-menu lt-enabled"> <div id="act-animate" xclass="lt-menu">
<i class="fas fa-running"></i>
<label>animate</label>
</div>
<div id="act-export" xclass="lt-menu">
<i class="fas fa-file-download"></i> <i class="fas fa-file-download"></i>
<label>export</label> <label>export</label>
</div> </div>

View file

@ -394,7 +394,7 @@ kiri.lang['en-us'] = {
// OUTPUT CAM // OUTPUT CAM
ou_toll_s: "tolerance", 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_s: "z top offset",
ou_ztof_l: "offset from stock surface\nto top face of part\nin workspace units", ou_ztof_l: "offset from stock surface\nto top face of part\nin workspace units",
ou_zbot_s: "z bottom", ou_zbot_s: "z bottom",