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;
$('print-filename').value = filename;
$('print-lines').value = UTIL.comma(segments);
$('print-close').onclick = API.modal.hide;
$('print-svg').onclick = download_svg;
$('print-dxf').onclick = download_dxf;
$('print-lg').onclick = download_gcode;
@ -213,7 +212,15 @@
let dev = devs[uuid];
html.push(`<option id="gl-${uuid}" value="${uuid}">${dev.stat.device.name}</option>`);
}
$('grid-local').innerHTML = html.join('\n');
if (html.length) {
$('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() {
@ -412,19 +419,18 @@
mins = floor(newtime / 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) {
UI.print.innerHTML = html;
$('print-close').onclick = API.modal.hide;
$('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-row').style.display = MODE === MODES.FDM ? '' : 'none';
$('mill-info').style.display = MODE === MODES.CAM ? '' : 'none';
$('print-filament-head').style.display = MODE === MODES.FDM ? '' : 'none';
$('print-filament-info').style.display = MODE === MODES.FDM ? '' : 'none';
$('print-filename').value = filename;
$('print-filesize').value = UTIL.comma(currentPrint.bytes);
$('print-filament').value = Math.round(currentPrint.distance);
@ -437,8 +443,10 @@
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

View file

@ -1133,6 +1133,7 @@
slider: $('slider'),
sliderMax: $('slider-max'),
sliderMin: $('slider-zero'),
sliderLo: $('slider-lo'),
sliderMid: $('slider-mid'),
sliderHi: $('slider-hi'),
@ -1415,9 +1416,11 @@
// slider setup
const slider = UI.sliderRange;
const drag = { };
function pxToInt(txt) {
return txt ? parseInt(txt.substring(0,txt.length-2)) : 0;
}
function sliderUpdate() {
let start = drag.top / 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.show.layer();
}
function dragit(el, delta) {
el.onmousedown = (ev) => {
tracker.style.display = 'block';
@ -1481,6 +1485,34 @@
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) => {
let height = slider.clientHeight;
let maxval = height - 40;

View file

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

View file

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

View file

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

View file

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

View file

@ -125,6 +125,9 @@ th, tr, td {
.a-end {
align-items: flex-end;
}
.a-stretch {
align-items: stretch;
}
.j-start {
justify-content: flex-start;
}
@ -486,6 +489,78 @@ th, tr, td {
bottom: -20px;
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 {
height: 10px;
border-bottom-left-radius: 10px;
@ -637,6 +712,17 @@ th, tr, td {
bottom: 10px;
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 {
flex-direction: column;
align-items: center;
@ -651,6 +737,7 @@ th, tr, td {
background-image: var(--holdbar);
}
#slider-zero {
z-index: 10;
margin-top: 3px;
background-color: #ccc;
border-bottom-left-radius: 10px;

View file

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

View file

@ -1,68 +1,57 @@
<button id="print-close" class="modal-x">X</button>
<span id="print-title">output options</span>
<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 class="header"><label>export</label></div>
<div id="print-info" class="col box">
<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><label>time estimate (h:m:s)</label><input id="output-time" size="12" disabled="true" /></div>
</div>
<div id="print-filament-row">
<table>
<tr><th>filament used (mm)</th><td><input id="print-filament" size="12" disabled="true" /></td></tr>
<tr><th>filament density (g/cm^3)</th><td><input id="print-density" size="12" value="1.25" /></td></tr>
<tr><th>printed weight (g)</th><td><input id="print-weight" size="12" disabled="true" /></td></tr>
<tr><th>time estimate (h:m:s)</th><td><input id="print-time" size="12" disabled="true" /></td></tr>
</table>
<div id="print-filament-head" class="header"><label>filament</label></div>
<div id="print-filament-info" class="col box">
<div><label>filament density (g/cm^3)</label><input id="print-density" size="12" value="1.25" /></div>
<div><label>filament used (mm)</label><input id="print-filament" size="12" disabled="true" /></div>
<div><label>printed weight (g)</label><input id="print-weight" size="12" disabled="true" /></div>
</div>
<div class="print-sel print-gcode flex frow">
<span><label>gcode</label></span>
<button id="print-download" class="fgro">download</button>
<div class="header"><label>gcode</label></div>
<div class="row box">
<button id="print-download" class="grow">download</button>
</div>
<div class="print-sel flex frow" id="send-to-octoprint">
<span><label>octoprint</label></span>
<div>
<table>
<tr id="ophost"><th>host</th><td><input id="octo-host" size="35" placeholder="http(s)://host:port" /></td></tr>
<tr id="opapik"><th>key</th><td><input id="octo-apik" size="35" /></td></tr>
<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 id="send-to-octohead" class="header"><label>octoprint</label></div>
<div id="send-to-octoprint" class="col box">
<div class="grow row">
<div class="col grow">
<div id="ophost"><label>host</label><input id="octo-host" size="20" placeholder="http(s)://host:port" /></div>
<div id="opapik"><label>key</label><input id="octo-apik" size="20" /></div>
</div>
<button id="print-octoprint">send</button>
</div>
<button id="print-octoprint" class="print-send">send</button>
<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 class="print-sel flex frow" id="send-to-gridhost">
<span><label>grid:host</label></span>
<div>
<table>
<tr><th>host</th><td><input id="grid-host" size="35" placeholder="http(s)://host:port" /></td></tr>
<tr id="gpapik"><th>api key</th><td><input id="grid-apik" size="35" /></td></tr>
<tr><th>target</th><td><select id="grid-target"></select></td></tr>
<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 class="header"><label>grid:host</label></div>
<div id="send-to-gridhost" class="col box">
<div class="grow row">
<div class="col grow">
<div><label>host</label><input id="grid-host" size="20" placeholder="http(s)://host:port" /></div>
<div id="gpapik"><label>api key</label><input id="grid-apik" size="20" /></div>
<div><label>target</label><select id="grid-target"></select></div>
</div>
<button id="print-gridhost">send</button>
</div>
<button id="print-gridhost" class="print-send">send</button>
<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 class="print-sel flex frow" id="send-to-gridspool">
<span><label>grid:local</label></span>
<div>
<table>
<tr><th>target</th><td width="100%"><select id="grid-local"></select></td></tr>
</table>
</div>
<div class="flex fcol print-send">
<button id="print-gridlocal">send</button>
<button id="admin-gridlocal">admin</button>
<div id="send-to-gridhead" class="header noshow"><label>grid:local</label></div>
<div id="send-to-gridspool" class="row box noshow">
<div class="grow row">
<div class="grow a-center j-center">
<label>target</label>
<select id="grid-local"></select>
</div>
<div class="col">
<button id="print-gridlocal">send</button>
<button id="admin-gridlocal">admin</button>
</div>
</div>
</div>

View file

@ -1,18 +1,12 @@
<button id="print-close" class="modal-x">X</button>
<span>output options</span>
<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 class="header"><label>export</label></div>
<div id="print-info" class="col box">
<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>
<div class="print-sel">
<table>
<tr><th><button id="print-svg">download as svg</button></th></tr>
<tr><th><button id="print-dxf">download as dxf</button></th></tr>
<tr><th><button id="print-lg">download as gcode</button></th></tr>
</table>
<div class="header"><label>download</label></div>
<div class="row box">
<button id="print-svg" class="grow">svg</button>
<button id="print-dxf" class="grow">dxf</button>
<button id="print-lg" class="grow">gcode</button>
</div>

View file

@ -1,22 +1,20 @@
<button id="print-close" class="modal-x">X</button>
<span>output options</span>
<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 class="header"><label>export</label></div>
<div id="print-info" class="col box">
<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><label>print time</label><input id="print-time" size="10" spellcheck="false" /></div>
</div>
<div class="print-sel">
<table>
<tr><th><button id="print-photon">download</button></th></tr>
</table>
<div class="header"><label>download</label></div>
<div class="row box">
<button id="print-photon" class="grow">download</button>
</div>
<div class="print-sel">
<input id="print-range" type="range"><label id="print-layer"></label>
<div class="header"><label>preview</label></div>
<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>
</div>