Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: solvespace/solvespace
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e74185b63940
Choose a base ref
...
head repository: solvespace/solvespace
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 668fe6f493eb
Choose a head ref
  • 2 commits
  • 8 files changed
  • 1 contributor

Commits on Sep 16, 2020

  1. Fix #131. Prevent UI freeze by having a timeout when finding which co…

    …nstraints can be removed to fix jacobian.
    phkahler committed Sep 16, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    issyl0 Issy Long
    Copy the full SHA
    6157084 View commit details
  2. Make the redundant constraint timeout a configuration value and add t…

    …he config UI elements to edit that value.
    phkahler committed Sep 16, 2020
    Copy the full SHA
    668fe6f View commit details
Showing with 44 additions and 1 deletion.
  1. +20 −0 src/confscreen.cpp
  2. +1 −0 src/generate.cpp
  3. +2 −0 src/sketch.h
  4. +4 −0 src/solvespace.cpp
  5. +3 −1 src/solvespace.h
  6. +7 −0 src/system.cpp
  7. +5 −0 src/textscreens.cpp
  8. +2 −0 src/ui.h
20 changes: 20 additions & 0 deletions src/confscreen.cpp
Original file line number Diff line number Diff line change
@@ -204,6 +204,11 @@ void TextWindow::ScreenChangeAutosaveInterval(int link, uint32_t v) {
SS.TW.edit.meaning = Edit::AUTOSAVE_INTERVAL;
}

void TextWindow::ScreenChangeFindConstraintTimeout(int link, uint32_t v) {
SS.TW.ShowEditControl(3, std::to_string(SS.timeoutRedundantConstr));
SS.TW.edit.meaning = Edit::FIND_CONSTRAINT_TIMEOUT;
}

