add widget disable toggle. bump rev 3.2.D2
This commit is contained in:
parent
5788b800a8
commit
a2c282a072
16 changed files with 100 additions and 39 deletions
1
app.js
1
app.js
|
|
@ -331,6 +331,7 @@ const script = {
|
|||
"load/url",
|
||||
"load/file",
|
||||
"moto/broker",
|
||||
"moto/webui",
|
||||
"kiri/ui",
|
||||
"kiri/do",
|
||||
"kiri/pack",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "grid-apps",
|
||||
"version": "3.2.1D",
|
||||
"version": "3.2.2D",
|
||||
"description": "grid.space 3d slice & modeling tools",
|
||||
"author": "Stewart Allen <sa@grid.space>",
|
||||
"license": "MIT",
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
* @param {Object} [firstPoint] starting point
|
||||
*/
|
||||
CAM.prepare = function(widgets, settings, update) {
|
||||
widgets = widgets.filter(w => !w.track.ignore && !w.meta.disabled);
|
||||
|
||||
const count = widgets.length;
|
||||
const weight = 1/count;
|
||||
const print = self.worker.print = KIRI.newPrint(settings, widgets);
|
||||
|
|
@ -51,7 +53,7 @@
|
|||
|
||||
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,
|
||||
process = settings.process,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
*/
|
||||
FDM.prepare = function(widgets, settings, update) {
|
||||
// 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,
|
||||
{ device, process, controller, bounds, mode } = settings,
|
||||
|
|
|
|||
|
|
@ -98,9 +98,11 @@
|
|||
|
||||
FDM.sliceAll = function(settings, onupdate) {
|
||||
// future home of brim and anchor generation
|
||||
let widgets = Object.values(KIRI.worker.cache).sort((a,b) => {
|
||||
return a.slices[0].z - b.slices[0].z
|
||||
});
|
||||
let widgets = Object.values(KIRI.worker.cache)
|
||||
.filter(w => !w.meta.disabled)
|
||||
.sort((a,b) => {
|
||||
return a.slices[0].z - b.slices[0].z
|
||||
});
|
||||
// ignore first widget
|
||||
widgets.shift();
|
||||
// count extruders used
|
||||
|
|
|
|||
|
|
@ -148,6 +148,9 @@
|
|||
totalSlices = 0,
|
||||
slices = 0;
|
||||
|
||||
// filter ignored widgets
|
||||
widgets = widgets.filter(w => !w.track.ignore && !w.meta.disabled);
|
||||
|
||||
function arc(center, s1, s2, out) {
|
||||
let a1 = s1.angle;
|
||||
let a2 = s2.angle;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@
|
|||
mark = Date.now(),
|
||||
layermax = 0;
|
||||
|
||||
// filter ignored widgets
|
||||
widgets = widgets.filter(w => !w.track.ignore && !w.meta.disabled);
|
||||
|
||||
// find max layer count
|
||||
widgets.forEach(widget => {
|
||||
layermax = Math.max(widget.slices.length);
|
||||
|
|
|
|||
|
|
@ -163,6 +163,7 @@ KIRI.work = {
|
|||
let vertices = widget.getGeoVertices().buffer.slice(0);
|
||||
send("sync", {
|
||||
id: widget.id,
|
||||
meta: widget.meta,
|
||||
group: widget.group.id,
|
||||
track: widget.track,
|
||||
vertices: vertices,
|
||||
|
|
|
|||
|
|
@ -1527,8 +1527,14 @@
|
|||
speedbar: $('speedbar'),
|
||||
context: $('context-menu'),
|
||||
|
||||
options: {
|
||||
area: $('lt-options'),
|
||||
trash: $('lt-trash'),
|
||||
enable: $('lt-w-enable'),
|
||||
disable: $('lt-w-disable'),
|
||||
},
|
||||
|
||||
back: $('lt-back'),
|
||||
trash: $('lt-trash'),
|
||||
ltsetup: $('lt-setup'),
|
||||
ltfile: $('lt-file'),
|
||||
ltview: $('lt-view'),
|
||||
|
|
@ -2605,7 +2611,9 @@
|
|||
$('file-recent').onclick = () => { API.modal.show('files') };
|
||||
$('file-import').onclick = (ev) => { API.event.import(ev) };
|
||||
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.preview.onclick = (ev) => { ev.stopPropagation(); API.function.print() };
|
||||
UI.func.animate.onclick = (ev) => { ev.stopPropagation(); API.function.animate() };
|
||||
|
|
@ -2693,11 +2701,14 @@
|
|||
let tid = tt.getAttribute('target');
|
||||
let target = tid ? $(tid) : parentWithClass(tt, 'movable');
|
||||
target.style.display = 'none';
|
||||
tt.onmousedown = (ev) => {
|
||||
let close = tt.onmousedown = (ev) => {
|
||||
target.style.display = 'none';
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
if (ev) {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
}
|
||||
};
|
||||
API.event.on('key.esc', close);
|
||||
}
|
||||
// add drag behavior to movers
|
||||
[...document.getElementsByClassName('mover')].forEach(mover => {
|
||||
|
|
|
|||
|
|
@ -109,7 +109,13 @@
|
|||
update_bounds: updateSelectedBounds,
|
||||
update_info: updateSelectedInfo,
|
||||
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 = {
|
||||
|
|
@ -1130,7 +1136,7 @@
|
|||
API.conf.save();
|
||||
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
|
||||
for (let widget of slicing) {
|
||||
|
|
@ -1956,9 +1962,14 @@
|
|||
let selreal = selection.widgets();
|
||||
let selwid = selection.widgets(true);
|
||||
let selcount = selwid.length;
|
||||
let extruders = settings.device.extruders;
|
||||
UI.trash.style.display = selreal.length ? 'flex' : '';
|
||||
let { extruders } = settings.device;
|
||||
let { area, enable, disable } = UI.options;
|
||||
area.style.display = selreal.length ? 'flex' : '';
|
||||
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');
|
||||
if (feature.meta && selcount === 1) {
|
||||
let sel = selwid[0];
|
||||
|
|
@ -1983,6 +1994,8 @@
|
|||
UI.mesh.faces.innerText = '-';
|
||||
}
|
||||
} else {
|
||||
enable.style.display = 'none';
|
||||
disable.style.display = 'none';
|
||||
UI.mesh.name.innerText = '[0]';
|
||||
UI.mesh.points.innerText = '-';
|
||||
UI.mesh.faces.innerText = '-';
|
||||
|
|
@ -2001,6 +2014,10 @@
|
|||
if (b) b.classList.add('pop-sel');
|
||||
w.saveState();
|
||||
}, true);
|
||||
} else {
|
||||
forSelectedWidgets(w => {
|
||||
w.setColor(color.selected);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2186,25 +2203,24 @@
|
|||
}
|
||||
|
||||
function platformChanged() {
|
||||
let fts = $('ft-select');
|
||||
fts.innerHTML = '';
|
||||
for (let w of WIDGETS) {
|
||||
let b = DOC.createElement('button');
|
||||
fts.appendChild(b);
|
||||
b.innerText = w.meta.file || 'no name';
|
||||
h.bind($('ft-select'), WIDGETS.map(w => {
|
||||
let color;
|
||||
b.onmouseenter = function() {
|
||||
color = w.getColor();
|
||||
w.setColor(0x0088ff);
|
||||
};
|
||||
b.onmouseleave = function() {
|
||||
w.setColor(color);
|
||||
};
|
||||
b.onclick = function() {
|
||||
platformSelect(w, true, false);
|
||||
color = w.getColor();
|
||||
};
|
||||
}
|
||||
return [
|
||||
h.button({ _: w.meta.file || 'no name',
|
||||
onmouseenter() {
|
||||
color = w.getColor();
|
||||
w.setColor(0x0088ff);
|
||||
},
|
||||
onmouseleave() {
|
||||
w.setColor(color);
|
||||
},
|
||||
onclick() {
|
||||
platformSelect(w, true, false);
|
||||
color = w.getColor();
|
||||
}
|
||||
})
|
||||
]
|
||||
}));
|
||||
}
|
||||
|
||||
function platformSelectAll() {
|
||||
|
|
|
|||
|
|
@ -498,6 +498,19 @@ console.log/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
|||
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
|
||||
*/
|
||||
|
|
@ -512,7 +525,7 @@ console.log/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
|||
this.color = color;
|
||||
}
|
||||
let material = this.mesh.material;
|
||||
material.color.set(color);
|
||||
material.color.set(this.meta.disabled ? avgc(0x888888, color, 3) : color);
|
||||
};
|
||||
|
||||
PRO.getColor = function() {
|
||||
|
|
|
|||
|
|
@ -273,6 +273,8 @@ KIRI.worker = {
|
|||
wcache[data.id] = widget;
|
||||
// stored for possible future rotations
|
||||
widget.vertices = vertices;
|
||||
// restore meta
|
||||
widget.meta = data.meta;
|
||||
// restore tracking object
|
||||
widget.track = data.track;
|
||||
send.done(data.id);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
if (!self.kiri) {
|
||||
let kiri = self.kiri = {
|
||||
beta: 3201,
|
||||
beta: 3202,
|
||||
driver: {}, // driver modules
|
||||
loader: [], // module loading: array of functions
|
||||
load: (fn) => kiri.loader.push(fn)
|
||||
|
|
|
|||
|
|
@ -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: "3.2.D1"
|
||||
VERSION: "3.2.D2"
|
||||
};
|
||||
|
||||
if (typeof(module) === 'object') {
|
||||
|
|
|
|||
|
|
@ -647,11 +647,16 @@ th, tr, td, label {
|
|||
left: -5px;
|
||||
}
|
||||
|
||||
#lt-back, #lt-trash {
|
||||
#lt-back, #lt-options {
|
||||
flex-direction: row;
|
||||
position: absolute;
|
||||
display: none;
|
||||
gap: 5px;
|
||||
top: 0;
|
||||
}
|
||||
#lt-trash:hover, #lt-w-enable:hover, #lt-w-disable:hover {
|
||||
color: var(--main-color);
|
||||
}
|
||||
#act-sep, #lt-sep {
|
||||
border-top-right-radius: 3px;
|
||||
border-bottom-right-radius: 3px;
|
||||
|
|
|
|||
|
|
@ -80,8 +80,10 @@
|
|||
<div id="lt-back" class="lt-menu lt-enabled">
|
||||
<i class="fas fa-arrow-circle-left"></i>
|
||||
</div>
|
||||
<div id="lt-trash" class="lt-menu lt-enabled">
|
||||
<i class="fas fa-times-circle"></i>
|
||||
<div id="lt-options" class="lt-menu lt-enabled">
|
||||
<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 id="lt-top">
|
||||
<div id="float-tools" class="f-col movable">
|
||||
|
|
|
|||
Loading…
Reference in a new issue