Instead of creating an exact copy of existing constraint, select it.
parent
09ca442715
commit
406c55e8b9
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -655,6 +655,15 @@ public:
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue