]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix the problem of the updating of "multi" constraints
authorazv <azv@opencascade.com>
Tue, 23 May 2017 09:54:12 +0000 (12:54 +0300)
committerazv <azv@opencascade.com>
Tue, 23 May 2017 10:03:42 +0000 (13:03 +0300)
src/SketchSolver/SketchSolver_ConstraintMulti.cpp
src/SketchSolver/SketchSolver_ConstraintMulti.h
src/SketchSolver/SketchSolver_ConstraintMultiRotation.cpp
src/SketchSolver/SketchSolver_ConstraintMultiTranslation.cpp

index 9c270943f3445772c9ec038337b8019f1cbfcb65..82feccdf4f792b2429fb72e78321caaaff59e834 100644 (file)
@@ -60,13 +60,13 @@ void SketchSolver_ConstraintMulti::getEntities(std::list<EntityWrapperPtr>& theE
     if (!myStorage->update(aFeature))
       myStorage->update(aFeature, true);
     theEntities.push_back(myStorage->entity(aFeature));
-    myFeatures.insert(aFeature);
+    myOriginalFeatures.insert(aFeature);
     for (int i = 0; i < myNumberOfCopies && anObjIt != anObjectList.end(); ++i, ++anObjIt) {
       // just add copied features into the list of objects
       aFeature = ModelAPI_Feature::feature(*anObjIt);
       if (aFeature) {
         createCopiedEntity(aFeature, myStorage);
-        myFeatures.insert(aFeature);
+        myCopiedFeatures.insert(aFeature);
       }
     }
   }
@@ -78,8 +78,8 @@ bool SketchSolver_ConstraintMulti::remove()
 
   // "Multi" constraint has been removed, thus all copy features become non-copied,
   // add them once again to be a common feature
-  std::set<FeaturePtr>::iterator anIt = myFeatures.begin();
-  for (; anIt != myFeatures.end(); ++anIt) {
+  std::set<FeaturePtr>::iterator anIt = myCopiedFeatures.begin();
+  for (; anIt != myCopiedFeatures.end(); ++anIt) {
     EntityWrapperPtr anEntity = myStorage->entity(*anIt);
     if (anEntity) {
       std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
@@ -90,7 +90,8 @@ bool SketchSolver_ConstraintMulti::remove()
       myStorage->update(*anIt, true);
   }
 
-  myFeatures.clear();
+  myOriginalFeatures.clear();
+  myCopiedFeatures.clear();
   return SketchSolver_Constraint::remove();
 }
 
@@ -114,7 +115,8 @@ void SketchSolver_ConstraintMulti::update()
       std::list<ObjectPtr>::iterator anObjIt = anObjectList.begin();
       for (; anObjIt != anObjectList.end(); ++anObjIt) {
         aFeature = ModelAPI_Feature::feature(*anObjIt);
-        if (aFeature && myFeatures.find(aFeature) == myFeatures.end()) {
+        if (aFeature && myOriginalFeatures.find(aFeature) == myOriginalFeatures.end() &&
+            myCopiedFeatures.find(aFeature) == myCopiedFeatures.end()) {
           isUpdated = true;
           break;
         }
@@ -208,7 +210,8 @@ void SketchSolver_ConstraintMulti::adjustConstraint()
 void SketchSolver_ConstraintMulti::notify(const FeaturePtr& theFeature,
                                           PlaneGCSSolver_Update*)
 {
-  if (myFeatures.find(theFeature) == myFeatures.end())
+  if (myOriginalFeatures.find(theFeature) == myOriginalFeatures.end() &&
+      myCopiedFeatures.find(theFeature) == myCopiedFeatures.end())
     return; // the feature is not used by constraint => nothing to update
 
   // update derivative object
@@ -221,8 +224,10 @@ void SketchSolver_ConstraintMulti::blockEvents(bool isBlocked)
 {
   myIsEventsBlocked = isBlocked;
 
-  std::set<FeaturePtr>::iterator anIt = myFeatures.begin();
-  for (; anIt != myFeatures.end(); ++anIt)
+  std::set<FeaturePtr>::iterator anIt = myOriginalFeatures.begin();
+  for (; anIt != myOriginalFeatures.end(); ++anIt)
+    (*anIt)->data()->blockSendAttributeUpdated(isBlocked);
+  for (anIt = myCopiedFeatures.begin(); anIt != myCopiedFeatures.end(); ++anIt)
     (*anIt)->data()->blockSendAttributeUpdated(isBlocked);
 
   SketchSolver_Constraint::blockEvents(isBlocked);
index 969b4ae0d6f2ac5abc0d2424aef20ca854b4813a..976a4f369beb924ad5fe91650b12705dd98f2f85 100644 (file)
@@ -78,8 +78,9 @@ protected:
 
   bool myAdjusted; ///< the constraint is already adjusted (to not do it several times)
 
-  /// list of features and their copies to find whether some of them are disappeared
-  std::set<FeaturePtr> myFeatures;
+  /// lists of original features and their copies to find whether some of them are disappeared
+  std::set<FeaturePtr> myOriginalFeatures;
+  std::set<FeaturePtr> myCopiedFeatures;
 
   bool myIsEventsBlocked;
 };
index 59a095d71b66bb14e5f6e4703f32210dc7ce10b3..16a3eaebd1c078793411c4dc927f1651c4ac4937 100644 (file)
@@ -46,7 +46,7 @@ void SketchSolver_ConstraintMultiRotation::getAttributes(
   // add owner of central point of Multi-Rotation to the list of monitored features
   FeaturePtr anOwner = ModelAPI_Feature::feature(aCenterAttr->attr()->owner());
   if (anOwner)
-    myFeatures.insert(anOwner);
+    myOriginalFeatures.insert(anOwner);
 }
 
 void SketchSolver_ConstraintMultiRotation::process()
index 7bbd8c18f382dd972a7972da43cad7adc17a0271..c954c5b068cf403ddf0f911a7c8af8d88f546973 100644 (file)
@@ -42,10 +42,10 @@ void SketchSolver_ConstraintMultiTranslation::getAttributes(
   // add owner of start and end points of Multi-Translation to the list of monitored features
   FeaturePtr anOwner = ModelAPI_Feature::feature(aStartPointAttr->attr()->owner());
   if (anOwner)
-    myFeatures.insert(anOwner);
+    myOriginalFeatures.insert(anOwner);
   anOwner = ModelAPI_Feature::feature(aEndPointAttr->attr()->owner());
   if (anOwner)
-    myFeatures.insert(anOwner);
+    myOriginalFeatures.insert(anOwner);
 }
 
 void SketchSolver_ConstraintMultiTranslation::process()