Two ugly hacks. Don't do the trick where I also deselect the point

under the just-deselected coincident point when I'm working on
batches, which really could have selected that underneath point.
And always pwl curves to at least two line segments (and likewise
retain at least one intermediate point when removing short edges),
to avoid confusion when holes end up square.

[git-p4: depot-paths = "//depot/solvespace/": change = 2070]
This commit is contained in:
Jonathan Westhues 2009-11-05 21:34:34 -08:00
parent e91bf7db79
commit 28d1bc67bc
6 changed files with 23 additions and 12 deletions

View File

@ -97,13 +97,13 @@ void GraphicsWindow::ClearNonexistentSelectionItems(void) {
// Toggle the selection state of the indicated item: if it was selected then // Toggle the selection state of the indicated item: if it was selected then
// un-select it, and if it wasn't then select it. // un-select it, and if it wasn't then select it.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void GraphicsWindow::ToggleSelectionStateOf(hEntity he) { void GraphicsWindow::ToggleSelectionStateOf(hEntity he, bool batch) {
Selection stog; Selection stog;
ZERO(&stog); ZERO(&stog);
stog.entity = he; stog.entity = he;
ToggleSelectionStateOf(&stog); ToggleSelectionStateOf(&stog, batch);
} }
void GraphicsWindow::ToggleSelectionStateOf(Selection *stog) { void GraphicsWindow::ToggleSelectionStateOf(Selection *stog, bool batch) {
if(stog->IsEmpty()) return; if(stog->IsEmpty()) return;
Selection *s; Selection *s;
@ -121,7 +121,7 @@ void GraphicsWindow::ToggleSelectionStateOf(Selection *stog) {
// If two points are coincident, then it's impossible to hover one of // If two points are coincident, then it's impossible to hover one of
// them. But make sure to deselect both, to avoid mysterious seeming // them. But make sure to deselect both, to avoid mysterious seeming
// inability to deselect if the bottom one did somehow get selected. // inability to deselect if the bottom one did somehow get selected.
if(wasSelected && stog->entity.v) { if(wasSelected && stog->entity.v && !batch) {
Entity *e = SK.GetEntity(stog->entity); Entity *e = SK.GetEntity(stog->entity);
if(e->IsPoint()) { if(e->IsPoint()) {
Vector ep = e->PointGetNum(); Vector ep = e->PointGetNum();
@ -184,7 +184,7 @@ void GraphicsWindow::SelectByMarquee(void) {
if(pp.x >= xmin && pp.x <= xmax && if(pp.x >= xmin && pp.x <= xmax &&
pp.y >= ymin && pp.y <= ymax) pp.y >= ymin && pp.y <= ymax)
{ {
ToggleSelectionStateOf(e->h); ToggleSelectionStateOf(e->h, true);
} }
} else { } else {
// Use the 3d bounding box test routines, to avoid duplication; // Use the 3d bounding box test routines, to avoid duplication;
@ -206,7 +206,7 @@ void GraphicsWindow::SelectByMarquee(void) {
!ptA.OutsideAndNotOn(ptMax, ptMin) || !ptA.OutsideAndNotOn(ptMax, ptMin) ||
!ptB.OutsideAndNotOn(ptMax, ptMin)) !ptB.OutsideAndNotOn(ptMax, ptMin))
{ {
ToggleSelectionStateOf(e->h); ToggleSelectionStateOf(e->h, true);
break; break;
} }
} }

View File

@ -631,7 +631,7 @@ void GraphicsWindow::MenuEdit(int id) {
if(e->IsFace() || e->IsDistance()) continue; if(e->IsFace() || e->IsDistance()) continue;
if(!e->IsVisible()) continue; if(!e->IsVisible()) continue;
SS.GW.ToggleSelectionStateOf(e->h); SS.GW.ToggleSelectionStateOf(e->h, true);
} }
InvalidateGraphics(); InvalidateGraphics();
SS.later.showTW = true; SS.later.showTW = true;
@ -673,7 +673,7 @@ void GraphicsWindow::MenuEdit(int id) {
} }
} }
if(onChain && !alreadySelected) { if(onChain && !alreadySelected) {
SS.GW.ToggleSelectionStateOf(e->h); SS.GW.ToggleSelectionStateOf(e->h, true);
newlySelected++; newlySelected++;
didSomething = true; didSomething = true;
} }

View File

@ -793,7 +793,9 @@ SSurface *SCurve::GetSurfaceB(SShell *a, SShell *b) {
// stuff in the Booleans. So remove them. // stuff in the Booleans. So remove them.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void SCurve::RemoveShortSegments(SSurface *srfA, SSurface *srfB) { void SCurve::RemoveShortSegments(SSurface *srfA, SSurface *srfB) {
if(pts.n < 2) return; // Three, not two; curves are pwl'd to at least two edges (three points)
// even if not necessary, to avoid square holes.
if(pts.n <= 3) return;
pts.ClearTags(); pts.ClearTags();
Vector prev = pts.elem[0].p; Vector prev = pts.elem[0].p;

View File

@ -266,7 +266,15 @@ void SBezier::MakePwlInto(List<Vector> *l, double chordTol) {
chordTol = SS.ChordTolMm(); chordTol = SS.ChordTolMm();
} }
l->Add(&(ctrl[0])); l->Add(&(ctrl[0]));
MakePwlWorker(l, 0.0, 1.0, chordTol); if(deg == 1) {
l->Add(&(ctrl[1]));
} else {
// Never do fewer than one intermediate point; people seem to get
// unhappy when their circles turn into squares, but maybe less
// unhappy with octagons.
MakePwlWorker(l, 0.0, 0.5, chordTol);
MakePwlWorker(l, 0.5, 1.0, chordTol);
}
} }
void SBezier::MakePwlWorker(List<Vector> *l, double ta, double tb, void SBezier::MakePwlWorker(List<Vector> *l, double ta, double tb,
double chordTol) double chordTol)

4
ui.h
View File

@ -453,8 +453,8 @@ public:
int n; int n;
} gs; } gs;
void GroupSelection(void); void GroupSelection(void);
void ToggleSelectionStateOf(hEntity he); void ToggleSelectionStateOf(hEntity he, bool batch=false);
void ToggleSelectionStateOf(Selection *s); void ToggleSelectionStateOf(Selection *s, bool batch=false);
void SelectByMarquee(void); void SelectByMarquee(void);
void ClearSuper(void); void ClearSuper(void);

View File

@ -2,6 +2,7 @@
copy and paste copy and paste
background image background image
associative entities from solid model, as a special group associative entities from solid model, as a special group
n*log(n) intersection finding
----- -----
some kind of import some kind of import