add widget disable toggle. bump rev 3.2.D2

This commit is contained in:
Stewart Allen 2022-01-24 21:54:50 -05:00
commit a2c282a072
16 changed files with 100 additions and 39 deletions

1
app.js
View file

@ -331,6 +331,7 @@ const script = {
"load/url", "load/url",
"load/file", "load/file",
"moto/broker", "moto/broker",
"moto/webui",
"kiri/ui", "kiri/ui",
"kiri/do", "kiri/do",
"kiri/pack", "kiri/pack",

View file

@ -1,6 +1,6 @@
{ {
"name": "grid-apps", "name": "grid-apps",
"version": "3.2.1D", "version": "3.2.2D",
"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

@ -21,6 +21,8 @@
* @param {Object} [firstPoint] starting point * @param {Object} [firstPoint] starting point
*/ */
CAM.prepare = function(widgets, settings, update) { CAM.prepare = function(widgets, settings, update) {
widgets = widgets.filter(w => !w.track.ignore && !w.meta.disabled);
const count = widgets.length; const count = widgets.length;
const weight = 1/count; const weight = 1/count;
const print = self.worker.print = KIRI.newPrint(settings, widgets); const print = self.worker.print = KIRI.newPrint(settings, widgets);
@ -51,7 +53,7 @@
function prepEach(widget, settings, print, firstPoint, update) { function prepEach(widget, settings, print, firstPoint, update) {
if (widget.camops.length === 0) return; if (widget.camops.length === 0 || widget.meta.disabled) return;
let device = settings.device, let device = settings.device,
process = settings.process, process = settings.process,

View file

@ -22,7 +22,7 @@
*/ */
FDM.prepare = function(widgets, settings, update) { FDM.prepare = function(widgets, settings, update) {
// filter ignored widgets // filter ignored widgets
widgets = widgets.filter(w => !w.track.ignore); widgets = widgets.filter(w => !w.track.ignore && !w.meta.disabled);
let render = settings.render !== false, let render = settings.render !== false,
{ device, process, controller, bounds, mode } = settings, { device, process, controller, bounds, mode } = settings,

View file

@ -98,9 +98,11 @@
FDM.sliceAll = function(settings, onupdate) { FDM.sliceAll = function(settings, onupdate) {
// future home of brim and anchor generation // future home of brim and anchor generation
let widgets = Object.values(KIRI.worker.cache).sort((a,b) => { let widgets = Object.values(KIRI.worker.cache)
return a.slices[0].z - b.slices[0].z .filter(w => !w.meta.disabled)
}); .sort((a,b) => {
return a.slices[0].z - b.slices[0].z
});
// ignore first widget // ignore first widget
widgets.shift(); widgets.shift();
// count extruders used // count extruders used

View file

@ -148,6 +148,9 @@
totalSlices = 0, totalSlices = 0,
slices = 0; slices = 0;
// filter ignored widgets
widgets = widgets.filter(w => !w.track.ignore && !w.meta.disabled);
function arc(center, s1, s2, out) { function arc(center, s1, s2, out) {
let a1 = s1.angle; let a1 = s1.angle;
let a2 = s2.angle; let a2 = s2.angle;

View file

@ -28,6 +28,9 @@
mark = Date.now(), mark = Date.now(),
layermax = 0; layermax = 0;
// filter ignored widgets
widgets = widgets.filter(w => !w.track.ignore && !w.meta.disabled);
// find max layer count // find max layer count
widgets.forEach(widget => { widgets.forEach(widget => {
layermax = Math.max(widget.slices.length); layermax = Math.max(widget.slices.length);

View file

@ -163,6 +163,7 @@ KIRI.work = {
let vertices = widget.getGeoVertices().buffer.slice(0); let vertices = widget.getGeoVertices().buffer.slice(0);
send("sync", { send("sync", {
id: widget.id, id: widget.id,
meta: widget.meta,
group: widget.group.id, group: widget.group.id,
track: widget.track, track: widget.track,
vertices: vertices, vertices: vertices,

View file

@ -1527,8 +1527,14 @@
speedbar: $('speedbar'), speedbar: $('speedbar'),
context: $('context-menu'), context: $('context-menu'),
options: {
area: $('lt-options'),
trash: $('lt-trash'),
enable: $('lt-w-enable'),
disable: $('lt-w-disable'),
},
back: $('lt-back'), back: $('lt-back'),
trash: $('lt-trash'),
ltsetup: $('lt-setup'), ltsetup: $('lt-setup'),
ltfile: $('lt-file'), ltfile: $('lt-file'),
ltview: $('lt-view'), ltview: $('lt-view'),
@ -2605,7 +2611,9 @@
$('file-recent').onclick = () => { API.modal.show('files') }; $('file-recent').onclick = () => { API.modal.show('files') };
$('file-import').onclick = (ev) => { API.event.import(ev) }; $('file-import').onclick = (ev) => { API.event.import(ev) };
UI.back.onclick = API.platform.layout; UI.back.onclick = API.platform.layout;
UI.trash.onclick = API.selection.delete; UI.options.trash.onclick = API.selection.delete;
UI.options.enable.onclick = API.selection.enable;
UI.options.disable.onclick = API.selection.disable;
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.animate.onclick = (ev) => { ev.stopPropagation(); API.function.animate() };
@ -2693,11 +2701,14 @@
let tid = tt.getAttribute('target'); let tid = tt.getAttribute('target');
let target = tid ? $(tid) : parentWithClass(tt, 'movable'); let target = tid ? $(tid) : parentWithClass(tt, 'movable');
target.style.display = 'none'; target.style.display = 'none';
tt.onmousedown = (ev) => { let close = tt.onmousedown = (ev) => {
target.style.display = 'none'; target.style.display = 'none';
ev.preventDefault(); if (ev) {
ev.stopPropagation(); ev.preventDefault();
ev.stopPropagation();
}
}; };
API.event.on('key.esc', close);
} }
// add drag behavior to movers // add drag behavior to movers
[...document.getElementsByClassName('mover')].forEach(mover => { [...document.getElementsByClassName('mover')].forEach(mover => {

View file

@ -109,7 +109,13 @@
update_bounds: updateSelectedBounds, update_bounds: updateSelectedBounds,
update_info: updateSelectedInfo, update_info: updateSelectedInfo,
delete: function() { platform.delete(selection.widgets()) }, delete: function() { platform.delete(selection.widgets()) },
export: exportSelection export: exportSelection,
enable() { selection.setDisabled(false) },
disable() { selection.setDisabled(true) },
setDisabled(bool) {
forSelectedWidgets(w => w.meta.disabled = bool);
platformUpdateSelected();
}
}; };
const platform = { const platform = {
@ -1130,7 +1136,7 @@
API.conf.save(); API.conf.save();
API.event.emit('slice.begin', getMode()); API.event.emit('slice.begin', getMode());
let slicing = WIDGETS.slice().filter(w => !w.track.ignore); let slicing = WIDGETS.slice().filter(w => !w.track.ignore && !w.meta.disabled);
// determing this widgets % of processing time estimated by vertex count // determing this widgets % of processing time estimated by vertex count
for (let widget of slicing) { for (let widget of slicing) {
@ -1956,9 +1962,14 @@
let selreal = selection.widgets(); let selreal = selection.widgets();
let selwid = selection.widgets(true); let selwid = selection.widgets(true);
let selcount = selwid.length; let selcount = selwid.length;
let extruders = settings.device.extruders; let { extruders } = settings.device;
UI.trash.style.display = selreal.length ? 'flex' : ''; let { area, enable, disable } = UI.options;
area.style.display = selreal.length ? 'flex' : '';
if (selcount) { if (selcount) {
let enaC = selwid.filter(w => w.meta.disabled !== true).length;
let disC = selwid.filter(w => w.meta.disabled === true).length;
enable.style.display = disC ? 'flex' : 'none';
disable.style.display = enaC ? 'flex' : 'none';
UI.nozzle.classList.add('lt-active'); UI.nozzle.classList.add('lt-active');
if (feature.meta && selcount === 1) { if (feature.meta && selcount === 1) {
let sel = selwid[0]; let sel = selwid[0];
@ -1983,6 +1994,8 @@
UI.mesh.faces.innerText = '-'; UI.mesh.faces.innerText = '-';
} }
} else { } else {
enable.style.display = 'none';
disable.style.display = 'none';
UI.mesh.name.innerText = '[0]'; UI.mesh.name.innerText = '[0]';
UI.mesh.points.innerText = '-'; UI.mesh.points.innerText = '-';
UI.mesh.faces.innerText = '-'; UI.mesh.faces.innerText = '-';
@ -2001,6 +2014,10 @@
if (b) b.classList.add('pop-sel'); if (b) b.classList.add('pop-sel');
w.saveState(); w.saveState();
}, true); }, true);
} else {
forSelectedWidgets(w => {
w.setColor(color.selected);
});
} }
} }
@ -2186,25 +2203,24 @@
} }
function platformChanged() { function platformChanged() {
let fts = $('ft-select'); h.bind($('ft-select'), WIDGETS.map(w => {
fts.innerHTML = '';
for (let w of WIDGETS) {
let b = DOC.createElement('button');
fts.appendChild(b);
b.innerText = w.meta.file || 'no name';
let color; let color;
b.onmouseenter = function() { return [
color = w.getColor(); h.button({ _: w.meta.file || 'no name',
w.setColor(0x0088ff); onmouseenter() {
}; color = w.getColor();
b.onmouseleave = function() { w.setColor(0x0088ff);
w.setColor(color); },
}; onmouseleave() {
b.onclick = function() { w.setColor(color);
platformSelect(w, true, false); },
color = w.getColor(); onclick() {
}; platformSelect(w, true, false);
} color = w.getColor();
}
})
]
}));
} }
function platformSelectAll() { function platformSelectAll() {

View file

@ -498,6 +498,19 @@ console.log/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
this.slices = null; this.slices = null;
}; };
function rgb(c) {
return [ c >> 16, (c >> 8) & 0xff , c & 0xff ];
}
function avgc(c1, c2, w) {
let r1 = rgb(c1);
let r2 = rgb(c2);
let d = (w + 2);
return ((r1[0] * w + r2[0]) / d) << 16
| ((r1[1] * w + r2[1]) / d) << 8
| ((r1[2] * w + r2[2]) / d);
}
/** /**
* @param {number} color * @param {number} color
*/ */
@ -512,7 +525,7 @@ console.log/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
this.color = color; this.color = color;
} }
let material = this.mesh.material; let material = this.mesh.material;
material.color.set(color); material.color.set(this.meta.disabled ? avgc(0x888888, color, 3) : color);
}; };
PRO.getColor = function() { PRO.getColor = function() {

View file

@ -273,6 +273,8 @@ KIRI.worker = {
wcache[data.id] = widget; wcache[data.id] = widget;
// stored for possible future rotations // stored for possible future rotations
widget.vertices = vertices; widget.vertices = vertices;
// restore meta
widget.meta = data.meta;
// restore tracking object // restore tracking object
widget.track = data.track; widget.track = data.track;
send.done(data.id); send.done(data.id);

View file

@ -6,7 +6,7 @@
if (!self.kiri) { if (!self.kiri) {
let kiri = self.kiri = { let kiri = self.kiri = {
beta: 3201, beta: 3202,
driver: {}, // driver modules driver: {}, // driver modules
loader: [], // module loading: array of functions loader: [], // module loading: array of functions
load: (fn) => kiri.loader.push(fn) load: (fn) => kiri.loader.push(fn)

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: "3.2.D1" VERSION: "3.2.D2"
}; };
if (typeof(module) === 'object') { if (typeof(module) === 'object') {

View file

@ -647,11 +647,16 @@ th, tr, td, label {
left: -5px; left: -5px;
} }
#lt-back, #lt-trash { #lt-back, #lt-options {
flex-direction: row;
position: absolute; position: absolute;
display: none; display: none;
gap: 5px;
top: 0; top: 0;
} }
#lt-trash:hover, #lt-w-enable:hover, #lt-w-disable:hover {
color: var(--main-color);
}
#act-sep, #lt-sep { #act-sep, #lt-sep {
border-top-right-radius: 3px; border-top-right-radius: 3px;
border-bottom-right-radius: 3px; border-bottom-right-radius: 3px;

View file

@ -80,8 +80,10 @@
<div id="lt-back" class="lt-menu lt-enabled"> <div id="lt-back" class="lt-menu lt-enabled">
<i class="fas fa-arrow-circle-left"></i> <i class="fas fa-arrow-circle-left"></i>
</div> </div>
<div id="lt-trash" class="lt-menu lt-enabled"> <div id="lt-options" class="lt-menu lt-enabled">
<i class="fas fa-times-circle"></i> <div id="lt-trash"><i class="fas fa-trash"></i></div>
<div id="lt-w-enable"><i class="fas fa-check-circle"></i></div>
<div id="lt-w-disable"><i class="fas fa-times-circle"></i></div>
</div> </div>
<div id="lt-top"> <div id="lt-top">
<div id="float-tools" class="f-col movable"> <div id="float-tools" class="f-col movable">