checkpoint cam-op-pop editing

This commit is contained in:
Stewart Allen 2020-12-23 14:27:18 -05:00
commit f6775130ca
8 changed files with 267 additions and 131 deletions

View file

@ -1,6 +1,6 @@
# Kiri:Moto todo and notes
## 2.5 plan
## short list
# `cnc`
# - split gcode output
# - redo path planning
@ -8,11 +8,8 @@
# - more tracing types (in, out, clear, pocket)
# - trace re-ordering
# `fdm`
# - bind process to z ranges or boxed regions
# - non-planar actual
# - layer start point control
# `sla`
# - common support area detection from new fdm code
# - bind process to z ranges or boxed regions
## `C` cosmetic, `F` functional, `P` performance, `B` bug fix
@ -51,11 +48,16 @@
* `P` solid fill the tops of supports for down facing flats
* `P` sparse infill should follow polys between intersect points
# SLA
# FDM - SLA
# `P` common support area detection (fork new fdm code)
* `P` prioritize supports by length of unsupported span. mandatory when circularity > X
* or % area of inner to outer poly is high (making it a thin shell)
# FDM - BELT
# `B` z hop = y hop
# CAM
* `B` failure to go *up* when moving between parts?
@ -68,6 +70,7 @@
* `F` split out facing. make it use linear passes
* `F` add linear clearing strategy option for roughing / pocket
* `F` extend acute roughing on inside polys to clear small voids
* `F` option to use part / STL coordinate space to determine X,Y origin
* `F` validate muti-part layout and spacing exceeds largest outside tool diameter
* `F` skip "thru" holes checkbox for roughing and outlining
@ -80,12 +83,10 @@
* `F` z bounded slices (extension of z bottom offset feature)
* `F` z planar settings visualizations
* `F` convert acute angles to arcs
* `F` extend acute roughing on inside polys to clear small voids
* `F` lead-in milling
* `F` adaptive clearing in roughing mode
* `F` trapezoidal tabs (in the Z axis)
* `F` ease-in and ease-out especially on tab cut-out start/stop
* `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 support for tapered ball mills
* `F` warn when part > stock or cuts go outside bed

View file

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

View file

@ -6,7 +6,7 @@
if (!self.kiri) {
self.kiri = {
beta: 2507,
beta: 2508,
driver: {}, // driver modules
loader: [] // module loading: array of functions
};

View file

@ -323,7 +323,9 @@
},
tweak,
util: {
isSecure
isSecure,
ui2rec: updateSettingsFromFields,
rec2ui: updateFieldsFromSettings
},
view: {
get: function() { return viewMode },
@ -1633,46 +1635,51 @@
******************************************************************* */
// given a settings region, update values of matching bound UI fields
function updateFieldsFromSettings(scope) {
if (!scope) return console.trace("missing scope");
for (let key in scope) {
if (!scope.hasOwnProperty(key)) continue;
let val = scope[key];
if (UI.hasOwnProperty(key)) {
let uie = UI[key], typ = uie ? uie.type : null;
if (typ === 'text') {
if (uie.setv) {
uie.setv(val);
} else {
uie.value = val;
}
} else if (typ === 'checkbox') {
uie.checked = val;
} else if (typ === 'select-one') {
uie.innerHTML = '';
let source = uie.parentNode.getAttribute('source'),
list = settings[source] || lists[source],
chosen = null;
if (list) list.forEach(function(el, index) {
let id = el.id || el.name;
let ev = el.value || id;
if (val == id) {
chosen = index;
}
let opt = DOC.createElement('option');
opt.appendChild(DOC.createTextNode(el.name));
opt.setAttribute('value', ev);
uie.appendChild(opt);
});
if (chosen) {
uie.selectedIndex = chosen;
}
} else if (typ === 'textarea') {
if (Array.isArray(val)) {
uie.value = val.join('\n');
} else {
uie.value = '';
function updateFieldsFromSettings(setrec, uirec = UI) {
if (!setrec) {
return console.trace("missing scope");
}
for (let key in setrec) {
if (!setrec.hasOwnProperty(key)) {
continue;
}
let val = setrec[key];
if (!uirec.hasOwnProperty(key)) {
continue;
}
let uie = uirec[key], typ = uie ? uie.type : null;
if (typ === 'text') {
if (uie.setv) {
uie.setv(val);
} else {
uie.value = val;
}
} else if (typ === 'checkbox') {
uie.checked = val;
} else if (typ === 'select-one') {
uie.innerHTML = '';
let source = uie.parentNode.getAttribute('source'),
list = settings[source] || lists[source],
chosen = null;
if (list) list.forEach(function(el, index) {
let id = el.id || el.name;
let ev = el.value || id;
if (val == id) {
chosen = index;
}
let opt = DOC.createElement('option');
opt.appendChild(DOC.createTextNode(el.name));
opt.setAttribute('value', ev);
uie.appendChild(opt);
});
if (chosen) {
uie.selectedIndex = chosen;
}
} else if (typ === 'textarea') {
if (Array.isArray(val)) {
uie.value = val.join('\n');
} else {
uie.value = '';
}
}
}
@ -1681,44 +1688,47 @@
/**
* @returns {Object}
*/
function updateSettingsFromFields(scope) {
if (!scope) return console.trace("missing scope");
function updateSettingsFromFields(setrec, uirec = UI) {
if (!setrec) {
return console.trace("missing scope");
}
let key, changed = false;
// for each key in scope object
for (key in scope) {
if (!scope.hasOwnProperty(key)) {
// for each key in setrec object
for (key in setrec) {
if (!setrec.hasOwnProperty(key)) {
continue;
}
if (UI.hasOwnProperty(key)) {
let nval = null, uie = UI[key];
// skip empty UI values
if (!uie || uie === '') {
continue;
}
if (uie.type === 'text') {
nval = UI[key].convert();
} else if (uie.type === 'checkbox') {
nval = UI[key].checked;
} else if (uie.type === 'select-one') {
if (uie.selectedIndex >= 0) {
nval = uie.options[uie.selectedIndex].value;
let src = uie.parentNode.getAttribute('source');
if (src === 'tools') {
nval = parseInt(nval);
}
} else {
nval = scope[key];
if (!uirec.hasOwnProperty(key)) {
continue;
}
let nval = null, uie = uirec[key];
// skip empty UI values
if (!uie || uie === '') {
continue;
}
if (uie.type === 'text') {
nval = uirec[key].convert();
} else if (uie.type === 'checkbox') {
nval = uirec[key].checked;
} else if (uie.type === 'select-one') {
if (uie.selectedIndex >= 0) {
nval = uie.options[uie.selectedIndex].value;
let src = uie.parentNode.getAttribute('source');
if (src === 'tools') {
nval = parseInt(nval);
}
} else if (uie.type === 'textarea') {
nval = uie.value.trim().split('\n').filter(v => v !== '');
} else {
continue;
}
if (scope[key] != nval) {
scope[key] = nval;
nval = setrec[key];
}
} else if (uie.type === 'textarea') {
nval = uie.value.trim().split('\n').filter(v => v !== '');
} else {
continue;
}
if (setrec[key] != nval) {
setrec[key] = nval;
}
}

View file

@ -13,6 +13,7 @@
lastGroup = null,
lastDiv = null,
addTo = null,
bindTo = null,
groups = {},
groupShow = {},
groupSticky = false,
@ -51,6 +52,9 @@
toFloat,
hidePop,
isPopped,
isSticky,
setSticky,
newElement,
newBoolean,
newButton,
newBlank,
@ -177,13 +181,12 @@
return { addTo: at || addTo, lastDiv: at || lastDiv, lastGroup, groupName };
}
function restore(opt) {
if (opt) {
addTo = opt.addTo;
lastDiv = opt.lastDiv;
lastGroup = opt.lastGroup;
groupName = opt.groupName;
}
function restore(opt = {}) {
addTo = opt.addTo || addTo;
bindTo = opt.bindTo || null;
lastDiv = opt.lastDiv || lastDiv;
lastGroup = opt.lastGroup || lastGroup;
groupName = opt.groupName || groupName;
}
// at present only used by the layers popup menu
@ -194,13 +197,31 @@
return div;
}
function newElement(type, opt = {}) {
let el = DOC.createElement(type);
if (opt.id) {
el.setAttribute("id", opt.id);
}
if (opt.class) {
for (let cl of opt.class.split(' ')) {
el.classList.add(cl);
}
}
if (opt.attr) {
for (let [key, val] of Object.entries(opt.attr)) {
el.setAttribute(key, val);
}
}
return el;
}
function newGroup(label, div, options) {
lastDiv = div || lastDiv;
return addCollapsableGroup(label, lastDiv, options);
}
function addCollapsableGroup(label, div, options) {
let opt = options || {};
function addCollapsableGroup(label, div, opt = {}) {
let group = opt.group || label;
poppable[group] = opt.inline === true ? false : true;
@ -383,8 +404,8 @@
}
}
function addModeControls(el, options) {
let opt = options || {};
function addModeControls(el, opt = {}) {
el.__opt = opt;
el.__show = true;
el.__modeSave = null;
el.showMe = function() {
@ -444,6 +465,14 @@
return lastPop !== null;
}
function isSticky() {
return groupSticky;
}
function setSticky(bool) {
groupSticky = bool;
}
function newGCode(label, options) {
let opt = options || {},
row = lastDiv,
@ -454,7 +483,7 @@
txt.setAttribute("wrap", "off");
txt.setAttribute("spellcheck", "false");
txt.setAttribute("style", "resize: none");
txt.onblur = inputAction;
txt.onblur = bindTo || inputAction;
btn.setAttribute("class", "basis-50");
btn.appendChild(DOC.createTextNode(label));
@ -585,7 +614,7 @@
size = opt ? opt.size || 5 : 5,
height = opt ? opt.height : 0,
ip = height > 1 ? DOC.createElement('textarea') : DOC.createElement('input'),
action = opt.action || inputAction;
action = opt.action || bindTo || inputAction;
row.appendChild(newLabel(label));
row.appendChild(ip);
@ -674,7 +703,7 @@
let row = newDiv(options),
ip = DOC.createElement('input'),
hide = options && options.hide,
action = inputAction;
action = bindTo || inputAction;
if (label) row.appendChild(newLabel(label));
row.appendChild(ip);
@ -700,7 +729,7 @@
let row = newDiv(options),
ip = DOC.createElement('select'),
hide = options && options.hide,
action = inputAction;
action = bindTo || inputAction;
row.appendChild(newLabel(label));
row.appendChild(ip);
@ -714,7 +743,7 @@
if (options.action) action = options.action;
}
ip.setVisible = row.setVisible;
ip.onchange = function() {
ip.onchange = function(ev) {
action();
};
ip.onclick = (ev) => {
@ -728,7 +757,7 @@
return ip;
}
function newBoolean(label, action, options) {
function newBoolean(label, action = bindTo, options) {
let row = newDiv(options),
ip = DOC.createElement('input'),
hide = options && options.hide;
@ -748,7 +777,7 @@
row.setAttribute("title", options.title);
}
}
if (action) ip.onclick = function() { action() };
if (action) ip.onclick = function(ev) { action(ip) };
ip.setVisible = row.setVisible;
return ip;

View file

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

View file

@ -21,6 +21,7 @@
let traceOp = { type: "trace" },
zaxis = { x: 0, y: 0, z: 1 },
popOp = {},
func = {};
CAM.restoreTabs = restoreTabs;
@ -96,11 +97,12 @@
let hasTabs = false;
let hasTraces = false;
// ensure trace op is a singleton for now
if (isCamMode && proc.ops)
for (let i=0; i<proc.ops.length; i++) {
if (proc.ops[i].type === "trace") {
proc.ops[i] = traceOp;
}
if (isCamMode && proc.ops) {
proc.ops = proc.ops
.filter(v => v)
.map(op => {
return op.type === 'trace' ? traceOp : op
});
}
// for any tabs or traces to set markers
Object.keys(settings.widget).forEach(wid => {
@ -306,30 +308,8 @@
let bind = {};
let scale = API.view.unit_scale();
oplist.forEach((rec,i) => {
let entries = 0;
let title = Object.entries(rec).filter((v,i) => {
return v[0] !== 'type'
}).map(v => {
entries++;
let [ key, value ] = v;
switch (key) {
case 'tool':
value = new CAM.Tool(current, v[1]).getName();
break;
case 'down':
case 'rate':
case 'plunge':
case 'leave':
case 'lift':
value = (parseFloat(v[1]) / scale).round(2);
break;
}
return `<tr><th>${key}</th><td>${value}</td></tr>`;
}).join("\n");
title = `<table>${title}</table>`;
html.appendAll([
`<div id="${mark+i}">`,
entries ? `<div class="opop">${title}</div>` : '',
`<div id="${mark+i}" class="draggable">`,
`<label class="label">${rec.type}</label>`,
`<label id="${mark+i}-x" class="del"><i class="fas fa-times"></i></label>`,
`</div>`
@ -339,6 +319,7 @@
let listel = $('oplist');
listel.innerHTML = html.join('');
let bounds = [];
let unpop = null;
for (let [id, rec] of Object.entries(bind)) {
$(`${id}-x`).onmousedown = (ev) => {
ev.stopPropagation();
@ -351,16 +332,49 @@
};
let el = $(id);
bounds.push(el);
let timer = null;
let inside = true;
let poprec = popOp[rec.type];
el.unpop = () => {
let pos = [...el.childNodes].indexOf(poprec.div);
if (pos >= 0) {
el.removeChild(poprec.div);
}
};
el.onmouseenter = (ev) => {
if (unpop) unpop();
unpop = el.unpop;
inside = true;
poprec.use(rec);
el.appendChild(poprec.div);
// option click event appears latent
// and overides the sticky settings
setTimeout(() => {
UC.setSticky(false);
}, 0);
};
el.onmouseleave = () => {
inside = false;
clearTimeout(timer);
timer = setTimeout(() => {
if (!inside && poprec.using(rec) && !UC.isSticky()) {
el.unpop();
}
}, 250);
};
el.rec = rec;
el.onmousedown = (ev) => {
let target = ev.target;
target.classList.add("drag");
let target = ev.target, clist = target.classList;
if (!clist.contains("draggable")) {
return;
}
clist.add("drag");
ev.stopPropagation();
ev.preventDefault();
let tracker = UI.tracker;
tracker.style.display = 'block';
let cancel = tracker.onmouseup = (ev) => {
target.classList.remove("drag");
clist.remove("drag");
tracker.style.display = 'none';
if (ev) {
ev.stopPropagation();
@ -697,8 +711,78 @@
}
func.hover(data);
});
function hasSpindle() {
return current.device.spindleMax > 0;
}
createPopOp('rough').inputs = {
tool: UC.newSelect(LANG.cc_tool, {}, "tools"),
sep: UC.newBlank({class:"pop-sep"}),
spindle: UC.newInput(LANG.cc_spnd_s, {title:LANG.cc_spnd_l, convert:UC.toInt, show:hasSpindle}),
down: UC.newInput(LANG.cc_sdwn_s, {title:LANG.cc_sdwn_l, convert:UC.toFloat, units:true}),
step: UC.newInput(LANG.cc_sovr_s, {title:LANG.cc_sovr_l, convert:UC.toFloat, bound:UC.bound(0.01,1.0)}),
rate: UC.newInput(LANG.cc_feed_s, {title:LANG.cc_feed_l, convert:UC.toInt, units:true}),
plunge: UC.newInput(LANG.cc_plng_s, {title:LANG.cc_plng_l, convert:UC.toInt, units:true}),
leave: UC.newInput(LANG.cr_lsto_s, {title:LANG.cr_lsto_l, convert:UC.toFloat, units:true}),
sep: UC.newBlank({class:"pop-sep"}),
voids: UC.newBoolean(LANG.cr_clrp_s, undefined, {title:LANG.cr_clrp_l}),
flats: UC.newBoolean(LANG.cr_clrf_s, undefined, {title:LANG.cr_clrf_l}),
top: UC.newBoolean(LANG.cr_clrt_s, undefined, {title:LANG.cr_clrt_l}),
inside: UC.newBoolean(LANG.cr_olin_s, undefined, {title:LANG.cr_olin_l}),
};
createPopOp('outline').inputs = {
tool: UC.newSelect(LANG.cc_tool, {}, "tools"),
sep: UC.newBlank({class:"pop-sep"}),
spindle: UC.newInput(LANG.cc_spnd_s, {title:LANG.cc_spnd_l, convert:UC.toInt, show:hasSpindle}),
down: UC.newInput(LANG.cc_sdwn_s, {title:LANG.cc_sdwn_l, convert:UC.toFloat, units:true}),
step: UC.newInput(LANG.cc_sovr_s, {title:LANG.cc_sovr_l, convert:UC.toFloat, bound:UC.bound(0.01,1.0)}),
rate: UC.newInput(LANG.cc_feed_s, {title:LANG.cc_feed_l, convert:UC.toInt, units:true}),
plunge: UC.newInput(LANG.cc_plng_s, {title:LANG.cc_plng_l, convert:UC.toInt, units:true}),
sep: UC.newBlank({class:"pop-sep"}),
dogbones: UC.newBoolean(LANG.co_dogb_s, undefined, {title:LANG.co_dogb_l, show:(op) => { return !op.inputs.wide.checked }}),
inside: UC.newBoolean(LANG.co_olin_s, undefined, {title:LANG.co_olin_l, show:(op) => { return !op.inputs.outside.checked }}),
outside: UC.newBoolean(LANG.co_olot_s, undefined, {title:LANG.co_olot_l, show:(op) => { return !op.inputs.inside.checked }}),
wide: UC.newBoolean(LANG.co_wide_s, undefined, {title:LANG.co_wide_l, show:(op) => { return !op.inputs.inside.checked }}),
};
};
function createPopOp(type) {
let op = popOp[type] = {
div: UC.newElement('div', { id:`${type}-op`, class:"cam-pop-op" }),
use: (rec) => {
op.rec = rec;
API.util.rec2ui(rec, op.inputs);
op.hideshow();
},
using: (rec) => {
return op.rec === rec;
},
bind: (ev) => {
API.util.ui2rec(op.rec, op.inputs);
API.conf.save();
op.hideshow();
},
hideshow: () => {
for (let inp of Object.values(op.inputs)) {
let parent = inp.parentElement;
if (parent.setVisible && parent.__opt.show) {
parent.setVisible(parent.__opt.show(op));
}
}
},
group: []
};
UC.restore({
addTo: op.div,
bindTo: op.bind,
lastDiv: op.div,
lastGroup: op.group
});
return op;
}
function createTabBox(iw, ic, n) {
const { track } = iw;
const { stock, bounds, process } = API.conf.get();

View file

@ -548,7 +548,19 @@ th, tr, td, label {
background-color: var(--bg-gray);
margin-left: 1px;
}
#oplist div {
.cam-pop-op {
text-align: left;
position: absolute;
white-space: nowrap;
flex-direction: column;
bottom: 40px;
background-color: rgba(255,255,255,0.8);
border: 1px solid #aaa;
border-radius: 5px;
margin-right: 5px;
padding: 5px;
}
#oplist > div {
display: flex;
flex-direction: column;
align-items: center;