fix output dialogs. add slider min/max shortcuts

This commit is contained in:
Stewart Allen 2020-06-08 21:46:53 -04:00
commit 2f0eb9dbf8
11 changed files with 221 additions and 102 deletions

View file

@ -113,7 +113,6 @@
UI.print.innerHTML = html; UI.print.innerHTML = html;
$('print-filename').value = filename; $('print-filename').value = filename;
$('print-lines').value = UTIL.comma(segments); $('print-lines').value = UTIL.comma(segments);
$('print-close').onclick = API.modal.hide;
$('print-svg').onclick = download_svg; $('print-svg').onclick = download_svg;
$('print-dxf').onclick = download_dxf; $('print-dxf').onclick = download_dxf;
$('print-lg').onclick = download_gcode; $('print-lg').onclick = download_gcode;
@ -213,7 +212,15 @@
let dev = devs[uuid]; let dev = devs[uuid];
html.push(`<option id="gl-${uuid}" value="${uuid}">${dev.stat.device.name}</option>`); html.push(`<option id="gl-${uuid}" value="${uuid}">${dev.stat.device.name}</option>`);
} }
if (html.length) {
$('grid-local').innerHTML = html.join('\n'); $('grid-local').innerHTML = html.join('\n');
$('send-to-gridhead').style.display = 'flex';
$('send-to-gridspool').style.display = 'flex';
} else {
$('send-to-gridhead').style.display = '';
$('send-to-gridspool').style.display = '';
}
} }
function sendto_gridlocal() { function sendto_gridlocal() {
@ -412,19 +419,18 @@
mins = floor(newtime / 60), mins = floor(newtime / 60),
secs = newtime - mins * 60; secs = newtime - mins * 60;
$('mill-time').value = $('print-time').value = [pad(hours),pad(mins),pad(secs)].join(':'); $('output-time').value = [pad(hours),pad(mins),pad(secs)].join(':');
} }
API.ajax("/kiri/output-gcode.html", function(html) { API.ajax("/kiri/output-gcode.html", function(html) {
UI.print.innerHTML = html; UI.print.innerHTML = html;
$('print-close').onclick = API.modal.hide;
$('print-download').onclick = download; $('print-download').onclick = download;
$('print-octoprint').onclick = sendto_octoprint; $('print-octoprint').onclick = sendto_octoprint;
$('print-gridhost').onclick = sendto_gridhost; $('print-gridhost').onclick = sendto_gridhost;
$('print-gridlocal').onclick = sendto_gridlocal; $('print-gridlocal').onclick = sendto_gridlocal;
$('admin-gridlocal').onclick = admin_gridlocal; $('admin-gridlocal').onclick = admin_gridlocal;
$('print-filament-row').style.display = MODE === MODES.FDM ? '' : 'none'; $('print-filament-head').style.display = MODE === MODES.FDM ? '' : 'none';
$('mill-info').style.display = MODE === MODES.CAM ? '' : 'none'; $('print-filament-info').style.display = MODE === MODES.FDM ? '' : 'none';
$('print-filename').value = filename; $('print-filename').value = filename;
$('print-filesize').value = UTIL.comma(currentPrint.bytes); $('print-filesize').value = UTIL.comma(currentPrint.bytes);
$('print-filament').value = Math.round(currentPrint.distance); $('print-filament').value = Math.round(currentPrint.distance);
@ -437,8 +443,10 @@
octo_host = $('octo-host'); octo_host = $('octo-host');
octo_apik = $('octo-apik'); octo_apik = $('octo-apik');
if (MODE === MODES.CAM) { if (MODE === MODES.CAM) {
$('send-to-octohead').style.display = 'none';
$('send-to-octoprint').style.display = 'none'; $('send-to-octoprint').style.display = 'none';
} else { } else {
$('send-to-octohead').style.display = '';
$('send-to-octoprint').style.display = ''; $('send-to-octoprint').style.display = '';
} }
// hide octoprint when hard-coded in the url // hide octoprint when hard-coded in the url

View file

@ -1133,6 +1133,7 @@
slider: $('slider'), slider: $('slider'),
sliderMax: $('slider-max'), sliderMax: $('slider-max'),
sliderMin: $('slider-zero'),
sliderLo: $('slider-lo'), sliderLo: $('slider-lo'),
sliderMid: $('slider-mid'), sliderMid: $('slider-mid'),
sliderHi: $('slider-hi'), sliderHi: $('slider-hi'),
@ -1415,9 +1416,11 @@
// slider setup // slider setup
const slider = UI.sliderRange; const slider = UI.sliderRange;
const drag = { }; const drag = { };
function pxToInt(txt) { function pxToInt(txt) {
return txt ? parseInt(txt.substring(0,txt.length-2)) : 0; return txt ? parseInt(txt.substring(0,txt.length-2)) : 0;
} }
function sliderUpdate() { function sliderUpdate() {
let start = drag.top / drag.maxval; let start = drag.top / drag.maxval;
let end = (drag.top + drag.mid - 20) / drag.maxval; let end = (drag.top + drag.mid - 20) / drag.maxval;
@ -1426,6 +1429,7 @@
API.var.layer_lo = Math.round((1 - end) * API.var.layer_max); API.var.layer_lo = Math.round((1 - end) * API.var.layer_max);
API.show.layer(); API.show.layer();
} }
function dragit(el, delta) { function dragit(el, delta) {
el.onmousedown = (ev) => { el.onmousedown = (ev) => {
tracker.style.display = 'block'; tracker.style.display = 'block';
@ -1481,6 +1485,34 @@
sliderUpdate(); sliderUpdate();
}); });
UI.sliderMin.onclick = () => {
API.show.layer(0,0);
}
UI.sliderMax.onclick = () => {
API.show.layer(API.var.layer_max,0);
}
UI.slider.onmouseover = (ev) => {
API.event.emit('slider.label');
};
UI.slider.onmouseleave = (ev) => {
if (!ev.buttons) API.event.emit('slider.unlabel');
};
API.event.on('slider.unlabel', (values) => {
$('slider-hi-val').style.display = 'none';
$('slider-lo-val').style.display = 'none';
});
API.event.on('slider.label', (values) => {
$('slider-hi-val').style.display = 'flex';
$('slider-lo-val').style.display = 'flex';
$('slider-hi-val').innerText = API.var.layer_hi;
$('slider-lo-val').innerText = API.var.layer_lo;
});
API.event.on('slider.set', (values) => { API.event.on('slider.set', (values) => {
let height = slider.clientHeight; let height = slider.clientHeight;
let maxval = height - 40; let maxval = height - 40;

View file

@ -253,6 +253,7 @@
view: { view: {
get: function() { return viewMode }, get: function() { return viewMode },
set: setViewMode, set: setViewMode,
update_slider: updateSlider,
update_fields: updateFields, update_fields: updateFields,
wireframe: toggleWireframe, wireframe: toggleWireframe,
snapshot: null snapshot: null
@ -465,8 +466,11 @@
} }
function setVisibleLayer(h, l) { function setVisibleLayer(h, l) {
API.var.layer_hi = bound(h || API.var.layer_hi, 0, API.var.layer_max); h = h >= 0 ? h : API.var.layer_hi;
API.var.layer_lo = bound(l || API.var.layer_lo, 0, API.var.layer_hi); l = l >= 0 ? l : API.var.layer_lo;
API.var.layer_hi = bound(h, 0, API.var.layer_max);
API.var.layer_lo = bound(l, 0, h);
API.event.emit("slider.label");
updateSlider(); updateSlider();
showSlices(); showSlices();
} }
@ -526,6 +530,7 @@
API.var.layer_max = UI.sliderMax.innerText = max; API.var.layer_max = UI.sliderMax.innerText = max;
if (set || max < API.var.layer_hi) { if (set || max < API.var.layer_hi) {
API.var.layer_hi = API.var.layer_max; API.var.layer_hi = API.var.layer_max;
API.event.emit("slider.label");
updateSlider(); updateSlider();
} }
} }
@ -561,6 +566,7 @@
layer = bound(layer, 0, API.var.layer_max); layer = bound(layer, 0, API.var.layer_max);
API.var.layer_hi = layer; API.var.layer_hi = layer;
API.event.emit("slider.label");
let print = UI.layerPrint.checked, let print = UI.layerPrint.checked,
moves = UI.layerMoves.checked, moves = UI.layerMoves.checked,
@ -1815,6 +1821,7 @@
fetch("/api/grid_local") fetch("/api/grid_local")
.then(r => r.json()) .then(r => r.json())
.then(j => { .then(j => {
let devc = 0;
let bind = []; let bind = [];
let html = ['<table>']; let html = ['<table>'];
html.push(`<thead><tr><th>device</th><th>type</th><th>status</th><th></th></tr></thead>`); html.push(`<thead><tr><th>device</th><th>type</th><th>status</th><th></th></tr></thead>`);
@ -1828,10 +1835,15 @@
html.push(`<td>${r.state}</td>`); html.push(`<td>${r.state}</td>`);
html.push(`<td><button id="${r.device.uuid}">admin</button></td>`); html.push(`<td><button id="${r.device.uuid}">admin</button></td>`);
html.push(`</tr>`); html.push(`</tr>`);
devc++;
} }
html.push(`</tbody>`); html.push(`</tbody>`);
html.push(`</table>`); html.push(`</table>`);
$('local-dev').innerHTML = html.join(''); if (devc) {
$('mod-local').innerHTML = html.join('');
} else {
$('mod-local').innerHTML = `<br><b>no local devices</b>`;
}
bind.forEach(rec => { bind.forEach(rec => {
$(rec.uuid).onclick = () => { $(rec.uuid).onclick = () => {
window.open(`http://${rec.host}:${rec.port||4080}/`); window.open(`http://${rec.host}:${rec.port||4080}/`);

View file

@ -1858,7 +1858,7 @@
} }
if (!stripComments) { if (!stripComments) {
append(`; Generated by Kiri:Moto ${exports.VERSION}`); append(`; Generated by Kiri:Moto ${KIRI.VERSION}`);
append(`; ${new Date().toString()}`); append(`; ${new Date().toString()}`);
filterEmit(["; Bed left:{left} right:{right} top:{top} bottom:{bottom}"], consts); filterEmit(["; Bed left:{left} right:{right} top:{top} bottom:{bottom}"], consts);
append(`; Target: ${settings.filter[settings.mode]}`); append(`; Target: ${settings.filter[settings.mode]}`);

View file

@ -848,7 +848,7 @@
arr.forEach(function(line) { appendSub(line) }); arr.forEach(function(line) { appendSub(line) });
} }
append(`; Generated by Kiri:Moto ${exports.VERSION}`); append(`; Generated by Kiri:Moto ${KIRI.VERSION}`);
append(`; ${new Date().toString()}`); append(`; ${new Date().toString()}`);
appendSub("; Bed left:{left} right:{right} top:{top} bottom:{bottom}"); appendSub("; Bed left:{left} right:{right} top:{top} bottom:{bottom}");
append(`; Target: ${settings.filter[settings.mode]}`); append(`; Target: ${settings.filter[settings.mode]}`);

View file

@ -795,7 +795,6 @@
$('print-filename').value = filename; $('print-filename').value = filename;
$('print-layers').value = lines.length; $('print-layers').value = lines.length;
$('print-time').value = `${print_hrs}:${print_min}:${print_sec}`; $('print-time').value = `${print_hrs}:${print_min}:${print_sec}`;
$('print-close').onclick = API.modal.hide;
switch (device.deviceName) { switch (device.deviceName) {
case 'Anycubic.Photon': case 'Anycubic.Photon':

View file

@ -125,6 +125,9 @@ th, tr, td {
.a-end { .a-end {
align-items: flex-end; align-items: flex-end;
} }
.a-stretch {
align-items: stretch;
}
.j-start { .j-start {
justify-content: flex-start; justify-content: flex-start;
} }
@ -486,6 +489,78 @@ th, tr, td {
bottom: -20px; bottom: -20px;
right: 5px; right: 5px;
} }
#mod-print {
background-color: rgba(255,255,255,0.85);
}
#mod-print .grow button {
margin-left: 5px;
}
#mod-print .hint {
color: #345;
font-size: 12px;
font-style: italic;
text-align: center;
font-weight: normal;
padding-top: 5px;
}
#mod-print .box {
background-color: rgba(255,255,255,0.5);
border: 1px solid #bbb;
border-radius: 3px;
padding: 20px 10px 10px 10px;
}
#mod-print .box select {
min-width: 10em;
}
#mod-print .header {
flex-direction: column;
justify-content: center;
align-items: center;
transform: translateY(50%);
z-index: 10;
}
#mod-print .header label {
background-color: white;
padding: 0 10px 0 10px;
border-radius: 5px;
border-right: 1px solid #bbb;
border-left: 1px solid #bbb;
}
#mod-print a {
text-decoration: underline;
}
#mod-print a:hover {
color: #567;
background-color: #ddd;
}
#mod-print label {
flex-grow: 1;
font-weight: bold;
padding-right: 10px;
}
#mod-print button {
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 2em;
}
#print-canvas {
width: 180px;
height: 320px;
border: 1px solid #ccc;
background-color: #f5f5f5;
transform: scale(-1, 1);
}
#print-layer {
font-family: 'Russo One', sans-serif;
font-size: small;
width: 5em;
padding: 0 !important;
text-align: right;
}
#print-download {
min-height: 4em !important;
}
.mod-end { .mod-end {
height: 10px; height: 10px;
border-bottom-left-radius: 10px; border-bottom-left-radius: 10px;
@ -637,6 +712,17 @@ th, tr, td {
bottom: 10px; bottom: 10px;
width: 50px; width: 50px;
} }
#slider-hi-val, #slider-lo-val {
display: none;
position: absolute;
font-family: monospace;
transform: translateY(-50%);
background-color: rgba(255,255,255,0.5);
border: 1px solid #ddd;
border-radius: 3px;
right: 110%;
top: 50%;
}
#slider > div { #slider > div {
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
@ -651,6 +737,7 @@ th, tr, td {
background-image: var(--holdbar); background-image: var(--holdbar);
} }
#slider-zero { #slider-zero {
z-index: 10;
margin-top: 3px; margin-top: 3px;
background-color: #ccc; background-color: #ccc;
border-bottom-left-radius: 10px; border-bottom-left-radius: 10px;

