add CAM tools export / import parity with devices and settings

This commit is contained in:
Stewart Allen 2022-10-30 00:33:10 -04:00
commit 889dce3051
7 changed files with 37 additions and 7 deletions

View file

@ -5,9 +5,10 @@ Full docs @ https://docs.grid.space/projects/kiri-moto
# Release 3.7
* replace jscad/modeling with Manifold project for faster mesh boolean
* various CAM gcode, preview, animation fixes
* various CAM gcode, preview, animation fixes (3 axis)
* various mobile touch, file load fixes
* add FDM slice support growth option to help merging pillars
* add CAM tools export / import parity with devices and settings
# Release 3.6 (2022-10-22)

View file

@ -1404,7 +1404,6 @@ function slicePrintPath(print, slice, startPoint, offset, output, opt = {}) {
break;
case "position":
startPoint = newPoint(-bedOffset.x+process.sliceLayerStartX, -bedOffset.y+process.sliceLayerStartY, startPoint.z);
console.log("startPoint", top);
break;
}

View file

@ -1286,7 +1286,6 @@ gapp.register("kiri.init", [], (root, exports) => {
function showTools() {
if (api.mode.get_id() !== MODES.CAM) return;
let selectedIndex = null;
editTools = settings().tools.slice().sort((a,b) => {
@ -1333,6 +1332,19 @@ gapp.register("kiri.init", [], (root, exports) => {
api.conf.update_fields();
api.event.settings();
};
ui.toolsExport.onclick = () => {
uc.prompt("Export Tools Filename", "tools").then(name => {
if (!name) {
return;
}
const record = {
version: kiri.version,
tools: api.conf.get().tools,
time: Date.now()
};
api.util.download(api.util.b64enc(record), `${name}.km`);
});
};
renderTools();
if (editTools.length > 0) {
@ -1346,6 +1358,9 @@ gapp.register("kiri.init", [], (root, exports) => {
ui.toolSelect.focus();
}
// not the best way to do this, but main decl of api.show is broken
api.show.tools = showTools;
function updateDeviceList() {
renderDevices(Object.keys(devices[api.mode.get_lower()]).sort());
}
@ -1638,6 +1653,7 @@ gapp.register("kiri.init", [], (root, exports) => {
toolsSave: $('tools-save'),
toolsClose: $('tools-close'),
toolsExport: $('tools-export'),
toolSelect: $('tool-select'),
toolAdd: $('tool-add'),
toolDelete: $('tool-del'),
@ -1904,6 +1920,7 @@ gapp.register("kiri.init", [], (root, exports) => {
camStockX: uc.newInput(LANG.cs_wdth_s, {title:LANG.cs_wdth_l, convert:uc.toFloat, bound:uc.bound(0,9999), modes:CAM, units:true}),
camStockY: uc.newInput(LANG.cs_dpth_s, {title:LANG.cs_dpth_l, convert:uc.toFloat, bound:uc.bound(0,9999), modes:CAM, units:true}),
camStockZ: uc.newInput(LANG.cs_hght_s, {title:LANG.cs_hght_l, convert:uc.toFloat, bound:uc.bound(0,9999), modes:CAM, units:true}),
camSep: uc.newBlank({class:"pop-sep"}),
camStockOffset: uc.newBoolean(LANG.cs_offs_s, onBooleanClick, {title:LANG.cs_offs_l, modes:CAM}),
camStockClipTo: uc.newBoolean(LANG.cs_clip_s, onBooleanClick, {title:LANG.cs_clip_l, modes:CAM}),
camStockIndexed: uc.newBoolean(LANG.cs_indx_s, onBooleanClick, {title:LANG.cs_indx_l, modes:CAM}),
@ -1912,6 +1929,7 @@ gapp.register("kiri.init", [], (root, exports) => {
camCommon: uc.newGroup(LANG.cc_menu, null, {modes:CAM}),
camZAnchor: uc.newSelect(LANG.ou_zanc_s, {title: LANG.ou_zanc_l, action:zAnchorSave, modes:CAM, trace:true}, "zanchor"),
camSep: uc.newBlank({class:"pop-sep"}),
camZOffset: uc.newInput(LANG.ou_ztof_s, {title:LANG.ou_ztof_l, convert:uc.toFloat, modes:CAM, units:true}),
camZBottom: uc.newInput(LANG.ou_zbot_s, {title:LANG.ou_zbot_l, convert:uc.toFloat, modes:CAM, units:true, trigger: true}),
camZThru: uc.newInput(LANG.ou_ztru_s, {title:LANG.ou_ztru_l, convert:uc.toFloat, bound:uc.bound(0.0,100), modes:CAM, units:true, show:() => { return ui.camZBottom.value == 0 }}),

View file

@ -159,6 +159,7 @@ gapp.register("kiri.main", [], (root, exports) => {
slices: showSlices,
layer: setVisibleLayer,
local: showLocal,
tools: noop, // set during init
import: function() { UI.import.style.display = '' }
},
space: {
@ -234,8 +235,10 @@ gapp.register("kiri.main", [], (root, exports) => {
pos.y /= sel.length;
pos.z /= sel.length;
}
SPACE.platform.setCenter(pos.x, -pos.y, platform.top_z() / 2);
SPACE.view.setFocus(new THREE.Vector3(pos.x, platform.top_z() / 2, -pos.y));
let cam_index = api.conf.get().process.camStockIndexed || false;
let focus_z = cam_index ? 0 : platform.top_z() / 2;
SPACE.platform.setCenter(pos.x, -pos.y, focus_z);
SPACE.view.setFocus(new THREE.Vector3(pos.x, focus_z, -pos.y));
}
function reload() {

View file

@ -186,6 +186,7 @@ function rotate(x, y, z) {
selection.update_bounds();
api.platform.update_bounds();
api.platform.compute_max_z();
api.platform.update_top_z();
api.event.emit('selection.rotate', {x, y, z});
selection.update_info();
api.space.auto_save();

View file

@ -516,8 +516,9 @@ function settingsImport(data, ask) {
let isSettings = (data.settings && data.version && data.time);
let isProcess = (data.process && data.version && data.time && data.mode && data.name);
let isDevice = (data.device && data.version && data.time);
let isTools = (data.tools && data.version && data.time)
let isWork = (data.work);
if (!isSettings && !isDevice && !isProcess) {
if (!isSettings && !isDevice && !isProcess && !isTools) {
uc.alert('invalid settings or device format');
console.log('data',data);
return;
@ -574,12 +575,17 @@ function settingsImport(data, ask) {
restoreSettings();
api.space.restore(() => { ui.sync() }, true);
}
if (isTools && Array.isArray(data.tools)) {
settings.tools = data.tools;
api.show.tools();
}
}
if (ask) {
let opt = {};
let prompt = isDevice ?
`Import device "${data.device}"?` : isProcess ?
`Import process "${data.name}"?` :
`Import process "${data.name}"?` : isTools ?
`Import tool definitions?`:
`Import settings made in Kiri:Moto version ${data.version} on<br>${new Date(data.time)}?`;
if (data.screen) {
opt.pre = [

View file

@ -420,6 +420,8 @@
<div class="t-pad2"></div>
<button id="tools-save" lk="save">save</button>
<button id="tools-close" lk="done">done</button>
<div class="t-pad2"></div>
<button id="tools-export" lk="export">export</button>
</div>
</div>
</div>