]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2612 : Re-calculate model after modification of parameters
authormpv <mpv@opencascade.com>
Thu, 6 Sep 2018 11:06:32 +0000 (14:06 +0300)
committermpv <mpv@opencascade.com>
Thu, 6 Sep 2018 11:06:47 +0000 (14:06 +0300)
Correct behavior of auto-update flag on Undo/Redo

src/Model/Model_Update.cpp

index 2bf951ae7962223f3f85ae29b312f920f6c7d879..60b2c72062af6c02e22c288e5627dc35dc48c112 100755 (executable)
@@ -246,6 +246,32 @@ void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessag
 #ifdef DEB_UPDATE
   std::cout<<"****** Event "<<theMessage->eventID().eventText()<<std::endl;
 #endif
+  // check the automatic update flag on any event
+  bool aNewAutomaticState = ModelAPI_Session::get()->isAutoUpdateBlocked();
+  if (myUpdateBlocked != aNewAutomaticState) {
+    myUpdateBlocked = aNewAutomaticState;
+    if (!myUpdateBlocked) { // process all modified features, even if preview is blocked
+      bool aPreviewBlockedState = myIsPreviewBlocked; // to update the selected arguments
+      myIsPreviewBlocked = false;
+      // iterate everything and add efatures in state "MustBeUpdated" into modified
+      std::list<std::shared_ptr<ModelAPI_Document> > allDocs =
+        ModelAPI_Session::get()->allOpenedDocuments();
+      std::list<std::shared_ptr<ModelAPI_Document> >::iterator aDoc = allDocs.begin();
+      for(; aDoc != allDocs.end(); aDoc++) {
+        std::list<std::shared_ptr<ModelAPI_Feature> > allFeats = (*aDoc)->allFeatures();
+        std::list<std::shared_ptr<ModelAPI_Feature> >::iterator aFeat = allFeats.begin();
+        for(; aFeat != allFeats.end(); aFeat++) {
+          if ((*aFeat)->data()->isValid() &&
+            (*aFeat)->data()->execState() == ModelAPI_StateMustBeUpdated) {
+            addModified(*aFeat, FeaturePtr());
+          }
+        }
+      }
+      processFeatures();
+      myIsPreviewBlocked = myIsPreviewBlocked;
+    }
+  }
+
   if (theMessage->eventID() == kStabilityEvent) {
     updateStability(theMessage->sender());
     return;
@@ -265,32 +291,6 @@ void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessag
     }
     return;
   }
-  if (theMessage->eventID() == kAutomaticOff) {
-    myUpdateBlocked = true;
-    return;
-  }
-  if (theMessage->eventID() == kAutomaticOn) {
-    myUpdateBlocked = false; // then process all modified features, even if preview is blocked
-    bool aPreviewBlockedState = myIsPreviewBlocked; // to update the selected arguments
-    myIsPreviewBlocked = false;
-    // iterate everything and add efatures in state "MustBeUpdated" into modified
-    std::list<std::shared_ptr<ModelAPI_Document> > allDocs =
-      ModelAPI_Session::get()->allOpenedDocuments();
-    std::list<std::shared_ptr<ModelAPI_Document> >::iterator aDoc = allDocs.begin();
-    for(; aDoc != allDocs.end(); aDoc++) {
-      std::list<std::shared_ptr<ModelAPI_Feature> > allFeats = (*aDoc)->allFeatures();
-      std::list<std::shared_ptr<ModelAPI_Feature> >::iterator aFeat = allFeats.begin();
-      for(; aFeat != allFeats.end(); aFeat++) {
-        if ((*aFeat)->data()->isValid() &&
-            (*aFeat)->data()->execState() == ModelAPI_StateMustBeUpdated) {
-          addModified(*aFeat, FeaturePtr());
-        }
-      }
-    }
-    processFeatures();
-    myIsPreviewBlocked = myIsPreviewBlocked;
-    return;
-  }
   if (theMessage->eventID() == kUpdatedSel) {
     std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aMsg =
         std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);