From d99a13398225e5bb25f92ac9ea84c960f17f0614 Mon Sep 17 00:00:00 2001 From: Evil-Spirit Date: Mon, 26 Dec 2016 09:09:45 +0700 Subject: [PATCH] Do ScheduleGenerateAll in MarkGroupDirty. This generally simplifies code, and also fixes a bug where adding a datum point would not regenerate the sketch. --- src/clipboard.cpp | 2 -- src/constraint.cpp | 5 +---- src/describescreen.cpp | 1 - src/generate.cpp | 4 +++- src/graphicswin.cpp | 3 --- src/group.cpp | 1 - src/modify.cpp | 3 --- src/mouse.cpp | 7 ------- src/solvespace.cpp | 2 +- src/solvespace.h | 2 +- src/style.cpp | 2 +- src/textscreens.cpp | 8 +------- 12 files changed, 8 insertions(+), 32 deletions(-) diff --git a/src/clipboard.cpp b/src/clipboard.cpp index 152ce3a8..369fc34e 100644 --- a/src/clipboard.cpp +++ b/src/clipboard.cpp @@ -235,8 +235,6 @@ void GraphicsWindow::PasteClipboard(Vector trans, double theta, double scale) { MakeSelected(hc); } } - - SS.ScheduleGenerateAll(); } void GraphicsWindow::MenuClipboard(Command id) { diff --git a/src/constraint.cpp b/src/constraint.cpp index 86073c7b..f71f8b5f 100644 --- a/src/constraint.cpp +++ b/src/constraint.cpp @@ -86,7 +86,6 @@ hConstraint Constraint::AddConstraint(Constraint *c, bool rememberForUndo) { SS.MarkGroupDirty(c->group); SK.GetGroup(c->group)->dofCheckOk = false; - SS.ScheduleGenerateAll(); return c->h; } @@ -540,7 +539,6 @@ void Constraint::MenuConstrain(Command id) { SS.UndoRemember(); c->other = !(c->other); SS.MarkGroupDirty(c->group); - SS.ScheduleGenerateAll(); break; } } @@ -552,8 +550,7 @@ void Constraint::MenuConstrain(Command id) { Constraint *c = SK.GetConstraint(gs.constraint[0]); if(c->HasLabel() && c->type != Type::COMMENT) { (c->reference) = !(c->reference); - SK.GetGroup(c->group)->clean = false; - SS.GenerateAll(); + SS.MarkGroupDirty(c->group, /*onlyThis=*/true); break; } } diff --git a/src/describescreen.cpp b/src/describescreen.cpp index 0aef0916..46670ae6 100644 --- a/src/describescreen.cpp +++ b/src/describescreen.cpp @@ -37,7 +37,6 @@ void TextWindow::ScreenSetTtfFont(int link, uint32_t v) { SS.UndoRemember(); r->font = SS.fonts.l.elem[i].FontFileBaseName(); SS.MarkGroupDirty(r->group); - SS.ScheduleGenerateAll(); SS.ScheduleShowTW(); } diff --git a/src/generate.cpp b/src/generate.cpp index acf82637..a89f59ba 100644 --- a/src/generate.cpp +++ b/src/generate.cpp @@ -13,7 +13,7 @@ void SolveSpaceUI::MarkGroupDirtyByEntity(hEntity he) { MarkGroupDirty(e->group); } -void SolveSpaceUI::MarkGroupDirty(hGroup hg) { +void SolveSpaceUI::MarkGroupDirty(hGroup hg, bool onlyThis) { int i; bool go = false; for(i = 0; i < SK.groupOrder.n; i++) { @@ -23,9 +23,11 @@ void SolveSpaceUI::MarkGroupDirty(hGroup hg) { } if(go) { g->clean = false; + if(onlyThis) break; } } unsaved = true; + ScheduleGenerateAll(); } bool SolveSpaceUI::PruneOrphans() { diff --git a/src/graphicswin.cpp b/src/graphicswin.cpp index 2dc1a2fc..8624aa1a 100644 --- a/src/graphicswin.cpp +++ b/src/graphicswin.cpp @@ -901,7 +901,6 @@ void GraphicsWindow::MenuEdit(Command id) { // and regenerate as necessary. SS.MarkGroupDirty(hg); - SS.GenerateAll(); break; } @@ -941,7 +940,6 @@ void GraphicsWindow::MenuEdit(Command id) { } // Regenerate, with these points marked as dragged so that they // get placed as close as possible to our snap grid. - SS.GenerateAll(); SS.GW.ClearPending(); SS.GW.ClearSelection(); @@ -1053,7 +1051,6 @@ c: SS.MarkGroupDirty(r->group); } SS.GW.ClearSelection(); - SS.GenerateAll(); break; } diff --git a/src/group.cpp b/src/group.cpp index 9be575ed..054ea399 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -350,7 +350,6 @@ void Group::Activate() { SS.GW.showFaces = false; } SS.MarkGroupDirty(h); // for good measure; shouldn't be needed - SS.ScheduleGenerateAll(); SS.ScheduleShowTW(); } diff --git a/src/modify.cpp b/src/modify.cpp index 582212ac..0165b8b0 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -420,8 +420,6 @@ void GraphicsWindow::MakeTangentArc() { if(SS.tangentArcDeleteOld) { DeleteTaggedRequests(); } - - SS.ScheduleGenerateAll(); } hEntity GraphicsWindow::SplitLine(hEntity he, Vector pinter) { @@ -663,6 +661,5 @@ void GraphicsWindow::SplitLinesOrCurves() { sbla.Clear(); sblb.Clear(); ClearSelection(); - SS.ScheduleGenerateAll(); } diff --git a/src/mouse.cpp b/src/mouse.cpp index 7b0ff4b6..e0cf7d6b 100644 --- a/src/mouse.cpp +++ b/src/mouse.cpp @@ -459,8 +459,6 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown, case Pending::COMMAND: ssassert(false, "Unexpected pending operation"); } - - SS.GenerateAll(); } void GraphicsWindow::ClearPending() { @@ -748,7 +746,6 @@ void GraphicsWindow::MouseRightUp(double x, double y) { } r->extraPoints--; SS.MarkGroupDirtyByEntity(gs.point[0]); - SS.ScheduleGenerateAll(); ClearSelection(); break; } @@ -775,7 +772,6 @@ void GraphicsWindow::MouseRightUp(double x, double y) { Entity *p = SK.GetEntity(e->point[addAfterPoint + 1]); p->PointForceTo(v); SS.MarkGroupDirtyByEntity(gs.entity[0]); - SS.ScheduleGenerateAll(); ClearSelection(); } else { Error("Cannot add spline point: maximum number of points reached."); @@ -1126,7 +1122,6 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) { r->extraPoints -= 2; // And we're done. SS.MarkGroupDirty(r->group); - SS.ScheduleGenerateAll(); ClearPending(); break; } @@ -1394,7 +1389,6 @@ void GraphicsWindow::EditControlDone(const char *s) { break; } SS.MarkGroupDirty(c->group); - SS.GenerateAll(); } } @@ -1500,7 +1494,6 @@ void GraphicsWindow::SpaceNavigatorMoved(double tx, double ty, double tz, lastSpaceNavigatorTime = now; lastSpaceNavigatorGroup = g->h; SS.MarkGroupDirty(g->h); - SS.ScheduleGenerateAll(); } else { // Apply the transformation to the view of the everything. The // x and y components are translation; but z component is scale, diff --git a/src/solvespace.cpp b/src/solvespace.cpp index 0b92ddf1..8b0fec55 100644 --- a/src/solvespace.cpp +++ b/src/solvespace.cpp @@ -734,7 +734,7 @@ void SolveSpaceUI::MenuAnalyze(Command id) { case Command::SHOW_DOF: // This works like a normal solve, except that it calculates // which variables are free/bound at the same time. - SS.GenerateAll(SolveSpaceUI::Generate::ALL, true); + SS.GenerateAll(SolveSpaceUI::Generate::ALL, /*andFindFree=*/true); break; case Command::TRACE_PT: diff --git a/src/solvespace.h b/src/solvespace.h index 3fd468e0..f914136b 100644 --- a/src/solvespace.h +++ b/src/solvespace.h @@ -870,7 +870,7 @@ public: }; Clipboard clipboard; - void MarkGroupDirty(hGroup hg); + void MarkGroupDirty(hGroup hg, bool onlyThis = false); void MarkGroupDirtyByEntity(hEntity he); // Consistency checking on the sketch: stuff with missing dependencies diff --git a/src/style.cpp b/src/style.cpp index 23a87cf6..d1a5e007 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -154,6 +154,7 @@ void Style::AssignSelectionToStyle(uint32_t v) { if(!c->IsStylable()) continue; c->disp.style.v = v; + SS.MarkGroupDirty(c->group); } if(showError) { @@ -163,7 +164,6 @@ void Style::AssignSelectionToStyle(uint32_t v) { SS.GW.ClearSelection(); InvalidateGraphics(); - SS.ScheduleGenerateAll(); // And show that style's info screen in the text window. SS.TW.GoToScreen(TextWindow::Screen::STYLE_INFO); diff --git a/src/textscreens.cpp b/src/textscreens.cpp index 74ad4f57..7a06109a 100644 --- a/src/textscreens.cpp +++ b/src/textscreens.cpp @@ -218,7 +218,6 @@ void TextWindow::ScreenChangeGroupOption(int link, uint32_t v) { } SS.MarkGroupDirty(g->h); - SS.GenerateAll(); SS.GW.ClearSuper(); } @@ -468,7 +467,7 @@ void TextWindow::ScreenAllowRedundant(int link, uint32_t v) { Group *g = SK.GetGroup(SS.TW.shown.group); g->allowRedundant = true; - SS.GenerateAll(); + SS.MarkGroupDirty(SS.TW.shown.group); SS.TW.shown.screen = Screen::GROUP_INFO; SS.TW.Show(); @@ -683,7 +682,6 @@ void TextWindow::EditControlDone(const char *s) { } SS.MarkGroupDirty(g->h); - SS.ScheduleGenerateAll(); } break; } @@ -708,7 +706,6 @@ void TextWindow::EditControlDone(const char *s) { Group *g = SK.GetGroup(edit.group); g->scale = ev; SS.MarkGroupDirty(g->h); - SS.ScheduleGenerateAll(); } } break; @@ -723,7 +720,6 @@ void TextWindow::EditControlDone(const char *s) { g->color = RGBf(rgb.x, rgb.y, rgb.z); SS.MarkGroupDirty(g->h); - SS.ScheduleGenerateAll(); SS.GW.ClearSuper(); } else { Error("Bad format: specify color as r, g, b"); @@ -740,7 +736,6 @@ void TextWindow::EditControlDone(const char *s) { Group *g = SK.GetGroup(edit.group); g->color.alpha = (int)(255.1f * alpha); SS.MarkGroupDirty(g->h); - SS.ScheduleGenerateAll(); SS.GW.ClearSuper(); } } @@ -752,7 +747,6 @@ void TextWindow::EditControlDone(const char *s) { if(r) { r->str = s; SS.MarkGroupDirty(r->group); - SS.ScheduleGenerateAll(); } break; }