checkpoint WireEDM surface selection and menu re-org

This commit is contained in:
Stewart Allen 2024-06-10 21:54:25 -07:00
commit 5eb795606b
8 changed files with 128 additions and 20 deletions

View file

@ -905,7 +905,7 @@ CAM.init = function(kiri, api) {
let radians = poppedRec.follow * DEG2RAD;
CAM.surface_prep(currentIndex * RAD2DEG, () => {
api.hide.alert(alert);
alert = api.show.alert("[esc] cancels surface editing");
alert = api.show.alert("[esc] cancels surface selection");
for (let [wid, arr] of Object.entries(surfaces)) {
let widget = api.widgets.forid(wid);
if (widget && arr.length)

View file

@ -15,6 +15,7 @@ const { polygons, newPoint } = base;
const POLY = polygons;
const DRIVER = driver.LASER = {
name: 'Laser',
init,
slice,
prepare,
@ -24,7 +25,7 @@ const DRIVER = driver.LASER = {
exportDXF
};
function init(kiri, api) {
function init(kiri, api, driver) {
api.event.on("settings.saved", settings => {
let ui = kiri.api.ui;
});

View file

@ -5,7 +5,105 @@
// dep: kiri-mode.laser.driver
gapp.register("kiri-mode.wedm.driver", [], (root, exports) => {
root.kiri.driver.WEDM = root.kiri.driver.LASER;
const { kiri, moto } = root;
const DRIVERS = kiri.driver;
const { CAM, LASER } = DRIVERS;
const WEDM = DRIVERS.WEDM = Object.assign({}, LASER, { name: "WireEDM" });
const DEG2RAD = Math.PI / 180;
const state = {
api: undefined,
alert: undefined,
radians: 0,
surfaces: [],
selecting: false
};
function faceAdd() {
if (state.selecting) return faceDone();
const { api, radians, surfaces } = state;
CAM.surface_prep(radians, () => {
api.hide.alert(alert);
state.alert = api.show.alert("[esc] cancels surface selection");
for (let [wid, arr] of Object.entries(surfaces)) {
let widget = api.widgets.forid(wid);
if (widget && arr.length)
for (let faceid of arr) {
CAM.surface_toggle(widget, faceid, radians, faceids => {
// surfaces[widget.id] = faceids;
});
}
}
api.feature.on_mouse_up = (obj, ev) => {
let { face } = obj;
let min = Math.min(face.a, face.b, face.c);
let faceid = min / 3;
let widget = obj.object.widget;
CAM.surface_toggle(widget, faceid, radians, faceids => {
surfaces[widget.id] = faceids;
});
};
state.selecting = true;
});
}
function faceDone() {
if (!state.selecting) return;
const { api, alert, surfaces } = state;
for (let wid of Object.keys(surfaces)) {
let widget = api.widgets.forid(wid);
if (widget) {
CAM.surface_clear(widget);
} else {
delete surfaces[wid];
}
}
api.hide.alert(alert);
api.feature.on_mouse_up = undefined;
api.ui.faceAdd.classList.remove('editing')
state.selecting = false;
}
WEDM.init = (kiri, api, driver) => {
LASER.init(kiri, api, driver);
state.api = api;
api.event.on("key.esc", () => {
if (state.selecting) {
faceDone();
}
});
api.event.on("mode.set", (mode) => {
console.log({ dev_mode: mode });
});
api.event.on("view.set", (mode) => {
console.log({ view_mode: mode });
});
// Surface Selection Buttons
api.event.on("button.click", target => {
let process = api.conf.get().process;
switch (target) {
case api.ui.faceAdd:
target.classList.add('editing');
return faceAdd();
case api.ui.faceDun:
return faceDone();
case api.ui.faceClr:
api.uc.confirm("clear surface selection?").then(ok => {
// todo
});
break;
}
});
};
});

View file

@ -5,7 +5,8 @@
// dep: kiri-mode.laser.driver
gapp.register("kiri-mode.wjet.driver", [], (root, exports) => {
root.kiri.driver.WJET = root.kiri.driver.LASER;
const DRIVERS = root.kiri.driver;
DRIVERS.WJET = Object.assign({}, DRIVERS.LASER, { name: 'WaterJet' });
});

View file

@ -26,6 +26,7 @@ gapp.register("kiri.init", [], (root, exports) => {
STARTMODE = SETUP.sm && SETUP.sm.length === 1 ? SETUP.sm[0] : null,
{ CAM, SLA, FDM, LASER, DRAG, WJET, WEDM } = MODES,
TWOD = [LASER, DRAG, WJET, WEDM],
TWONED= [LASER, DRAG, WJET],
THREED = [FDM, CAM, SLA],
GCODE = [FDM, CAM, ...TWOD],
CAM_LZR = [CAM, ...TWOD],
@ -1941,28 +1942,34 @@ gapp.register("kiri.init", [], (root, exports) => {
_____: newGroup(LANG.sl_menu, $('lzr-slice'), { modes:TWOD, driven, separator }),
ctSliceKerf: newInput(LANG.ls_offs_s, {title:LANG.ls_offs_l, convert:toFloat}),
ctSliceHeight: newInput(LANG.ls_lahi_s, {title:LANG.ls_lahi_l, convert:toFloat, trigger: true}),
ctSliceHeightMin: newInput(LANG.ls_lahm_s, {title:LANG.ls_lahm_l, convert:toFloat, show:() => ui.ctSliceHeight.value == 0 && !ui.ctSliceSingle.checked }),
separator: newBlank({ class:"set-sep", driven }),
ctSliceSingle: newBoolean(LANG.ls_sngl_s, onBooleanClick, {title:LANG.ls_sngl_l}),
knife: newGroup(LANG.dk_menu, $('lzr-knife'), { modes:DRAG, marker:true, driven, separator }),
ctSliceHeight: newInput(LANG.ls_lahi_s, {title:LANG.ls_lahi_l, convert:toFloat, trigger: true, modes:TWONED}),
ctSliceHeightMin: newInput(LANG.ls_lahm_s, {title:LANG.ls_lahm_l, convert:toFloat, modes:TWONED, show:() => ui.ctSliceHeight.value == 0 && !ui.ctSliceSingle.checked }),
separator: newBlank({ class:"set-sep", driven, modes:TWONED }),
ctSliceSingle: newBoolean(LANG.ls_sngl_s, onBooleanClick, {title:LANG.ls_sngl_l, modes:TWONED}),
_____: newGroup('surfaces', $('lzr-surface'), { modes:WEDM, driven, separator }),
ctSurfaces: newRow([
(ui.faceAdd = newButton(undefined, onButtonClick, {icon:'<i class="fas fa-plus"></i>'})),
(ui.faceDun = newButton(undefined, onButtonClick, {icon:'<i class="fas fa-check"></i>'})),
(ui.faceClr = newButton(undefined, onButtonClick, {icon:'<i class="fas fa-trash-alt"></i>'}))
], {class:"ext-buttons f-row", modes:WEDM}),
_____: newGroup(LANG.dk_menu, $('lzr-knife'), { modes:DRAG, marker:true, driven, separator }),
ctOutKnifeDepth: newInput(LANG.dk_dpth_s, {title:LANG.dk_dpth_l, convert:toFloat, bound:bound(0.0,5.0) }),
ctOutKnifePasses: newInput(LANG.dk_pass_s, {title:LANG.dk_pass_l, convert:toInt, bound:bound(0,5) }),
ctOutKnifeTip: newInput(LANG.dk_offs_s, {title:LANG.dk_offs_l, convert:toFloat, bound:bound(0.0,10.0) }),
laserLayout: newGroup(LANG.lo_menu, $('lzr-layout'), { modes:TWOD, driven, separator }),
_____: newGroup(LANG.lo_menu, $('lzr-layout'), { modes:TWONED, driven, separator }),
ctOutTileSpacing: newInput(LANG.ou_spac_s, {title:LANG.ou_spac_l, convert:toInt}),
ctOutMerged: newBoolean(LANG.ou_mrgd_s, onBooleanClick, {title:LANG.ou_mrgd_l}),
ctOutGroup: newBoolean(LANG.ou_grpd_s, onBooleanClick, {title:LANG.ou_grpd_l, show:() => !ui.ctOutStack.checked}),
laserOutput: newGroup(LANG.ou_menu, $('lzr-output'), { modes:TWOD, driven, separator }),
_____: newGroup(LANG.ou_menu, $('lzr-output'), { modes:TWOD, driven, separator }),
ctOutPower: newInput(LANG.ou_powr_s, {title:LANG.ou_powr_l, convert:toInt, bound:bound(1,100)}),
ctOutSpeed: newInput(LANG.ou_sped_s, {title:LANG.ou_sped_l, convert:toInt}),
separator: newBlank({ class:"set-sep", driven }),
ctOriginBounds: newBoolean(LANG.or_bnds_s, onBooleanClick, {title:LANG.or_bnds_l}),
ctOriginCenter: newBoolean(LANG.or_cntr_s, onBooleanClick, {title:LANG.or_cntr_l}),
separator: newBlank({ class:"set-sep", driven }),
ctOutZColor: newBoolean(LANG.ou_layo_s, onBooleanClick, {title:LANG.ou_layo_l, show:() => { return ui.ctOutMerged.checked === false }}),
ctOutLayer: newBoolean(LANG.ou_layr_s, onBooleanClick, {title:LANG.ou_layr_l}),
ctOutStack: newBoolean(LANG.ou_lays_s, onBooleanClick, {title:LANG.ou_lays_l}),
ctOriginCenter: newBoolean(LANG.or_cntr_s, onBooleanClick, {title:LANG.or_cntr_l}),
separator: newBlank({ class:"set-sep", driven, modes:TWONED }),
ctOutZColor: newBoolean(LANG.ou_layo_s, onBooleanClick, {title:LANG.ou_layo_l, modes:TWONED, show:() => { return ui.ctOutMerged.checked === false }}),
ctOutLayer: newBoolean(LANG.ou_layr_s, onBooleanClick, {title:LANG.ou_layr_l, modes:TWONED}),
ctOutStack: newBoolean(LANG.ou_lays_s, onBooleanClick, {title:LANG.ou_lays_l, modes:TWONED}),
/** SLA SETTINGS */
@ -2481,7 +2488,7 @@ gapp.register("kiri.init", [], (root, exports) => {
// call driver initializations, if present
Object.values(kiri.driver).forEach(driver => {
if (driver.init) try {
driver.init(kiri, api);
driver.init(kiri, api, driver);
} catch (error) {
console.log({driver_init_fail: driver, error})
}

View file

@ -1314,7 +1314,7 @@ th, tr, td, label {
#oplist > div:hover, #op-add:hover {
background-color: var(--blue-4);
}
#oplist > div.editing {
#oplist > div.editing, #lzr-surface button.editing {
background-color: rgba(190,230,190,0.85);
}
#oplist .drag {

View file

@ -331,8 +331,9 @@
<div id="cam-output" class="set2-group mode-cam"></div>
<div id="cam-origin" class="set2-group mode-cam"></div>
<div id="cam-expert" class="set2-group mode-cam"></div>
<!-- LASER -->
<!-- LASER / 2D Cut Tools -->
<div id="lzr-slice" class="set2-group mode-laser"></div>
<div id="lzr-surface" class="set2-group mode-laser"></div>
<div id="lzr-knife" class="set2-group mode-laser"></div>
<div id="lzr-layout" class="set2-group mode-laser"></div>
<div id="lzr-output" class="set2-group mode-laser"></div>

View file

@ -315,7 +315,7 @@ self.kiri.lang['en-us'] = {
se_save: "save",
// FDM LAYERS
sl_menu: "layers",
sl_menu: "paths",
sl_lahi_s: "layer height",
sl_lahi_l: ["height of each slice","layer in millimeters"],
ad_minl_s: "layer minimum",