From d43bd93060856a81a7dce5db92828c63bc96e490 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 13 Feb 2016 22:14:02 +0000 Subject: [PATCH] Only consider groups until active when checking for solver failure. After commit 2f734d9, inactive groups are no longer regenerated for trivial changes, e.g. changing parameters, so it's possible to switch to an earlier group and work on it without incurring the computational (slowdown) and cognitive (annoyance by red background) overhead of later groups failing to solve. However, if a group--any group anywhere--was not solved OK, the interface reacted accordingly, which diminished usefulness of the change, especially given that, if we have groups A and B with B depending on A, if B is broken by a change in A and we activate A and fix it, B will not be regenerated. After this commit, only active groups are considered when deciding if generating the entire sketch would fail. --- src/draw.cpp | 2 +- src/generate.cpp | 7 +++++-- src/solvespace.h | 2 +- src/textscreens.cpp | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/draw.cpp b/src/draw.cpp index af760ef..fa056c1 100644 --- a/src/draw.cpp +++ b/src/draw.cpp @@ -506,7 +506,7 @@ void GraphicsWindow::Paint(void) { // At the same depth, we want later lines drawn over earlier. glDepthFunc(GL_LEQUAL); - if(SS.AllGroupsOkay()) { + if(SS.ActiveGroupsOkay()) { glClearColor(SS.backgroundColor.redF(), SS.backgroundColor.greenF(), SS.backgroundColor.blueF(), 1.0f); diff --git a/src/generate.cpp b/src/generate.cpp index 4e248b5..18a84ca 100644 --- a/src/generate.cpp +++ b/src/generate.cpp @@ -506,10 +506,13 @@ void SolveSpaceUI::SolveGroup(hGroup hg, bool andFindFree) { FreeAllTemporary(); } -bool SolveSpaceUI::AllGroupsOkay() { +bool SolveSpaceUI::ActiveGroupsOkay() { for(int i = 0; i < SK.group.n; i++) { - if(!SK.group.elem[i].IsSolvedOkay()) + Group *group = &SK.group.elem[i]; + if(!group->IsSolvedOkay()) return false; + if(group->h.v == SS.GW.activeGroup.v) + break; } return true; } diff --git a/src/solvespace.h b/src/solvespace.h index 8aceaa6..ae6b216 100644 --- a/src/solvespace.h +++ b/src/solvespace.h @@ -874,7 +874,7 @@ public: void MarkDraggedParams(void); void ForceReferences(void); - bool AllGroupsOkay(void); + bool ActiveGroupsOkay(void); // The system to be solved. System sys; diff --git a/src/textscreens.cpp b/src/textscreens.cpp index 07c28fd..0caf6c1 100644 --- a/src/textscreens.cpp +++ b/src/textscreens.cpp @@ -552,7 +552,7 @@ void TextWindow::ScreenStepDimGo(int link, uint32_t v) { c->valA = start + ((finish - start)*i)/n; SS.MarkGroupDirty(c->group); SS.GenerateAll(); - if(!SS.AllGroupsOkay()) { + if(!SS.ActiveGroupsOkay()) { // Failed to solve, so quit break; }