add option for screenshot/thumbnail in gcode export
This commit is contained in:
parent
988dbc129f
commit
5ae6b74a3f
6 changed files with 47 additions and 6 deletions
|
|
@ -170,7 +170,7 @@
|
|||
return this.filter(v => isNaN(v)).length > 0;
|
||||
};
|
||||
|
||||
for(let i in AP){
|
||||
for (let i in AP) {
|
||||
Object.defineProperty(Array.prototype, i, {
|
||||
value: AP[i],
|
||||
enumerable: false
|
||||
|
|
@ -193,6 +193,14 @@
|
|||
return o ? JSON.parse(JSON.stringify(o)) : o;
|
||||
};
|
||||
|
||||
Object.toArray = function(o) {
|
||||
let ret = [];
|
||||
for (let [key,value] of Object.entries(o)) {
|
||||
ret.push({key, value});
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
Math.bound = function(val,min,max) {
|
||||
return Math.max(min,Math.min(max,val));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -686,6 +686,7 @@
|
|||
exportOcto: false,
|
||||
exportGhost: false,
|
||||
exportLocal: false,
|
||||
exportThumb: false,
|
||||
exportPreview: false,
|
||||
decimate: true,
|
||||
detail: "75",
|
||||
|
|
|
|||
|
|
@ -157,6 +157,7 @@
|
|||
control.exportOcto = UI.exportOcto.checked;
|
||||
control.exportGhost = UI.exportGhost.checked;
|
||||
control.exportLocal = UI.exportLocal.checked;
|
||||
control.exportThumb = UI.exportThumb.checked;
|
||||
control.exportPreview = UI.exportPreview.checked;
|
||||
control.decimate = UI.decimate.checked;
|
||||
control.healMesh = UI.healMesh.checked;
|
||||
|
|
@ -1644,6 +1645,7 @@
|
|||
exportOcto: UC.newBoolean(`OctoPrint`, booleanSave),
|
||||
exportGhost: UC.newBoolean(`Grid:Host`, booleanSave),
|
||||
exportLocal: UC.newBoolean(`Grid:Local`, booleanSave),
|
||||
exportThumb: UC.newBoolean(`Thumbnail`, booleanSave),
|
||||
exportPreview: UC.newBoolean(`Code Preview`, booleanSave),
|
||||
|
||||
parts: UC.newGroup(LANG.pt_menu, $('prefs-prt'), {inline: true}),
|
||||
|
|
|
|||
|
|
@ -992,8 +992,8 @@ console.log/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
|||
function prepareSlices(callback, scale = 1, offset = 0) {
|
||||
if (viewMode == VIEWS.ARRANGE) {
|
||||
let snap = SPACE.screenshot();
|
||||
API.view.snapshot = snap.substring(snap.indexOf(",")+1);
|
||||
KIRI.work.snap(API.view.snapshot);
|
||||
API.view.snapshot = snap.substring(snap.indexOf(",") + 1);
|
||||
KIRI.work.snap(SPACE.screenshot2());
|
||||
}
|
||||
if (MODE === MODES.SLA && !callback) {
|
||||
callback = preparePreview;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
FDM.export = function(print, online, ondone, ondebug) {
|
||||
let layers = print.output,
|
||||
settings = FDM.fixExtruders(print.settings),
|
||||
controller = settings.controller,
|
||||
thumbnails = controller.exportThumb,
|
||||
getRangeParameters = FDM.getRangeParameters,
|
||||
device = settings.device,
|
||||
extruders = device.extruders,
|
||||
|
|
@ -27,7 +29,7 @@
|
|||
zMoveMax = device.deviceZMax || 0,
|
||||
tool = 0,
|
||||
fwRetract = device.fwRetract,
|
||||
isDanger = settings.controller.danger,
|
||||
isDanger = controller.danger,
|
||||
isBelt = device.bedBelt,
|
||||
bedType = isBelt ? "belt" : "fixed",
|
||||
extruder = extruders[tool],
|
||||
|
|
@ -205,6 +207,16 @@
|
|||
appendSub("; Bed left:{left} right:{right} top:{top} bottom:{bottom}");
|
||||
append(`; Bed type: ${bedType}`);
|
||||
append(`; Target: ${settings.filter[settings.mode]}`);
|
||||
// inject thumbnail preview
|
||||
if (thumbnails && worker.snap) {
|
||||
let { width, height, url } = worker.snap;
|
||||
let data = url.substring(url.indexOf(',') + 1);
|
||||
append(`; thumbnail begin ${width} ${height} ${data.length}`);
|
||||
for (let i=0; i<data.length; i += 78) {
|
||||
append(`; ${data.substring(i, i + 78)}`);
|
||||
}
|
||||
append('; thumbnail end');
|
||||
}
|
||||
append("; --- process ---");
|
||||
for (let pk in process) {
|
||||
append("; " + pk + " = " + process[pk]);
|
||||
|
|
|
|||
|
|
@ -1027,8 +1027,26 @@
|
|||
return WC;
|
||||
},
|
||||
|
||||
screenshot: function(format) {
|
||||
return renderer.domElement.toDataURL(format || "image/png");
|
||||
screenshot: function(format, options) {
|
||||
return renderer.domElement.toDataURL(format || "image/png", options);
|
||||
},
|
||||
|
||||
screenshot2: function(param = {}) {
|
||||
let oco = renderer.domElement;
|
||||
let oWidth = oco.offsetWidth;
|
||||
let oHeight = oco.offsetHeight;
|
||||
let oRatio = oHeight / oWidth;
|
||||
let width = param.width || 240;
|
||||
let ncv = document.createElement('canvas');
|
||||
ncv.width = width;
|
||||
ncv.height = width * oRatio;
|
||||
let nco = ncv.getContext('2d');
|
||||
nco.drawImage(oco, 0, 0, ncv.width, ncv.height);
|
||||
return {
|
||||
url: ncv.toDataURL(param.format || "image/png", param.options),
|
||||
width: ncv.width,
|
||||
height: ncv.height
|
||||
};
|
||||
},
|
||||
|
||||
internals: function() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue