add kiri settings export / import
This commit is contained in:
parent
e9a04969ee
commit
81b6395113
6 changed files with 104 additions and 38 deletions
|
|
@ -10,6 +10,7 @@ var gs_kiri_init = exports;
|
||||||
if (self.kiri.init) return;
|
if (self.kiri.init) return;
|
||||||
|
|
||||||
let KIRI = self.kiri,
|
let KIRI = self.kiri,
|
||||||
|
MOTO = self.moto,
|
||||||
WIN = self.window,
|
WIN = self.window,
|
||||||
DOC = self.document,
|
DOC = self.document,
|
||||||
LOC = self.location,
|
LOC = self.location,
|
||||||
|
|
@ -434,6 +435,15 @@ var gs_kiri_init = exports;
|
||||||
}).request("/data/"+ settings().id + "/" + settings().ver, set);
|
}).request("/data/"+ settings().id + "/" + settings().ver, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function settingsExport() {
|
||||||
|
if (!confirm('Download Kiri:Moto Settings?')) return;
|
||||||
|
let json = API.conf.export();
|
||||||
|
let blob = new Blob([json], {type: "octet/stream"});
|
||||||
|
let url = WIN.URL.createObjectURL(blob);
|
||||||
|
$('help').innerHTML = `<a id="sexport" href="${url}" download="kiriconf.b64">x</a>`;
|
||||||
|
$('sexport').click();
|
||||||
|
}
|
||||||
|
|
||||||
function settingsSave() {
|
function settingsSave() {
|
||||||
API.dialog.hide();
|
API.dialog.hide();
|
||||||
let mode = API.mode.get(),
|
let mode = API.mode.get(),
|
||||||
|
|
@ -1218,6 +1228,9 @@ var gs_kiri_init = exports;
|
||||||
],[
|
],[
|
||||||
UI.setupTools =
|
UI.setupTools =
|
||||||
UC.newButton(LANG.su_tool, showTools, {modes:CAM})
|
UC.newButton(LANG.su_tool, showTools, {modes:CAM})
|
||||||
|
],[
|
||||||
|
UI.setupExport =
|
||||||
|
UC.newButton(LANG.su_xprt, settingsExport, {modes:ALL})
|
||||||
],[
|
],[
|
||||||
UI.localButton =
|
UI.localButton =
|
||||||
UC.newButton(LANG.su_locl, API.show.local, {modes:FDM_CAM, expert:true})
|
UC.newButton(LANG.su_locl, API.show.local, {modes:FDM_CAM, expert:true})
|
||||||
|
|
|
||||||
80
js/kiri.js
80
js/kiri.js
|
|
@ -106,7 +106,7 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
update_stock: platformUpdateStock,
|
update_stock: platformUpdateStock,
|
||||||
update_size: platformUpdateSize,
|
update_size: platformUpdateSize,
|
||||||
update_top_z: platformUpdateTopZ,
|
update_top_z: platformUpdateTopZ,
|
||||||
load_files: loadFiles,
|
load_files: platformLoadFiles,
|
||||||
group: platformGroup,
|
group: platformGroup,
|
||||||
group_done: platformGroupDone
|
group_done: platformGroupDone
|
||||||
};
|
};
|
||||||
|
|
@ -143,7 +143,9 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
save: saveSettings,
|
save: saveSettings,
|
||||||
show: showSettings,
|
show: showSettings,
|
||||||
update: updateSettings,
|
update: updateSettings,
|
||||||
restore: restoreSettings
|
restore: restoreSettings,
|
||||||
|
export: settingsExport,
|
||||||
|
import: settingsImport
|
||||||
},
|
},
|
||||||
color,
|
color,
|
||||||
const: {
|
const: {
|
||||||
|
|
@ -815,8 +817,12 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
* Selection Functions
|
* Selection Functions
|
||||||
******************************************************************* */
|
******************************************************************* */
|
||||||
|
|
||||||
function meshUpdateInfo(mesh) {
|
function updateSelectedInfo() {
|
||||||
if (!mesh) {
|
let bounds = new THREE.Box3();
|
||||||
|
forSelectedMeshes(mesh => {
|
||||||
|
bounds = bounds.union(mesh.getBoundingBox());
|
||||||
|
});
|
||||||
|
if (bounds.min.x === Infinity) {
|
||||||
if (selectedMeshes.length === 0) {
|
if (selectedMeshes.length === 0) {
|
||||||
UI.selWidth.innerHTML = '0';
|
UI.selWidth.innerHTML = '0';
|
||||||
UI.selDepth.innerHTML = '0';
|
UI.selDepth.innerHTML = '0';
|
||||||
|
|
@ -825,13 +831,15 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
UI.scaleY.value = '';
|
UI.scaleY.value = '';
|
||||||
UI.scaleZ.value = '';
|
UI.scaleZ.value = '';
|
||||||
}
|
}
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
let scale = unitScale();
|
let dx = bounds.max.x - bounds.min.x,
|
||||||
let {w, h, d} = mesh.widget.track.box;
|
dy = bounds.max.y - bounds.min.y,
|
||||||
UI.selWidth.innerHTML = UTIL.round(w/scale,2);
|
dz = bounds.max.z - bounds.min.z,
|
||||||
UI.selDepth.innerHTML = UTIL.round(h/scale,2);
|
scale = unitScale();
|
||||||
UI.selHeight.innerHTML = UTIL.round(d/scale,2);
|
UI.selWidth.innerHTML = UTIL.round(dx/scale,2);
|
||||||
|
UI.selDepth.innerHTML = UTIL.round(dy/scale,2);
|
||||||
|
UI.selHeight.innerHTML = UTIL.round(dz/scale,2);
|
||||||
UI.scaleX.value = 1;
|
UI.scaleX.value = 1;
|
||||||
UI.scaleY.value = 1;
|
UI.scaleY.value = 1;
|
||||||
UI.scaleZ.value = 1;
|
UI.scaleZ.value = 1;
|
||||||
|
|
@ -861,8 +869,8 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
z = parseFloat(UI.scaleZ.value || dv);
|
z = parseFloat(UI.scaleZ.value || dv);
|
||||||
forSelectedGroups(function (w) {
|
forSelectedGroups(function (w) {
|
||||||
w.scale(x,y,z);
|
w.scale(x,y,z);
|
||||||
meshUpdateInfo(w.mesh);
|
|
||||||
});
|
});
|
||||||
|
updateSelectedInfo();
|
||||||
UI.scaleX.value = 1;
|
UI.scaleX.value = 1;
|
||||||
UI.scaleY.value = 1;
|
UI.scaleY.value = 1;
|
||||||
UI.scaleZ.value = 1;
|
UI.scaleZ.value = 1;
|
||||||
|
|
@ -874,8 +882,8 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
function rotateSelection(x, y, z) {
|
function rotateSelection(x, y, z) {
|
||||||
forSelectedGroups(function (w) {
|
forSelectedGroups(function (w) {
|
||||||
w.rotate(x, y, z);
|
w.rotate(x, y, z);
|
||||||
meshUpdateInfo(w.mesh);
|
|
||||||
});
|
});
|
||||||
|
updateSelectedInfo();
|
||||||
platform.compute_max_z();
|
platform.compute_max_z();
|
||||||
platform.update_stock(true);
|
platform.update_stock(true);
|
||||||
SPACE.update();
|
SPACE.update();
|
||||||
|
|
@ -976,7 +984,7 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
selectedMeshes.push(mesh);
|
selectedMeshes.push(mesh);
|
||||||
API.event.emit('widget.select', widget);
|
API.event.emit('widget.select', widget);
|
||||||
widget.setColor(color.selected);
|
widget.setColor(color.selected);
|
||||||
meshUpdateInfo(mesh);
|
updateSelectedInfo();
|
||||||
}
|
}
|
||||||
platformUpdateSelected();
|
platformUpdateSelected();
|
||||||
SPACE.update();
|
SPACE.update();
|
||||||
|
|
@ -1012,7 +1020,7 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
widget.setColor(color.deselected);
|
widget.setColor(color.deselected);
|
||||||
platformUpdateSelected();
|
platformUpdateSelected();
|
||||||
SPACE.update();
|
SPACE.update();
|
||||||
meshUpdateInfo();
|
updateSelectedInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
function platformLoad(url, onload) {
|
function platformLoad(url, onload) {
|
||||||
|
|
@ -1395,7 +1403,41 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
SDB.setItem('ws-settings', JSON.stringify(settings));
|
SDB.setItem('ws-settings', JSON.stringify(settings));
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadFiles(files,group) {
|
function settingsImport(data, ask) {
|
||||||
|
if (typeof(data) === 'string') {
|
||||||
|
try {
|
||||||
|
data = JSON.parse(atob(data));
|
||||||
|
} catch (e) {
|
||||||
|
console.log({data})
|
||||||
|
alert('invalid settings format');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!(data.settings && data.moto && data.time)) {
|
||||||
|
alert('invalid settings format');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ask && !confirm(`Import settings made on ${new Date(data.time)} from Kiri:Moto version ${data.version}?`)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
settings = data.settings;
|
||||||
|
MOTO.restore(data.moto);
|
||||||
|
SDB.setItem('kiri-init', data.init || 2);
|
||||||
|
API.conf.save();
|
||||||
|
LOC.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
function settingsExport() {
|
||||||
|
return btoa(JSON.stringify({
|
||||||
|
settings: settings,
|
||||||
|
version: KIRI.version,
|
||||||
|
moto: MOTO.id,
|
||||||
|
init: SDB.getItem('kiri-init'),
|
||||||
|
time: Date.now()
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function platformLoadFiles(files,group) {
|
||||||
let loaded = files.length;
|
let loaded = files.length;
|
||||||
platform.group();
|
platform.group();
|
||||||
for (let i=0; i<files.length; i++) {
|
for (let i=0; i<files.length; i++) {
|
||||||
|
|
@ -1404,7 +1446,8 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
israw = lower.indexOf(".raw") > 0 || lower.indexOf('.') < 0,
|
israw = lower.indexOf(".raw") > 0 || lower.indexOf('.') < 0,
|
||||||
isstl = lower.indexOf(".stl") > 0,
|
isstl = lower.indexOf(".stl") > 0,
|
||||||
issvg = lower.indexOf(".svg") > 0,
|
issvg = lower.indexOf(".svg") > 0,
|
||||||
isgcode = lower.indexOf(".gcode") > 0 || lower.indexOf(".nc") > 0;
|
isgcode = lower.indexOf(".gcode") > 0 || lower.indexOf(".nc") > 0,
|
||||||
|
isset = lower.indexOf(".b64") > 0;
|
||||||
reader.file = files[i];
|
reader.file = files[i];
|
||||||
reader.onloadend = function (e) {
|
reader.onloadend = function (e) {
|
||||||
if (israw) platform.add(
|
if (israw) platform.add(
|
||||||
|
|
@ -1418,6 +1461,7 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
);
|
);
|
||||||
if (isgcode) loadCode(e.target.result, 'gcode');
|
if (isgcode) loadCode(e.target.result, 'gcode');
|
||||||
if (issvg) loadCode(e.target.result, 'svg');
|
if (issvg) loadCode(e.target.result, 'svg');
|
||||||
|
if (isset) settingsImport(e.target.result, true);
|
||||||
if (--loaded === 0) platform.group_done();
|
if (--loaded === 0) platform.group_done();
|
||||||
};
|
};
|
||||||
reader.readAsBinaryString(reader.file);
|
reader.readAsBinaryString(reader.file);
|
||||||
|
|
@ -1427,7 +1471,7 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
function loadFile() {
|
function loadFile() {
|
||||||
$('load-file').onchange = function(event) {
|
$('load-file').onchange = function(event) {
|
||||||
DBUG.log(event);
|
DBUG.log(event);
|
||||||
loadFiles(event.target.files);
|
platformLoadFiles(event.target.files);
|
||||||
};
|
};
|
||||||
$('load-file').click();
|
$('load-file').click();
|
||||||
// alert2("drag/drop STL files onto platform to import\nreload page to return to last saved state");
|
// alert2("drag/drop STL files onto platform to import\nreload page to return to last saved state");
|
||||||
|
|
@ -1757,7 +1801,7 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
var oldMode = viewMode;
|
var oldMode = viewMode;
|
||||||
viewMode = mode;
|
viewMode = mode;
|
||||||
platform.deselect();
|
platform.deselect();
|
||||||
meshUpdateInfo();
|
updateSelectedInfo();
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case VIEWS.ARRANGE:
|
case VIEWS.ARRANGE:
|
||||||
showLayerView(false);
|
showLayerView(false);
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,35 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var gs_moto_ajax = exports;
|
let gs_moto_ajax = exports;
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
if (!self.moto) self.moto = {};
|
let MOTO = self.moto;
|
||||||
if (self.moto.Ajax) return;
|
|
||||||
|
|
||||||
self.moto.Ajax = Ajax;
|
if (!MOTO) MOTO = self.moto = {};
|
||||||
self.moto.callAjax = function(url, handler) {
|
|
||||||
|
if (MOTO.Ajax) return;
|
||||||
|
|
||||||
|
MOTO.Ajax = Ajax;
|
||||||
|
|
||||||
|
MOTO.callAjax = function(url, handler) {
|
||||||
new Ajax(handler).request(url);
|
new Ajax(handler).request(url);
|
||||||
};
|
};
|
||||||
|
|
||||||
var STATES = [
|
let AP = Ajax.prototype,
|
||||||
|
KV = moto.KV,
|
||||||
|
KEY = "moto-ajax",
|
||||||
|
TIME = function() { return new Date().getTime() },
|
||||||
|
MOKEY = moto.id = KV.getItem(KEY) || (TIME().toString(36)+rnd()+rnd());
|
||||||
|
|
||||||
|
MOTO.restore = function(id) {
|
||||||
|
MOKEY = moto.id = id;
|
||||||
|
KV.setItem(KEY, MOKEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
KV.setItem(KEY, MOKEY);
|
||||||
|
|
||||||
|
let STATES = [
|
||||||
"request not initialized", // 0
|
"request not initialized", // 0
|
||||||
"server connection established", // 1
|
"server connection established", // 1
|
||||||
"request recieved", // 2
|
"request recieved", // 2
|
||||||
|
|
@ -34,18 +51,10 @@ var gs_moto_ajax = exports;
|
||||||
return Math.round(Math.random()*0xffffffff).toString(36);
|
return Math.round(Math.random()*0xffffffff).toString(36);
|
||||||
}
|
}
|
||||||
|
|
||||||
var AP = Ajax.prototype,
|
|
||||||
KV = moto.KV,
|
|
||||||
KEY = "moto-ajax",
|
|
||||||
TIME = function() { return new Date().getTime() },
|
|
||||||
MOKEY = KV.getItem(KEY) || (TIME().toString(36)+rnd()+rnd());
|
|
||||||
|
|
||||||
KV.setItem(KEY, MOKEY);
|
|
||||||
|
|
||||||
AP.onStateChange = function() {
|
AP.onStateChange = function() {
|
||||||
this.state = STATES[this.ajax.readyState];
|
this.state = STATES[this.ajax.readyState];
|
||||||
if (this.ajax.readyState === 4 && this.callback) {
|
if (this.ajax.readyState === 4 && this.callback) {
|
||||||
var status = this.ajax.status;
|
let status = this.ajax.status;
|
||||||
if (status >= 200 && status < 300) {
|
if (status >= 200 && status < 300) {
|
||||||
this.callback(this.ajax.responseType ? this.ajax.response : this.ajax.responseText, this.ajax);
|
this.callback(this.ajax.responseType ? this.ajax.response : this.ajax.responseText, this.ajax);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -64,7 +73,7 @@ var gs_moto_ajax = exports;
|
||||||
if (this.responseType) this.ajax.responseType = this.responseType;
|
if (this.responseType) this.ajax.responseType = this.responseType;
|
||||||
headers = headers || {};
|
headers = headers || {};
|
||||||
headers["X-Moto-Ajax"] = MOKEY;
|
headers["X-Moto-Ajax"] = MOKEY;
|
||||||
for (var k in headers) {
|
for (let k in headers) {
|
||||||
this.ajax.setRequestHeader(k, headers[k]);
|
this.ajax.setRequestHeader(k, headers[k]);
|
||||||
}
|
}
|
||||||
if (send) {
|
if (send) {
|
||||||
|
|
|
||||||
|
|
@ -529,7 +529,7 @@ var gs_moto_ui = exports;
|
||||||
b.appendChild(t);
|
b.appendChild(t);
|
||||||
b.onclick = function() {
|
b.onclick = function() {
|
||||||
if (compact) hidePoppers();
|
if (compact) hidePoppers();
|
||||||
action();
|
if (action) action();
|
||||||
};
|
};
|
||||||
|
|
||||||
if (options && options.class) {
|
if (options && options.class) {
|
||||||
|
|
|
||||||
5
notes.md
5
notes.md
|
|
@ -5,10 +5,8 @@
|
||||||
* `B` restore settings should restore all mode/device/settings (find corner cases)
|
* `B` restore settings should restore all mode/device/settings (find corner cases)
|
||||||
* `C` set page background color? or dark mode?
|
* `C` set page background color? or dark mode?
|
||||||
* `F` implement an in-app bug reporting system
|
* `F` implement an in-app bug reporting system
|
||||||
* `F` widget general add-ons (fdm supports, cam tabs)
|
|
||||||
* `F` extend mesh object to store raw + annotations (rot,scale,pos)
|
* `F` extend mesh object to store raw + annotations (rot,scale,pos)
|
||||||
* share raw data w/ dups, encode/decode
|
* share raw data w/ dups, encode/decode
|
||||||
* `F` remember object's original position/orientation for reset/multi-object import alignment
|
|
||||||
* `P` bail on decimation if it's proving ineffective
|
* `P` bail on decimation if it's proving ineffective
|
||||||
* `P` improve decimation speed by avoiding in/out of Point?
|
* `P` improve decimation speed by avoiding in/out of Point?
|
||||||
* `P` server-side processing (determine protocol and storage)
|
* `P` server-side processing (determine protocol and storage)
|
||||||
|
|
@ -18,6 +16,7 @@
|
||||||
# FDM
|
# FDM
|
||||||
|
|
||||||
* `B` check for support / brim intersections on first layer
|
* `B` check for support / brim intersections on first layer
|
||||||
|
* `F` detect M82 / M83 in the gcode header and use appropriate setting over device
|
||||||
* `F` manual support addition / control
|
* `F` manual support addition / control
|
||||||
* `F` polishing and other non-planar work
|
* `F` polishing and other non-planar work
|
||||||
* `F` gradient infill https://www.youtube.com/watch?v=hq53gsYREHU&feature=emb_logo
|
* `F` gradient infill https://www.youtube.com/watch?v=hq53gsYREHU&feature=emb_logo
|
||||||
|
|
@ -30,7 +29,7 @@
|
||||||
* `F` determine start point from gcode preamble
|
* `F` determine start point from gcode preamble
|
||||||
* `F` trim support offset from layer below
|
* `F` trim support offset from layer below
|
||||||
* `F` feather sharp tips by reducing extrusion in area of overlap
|
* `F` feather sharp tips by reducing extrusion in area of overlap
|
||||||
* `F` dual extruder and swapping extruder support
|
* `F` multi extruder and swapping extruder support
|
||||||
* `F` option to support interior bridges when 0% infill
|
* `F` option to support interior bridges when 0% infill
|
||||||
* `P` disable infill fingerprinting for gyroids
|
* `P` disable infill fingerprinting for gyroids
|
||||||
* `P` refactor thin fill to use outline and inside poly normal dist to self
|
* `P` refactor thin fill to use outline and inside poly normal dist to self
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ kiri.lang['en-us'] = {
|
||||||
su_devi: "Devices",
|
su_devi: "Devices",
|
||||||
su_tool: "Tools",
|
su_tool: "Tools",
|
||||||
su_locl: "Local",
|
su_locl: "Local",
|
||||||
|
su_xprt: "Export",
|
||||||
su_help: "Help",
|
su_help: "Help",
|
||||||
|
|
||||||
// FUNCTION
|
// FUNCTION
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue