checkpoint WireEDM surface selection and menu re-org
This commit is contained in:
parent
3f0bf78d8b
commit
5eb795606b
8 changed files with 128 additions and 20 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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' });
|
||||
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue