improve gcode editor

This commit is contained in:
Stewart Allen 2020-03-06 09:33:24 -05:00
commit 3dd93b2d6a
4 changed files with 42 additions and 23 deletions

View file

@ -744,7 +744,7 @@ var gs_kiri_cam = exports;
}
});
// for tracing out intersections
// required to match computed order of cutouts
trace.setClockwise();
let count = proc.camTabsCount;
@ -753,7 +753,6 @@ var gs_kiri_cam = exports;
let center = BASE.newPoint(0,0,slice.z);
let offset = (tabWidth + toolDiam) / 2;
let ints = [];
let segs = [];
while (count-- > 0) {
let slope = BASE.newSlopeFromAngle(angle);
let normal = BASE.newSlopeFromAngle(angle + 90);
@ -767,13 +766,11 @@ var gs_kiri_cam = exports;
ints.push(int1);
ints.push(int2);
}
// segs.push(BASE.newPolygon([c1, o1]).setOpen());
// segs.push(BASE.newPolygon([c2, o2]).setOpen());
angle -= angle_inc;
}
if (ints.length) {
let z = slice.z;
ints.push(ints.shift());
let segs = [];
for (let i=0; i<ints.length; i+=2) {
segs.push(trace.emitSegment(ints[i], ints[i+1]));
}

View file

@ -3381,6 +3381,7 @@ self.kiri.license = exports.LICENSE;
local = isLocalDevice(devicename),
dproc = settings.devproc[devicename],
mode = getMode();
settings.device = {
bedHeight: 2.5,
bedWidth: valueOf(set.bed_width, 300),
@ -3464,9 +3465,9 @@ self.kiri.license = exports.LICENSE;
UI.setDeviceFExt,
UI.setDeviceToken,
UI.setDeviceStrip
].forEach(function(e) {
].forEach(function(e) {
e.disabled = !local;
});
});
// hide spindle fields when device doens't support it
if (mode === 'CAM')
@ -3510,7 +3511,9 @@ self.kiri.license = exports.LICENSE;
devs = settings.devices;
for (var local in devs) {
if (!(devs.hasOwnProperty(local) && devs[local])) continue;
if (!(devs.hasOwnProperty(local) && devs[local])) {
continue;
}
var dev = devs[local],
fdmCode = dev.cmd,
fdmMode = (getMode() === 'FDM');
@ -3564,16 +3567,16 @@ self.kiri.license = exports.LICENSE;
first = device;
}
opt.appendChild(DOC.createTextNode(device));
opt.onclick = function() { selectDevice(device) };
opt.onclick = function() {
selectDevice(device);
};
opt.ondblclick = function() {
if (settings.favorites[device]) {
if (confirm(`remove "${device}" from favorites`)) {
delete settings.favorites[device];
}
delete settings.favorites[device];
alert2(`removed "${device}" from favorites`, 3);
} else {
if (confirm(`add "${device}" to favorites`)) {
settings.favorites[device] = true;
}
settings.favorites[device] = true;
alert2(`added "${device}" to favorites`, 3);
}
showDevices();
};
@ -3641,7 +3644,12 @@ self.kiri.license = exports.LICENSE;
selectedTool.type = ['endmill','ballmill'][UI.toolType.selectedIndex];
renderTools();
UI.toolSelect.selectedIndex = selectedTool.order;
editTools.changed = true;
setToolChanged(true);
}
function setToolChanged(changed) {
editTools.changed = changed;
UI.toolsSave.disabled = !changed;
}
function showTools() {
@ -3649,7 +3657,11 @@ self.kiri.license = exports.LICENSE;
var selectedIndex = null;
editTools = settings.tools.slice();
editTools = settings.tools.slice().sort((a,b) => {
return a.name > b.name ? 1 : -1;
});
setToolChanged(false);
UI.toolsClose.onclick = function() {
if (editTools.changed && !confirm("abandon changes?")) return;
@ -3667,23 +3679,22 @@ self.kiri.license = exports.LICENSE;
shaft_len: 3,
metric: false
});
editTools.changed = true;
setToolChanged(true);
renderTools();
UI.toolSelect.selectedIndex = editTools.length-1;
selectTool(editTools[editTools.length-1]);
};
UI.toolDelete.onclick = function() {
editTools.remove(selectedTool);
editTools.changed = true;
setToolChanged(true);
renderTools();
};
UI.toolsSave.onclick = function() {
editTools.changed = false;
if (selectedTool) updateTool();
settings.tools = editTools;
setToolChanged(false);
saveSettings();
updateFields();
hideDialog();
triggerSettingsEvent();
};
@ -3729,7 +3740,7 @@ self.kiri.license = exports.LICENSE;
SPACE.platform.setColor(0x555555);
var files = evt.dataTransfer.files,
plate = files.length < 5 || confirm('add objects to table?');
plate = files.length < 5 || confirm(`add ${files.length} objects to workspace?`);
if (plate) loadFiles(files);
}

View file

@ -213,7 +213,7 @@ var gs_moto_ui = exports;
pop.appendChild(txt);
lbl.appendChild(DOC.createTextNode(label));
txt.setAttribute("cols", 30);
txt.setAttribute("cols", 40);
txt.setAttribute("rows", 20);
txt.setAttribute("wrap", "off");
@ -222,6 +222,16 @@ var gs_moto_ui = exports;
btn.parentNode.appendChild(box);
btn.parentNode.onclick = btn.onclick;
ev.stopPropagation();
txt.scrollTop = 0;
txt.scrollLeft = 0;
txt.selectionEnd = 0;
let rows = txt.value.split('\n');
let cols = 0;
rows.forEach(row => {
cols = Math.max(cols, row.length);
});
txt.setAttribute("cols", Math.max(30, cols + 1));
txt.setAttribute("rows", Math.max(10, rows.length + 1));
// drop clicks on TextArea
if (ev.target === txt) {
ev.target.focus();

View file

@ -689,6 +689,7 @@ button[import="1"] {
}
#alert-text p {
margin: 5px;
text-align: center;
}
.flex {