When curves to be split intersect at multiple points, don't just

choose arbitrarily. Instead, split at the point closest to the
mouse pointer.

[git-p4: depot-paths = "//depot/solvespace/": change = 2170]
solver
Jonathan Westhues 2010-07-11 22:47:14 -08:00
parent 9ae29aa0e9
commit 319ba16541
4 changed files with 17 additions and 3 deletions

View File

@ -608,9 +608,20 @@ void GraphicsWindow::SplitLinesOrCurves(void) {
ZERO(&inters); ZERO(&inters);
sbla.AllIntersectionsWith(&sblb, &inters); sbla.AllIntersectionsWith(&sblb, &inters);
// If there's multiple points, then just take the first one.
if(inters.l.n > 0) { 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(); SS.UndoRemember();
hEntity hia = SplitEntity(ha, pi), hEntity hia = SplitEntity(ha, pi),
hib = SplitEntity(hb, pi); hib = SplitEntity(hb, pi);

View File

@ -108,6 +108,7 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown,
} }
Point2d mp = Point2d::From(x, y); Point2d mp = Point2d::From(x, y);
currentMousePosition = mp;
if(rightDown && orig.mouse.DistanceTo(mp) < 5 && !orig.startedMoving) { if(rightDown && orig.mouse.DistanceTo(mp) < 5 && !orig.startedMoving) {
// Avoid accidentally panning (or rotating if shift is down) if the // Avoid accidentally panning (or rotating if shift is down) if the

3
ui.h
View File

@ -420,6 +420,9 @@ public:
bool startedMoving; bool startedMoving;
} orig; } 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 // 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 // allowing a paint in between. The extra solves are wasted if they're
// not displayed. // not displayed.

View File

@ -4,7 +4,6 @@ crude DXF, HPGL import
a request to import a plane thing a request to import a plane thing
make export assemble only contours in same group make export assemble only contours in same group
make export rewrite fill color same as stroke color make export rewrite fill color same as stroke color
choose split point closest to mouse pointer
----- -----
rounding, as a special group rounding, as a special group