mark current mode, move remainder of mesh tool icons, cleanup colors
This commit is contained in:
parent
38f556736a
commit
c10af8126b
8 changed files with 95 additions and 160 deletions
|
|
@ -123,7 +123,7 @@ CAM.init = function(kiri, api) {
|
|||
|
||||
// wire up animate button in ui
|
||||
api.event.on("function.animate", (mode) => {
|
||||
if (isAnimate) {
|
||||
if (isAnimate || !isCamMode) {
|
||||
return;
|
||||
}
|
||||
api.function.prepare(() => {
|
||||
|
|
@ -1809,6 +1809,7 @@ function animate() {
|
|||
API.hide.slider();
|
||||
STACKS.clear();
|
||||
animFn().animate(API);
|
||||
API.view.set_animate();
|
||||
}
|
||||
|
||||
function updateStock() {
|
||||
|
|
|
|||
|
|
@ -133,7 +133,8 @@ const MODES = {
|
|||
const VIEWS = {
|
||||
ARRANGE: 1,
|
||||
SLICE: 2,
|
||||
PREVIEW: 3
|
||||
PREVIEW: 3,
|
||||
ANIMATE: 4
|
||||
};
|
||||
|
||||
// preview modes
|
||||
|
|
|
|||
|
|
@ -380,8 +380,7 @@ function prepareAnimation() {
|
|||
api.alerts.show("window prevents animations");
|
||||
return;
|
||||
}
|
||||
const settings = api.conf.get();
|
||||
api.event.emit("function.animate", {mode: settings.mode});
|
||||
api.event.emit("function.animate", {mode: api.conf.get().mode});
|
||||
}
|
||||
|
||||
function prepareExport() {
|
||||
|
|
|
|||
|
|
@ -1633,7 +1633,7 @@ gapp.register("kiri.init", [], (root, exports) => {
|
|||
ltact: $('lt-start'),
|
||||
edit: $('lt-tools'),
|
||||
nozzle: $('menu-nozzle'),
|
||||
render: $('menu-render'),
|
||||
// render: $('menu-render'),
|
||||
|
||||
modal: $('modal'),
|
||||
modalBox: $('modal-box'),
|
||||
|
|
@ -1794,7 +1794,7 @@ gapp.register("kiri.init", [], (root, exports) => {
|
|||
shiny: newBoolean(LANG.op_shny_s, booleanSave, {title:LANG.op_shny_l, modes:FDM}),
|
||||
lineType: newSelect(LANG.op_line_s, {title: LANG.op_line_l, action: lineTypeSave, modes:FDM}, "linetype"),
|
||||
animesh: newSelect(LANG.op_anim_s, {title: LANG.op_anim_l, action: aniMeshSave, modes:CAM}, "animesh"),
|
||||
units: newSelect(LANG.op_unit_s, {title: LANG.op_unit_l, action: unitsSave, modes:CAM, trace:true}, "units"),
|
||||
units: newSelect(LANG.op_unit_s, {title: LANG.op_unit_l, action: unitsSave, modes:CAM, trace:false}, "units"),
|
||||
layout: newGroup(LANG.lo_menu, $('prefs-lay'), {inline: true}),
|
||||
autoSave: newBoolean(LANG.op_save_s, booleanSave, {title:LANG.op_save_l}),
|
||||
autoLayout: newBoolean(LANG.op_auto_s, booleanSave, {title:LANG.op_auto_l}),
|
||||
|
|
@ -1819,7 +1819,7 @@ gapp.register("kiri.init", [], (root, exports) => {
|
|||
|
||||
_____: newGroup(LANG.sl_menu, $('fdm-layers'), { modes:FDM, driven, separator }),
|
||||
sliceHeight: newInput(LANG.sl_lahi_s, { title:LANG.sl_lahi_l, convert:toFloat }),
|
||||
sliceMinHeight: newInput(LANG.ad_minl_s, { title:LANG.ad_minl_l, convert:toFloat, bound:bound(0,3.0), show:() => ui.sliceAdaptive.checked, trace2:true }),
|
||||
sliceMinHeight: newInput(LANG.ad_minl_s, { title:LANG.ad_minl_l, convert:toFloat, bound:bound(0,3.0), show:() => ui.sliceAdaptive.checked }),
|
||||
sliceTopLayers: newInput(LANG.sl_ltop_s, { title:LANG.sl_ltop_l, convert:toInt }),
|
||||
sliceBottomLayers: newInput(LANG.sl_lbot_s, { title:LANG.sl_lbot_l, convert:toInt }),
|
||||
separator: newBlank({ class:"set-sep", driven }),
|
||||
|
|
@ -1858,7 +1858,7 @@ gapp.register("kiri.init", [], (root, exports) => {
|
|||
sliceSupportExtra: newInput(LANG.sp_xpnd_s, {title:LANG.sp_xpnd_l, convert:toFloat, bound:bound(0.0,10.0)}),
|
||||
sliceSupportGrow: newInput(LANG.sp_grow_s, {title:LANG.sp_grow_l, convert:toFloat, bound:bound(0.0,10.0)}),
|
||||
sliceSupportAngle: newInput(LANG.sp_angl_s, {title:LANG.sp_angl_l, convert:toFloat, bound:bound(0.0,90.0)}),
|
||||
sliceSupportSpan: newInput(LANG.sp_span_s, {title:LANG.sp_span_l, convert:toFloat, bound:bound(0.0,200.0), show:() => ui.sliceSupportEnable.checked, trace2:false }),
|
||||
sliceSupportSpan: newInput(LANG.sp_span_s, {title:LANG.sp_span_l, convert:toFloat, bound:bound(0.0,200.0), show:() => ui.sliceSupportEnable.checked }),
|
||||
separator: newBlank({ class:"set-sep", driven }),
|
||||
sliceSupportEnable: newBoolean(LANG.sp_auto_s, onBooleanClick, {title:LANG.sp_auto_l, show:isNotBelt}),
|
||||
sliceSupportOutline: newBoolean(LANG.sp_outl_s, onBooleanClick, {title:LANG.sp_outl_l}),
|
||||
|
|
@ -1955,7 +1955,7 @@ gapp.register("kiri.init", [], (root, exports) => {
|
|||
camStockIndexed: newBoolean(LANG.cs_indx_s, onBooleanClick, {title:LANG.cs_indx_l}),
|
||||
camStockIndexGrid: newBoolean(LANG.cs_ishg_s, onBooleanClick, {title:LANG.cs_ishg_l, show:() => ui.camStockIndexed.checked}),
|
||||
camLimits: newGroup(LANG.cc_menu, $('cam-limits'), { modes:CAM, driven, separator }),
|
||||
camZAnchor: newSelect(LANG.ou_zanc_s, {title: LANG.ou_zanc_l, action:zAnchorSave, trace:true, show:() => !ui.camStockIndexed.checked}, "zanchor"),
|
||||
camZAnchor: newSelect(LANG.ou_zanc_s, {title: LANG.ou_zanc_l, action:zAnchorSave, trace:false, show:() => !ui.camStockIndexed.checked}, "zanchor"),
|
||||
camZOffset: newInput(LANG.ou_ztof_s, {title:LANG.ou_ztof_l, convert:toFloat, units:true}),
|
||||
camZBottom: newInput(LANG.ou_zbot_s, {title:LANG.ou_zbot_l, convert:toFloat, units:true, trigger: true}),
|
||||
camZThru: newInput(LANG.ou_ztru_s, {title:LANG.ou_ztru_l, convert:toFloat, bound:bound(0.0,100), units:true, show:() => { return ui.camZBottom.value == 0 }}),
|
||||
|
|
@ -2769,7 +2769,7 @@ gapp.register("kiri.init", [], (root, exports) => {
|
|||
$('view-back').onclick = space.view.back;
|
||||
$('view-left').onclick = space.view.left;
|
||||
$('view-right').onclick = space.view.right;
|
||||
$('view-clear').onclick = api.platform.clear;
|
||||
// $('view-clear').onclick = api.platform.clear;
|
||||
$('unrotate').onclick = () => {
|
||||
api.widgets.for(w => w.unrotate());
|
||||
api.selection.update_info();
|
||||
|
|
@ -2784,7 +2784,7 @@ gapp.register("kiri.init", [], (root, exports) => {
|
|||
$('rot_z_lt').onclick = () => { api.selection.rotate(0,0, d) };
|
||||
$('rot_z_gt').onclick = () => { api.selection.rotate(0,0,-d) };
|
||||
// rendering options
|
||||
$('render-hide').onclick = () => { api.view.wireframe(false, 0, 0); };
|
||||
// $('render-hide').onclick = () => { api.view.wireframe(false, 0, 0); };
|
||||
$('render-ghost').onclick = () => { api.view.wireframe(false, 0, api.view.is_arrange() ? 0.4 : 0.25); };
|
||||
$('render-wire').onclick = () => { api.view.wireframe(true, 0, api.space.is_dark() ? 0.25 : 0.5); };
|
||||
$('render-solid').onclick = () => { api.view.wireframe(false, 0, 1); };
|
||||
|
|
|
|||
|
|
@ -186,9 +186,11 @@ gapp.register("kiri.main", [], (root, exports) => {
|
|||
set_arrange() { api.view.set(VIEWS.ARRANGE) },
|
||||
set_slice() { api.view.set(VIEWS.SLICE) },
|
||||
set_preview() { api.view.set(VIEWS.PREVIEW) },
|
||||
set_animate() { api.view.set(VIEWS.ANIMATE) },
|
||||
is_arrange() { return viewMode === VIEWS.ARRANGE },
|
||||
is_slice() { return viewMode === VIEWS.SLICE },
|
||||
is_preview() { return viewMode === VIEWS.PREVIEW },
|
||||
is_animate() { return viewMode === VIEWS.ANIMATE },
|
||||
update_stack_labels: updateStackLabelState,
|
||||
update_slider_max: updateSliderMax,
|
||||
update_slider: updateSlider,
|
||||
|
|
@ -840,12 +842,13 @@ gapp.register("kiri.main", [], (root, exports) => {
|
|||
platform.deselect();
|
||||
selection.update_info();
|
||||
// disable clear in non-arrange modes
|
||||
$('view-clear').style.display = mode === VIEWS.ARRANGE ? '' : 'none';
|
||||
['view-arrange','act-slice','act-preview','act-animate'].forEach(el => {
|
||||
$(el).classList.remove('selected')
|
||||
});
|
||||
switch (mode) {
|
||||
case VIEWS.ARRANGE:
|
||||
$('view-arrange').classList.add('selected');
|
||||
api.function.clear_progress();
|
||||
// UI.back.style.display = '';
|
||||
UI.render.style.display = '';
|
||||
kiri.client.clear();
|
||||
STACKS.clear();
|
||||
hideSlider();
|
||||
|
|
@ -855,17 +858,18 @@ gapp.register("kiri.main", [], (root, exports) => {
|
|||
api.widgets.opacity(1);
|
||||
break;
|
||||
case VIEWS.SLICE:
|
||||
if (isCAM) UI.render.classList.add('hide');
|
||||
else UI.render.classList.remove('hide');
|
||||
$('act-slice').classList.add('selected');
|
||||
updateSpeeds();
|
||||
updateSliderMax();
|
||||
setWidgetVisibility(true);
|
||||
break;
|
||||
case VIEWS.PREVIEW:
|
||||
if (isCAM) UI.render.classList.add('hide');
|
||||
else UI.render.classList.remove('hide');
|
||||
$('act-preview').classList.add('selected');
|
||||
setWidgetVisibility(true);
|
||||
break;
|
||||
case VIEWS.ANIMATE:
|
||||
$('act-animate').classList.add('selected');
|
||||
break;
|
||||
default:
|
||||
console.log("invalid view mode: "+mode);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ gapp.register("kiri.ui", [], (root, exports) => {
|
|||
addTo = null,
|
||||
bindTo = null,
|
||||
groups = {},
|
||||
groupShow = {},
|
||||
groupSticky = false,
|
||||
groupName = undefined,
|
||||
hasModes = [],
|
||||
|
|
@ -24,10 +23,7 @@ gapp.register("kiri.ui", [], (root, exports) => {
|
|||
lastMode = null,
|
||||
lastExpert = true,
|
||||
letHoverPop = true,
|
||||
exitimer = undefined,
|
||||
NOMODE = "nomode",
|
||||
prefix = "tab",
|
||||
state = {},
|
||||
units = 1,
|
||||
lastChange = null,
|
||||
lastBtn = null,
|
||||
|
|
@ -167,8 +163,8 @@ gapp.register("kiri.ui", [], (root, exports) => {
|
|||
});
|
||||
}
|
||||
|
||||
function refresh(all) {
|
||||
setMode(lastMode, all ? false : true);
|
||||
function refresh() {
|
||||
setMode(lastMode);
|
||||
setters.forEach(input => {
|
||||
if (input.setv) {
|
||||
input.setv(input.real);
|
||||
|
|
@ -176,21 +172,9 @@ gapp.register("kiri.ui", [], (root, exports) => {
|
|||
});
|
||||
}
|
||||
|
||||
function setMode(mode, nohide) {
|
||||
console.log({ gs: groupShow });
|
||||
Object.keys(groupShow).forEach(group => {
|
||||
updateGroupShow(group);
|
||||
});
|
||||
function setMode(mode) {
|
||||
lastMode = mode;
|
||||
if (nohide) {
|
||||
for (let div of hasModes.filter(d => d.isBlank)) {
|
||||
div.setMode(div._group && !groupShow[div._group] ? NOMODE : mode);
|
||||
}
|
||||
return;
|
||||
}
|
||||
hasModes.forEach(function(div) {
|
||||
div.setMode(div._group && !groupShow[div._group] ? NOMODE : mode);
|
||||
});
|
||||
hasModes.forEach(div => div.setMode(mode));
|
||||
hidePoppers();
|
||||
}
|
||||
|
||||
|
|
@ -200,7 +184,7 @@ console.log({ gs: groupShow });
|
|||
}
|
||||
|
||||
function setHoverPop(bool) {
|
||||
letHoverPop = bool;
|
||||
// letHoverPop = bool;
|
||||
}
|
||||
|
||||
function checkpoint(at) {
|
||||
|
|
@ -274,14 +258,6 @@ console.log({ gs: groupShow });
|
|||
lastGroup = groups[group] = [];
|
||||
lastGroup.key = dbkey;
|
||||
groupName = group;
|
||||
groupShow[group] = state[dbkey] !== 'false';
|
||||
row.onclick = function(ev) {
|
||||
if (ev.target !== link && ev.target !== row) {
|
||||
return;
|
||||
}
|
||||
console.log({ toggleGroup: group, dbkey });
|
||||
toggleGroup(group, dbkey);
|
||||
};
|
||||
|
||||
return row;
|
||||
}
|
||||
|
|
@ -294,33 +270,7 @@ console.log({ gs: groupShow });
|
|||
}
|
||||
|
||||
function hidePoppers() {
|
||||
showGroup(undefined);
|
||||
}
|
||||
|
||||
function showGroup(groupname) {
|
||||
Object.keys(groups).forEach(name => {
|
||||
let group = groups[name];
|
||||
groupShow[name] = true;//state[group.key] = (groupname === name);
|
||||
updateGroupShow(name);
|
||||
});
|
||||
groupSticky = false;
|
||||
}
|
||||
|
||||
function toggleGroup(groupname, dbkey) {
|
||||
let show = state[dbkey] === 'true' || state[dbkey] === true;
|
||||
groupShow[groupname] = state[dbkey] = !show;
|
||||
// console.log({ state, show });
|
||||
updateGroupShow(groupname);
|
||||
}
|
||||
|
||||
function updateGroupShow(groupname) {
|
||||
let show = groupShow[groupname] ?? true;
|
||||
// console.log({ updateGroupShow: groupname, show: groupShow[groupname] });
|
||||
let group = groups[groupname];
|
||||
group.forEach(div => {
|
||||
if (show) div.setMode(lastMode);
|
||||
else div.setMode(NOMODE);
|
||||
});
|
||||
// showGroup(undefined);
|
||||
}
|
||||
|
||||
function bound(low,high) {
|
||||
|
|
@ -344,10 +294,8 @@ console.log({ gs: groupShow });
|
|||
function toFloat() {
|
||||
let nv = this.value !== '' ? parseFloat(this.value) : null;
|
||||
if (nv !== null && this.bound) nv = this.bound(nv);
|
||||
// this.value = nv;
|
||||
if (this.setv) {
|
||||
return this.setv(nv * units);
|
||||
// return this.real = (nv * units);
|
||||
} else {
|
||||
this.value = nv;
|
||||
}
|
||||
|
|
@ -381,6 +329,14 @@ console.log({ gs: groupShow });
|
|||
}
|
||||
}
|
||||
|
||||
function safecall(fn) {
|
||||
try {
|
||||
return fn();
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function addModeControls(el, opt = {}) {
|
||||
if (opt.trace2) {
|
||||
console.log({ AMC: el, opt, groupName });
|
||||
|
|
@ -399,20 +355,16 @@ console.log({ gs: groupShow });
|
|||
};
|
||||
el.setMode = function(mode) {
|
||||
let xprt = opt.expert === undefined || (opt.expert === lastExpert);
|
||||
let show = opt.show ? opt.show() : true;
|
||||
let show = opt.show ? safecall(opt.show) : true;
|
||||
let disp = opt.visible ? opt.visible() : true;
|
||||
if (opt.trace2) console.log({ setMode: el, xprt, show, disp, fn: el.__opt.show });
|
||||
if (opt.trace2) console.log({ setMode: el, mode, modes: el.modes, xprt, show, disp, fn: el.__opt.show });
|
||||
el.setVisible(el.hasMode(mode) && show && xprt && disp);
|
||||
}
|
||||
el.hasMode = function(mode) {
|
||||
if (mode === NOMODE) return false;
|
||||
if (!el.modes) return true;
|
||||
return el.modes.contains(mode);
|
||||
}
|
||||
if (opt.modes) {
|
||||
el.modes = opt.modes;
|
||||
hasModes.push(el);
|
||||
return el.modes.length === 0 || el.modes.contains(mode);
|
||||
}
|
||||
el.modes = opt.modes || [];
|
||||
hasModes.push(el);
|
||||
}
|
||||
|
||||
function newDiv(opt = {}) {
|
||||
|
|
@ -449,7 +401,6 @@ console.log({ gs: groupShow });
|
|||
|
||||
function newGCode(label, options) {
|
||||
let opt = options || {},
|
||||
// row = lastDiv,
|
||||
btn = DOC.createElement("button"),
|
||||
txt = DOC.createElement("textarea"),
|
||||
area = opt.area;
|
||||
|
|
|
|||
Loading…
Reference in a new issue