Do ScheduleGenerateAll in MarkGroupDirty.

This generally simplifies code, and also fixes a bug where adding
a datum point would not regenerate the sketch.
pull/144/head
Evil-Spirit 2016-12-26 09:09:45 +07:00 committed by whitequark
parent 9148d0cb91
commit d99a133982
12 changed files with 8 additions and 32 deletions

View File

@ -235,8 +235,6 @@ void GraphicsWindow::PasteClipboard(Vector trans, double theta, double scale) {
MakeSelected(hc);
}
}
SS.ScheduleGenerateAll();
}
void GraphicsWindow::MenuClipboard(Command id) {

View File

@ -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;
}
}

View File

@ -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();
}

View File

@ -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() {

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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,

View File

@ -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:

View File

@ -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

View File

@ -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);

View File

@ -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;
}