]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the issue #1714: problems with extrusion update created on the sketch after...
authormpv <mpv@opencascade.com>
Tue, 6 Sep 2016 07:46:58 +0000 (10:46 +0300)
committermpv <mpv@opencascade.com>
Tue, 6 Sep 2016 07:46:58 +0000 (10:46 +0300)
src/Model/Model_SelectionNaming.cpp
src/Model/Model_Update.cpp
src/Model/Model_Update.h

index ecf334303ef04ca5df4843949b02be7d34adb210..2817bea492e7a4637dd88ef4c490a440c1f0b95e 100644 (file)
@@ -123,7 +123,10 @@ std::string Model_SelectionNaming::namingName(ResultPtr& theContext,
   if (theContext->groupName() == ModelAPI_ResultPart::group()) {
     ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(theContext);
     int anIndex;
-    return aPart->data()->name() + "/" + aPart->nameInPart(theSubSh, anIndex);
+    if (theSubSh.get())
+      return aPart->data()->name() + "/" + aPart->nameInPart(theSubSh, anIndex);
+    else 
+      return aPart->data()->name();
   }
 
   if (!theSubSh.get() || theSubSh->isNull()) { // no subshape, so just the whole feature name
index 48b8dcb00cb5284405ef05d0d77f2b705f9cbf49..a156d40021ce39b366690e32358e1403f7cd872b 100755 (executable)
@@ -71,9 +71,19 @@ bool Model_Update::addModified(FeaturePtr theFeature, FeaturePtr theReason) {
   if (!theFeature->data()->isValid())
     return false; // delete an extrusion created on the sketch
 
-  if (theFeature->isPersistentResult()) {
-    if (!std::dynamic_pointer_cast<Model_Document>((theFeature)->document())->executeFeatures())
+  bool isNotExecuted = theFeature->isPersistentResult() &&
+    !std::dynamic_pointer_cast<Model_Document>((theFeature)->document())->executeFeatures();
+  if (isNotExecuted) {
+    if (!theReason.get()) // no reason => no construction reason
       return false;
+    if (myNotPersistentRefs.find(theFeature) == myNotPersistentRefs.end()) {
+      myNotPersistentRefs[theFeature].insert(theReason);
+    } else {
+      std::set<std::shared_ptr<ModelAPI_Feature> > aNewSet;
+      aNewSet.insert(theReason);
+      myNotPersistentRefs[theFeature] = aNewSet;
+    }
+    return false;
   }
 
   // update arguments for "apply button" state change
@@ -119,7 +129,7 @@ bool Model_Update::addModified(FeaturePtr theFeature, FeaturePtr theReason) {
       if (theReason.get())
         aNewSet.insert(theReason);
     }
-    myModified[theFeature] = aNewSet;
+      myModified[theFeature] = aNewSet;
 #ifdef DEB_UPDATE
     if (theReason.get())
       std::cout<<"*** Add modified "<<theFeature->name()<<" reason "<<theReason->name()<<std::endl;
@@ -505,6 +515,8 @@ bool Model_Update::processFeature(FeaturePtr theFeature)
   // add this feature to the processed right now to be able remove it from this list on
   // update signal during this feature execution
   myModified.erase(theFeature);
+  if (myNotPersistentRefs.find(theFeature) != myNotPersistentRefs.end())
+    myNotPersistentRefs.erase(theFeature);
   if (theFeature->data()->execState() == ModelAPI_StateMustBeUpdated)
     theFeature->data()->execState(ModelAPI_StateDone);
 
@@ -728,18 +740,33 @@ bool Model_Update::isReason(std::shared_ptr<ModelAPI_Feature>& theFeature,
 {
   std::map<std::shared_ptr<ModelAPI_Feature>, std::set<std::shared_ptr<ModelAPI_Feature> > >
     ::iterator aReasonsIt = myModified.find(theFeature);
-  if (aReasonsIt == myModified.end())
-    return false; // this case only for not-previewed items update state, nothing is changed in args for it
-  if (aReasonsIt->second.find(theFeature) != aReasonsIt->second.end())
-    return true; // any is reason if it contains itself
-  FeaturePtr aReasFeat = std::dynamic_pointer_cast<ModelAPI_Feature>(theReason);
-  if (!aReasFeat.get()) { // try to get feature of this result
-    ResultPtr aReasRes = std::dynamic_pointer_cast<ModelAPI_Result>(theReason);
-    if (aReasRes.get())
-      aReasFeat = theReason->document()->feature(aReasRes);
-  }
-  return aReasonsIt->second.find(aReasFeat) != aReasonsIt->second.end();
+  if (aReasonsIt != myModified.end()) {
+    if (aReasonsIt->second.find(theFeature) != aReasonsIt->second.end())
+      return true; // any is reason if it contains itself
+    FeaturePtr aReasFeat = std::dynamic_pointer_cast<ModelAPI_Feature>(theReason);
+    if (!aReasFeat.get()) { // try to get feature of this result
+      ResultPtr aReasRes = std::dynamic_pointer_cast<ModelAPI_Result>(theReason);
+      if (aReasRes.get())
+        aReasFeat = theReason->document()->feature(aReasRes);
+    }
+    if (aReasonsIt->second.find(aReasFeat) != aReasonsIt->second.end())
+      return true;
+  }
+  // another try: postponed modification by not-persistences
+  std::map<std::shared_ptr<ModelAPI_Feature>, std::set<std::shared_ptr<ModelAPI_Feature> > >
+    ::iterator aNotPersist = myNotPersistentRefs.find(theFeature);
+  if (aNotPersist != myNotPersistentRefs.end()) {
+    FeaturePtr aReasFeat = std::dynamic_pointer_cast<ModelAPI_Feature>(theReason);
+    if (!aReasFeat.get()) { // try to get feature of this result
+      ResultPtr aReasRes = std::dynamic_pointer_cast<ModelAPI_Result>(theReason);
+      if (aReasRes.get())
+        aReasFeat = theReason->document()->feature(aReasRes);
+    }
+    if (aNotPersist->second.find(aReasFeat) != aNotPersist->second.end())
+      return true;
+  }
 
+  return false; // this case only for not-previewed items update state, nothing is changed in args for it
 }
 
 void Model_Update::executeFeature(FeaturePtr theFeature)
index 7eb4a8ef2e9424fd342efe8841a3b9cd8b2f92c0..9e37eddd23383e2604fbcceda273f4bf25642920 100644 (file)
@@ -29,6 +29,10 @@ class Model_Update : public Events_Listener
   /// The second set is the objects that causes this object is modified
   std::map<std::shared_ptr<ModelAPI_Feature>, std::set<std::shared_ptr<ModelAPI_Feature> > >
     myModified;
+  /// Features which arguments were modified by not-persistent changes.
+  /// So, these referencing arguments must be updated due to these features info also before execution).
+  std::map<std::shared_ptr<ModelAPI_Feature>, std::set<std::shared_ptr<ModelAPI_Feature> > >
+    myNotPersistentRefs;
   /// features that must be additionally processed after execution of finish operation
   std::set<std::shared_ptr<ModelAPI_Feature> > myWaitForFinish;
   /// to know that some parameter was changed during this operation (to enable update expressions)