View file

@ -289,8 +289,8 @@
</div> </div>
</div> </div>
<div id="mod-prefs" class="mdialog col"></div> <div id="mod-prefs" class="mdialog col"></div>
<div id="mod-local" class="mdialog"></div> <div id="mod-local" class="mdialog col"></div>
<div id="mod-print" class="mdialog"></div> <div id="mod-print" class="mdialog col"></div>
<!-- hidden file input loader --> <!-- hidden file input loader -->
<input id="load-file" type="file" name="loadme" style="display:none" accept=".stl,.gcode,.nc"/> <input id="load-file" type="file" name="loadme" style="display:none" accept=".stl,.gcode,.nc"/>
<div class="mod-end"></div></div> <div class="mod-end"></div></div>
@ -306,9 +306,9 @@
<div id="slider-max">&infin;</div> <div id="slider-max">&infin;</div>
<div id="slider-center" class="grow"> <div id="slider-center" class="grow">
<div id="slider-hold" class="col xa-center"> <div id="slider-hold" class="col xa-center">
<div id="slider-hi" class="handle"></div> <div id="slider-hi" class="handle"><div id="slider-hi-val"></div></div>
<div id="slider-mid">&nbsp;</div> <div id="slider-mid">&nbsp;</div>
<div id="slider-lo" class="handle"></div> <div id="slider-lo" class="handle"><div id="slider-lo-val"></div></div>
</div> </div>
</div> </div>
<div id="slider-zero">0</div> <div id="slider-zero">0</div>