void TextWindow::ShowConfiguration() {
int i;
Printf(true, "%Ft user color (r, g, b)");
@@ -371,6 +376,10 @@ void TextWindow::ShowConfiguration() {
Printf(false, "%Ft autosave interval (in minutes)%E");
Printf(false, "%Ba %d %Fl%Ll%f[change]%E",
SS.autosaveInterval, &ScreenChangeAutosaveInterval);
Printf(false, "");
Printf(false, "%Ft redundant constraint timeout (in ms)%E");
Printf(false, "%Ba %d %Fl%Ll%f[change]%E",
SS.timeoutRedundantConstr, &ScreenChangeFindConstraintTimeout);

if(canvas) {
const char *gl_vendor, *gl_renderer, *gl_version;
@@ -542,6 +551,17 @@ bool TextWindow::EditControlDoneForConfiguration(const std::string &s) {
}
break;
}
case Edit::FIND_CONSTRAINT_TIMEOUT: {
int timeout = atoi(s.c_str());
if(timeout) {
if(timeout >= 1) {
SS.timeoutRedundantConstr = timeout;
} else {
SS.timeoutRedundantConstr = 1000;
}
}
break;
}

default: return false;
}
1 change: 1 addition & 0 deletions src/generate.cpp
Original file line number Diff line number Diff line change
@@ -533,6 +533,7 @@ void SolveSpaceUI::SolveGroup(hGroup hg, bool andFindFree) {
WriteEqSystemForGroup(hg);
Group *g = SK.GetGroup(hg);
g->solved.remove.Clear();
g->solved.findToFixTimeout = SS.timeoutRedundantConstr;
SolveResult how = sys.Solve(g, NULL,
&(g->solved.dof),
&(g->solved.remove),
2 changes: 2 additions & 0 deletions src/sketch.h
Original file line number Diff line number Diff line change
@@ -189,6 +189,8 @@ class Group {
struct {
SolveResult how;
int dof;
int findToFixTimeout;
bool timeout;
List<hConstraint> remove;
} solved;

4 changes: 4 additions & 0 deletions src/solvespace.cpp
Original file line number Diff line number Diff line change
@@ -51,6 +51,8 @@ void SolveSpaceUI::Init() {
exportChordTol = settings->ThawFloat("ExportChordTolerance", 0.1);
// Max pwl segments to generate
exportMaxSegments = settings->ThawInt("ExportMaxSegments", 64);
// Timeout value for finding redundant constrains (ms)
timeoutRedundantConstr = settings->ThawInt("TimeoutRedundantConstraints", 1000);
// View units
viewUnits = (Unit)settings->ThawInt("ViewUnits", (uint32_t)Unit::MM);
// Number of digits after the decimal point
@@ -231,6 +233,8 @@ void SolveSpaceUI::Exit() {
settings->FreezeFloat("ExportChordTolerance", (float)exportChordTol);
// Export Max pwl segments to generate
settings->FreezeInt("ExportMaxSegments", (uint32_t)exportMaxSegments);
// Timeout for finding which constraints to fix Jacobian
settings->FreezeInt("TimeoutRedundantConstraints", (uint32_t)timeoutRedundantConstr);
// View units
settings->FreezeInt("ViewUnits", (uint32_t)viewUnits);
// Number of digits after the decimal point
4 changes: 3 additions & 1 deletion src/solvespace.h
Original file line number Diff line number Diff line change
@@ -268,7 +268,8 @@ class System {
void EvalJacobian();

void WriteEquationsExceptFor(hConstraint hc, Group *g);
void FindWhichToRemoveToFixJacobian(Group *g, List<hConstraint> *bad, bool forceDofCheck);
void FindWhichToRemoveToFixJacobian(Group *g, List<hConstraint> *bad,
bool forceDofCheck);
void SolveBySubstitution();

bool IsDragged(hParam p);
@@ -562,6 +563,7 @@ class SolveSpaceUI {
int maxSegments;
double exportChordTol;
int exportMaxSegments;
int timeoutRedundantConstr; //milliseconds
double cameraTangent;
double gridSpacing;
double exportScale;
7 changes: 7 additions & 0 deletions src/system.cpp
Original file line number Diff line number Diff line change
@@ -355,10 +355,17 @@ void System::WriteEquationsExceptFor(hConstraint hc, Group *g) {
}

void System::FindWhichToRemoveToFixJacobian(Group *g, List<hConstraint> *bad, bool forceDofCheck) {
auto time = GetMilliseconds();
g->solved.timeout = false;
int a;

for(a = 0; a < 2; a++) {
for(auto &con : SK.constraint) {
if((GetMilliseconds() - time) > g->solved.findToFixTimeout) {
g->solved.timeout = true;
return;
}

ConstraintBase *c = &con;
if(c->group != g->h) continue;
if((c->type == Constraint::Type::POINTS_COINCIDENT && a == 0) ||
5 changes: 5 additions & 0 deletions src/textscreens.cpp
Original file line number Diff line number Diff line change
@@ -578,6 +578,11 @@ void TextWindow::ShowGroupSolveInfo() {
c->DescriptionString().c_str());
}

if(g->solved.timeout) {
Printf(true, "%FxSome items in list have been ommitted%Fd");
Printf(false, "%Fxbecause the operation timed out.%Fd");
}

Printf(true, "It may be possible to fix the problem ");
Printf(false, "by selecting Edit -> Undo.");

2 changes: 2 additions & 0 deletions src/ui.h
Original file line number Diff line number Diff line change
@@ -316,6 +316,7 @@ class TextWindow {
G_CODE_PLUNGE_FEED = 115,
AUTOSAVE_INTERVAL = 116,
LIGHT_AMBIENT = 117,
FIND_CONSTRAINT_TIMEOUT = 118,
// For TTF text
TTF_TEXT = 300,
// For the step dimension screen
@@ -488,6 +489,7 @@ class TextWindow {
static void ScreenChangeExportOffset(int link, uint32_t v);
static void ScreenChangeGCodeParameter(int link, uint32_t v);
static void ScreenChangeAutosaveInterval(int link, uint32_t v);
static void ScreenChangeFindConstraintTimeout(int link, uint32_t v);
static void ScreenChangeStyleName(int link, uint32_t v);
static void ScreenChangeStyleMetric(int link, uint32_t v);
static void ScreenChangeStyleTextAngle(int link, uint32_t v);