diff --git a/notes.md b/notes.md index a455cacb..6c511505 100644 --- a/notes.md +++ b/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 diff --git a/src/geo/bounds.js b/src/geo/bounds.js index a89ecc4b..f4f06ad8 100644 --- a/src/geo/bounds.js +++ b/src/geo/bounds.js @@ -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) { diff --git a/src/kiri/main.js b/src/kiri/main.js index 7fbca0af..10b21adc 100644 --- a/src/kiri/main.js +++ b/src/kiri/main.js @@ -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