View file

@ -1,68 +1,57 @@
<button id="print-close" class="modal-x">X</button> <div class="header"><label>export</label></div>
<div id="print-info" class="col box">
<span id="print-title">output options</span> <div><label>file name</label><input id="print-filename" size="20" spellcheck="false" /></div>
<div><label>file size (bytes)</label><input id="print-filesize" size="12" disabled="true" /></div>
<div> <div><label>time estimate (h:m:s)</label><input id="output-time" size="12" disabled="true" /></div>
<table id="print-info">
<tr><th>file name</th><td><input id="print-filename" size="30" spellcheck="false" /></td></tr>
<tr><th>file size (bytes)</th><td><input id="print-filesize" size="12" disabled="true" /></td></tr>
<tr id="mill-info"><th>time estimate (h:m:s)</th><td><input id="mill-time" size="12" disabled="true" /></td></tr>
</table>
</div> </div>
<div id="print-filament-row"> <div id="print-filament-head" class="header"><label>filament</label></div>
<table> <div id="print-filament-info" class="col box">
<tr><th>filament used (mm)</th><td><input id="print-filament" size="12" disabled="true" /></td></tr> <div><label>filament density (g/cm^3)</label><input id="print-density" size="12" value="1.25" /></div>
<tr><th>filament density (g/cm^3)</th><td><input id="print-density" size="12" value="1.25" /></td></tr> <div><label>filament used (mm)</label><input id="print-filament" size="12" disabled="true" /></div>
<tr><th>printed weight (g)</th><td><input id="print-weight" size="12" disabled="true" /></td></tr> <div><label>printed weight (g)</label><input id="print-weight" size="12" disabled="true" /></div>
<tr><th>time estimate (h:m:s)</th><td><input id="print-time" size="12" disabled="true" /></td></tr>
</table>
</div> </div>
<div class="print-sel print-gcode flex frow"> <div class="header"><label>gcode</label></div>
<span><label>gcode</label></span> <div class="row box">
<button id="print-download" class="fgro">download</button> <button id="print-download" class="grow">download</button>
</div> </div>
<div class="print-sel flex frow" id="send-to-octoprint"> <div id="send-to-octohead" class="header"><label>octoprint</label></div>
<span><label>octoprint</label></span> <div id="send-to-octoprint" class="col box">
<div> <div class="grow row">
<table> <div class="col grow">
<tr id="ophost"><th>host</th><td><input id="octo-host" size="35" placeholder="http(s)://host:port" /></td></tr> <div id="ophost"><label>host</label><input id="octo-host" size="20" placeholder="http(s)://host:port" /></div>
<tr id="opapik"><th>key</th><td><input id="octo-apik" size="35" /></td></tr> <div id="opapik"><label>key</label><input id="octo-apik" size="20" /></div>
<tr id="ophint"><td colspan="2">
<span id="octo-hint">
<a href="http://docs.octoprint.org/en/master/api/general.html?highlight=cors#cross-origin-requests" target="_help">CORS support</a>
must be enabled in API settings
</span>
</td></tr>
</table>
</div> </div>
<button id="print-octoprint" class="print-send">send</button> <button id="print-octoprint">send</button>
</div>
<div id="ophint"><label class="hint"><a href="http://docs.octoprint.org/en/master/api/general.html?highlight=cors#cross-origin-requests" target="_help">CORS support</a> must be enabled in API settings</label></div>
</div> </div>
<div class="print-sel flex frow" id="send-to-gridhost"> <div class="header"><label>grid:host</label></div>
<span><label>grid:host</label></span> <div id="send-to-gridhost" class="col box">
<div> <div class="grow row">
<table> <div class="col grow">
<tr><th>host</th><td><input id="grid-host" size="35" placeholder="http(s)://host:port" /></td></tr> <div><label>host</label><input id="grid-host" size="20" placeholder="http(s)://host:port" /></div>
<tr id="gpapik"><th>api key</th><td><input id="grid-apik" size="35" /></td></tr> <div id="gpapik"><label>api key</label><input id="grid-apik" size="20" /></div>
<tr><th>target</th><td><select id="grid-target"></select></td></tr> <div><label>target</label><select id="grid-target"></select></div>
<tr><td colspan="2"><span id="grid-hint">setup <a href="https://github.com/GridSpace/grid-host" target="_help">grid:host</a> for your network</span></td></tr>
</table>
</div> </div>
<button id="print-gridhost" class="print-send">send</button> <button id="print-gridhost">send</button>
</div>
<div><label class="hint">setup <a href="https://github.com/GridSpace/grid-host" target="_help">grid:host</a> for your network</label></div>
</div> </div>
<div class="print-sel flex frow" id="send-to-gridspool"> <div id="send-to-gridhead" class="header noshow"><label>grid:local</label></div>
<span><label>grid:local</label></span> <div id="send-to-gridspool" class="row box noshow">
<div> <div class="grow row">
<table> <div class="grow a-center j-center">
<tr><th>target</th><td width="100%"><select id="grid-local"></select></td></tr> <label>target</label>
</table> <select id="grid-local"></select>
</div> </div>
<div class="flex fcol print-send"> <div class="col">
<button id="print-gridlocal">send</button> <button id="print-gridlocal">send</button>
<button id="admin-gridlocal">admin</button> <button id="admin-gridlocal">admin</button>
</div> </div>
</div> </div>
</div>

