File tree 3 files changed +22
-1
lines changed
3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ New constraint features:
35
35
in the text window.
36
36
* Distance constraint labels can now be formatted to use SI prefixes.
37
37
Values are edited in the configured unit regardless of label format.
38
+ * When creating a constraint, if an exactly identical constraint already
39
+ exists, it is now selected instead of adding a redundant constraint.
38
40
* It is now possible to turn off automatic creation of horizontal/vertical
39
41
constraints on line segments.
40
42
* Automatic creation of constraints no longer happens if the constraint
Original file line number Diff line number Diff line change @@ -745,6 +745,17 @@ void Constraint::MenuConstrain(Command id) {
745
745
default : ssassert (false , " Unexpected menu ID" );
746
746
}
747
747
748
+ for (const Constraint &cc : SK.constraint ) {
749
+ if (c.h .v != cc.h .v && c.Equals (cc)) {
750
+ // Oops, we already have this exact constraint. Remove the one we just added.
751
+ SK.constraint .RemoveById (c.h );
752
+ SS.GW .ClearSelection ();
753
+ // And now select the old one, to give feedback.
754
+ SS.GW .MakeSelected (cc.h );
755
+ return ;
756
+ }
757
+ }
758
+
748
759
if (SK.constraint .FindByIdNoOops (c.h )) {
749
760
Constraint *constraint = SK.GetConstraint (c.h );
750
761
if (SS.TestRankForGroup (c.group ) == SolveResult::REDUNDANT_OKAY &&
@@ -755,7 +766,6 @@ void Constraint::MenuConstrain(Command id) {
755
766
}
756
767
757
768
SS.GW .ClearSelection ();
758
- SS.GW .Invalidate ();
759
769
}
760
770
761
771
#endif /* ! LIBRARY */
Original file line number Diff line number Diff line change @@ -655,6 +655,15 @@ class ConstraintBase {
655
655
bool reference; // a ref dimension, that generates no eqs
656
656
std::string comment; // since comments are represented as constraints
657
657
658
+ bool Equals (const ConstraintBase &c) const {
659
+ return type == c.type && group.v == c.group .v && workplane.v == c.workplane .v &&
660
+ valA == c.valA && valP.v == c.valP .v && ptA.v == c.ptA .v && ptB.v == c.ptB .v &&
661
+ entityA.v == c.entityA .v && entityB.v == c.entityB .v &&
662
+ entityC.v == c.entityC .v && entityD.v == c.entityD .v &&
663
+ other == c.other && other2 == c.other2 && reference == c.reference &&
664
+ comment == c.comment ;
Has comments. Original line has comments.
665
+ }
666
+
658
667
bool HasLabel () const ;
659
668
660
669
void Generate (IdList<Param, hParam> *param);
You can’t perform that action at this time.