circular layout position on new add without full re-layout when auto layout disabled
This commit is contained in:
parent
bd38764083
commit
3ef2005a4e
3 changed files with 49 additions and 4 deletions
4
notes.md
4
notes.md
|
|
@ -3,8 +3,6 @@
|
|||
## 2.4 roadmap
|
||||
* `laser`
|
||||
* - drag knife support
|
||||
* `all`
|
||||
* - circular fit/layout when no-layout to prevent collisions
|
||||
|
||||
## 2.5 roadmap
|
||||
# `cnc`
|
||||
|
|
@ -12,6 +10,7 @@
|
|||
# - complex process order
|
||||
# - split gcode output
|
||||
# - double-sided assistance
|
||||
# - redo path planning
|
||||
# `fdm`
|
||||
# - redo automatic supports using faces instead of deltas
|
||||
# - bind process to z ranges or boxed regions
|
||||
|
|
@ -89,6 +88,7 @@
|
|||
* `F` A-B linked cutting profiles for double-sided milling / part flips
|
||||
* `P` crossing open space check point is outside camshell before returning max z
|
||||
* `P` detect render message backlog and pause or warn
|
||||
* `P` redo all path route / planning in prepare to account for terrain before camOut
|
||||
|
||||
# Laser
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
this.miny = 10e7;
|
||||
this.maxx = -10e7;
|
||||
this.maxy = -10e7;
|
||||
this.leftMost = null;
|
||||
}
|
||||
|
||||
const BASE = self.base,
|
||||
|
|
@ -30,6 +29,14 @@
|
|||
* Bounds Prototype Functions
|
||||
******************************************************************* */
|
||||
|
||||
PRO.set = function(minx, maxx, miny, maxy) {
|
||||
this.minx = minx;
|
||||
this.miny = miny;
|
||||
this.maxx = maxx;
|
||||
this.maxy = maxy;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {Bounds}
|
||||
*/
|
||||
|
|
@ -59,6 +66,7 @@
|
|||
this.maxx = Math.max(this.maxx, b.maxx);
|
||||
this.miny = Math.min(this.miny, b.miny);
|
||||
this.maxy = Math.max(this.maxy, b.maxy);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -69,7 +77,7 @@
|
|||
this.maxx = Math.max(this.maxx, p.x);
|
||||
this.miny = Math.min(this.miny, p.y);
|
||||
this.maxy = Math.max(this.maxy, p.y);
|
||||
if (this.minx === p.x) this.leftMost = p;
|
||||
return this;
|
||||
};
|
||||
|
||||
PRO.contains = function(bounds) {
|
||||
|
|
|
|||
|
|
@ -1401,11 +1401,48 @@
|
|||
}
|
||||
if (!grouping) {
|
||||
platformGroupDone();
|
||||
if (!settings.controller.autoLayout) {
|
||||
positionNewWidget(widget);
|
||||
}
|
||||
} else if (feature.drop_layout) {
|
||||
platform.layout();
|
||||
}
|
||||
}
|
||||
|
||||
function positionNewWidget(widget) {
|
||||
if (WIDGETS.length <= 1) return;
|
||||
let DEG2RAD = Math.PI / 180;
|
||||
let { bedWidth, bedDepth } = settings.device;
|
||||
let devOff = bedWidth / 2;
|
||||
let wbb = widget.getBoundingBox();
|
||||
let dim = { x: wbb.max.x - wbb.min.x, y: wbb.max.y - wbb.min.y };
|
||||
let hdim = { x: dim.x / 2, y: dim.y / 2 };
|
||||
let bounds = BASE.newBounds(), target = BASE.newBounds();
|
||||
// look for best position for new widget that doesn't collide
|
||||
outer: for (let rad=10; rad<200; rad += 10) {
|
||||
inner: for (let d=0; d<360; d += 1) {
|
||||
let dx = Math.cos(d * DEG2RAD) * rad;
|
||||
let dy = Math.sin(d * DEG2RAD) * rad;
|
||||
bounds.set(dx - hdim.x, dx + hdim.x, dy - hdim.y, dy + hdim.y);
|
||||
for (let w=0, wl=WIDGETS.length; w<wl; w++) {
|
||||
let wt = WIDGETS[w];
|
||||
if (wt === widget) {
|
||||
continue;
|
||||
}
|
||||
let tpo = wt.track.pos;
|
||||
let tbb = wt.getBoundingBox();
|
||||
let dim = { x: (tbb.max.x - tbb.min.x) / 2, y : (tbb.max.y - tbb.min.y) / 2 };
|
||||
target.set(tpo.x - dim.x, tpo.x + dim.x, tpo.y - dim.y, tpo.y + dim.y);
|
||||
if (target.overlaps(bounds, 5)) {
|
||||
continue inner;
|
||||
}
|
||||
}
|
||||
widget._move(dx, dy, widget.track.pos.z, true);
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function platformDelete(widget) {
|
||||
if (!widget) {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue