]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Incorrect changing attribute of Fixed constraint
authorazv <azv@opencascade.com>
Thu, 1 Sep 2016 04:21:17 +0000 (07:21 +0300)
committerazv <azv@opencascade.com>
Thu, 1 Sep 2016 04:22:19 +0000 (07:22 +0300)
src/SketchSolver/SketchSolver_ConstraintFixed.cpp
src/SketchSolver/SketchSolver_ConstraintFixed.h
src/SketchSolver/SketchSolver_Group.cpp

index c048a85287324e3010c904ca5bf8757179b67793..73c1a52202dbe1dece1003a9518798178f9cac4e 100644 (file)
@@ -20,8 +20,12 @@ SketchSolver_ConstraintFixed::SketchSolver_ConstraintFixed(ConstraintPtr theCons
 {
   myBaseConstraint = theConstraint;
   myType = CONSTRAINT_FIXED;
-  myFixedAttribute = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-      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);
index 518683755ec1a8a74a0663da75b8bfe174057f60..87bdd6d358757085d5a2199a6dee9ebf6819ce72 100644 (file)
@@ -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
index 0c6017cb587b1bb6e29d7e7407dcfcf533433da1..106ba9b339f79dafb85f5d77ac4bff8599014276 100644 (file)
@@ -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;