From 3fe414062cef58d55ab0fa0eca8d030392084b51 Mon Sep 17 00:00:00 2001 From: azv Date: Thu, 1 Sep 2016 07:21:17 +0300 Subject: [PATCH] Incorrect changing attribute of Fixed constraint --- .../SketchSolver_ConstraintFixed.cpp | 20 ++++++++++--------- .../SketchSolver_ConstraintFixed.h | 3 ++- src/SketchSolver/SketchSolver_Group.cpp | 3 ++- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/SketchSolver/SketchSolver_ConstraintFixed.cpp b/src/SketchSolver/SketchSolver_ConstraintFixed.cpp index c048a8528..73c1a5220 100644 --- a/src/SketchSolver/SketchSolver_ConstraintFixed.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintFixed.cpp @@ -20,8 +20,12 @@ SketchSolver_ConstraintFixed::SketchSolver_ConstraintFixed(ConstraintPtr theCons { myBaseConstraint = theConstraint; myType = CONSTRAINT_FIXED; - myFixedAttribute = std::dynamic_pointer_cast( - theConstraint->attribute(SketchPlugin_ConstraintRigid::ENTITY_A())); + AttributeRefAttrPtr anAttribute = + theConstraint->refattr(SketchPlugin_ConstraintRigid::ENTITY_A()); + if (anAttribute->isObject()) + myFixedFeature = ModelAPI_Feature::feature(anAttribute->object()); + else + myFixedAttribute = anAttribute->attr(); } SketchSolver_ConstraintFixed::SketchSolver_ConstraintFixed(FeaturePtr theFeature) @@ -97,13 +101,11 @@ bool SketchSolver_ConstraintFixed::remove() cleanErrorMsg(); // Move fixed entities back to the current group FeaturePtr aFeature = myBaseFeature; - if (myBaseConstraint && myFixedAttribute) { - if (myFixedAttribute->isObject()) - aFeature = ModelAPI_Feature::feature(myFixedAttribute->object()); - else { - if (myFixedAttribute->attr().get()) - myStorage->update(AttributePtr(myFixedAttribute), myGroupID); - } + if (myBaseConstraint) { + if (myFixedFeature) + aFeature = myFixedFeature; + else if (myFixedAttribute) + myStorage->update(AttributePtr(myFixedAttribute), myGroupID); } if (aFeature) myStorage->update(aFeature, myGroupID); diff --git a/src/SketchSolver/SketchSolver_ConstraintFixed.h b/src/SketchSolver/SketchSolver_ConstraintFixed.h index 518683755..87bdd6d35 100644 --- a/src/SketchSolver/SketchSolver_ConstraintFixed.h +++ b/src/SketchSolver/SketchSolver_ConstraintFixed.h @@ -49,7 +49,8 @@ protected: FeaturePtr myBaseFeature; ///< fixed feature (when it is set, myBaseConstraint should be NULL) private: - AttributeRefAttrPtr myFixedAttribute; ///< attribute of a fixed constraint (for correct remove) + AttributePtr myFixedAttribute; ///< possible attribute of a fixed constraint (for correct remove) + FeaturePtr myFixedFeature; ///< possible attribute of a fixed constraint (for correct remove) }; #endif diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index 0c6017cb5..106ba9b33 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -625,6 +625,7 @@ void SketchSolver_Group::removeConstraint(ConstraintPtr theConstraint) // empty group => clear storage if (myConstraints.empty()) { myStorage = StoragePtr(); + mySketchSolver = SolverPtr(); updateWorkplane(); } } @@ -694,7 +695,7 @@ static double featureToVal(FeaturePtr theFeature) anID == SketchPlugin_ConstraintMirror::ID()) return 6.0; if (anID == SketchPlugin_ConstraintRigid::ID()) - return 7.0; + return 0.5; if (anID == SketchPlugin_MultiRotation::ID() || anID == SketchPlugin_MultiTranslation::ID()) return 8.0; -- 2.39.2