GeezerVison is showing github.com — Use an enum to select the mode of operation for GenerateAll. · realthunder/solvespace@b28fa34
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/clipboard.cpp +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -150,7 +150,7 @@ void GraphicsWindow::PasteClipboard(Vector trans, double theta, double scale) { | 150 | 150 | r->construction = cr->construction; | 151 | 151 | // Need to regen to get the right number of points, if extraPoints | 152 | 152 | // changed. | 153 | | - SS.GenerateAll(-1, -1); | | 153 | + SS.GenerateAll(SolveSpaceUI::GENERATE_REGEN); | 154 | 154 | SS.MarkGroupDirty(r->group); | 155 | 155 | bool hasDistance; | 156 | 156 | int i, pts; | |
Collapse file Copy file name to clipboardExpand all lines: src/confscreen.cpp +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -313,12 +313,12 @@ bool TextWindow::EditControlDoneForConfiguration(const char *s) { | 313 | 313 | } | 314 | 314 | case EDIT_CHORD_TOLERANCE: { | 315 | 315 | SS.chordTol = min(10.0, max(0.1, atof(s))); | 316 | | - SS.GenerateAll(0, INT_MAX); | | 316 | + SS.GenerateAll(SolveSpaceUI::GENERATE_ALL); | 317 | 317 | break; | 318 | 318 | } | 319 | 319 | case EDIT_MAX_SEGMENTS: { | 320 | 320 | SS.maxSegments = min(1000, max(7, atoi(s))); | 321 | | - SS.GenerateAll(0, INT_MAX); | | 321 | + SS.GenerateAll(SolveSpaceUI::GENERATE_ALL); | 322 | 322 | break; | 323 | 323 | } | 324 | 324 | case EDIT_CAMERA_TANGENT: { | |
Collapse file Copy file name to clipboardExpand all lines: src/file.cpp +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -255,7 +255,7 @@ bool SolveSpaceUI::SaveToFile(const std::string &filename) { | 255 | 255 | // the impFileRel for our possibly-new filename. | 256 | 256 | SS.ScheduleShowTW(); | 257 | 257 | SS.ReloadAllImported(); | 258 | | - SS.GenerateAll(0, INT_MAX); | | 258 | + SS.GenerateAll(SolveSpaceUI::GENERATE_ALL); | 259 | 259 |
| 260 | 260 | fh = ssfopen(filename, "wb"); | 261 | 261 | if(!fh) { | |
Collapse file Copy file name to clipboardExpand all lines: src/generate.cpp +10-1Lines changed: 10 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -158,13 +158,22 @@ void SolveSpaceUI::GenerateAll(void) { | 158 | 158 | } | 159 | 159 | if(firstDirty == INT_MAX || lastVisible == 0) { | 160 | 160 | // All clean; so just regenerate the entities, and don't solve anything. | 161 | | - GenerateAll(-1, -1); | | 161 | + GenerateAll(GENERATE_REGEN); | 162 | 162 | } else { | 163 | 163 | SS.nakedEdges.Clear(); | 164 | 164 | GenerateAll(firstDirty, lastVisible); | 165 | 165 | } | 166 | 166 | } | 167 | 167 |
| | 168 | +void SolveSpaceUI::GenerateAll(GenerateType type, bool andFindFree) { | | 169 | + switch(type) { | | 170 | + case GENERATE_ALL: GenerateAll(0, INT_MAX, andFindFree); break; | | 171 | + case GENERATE_REGEN: GenerateAll(-1, -1, andFindFree); break; | | 172 | + case GENERATE_UNTIL_ACTIVE: GenerateAll(0, -2, andFindFree); break; | | 173 | + default: oops(); | | 174 | + } | | 175 | +} | | 176 | + | 168 | 177 | void SolveSpaceUI::GenerateAll(int first, int last, bool andFindFree) { | 169 | 178 | int i, j; | 170 | 179 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/graphicswin.cpp +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -678,7 +678,7 @@ void GraphicsWindow::DeleteTaggedRequests(void) { | 678 | 678 | ClearSuper(); | 679 | 679 | // And regenerate to get rid of what it generates, plus anything | 680 | 680 | // that references it (since the regen code checks for that). | 681 | | - SS.GenerateAll(0, INT_MAX); | | 681 | + SS.GenerateAll(SolveSpaceUI::GENERATE_ALL); | 682 | 682 | EnsureValidActives(); | 683 | 683 | SS.ScheduleShowTW(); | 684 | 684 | } | @@ -886,7 +886,7 @@ void GraphicsWindow::MenuEdit(int id) { | 886 | 886 |
| 887 | 887 | case MNU_REGEN_ALL: | 888 | 888 | SS.ReloadAllImported(); | 889 | | - SS.GenerateAll(0, -2); | | 889 | + SS.GenerateAll(SolveSpaceUI::GENERATE_UNTIL_ACTIVE); | 890 | 890 | SS.ScheduleShowTW(); | 891 | 891 | break; | 892 | 892 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/mouse.cpp +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -743,7 +743,7 @@ hRequest GraphicsWindow::AddRequest(int type, bool rememberForUndo) { | 743 | 743 | // place this request's entities where the mouse is can do so. But | 744 | 744 | // we mustn't try to solve until reasonable values have been supplied | 745 | 745 | // for these new parameters, or else we'll get a numerical blowup. | 746 | | - SS.GenerateAll(-1, -1); | | 746 | + SS.GenerateAll(SolveSpaceUI::GENERATE_REGEN); | 747 | 747 | SS.MarkGroupDirty(r.group); | 748 | 748 | return r.h; | 749 | 749 | } | @@ -1006,7 +1006,7 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) { | 1006 | 1006 | } | 1007 | 1007 |
| 1008 | 1008 | (SK.GetRequest(hr)->extraPoints)++; | 1009 | | - SS.GenerateAll(-1, -1); | | 1009 | + SS.GenerateAll(SolveSpaceUI::GENERATE_REGEN); | 1010 | 1010 |
| 1011 | 1011 | int ep = r->extraPoints; | 1012 | 1012 | Vector last = SK.GetEntity(hr.entity(3+ep))->PointGetNum(); | |
Collapse file Copy file name to clipboardExpand all lines: src/solvespace.cpp +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -294,7 +294,7 @@ void SolveSpaceUI::AfterNewFile(void) { | 294 | 294 | SS.GW.projRight = Vector::From(1, 0, 0); | 295 | 295 | SS.GW.projUp = Vector::From(0, 1, 0); | 296 | 296 |
| 297 | | - GenerateAll(-1, -1); | | 297 | + GenerateAll(GENERATE_REGEN); | 298 | 298 |
| 299 | 299 | TW.Init(); | 300 | 300 | GW.Init(); | @@ -312,7 +312,7 @@ void SolveSpaceUI::AfterNewFile(void) { | 312 | 312 | // thing visible is the not-yet-generated surfaces. | 313 | 313 | GW.ZoomToFit(true); | 314 | 314 |
| 315 | | - GenerateAll(0, INT_MAX); | | 315 | + GenerateAll(GENERATE_ALL); | 316 | 316 | SS.ScheduleShowTW(); | 317 | 317 | // Then zoom to fit again, to fit the triangles | 318 | 318 | GW.ZoomToFit(false); | @@ -713,7 +713,7 @@ void SolveSpaceUI::MenuAnalyze(int id) { | 713 | 713 | case GraphicsWindow::MNU_SHOW_DOF: | 714 | 714 | // This works like a normal solve, except that it calculates | 715 | 715 | // which variables are free/bound at the same time. | 716 | | - SS.GenerateAll(0, INT_MAX, true); | | 716 | + SS.GenerateAll(SolveSpaceUI::GENERATE_ALL, true); | 717 | 717 | break; | 718 | 718 |
| 719 | 719 | case GraphicsWindow::MNU_TRACE_PT: | |
Collapse file Copy file name to clipboardExpand all lines: src/solvespace.h +7Lines changed: 7 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -926,6 +926,13 @@ class SolveSpaceUI { | 926 | 926 | bool PruneRequests(hGroup hg); | 927 | 927 | bool PruneConstraints(hGroup hg); | 928 | 928 |
| | 929 | + enum GenerateType { | | 930 | + GENERATE_ALL, | | 931 | + GENERATE_REGEN, | | 932 | + GENERATE_UNTIL_ACTIVE, | | 933 | + }; | | 934 | + | | 935 | + void GenerateAll(GenerateType type, bool andFindFree = false); | 929 | 936 | void GenerateAll(void); | 930 | 937 | void GenerateAll(int first, int last, bool andFindFree=false); | 931 | 938 | void SolveGroup(hGroup hg, bool andFindFree); | |
Collapse file Copy file name to clipboardExpand all lines: src/textscreens.cpp +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -266,7 +266,7 @@ void TextWindow::ScreenDeleteGroup(int link, uint32_t v) { | 266 | 266 | // This is a major change, so let's re-solve everything. | 267 | 267 | SS.TW.ClearSuper(); | 268 | 268 | SS.GW.ClearSuper(); | 269 | | - SS.GenerateAll(0, INT_MAX); | | 269 | + SS.GenerateAll(SolveSpaceUI::GENERATE_ALL); | 270 | 270 | } | 271 | 271 | void TextWindow::ShowGroupInfo(void) { | 272 | 272 | Group *g = SK.group.FindById(shown.group); | |
Collapse file Copy file name to clipboardExpand all lines: src/undoredo.cpp +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -127,7 +127,7 @@ void SolveSpaceUI::PopOntoCurrentFrom(UndoStack *uk) { | 127 | 127 | SS.GW.ClearSuper(); | 128 | 128 | SS.TW.ClearSuper(); | 129 | 129 | SS.ReloadAllImported(); | 130 | | - SS.GenerateAll(0, INT_MAX); | | 130 | + SS.GenerateAll(SolveSpaceUI::GENERATE_ALL); | 131 | 131 | SS.ScheduleShowTW(); | 132 | 132 |
| 133 | 133 | // Activate the group that was active before. | |
|