diff --git a/src/kiri/conf.js b/src/kiri/conf.js index ef9ab755..43f7385f 100644 --- a/src/kiri/conf.js +++ b/src/kiri/conf.js @@ -544,7 +544,10 @@ freeLayout: true, autoLayout: true, alignTop: true, - units: "mm" + units: "mm", + exportOcto: true, + exportGhost: false, + exportLocal: false }, // for passing temporary slice hints (topo currently) synth: {}, diff --git a/src/kiri/export.js b/src/kiri/export.js index b9ef98eb..3758ccf3 100644 --- a/src/kiri/export.js +++ b/src/kiri/export.js @@ -427,52 +427,75 @@ $('output-time').value = [pad(hours),pad(mins),pad(secs)].join(':'); } - API.ajax("/kiri/output-gcode.html", function(html) { + fetch("/kiri/output-gcode.html").then(r => r.text()).then(html => { UI.print.innerHTML = html; + let set = API.conf.get(); + let fdm = MODE === MODES.FDM; + let octo = set.controller.exportOcto && MODE !== MODES.CAM; + let ghost = set.controller.exportGhost; + let local = set.controller.exportLocal; $('print-download').onclick = download; - $('print-octoprint').onclick = sendto_octoprint; - $('print-gridhost').onclick = sendto_gridhost; - $('print-gridlocal').onclick = sendto_gridlocal; - $('admin-gridlocal').onclick = admin_gridlocal; - $('print-filament-head').style.display = MODE === MODES.FDM ? '' : 'none'; - $('print-filament-info').style.display = MODE === MODES.FDM ? '' : 'none'; + $('print-filament-head').style.display = fdm ? '' : 'none'; + $('print-filament-info').style.display = fdm ? '' : 'none'; $('print-filename').value = filename; $('print-filesize').value = UTIL.comma(currentPrint.bytes); $('print-filament').value = Math.round(currentPrint.distance); - $('grid-host').onkeyup = gridhost_probe; - $('grid-apik').onkeyup = gridhost_probe; calcTime(); - if (MODE === MODES.FDM) { + if (fdm) { calcWeight(); } - octo_host = $('octo-host'); - octo_apik = $('octo-apik'); - if (MODE === MODES.CAM) { - $('send-to-octohead').style.display = 'none'; - $('send-to-octoprint').style.display = 'none'; - } else { - $('send-to-octohead').style.display = ''; - $('send-to-octoprint').style.display = ''; - } - // hide octoprint when hard-coded in the url - if (API.const.OCTO) { - $('ophost').style.display = 'none'; - $('opapik').style.display = 'none'; - $('ophint').style.display = 'none'; - $('send-to-gridhost').style.display = 'none'; - } - octo_host.value = SDB['octo-host'] || ''; - octo_apik.value = SDB['octo-apik'] || ''; - grid_host = $('grid-host'); - grid_apik = $('grid-apik'); - grid_target = $('grid-target'); - grid_target.onchange = function(ev) { - SDB['grid-target'] = grid_targets[grid_target.selectedIndex]; - }; - grid_host.value = SDB['grid-host'] || ''; - grid_apik.value = SDB['grid-apik'] || ''; - gridhost_probe(); - gridlocal_probe(); + + // octoprint setup + $('send-to-octohead').style.display = octo ? '' : 'none'; + $('send-to-octoprint').style.display = octo ? '' : 'none'; + if (octo) try { + $('print-octoprint').onclick = sendto_octoprint; + octo_host = $('octo-host'); + octo_apik = $('octo-apik'); + if (MODE === MODES.CAM) { + $('send-to-octohead').style.display = 'none'; + $('send-to-octoprint').style.display = 'none'; + } else { + $('send-to-octohead').style.display = ''; + $('send-to-octoprint').style.display = ''; + } + // hide octoprint when hard-coded in the url + if (API.const.OCTO) { + $('ophost').style.display = 'none'; + $('opapik').style.display = 'none'; + $('ophint').style.display = 'none'; + $('send-to-gridhost').style.display = 'none'; + } + octo_host.value = SDB['octo-host'] || ''; + octo_apik.value = SDB['octo-apik'] || ''; + } catch (e) { console.log(e) } + + // grid:host setup + $('send-to-hosthead').style.display = ghost ? '' : 'none'; + $('send-to-gridhost').style.display = ghost ? '' : 'none'; + if (ghost) try { + $('print-gridhost').onclick = sendto_gridhost; + $('grid-host').onkeyup = gridhost_probe; + $('grid-apik').onkeyup = gridhost_probe; + grid_host = $('grid-host'); + grid_apik = $('grid-apik'); + grid_target = $('grid-target'); + grid_target.onchange = function(ev) { + SDB['grid-target'] = grid_targets[grid_target.selectedIndex]; + }; + grid_host.value = SDB['grid-host'] || ''; + grid_apik.value = SDB['grid-apik'] || ''; + gridhost_probe(); + } catch (e) { console.log(e) } + + // grid:local setup + if (local) try { + gridlocal_probe(); + $('print-gridlocal').onclick = sendto_gridlocal; + $('admin-gridlocal').onclick = admin_gridlocal; + } catch (e) { console.log(e) } + + // show dialog API.modal.show('print'); }); } diff --git a/src/kiri/init.js b/src/kiri/init.js index 7d0ad8cf..dae241d6 100644 --- a/src/kiri/init.js +++ b/src/kiri/init.js @@ -90,6 +90,9 @@ control.reverseZoom = UI.reverseZoom.checked; control.thinRender = UI.thinRender.checked; control.dark = UI.dark.checked; + control.exportOcto = UI.exportOcto.checked; + control.exportGhost = UI.exportGhost.checked; + control.exportLocal = UI.exportLocal.checked; SPACE.view.setZoom(control.reverseZoom, control.zoomSpeed); platform.layout(); platform.update_stock(); @@ -1234,17 +1237,22 @@ gcodePre: UC.newText(LANG.dv_head_s, {title:LANG.dv_head_l, modes:GCODE, size:14, height:3, area:gcode}), gcodePost: UC.newText(LANG.dv_foot_s, {title:LANG.dv_foot_l, modes:GCODE, size:14, height:3, area:gcode}), - layout: UC.newGroup(LANG.op_menu, $('mod-prefs'), {inline: true}), - expert: UC.newBoolean(LANG.op_xprt_s, booleanSave, {title:LANG.op_xprt_l}), - dark: UC.newBoolean(LANG.op_dark_s, booleanSave, {title:LANG.op_dark_l}), - showOrigin: UC.newBoolean(LANG.op_show_s, booleanSave, {title:LANG.op_show_l, modes:GCODE}), - alignTop: UC.newBoolean(LANG.op_alig_s, booleanSave, {title:LANG.op_alig_l, modes:CAM}), - autoLayout: UC.newBoolean(LANG.op_auto_s, booleanSave, {title:LANG.op_auto_l}), - freeLayout: UC.newBoolean(LANG.op_free_s, booleanSave, {title:LANG.op_free_l, modes:ALL}), - reverseZoom: UC.newBoolean(LANG.op_invr_s, booleanSave, {title:LANG.op_invr_l, modes:ALL}), - thinRender: UC.newBoolean(LANG.op_thin_s, booleanSave, {title:LANG.op_thin_l, modes:ALL}), - units: UC.newSelect(LANG.op_unit_s, {title: LANG.op_unit_l, modes:CAM}, "units"), - prefadd: UC.checkpoint(), + layout: UC.newGroup(LANG.op_menu, $('prefs-gen'), {inline: true}), + expert: UC.newBoolean(LANG.op_xprt_s, booleanSave, {title:LANG.op_xprt_l}), + dark: UC.newBoolean(LANG.op_dark_s, booleanSave, {title:LANG.op_dark_l}), + showOrigin: UC.newBoolean(LANG.op_show_s, booleanSave, {title:LANG.op_show_l, modes:GCODE}), + alignTop: UC.newBoolean(LANG.op_alig_s, booleanSave, {title:LANG.op_alig_l, modes:CAM}), + autoLayout: UC.newBoolean(LANG.op_auto_s, booleanSave, {title:LANG.op_auto_l}), + freeLayout: UC.newBoolean(LANG.op_free_s, booleanSave, {title:LANG.op_free_l, modes:ALL}), + reverseZoom: UC.newBoolean(LANG.op_invr_s, booleanSave, {title:LANG.op_invr_l, modes:ALL}), + thinRender: UC.newBoolean(LANG.op_thin_s, booleanSave, {title:LANG.op_thin_l, modes:ALL}), + units: UC.newSelect(LANG.op_unit_s, {title: LANG.op_unit_l, modes:CAM}, "units"), + prefadd: UC.checkpoint(), + + export: UC.newGroup(LANG.xp_menu, $('prefs-out'), {inline: true}), + exportOcto: UC.newBoolean(`OctoPrint`, booleanSave), + exportGhost: UC.newBoolean(`Grid:Host`, booleanSave), + exportLocal: UC.newBoolean(`Grid:Local`, booleanSave), process: UC.newGroup(LANG.sl_menu, $('settings'), {modes:FDM_LASER}), sliceHeight: UC.newInput(LANG.sl_lahi_s, {title:LANG.sl_lahi_l, convert:UC.toFloat, modes:FDM}), diff --git a/web/kiri/index.html b/web/kiri/index.html index 2c917786..cf28d1c3 100644 --- a/web/kiri/index.html +++ b/web/kiri/index.html @@ -288,7 +288,11 @@ -
+
+
+
+
+
diff --git a/web/kiri/lang/en.js b/web/kiri/lang/en.js index 316bd0c3..126d5185 100644 --- a/web/kiri/lang/en.js +++ b/web/kiri/lang/en.js @@ -134,6 +134,8 @@ kiri.lang['en-us'] = { op_unit_s: "units", op_unit_l: "workspace units affects\nspeeds and distances", + xp_menu: "export", + // LAYERS pop-menu la_menu: "layers", la_olin: "outline", diff --git a/web/kiri/output-gcode.html b/web/kiri/output-gcode.html index e0145306..649c7a0d 100644 --- a/web/kiri/output-gcode.html +++ b/web/kiri/output-gcode.html @@ -29,7 +29,7 @@
-
+