set view mode on part move,rotate,scale. debug code for tab intersections

This commit is contained in:
Stewart Allen 2020-11-19 21:04:45 -05:00
commit 3738750ba3
3 changed files with 26 additions and 4 deletions

View file

@ -868,6 +868,8 @@
let int = UTIL.intersect(lp1, lp2, pp1, pp2, BASE.key.SEGINT, false); let int = UTIL.intersect(lp1, lp2, pp1, pp2, BASE.key.SEGINT, false);
if (int) { if (int) {
list.push(int); list.push(int);
// console.log('pp1.pos',pp1.pos,'to',ip1);
// console.log('pp2.pos',pp2.pos,'to',ip2);
pp1.pos = ip1; pp1.pos = ip1;
pp2.pos = ip2; pp2.pos = ip2;
} }
@ -907,13 +909,18 @@
let poly = newPolygon(), let poly = newPolygon(),
start = i1.p2.pos, start = i1.p2.pos,
end = i2.p1.pos; end = i2.p1.pos;
// console.log({emitSeg: this, i1, i2, start, end});
poly.setOpen(); poly.setOpen();
poly.push(i1); poly.push(i1);
this.forEachPoint(function(p, pos) { this.forEachPoint(function(p, pos) {
poly.push(p); poly.push(p);
if (p === i2.p1) return true; if (p === i2.p1) {
// console.log('hit end point @', pos);
return true;
}
}, true, start); }, true, start);
poly.push(i2); poly.push(i2);
// console.log({emit: poly});
return poly; return poly;
}; };

View file

@ -933,6 +933,7 @@
} }
function moveSelection(x, y, z, abs) { function moveSelection(x, y, z, abs) {
setViewMode(VIEWS.ARRANGE);
forSelectedGroups(function (w) { forSelectedGroups(function (w) {
w.move(x, y, z, abs); w.move(x, y, z, abs);
}); });
@ -942,6 +943,7 @@
} }
function scaleSelection() { function scaleSelection() {
setViewMode(VIEWS.ARRANGE);
let args = arguments; let args = arguments;
forSelectedGroups(function (w) { forSelectedGroups(function (w) {
w.scale(...args); w.scale(...args);
@ -958,6 +960,7 @@
} }
function rotateSelection(x, y, z) { function rotateSelection(x, y, z) {
setViewMode(VIEWS.ARRANGE);
forSelectedGroups(function (w) { forSelectedGroups(function (w) {
w.rotate(x, y, z); w.rotate(x, y, z);
}); });

View file

@ -274,7 +274,7 @@
if (outside) { if (outside) {
offset.appendAll(outside); offset.appendAll(outside);
if (addTabsOutline && slice.z <= zMin + tabHeight) { if (addTabsOutline && slice.z <= zMin + tabHeight) {
offset = addCutoutTabs(offset, slice.z, roughToolDiam, tabWidth, proc.camTabsCount, proc.camTabsAngle); offset = addCutoutTabs(offset, slice.z, roughToolDiam, tabWidth, proc.camTabsCount, proc.camTabsAngle, slice);
} }
} }
} }
@ -533,7 +533,7 @@
} }
// cut outside traces at the right points // cut outside traces at the right points
function addCutoutTabs(polys, z, toolDiam, tabWidth, tabCount, tabAngle) { function addCutoutTabs(polys, z, toolDiam, tabWidth, tabCount, tabAngle, slice) {
// skip if no tops | traces // skip if no tops | traces
if (polys.length === 0) return polys; if (polys.length === 0) return polys;
@ -553,16 +553,28 @@
if (int1 && int2) { if (int1 && int2) {
ints.push(int1); ints.push(int1);
ints.push(int2); ints.push(int2);
// slice.output().setLayer('int',0xff0000).addLine(int1, int2);
} }
}); });
let segs = []; let segs = [];
if (ints.length) { if (ints.length) {
ints.push(ints.shift()); ints.push(ints.shift());
// let cv = 0;
for (let i=0; i<ints.length; i+=2) { for (let i=0; i<ints.length; i+=2) {
segs.push(trace.emitSegment(ints[i], ints[i+1])); const seg = trace.emitSegment(ints[i], ints[i+1]);
// const col = [0x0000ff,0x009900,0x999900];
// seg.setZ(seg.getZ()+i);
// seg.points.forEach((p,i) => p.z += (i*0.01));
// slice.output().setLayer(`seg${i}`,col[cv++]).addPoly(seg);
// slice.output().setLayer(`seg${i}`).addPoly(newPolygon().centerCircle(seg.first(),1,5));
// slice.output().setLayer(`seg${i}`).addPoly(newPolygon().centerCircle(seg.last(),1,4));
// slice.output().setLayer(`seg${i}`).addPoly(newPolygon().centerCircle(trace.first(),2,5));
// slice.output().setLayer(`seg${i}`).addPoly(newPolygon().centerCircle(trace.last(),2,4));
segs.push(seg);
} }
// check for and eliminate overlaps // check for and eliminate overlaps
if (false)
for (let i=0, il=segs.length; i < il; i++) { for (let i=0, il=segs.length; i < il; i++) {
let si = segs[i]; let si = segs[i];
for (let j=i+1; j<il; j++) { for (let j=i+1; j<il; j++) {