Salome HOME
Issue #393: Make fixed feature movable
authorazv <azv@opencascade.com>
Tue, 14 Apr 2015 05:45:31 +0000 (08:45 +0300)
committerazv <azv@opencascade.com>
Tue, 14 Apr 2015 05:46:12 +0000 (08:46 +0300)
src/SketchSolver/SketchSolver_ConstraintRigid.cpp
src/SketchSolver/SketchSolver_Error.h
src/SketchSolver/SketchSolver_Group.cpp

index 3483973fe30f2ae5661d04de2e26a16984926532..49fded0732536720edf771eb86dbf4f7dd9393df 100644 (file)
@@ -35,17 +35,23 @@ void SketchSolver_ConstraintRigid::process()
   if (!myErrorMsg.empty() || myFeatureMap.empty())
     return;
 
+  Slvs_hEntity anEntID = myFeatureMap.begin()->second;
+  if (myStorage->isEntityFixed(anEntID, true)) {
+    myErrorMsg = SketchSolver_Error::ALREADY_FIXED();
+    return;
+  }
+
   if (myFeatureMap.begin()->first->getKind() == SketchPlugin_Line::ID()) {
-    Slvs_Entity aLine = myStorage->getEntity(myFeatureMap.begin()->second);
+    Slvs_Entity aLine = myStorage->getEntity(anEntID);
     fixLine(aLine);
   }
   else if (myFeatureMap.begin()->first->getKind() == SketchPlugin_Arc::ID()) {
-    Slvs_Entity anArc = myStorage->getEntity(myFeatureMap.begin()->second);
+    Slvs_Entity anArc = myStorage->getEntity(anEntID);
     fixArc(anArc);
   }
   else if (myFeatureMap.begin()->first->getKind() == SketchPlugin_Circle::ID()) {
-    Slvs_Entity aCirc = myStorage->getEntity(myFeatureMap.begin()->second);
-    fixArc(aCirc);
+    Slvs_Entity aCirc = myStorage->getEntity(anEntID);
+    fixCircle(aCirc);
   }
 }
 
index e0446b558eb8e699510a45d027ecfafe3bb782aa..0ae33d3c60abb8c4d4ccf2f4131d273e5a43534f 100644 (file)
@@ -59,6 +59,12 @@ class SketchSolver_Error
     static const std::string MY_ERROR_VALUE("Mirror constraint has wrong attributes");
     return MY_ERROR_VALUE;
   }
+  /// Entity is already fixed
+  inline static const std::string& ALREADY_FIXED()
+  {
+    static const std::string MY_ERROR_VALUE("Entity already fixed");
+    return MY_ERROR_VALUE;
+  }
   /// Crash in SolveSpace
   inline static const std::string& SOLVESPACE_CRASH()
   {
index 58d822786f807d1b4b92446b4e8be22be41dde35..9a4623428c65f1b639ee05aeae935ed18ccce43e 100644 (file)
@@ -278,7 +278,8 @@ void SketchSolver_Group::moveFeature(std::shared_ptr<SketchPlugin_Feature> theFe
     return;
   aConstraint->setGroup(this);
   aConstraint->setStorage(myStorage);
-  setTemporary(aConstraint);
+  if (aConstraint->error().empty())
+    setTemporary(aConstraint);
 }
 
 // ============================================================================