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: eb7e12b829fb
Choose a base ref
...
head repository: solvespace/solvespace
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 406c55e8b984
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on May 24, 2019

  1. Copy the full SHA
    09ca442 View commit details
  2. 2
    Copy the full SHA
    406c55e View commit details
Showing with 23 additions and 2 deletions.
  1. +2 −0 CHANGELOG.md
  2. +11 −1 src/constraint.cpp
  3. +1 −1 src/lib.cpp
  4. +9 −0 src/sketch.h
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -35,6 +35,8 @@ New constraint features:
in the text window.
* Distance constraint labels can now be formatted to use SI prefixes.
Values are edited in the configured unit regardless of label format.
* When creating a constraint, if an exactly identical constraint already
exists, it is now selected instead of adding a redundant constraint.
* It is now possible to turn off automatic creation of horizontal/vertical
constraints on line segments.
* Automatic creation of constraints no longer happens if the constraint
12 changes: 11 additions & 1 deletion src/constraint.cpp
Original file line number Diff line number Diff line change
@@ -745,6 +745,17 @@ void Constraint::MenuConstrain(Command id) {
default: ssassert(false, "Unexpected menu ID");
}

for(const Constraint &cc : SK.constraint) {
if(c.h.v != cc.h.v && c.Equals(cc)) {
// Oops, we already have this exact constraint. Remove the one we just added.
SK.constraint.RemoveById(c.h);
SS.GW.ClearSelection();
// And now select the old one, to give feedback.
SS.GW.MakeSelected(cc.h);
return;
}
}

if(SK.constraint.FindByIdNoOops(c.h)) {
Constraint *constraint = SK.GetConstraint(c.h);
if(SS.TestRankForGroup(c.group) == SolveResult::REDUNDANT_OKAY &&
@@ -755,7 +766,6 @@ void Constraint::MenuConstrain(Command id) {
}

SS.GW.ClearSelection();
SS.GW.Invalidate();
}

#endif /* ! LIBRARY */
2 changes: 1 addition & 1 deletion src/lib.cpp
Original file line number Diff line number Diff line change
@@ -209,7 +209,7 @@ default: dbp("bad constraint type %d", sc->type); return;

// Now we're finally ready to solve!
bool andFindBad = ssys->calculateFaileds ? true : false;
SolveResult how = SYS.Solve(&g, &(ssys->dof), &bad, andFindBad, /*andFindFree=*/false);
SolveResult how = SYS.Solve(&g, NULL, &(ssys->dof), &bad, andFindBad, /*andFindFree=*/false);

switch(how) {
case SolveResult::OKAY:
9 changes: 9 additions & 0 deletions src/sketch.h
Original file line number Diff line number Diff line change
@@ -655,6 +655,15 @@ class ConstraintBase {
bool reference; // a ref dimension, that generates no eqs
std::string comment; // since comments are represented as constraints

bool Equals(const ConstraintBase &c) const {
return type == c.type && group.v == c.group.v && workplane.v == c.workplane.v &&
valA == c.valA && valP.v == c.valP.v && ptA.v == c.ptA.v && ptB.v == c.ptB.v &&
entityA.v == c.entityA.v && entityB.v == c.entityB.v &&
entityC.v == c.entityC.v && entityD.v == c.entityD.v &&
other == c.other && other2 == c.other2 && reference == c.reference &&
comment == c.comment;
}

bool HasLabel() const;

void Generate(IdList<Param, hParam> *param);