diff --git a/modify.cpp b/modify.cpp index 38c9adf..31cf881 100644 --- a/modify.cpp +++ b/modify.cpp @@ -608,9 +608,20 @@ void GraphicsWindow::SplitLinesOrCurves(void) { ZERO(&inters); sbla.AllIntersectionsWith(&sblb, &inters); - // If there's multiple points, then just take the first one. if(inters.l.n > 0) { - Vector pi = inters.l.elem[0].p; + Vector pi; + // If there's multiple points, then take the one closest to the + // mouse pointer. + double dmin = VERY_POSITIVE; + SPoint *sp; + for(sp = inters.l.First(); sp; sp = inters.l.NextAfter(sp)) { + double d = ProjectPoint(sp->p).DistanceTo(currentMousePosition); + if(d < dmin) { + dmin = d; + pi = sp->p; + } + } + SS.UndoRemember(); hEntity hia = SplitEntity(ha, pi), hib = SplitEntity(hb, pi); diff --git a/mouse.cpp b/mouse.cpp index b49f31a..4ff1a44 100644 --- a/mouse.cpp +++ b/mouse.cpp @@ -108,6 +108,7 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown, } Point2d mp = Point2d::From(x, y); + currentMousePosition = mp; if(rightDown && orig.mouse.DistanceTo(mp) < 5 && !orig.startedMoving) { // Avoid accidentally panning (or rotating if shift is down) if the diff --git a/ui.h b/ui.h index ffa1f1b..65c95bc 100644 --- a/ui.h +++ b/ui.h @@ -420,6 +420,9 @@ public: bool startedMoving; } orig; + // Most recent mouse position, updated every time the mouse moves. + Point2d currentMousePosition; + // When the user is dragging a point, don't solve multiple times without // allowing a paint in between. The extra solves are wasted if they're // not displayed. diff --git a/wishlist.txt b/wishlist.txt index 3c59e8d..bf89f1b 100644 --- a/wishlist.txt +++ b/wishlist.txt @@ -4,7 +4,6 @@ crude DXF, HPGL import a request to import a plane thing make export assemble only contours in same group make export rewrite fill color same as stroke color -choose split point closest to mouse pointer ----- rounding, as a special group