View file

@ -1,18 +1,12 @@
<button id="print-close" class="modal-x">X</button> <div class="header"><label>export</label></div>
<div id="print-info" class="col box">
<span>output options</span> <div><label>file name</label><input id="print-filename" size="20" spellcheck="false" /></div>
<div><label>segments</label><input id="print-lines" size="12" disabled="true" /></div>
<div>
<table id="print-info">
<tr><th>file name</th><td><input id="print-filename" size="30" spellcheck="false" /></td></tr>
<tr><th>segments</th><td><input id="print-lines" size="12" disabled="true" /></td></tr>
</table>
</div> </div>
<div class="print-sel"> <div class="header"><label>download</label></div>
<table> <div class="row box">
<tr><th><button id="print-svg">download as svg</button></th></tr> <button id="print-svg" class="grow">svg</button>
<tr><th><button id="print-dxf">download as dxf</button></th></tr> <button id="print-dxf" class="grow">dxf</button>
<tr><th><button id="print-lg">download as gcode</button></th></tr> <button id="print-lg" class="grow">gcode</button>
</table>
</div> </div>

View file

@ -1,22 +1,20 @@
<button id="print-close" class="modal-x">X</button> <div class="header"><label>export</label></div>
<div id="print-info" class="col box">
<span>output options</span> <div><label>file name</label><input id="print-filename" size="20" spellcheck="false" /></div>
<div><label>print layers</label><input id="print-layers" size="10" spellcheck="false" /></div>
<div> <div><label>print time</label><input id="print-time" size="10" spellcheck="false" /></div>
<table id="print-info">
<tr><th>file name</th><td><input id="print-filename" size="30" spellcheck="false" /></td></tr>
<tr><th>print layers</th><td><input id="print-layers" size="10" spellcheck="false" /></td></tr>
<tr><th>print time</th><td><input id="print-time" size="10" spellcheck="false" /></td></tr>
</table>
</div> </div>
<div class="print-sel"> <div class="header"><label>download</label></div>
<table> <div class="row box">
<tr><th><button id="print-photon">download</button></th></tr> <button id="print-photon" class="grow">download</button>
</table>
</div> </div>
<div class="print-sel"> <div class="header"><label>preview</label></div>
<input id="print-range" type="range"><label id="print-layer"></label> <div class="col box a-center j-center">
<div class="row a-center j-center">
<input id="print-range" type="range" class="grow">
<label id="print-layer"></label>
</div>
<canvas id="print-canvas" width="1440" height="2560"></canvas> <canvas id="print-canvas" width="1440" height="2560"></canvas>
</div> </div>