Salome HOME
Geometrical naming for edges and intersections debug.
[modules/shaper.git] / src / Model / Model_Update.cpp
index 2bf951ae7962223f3f85ae29b312f920f6c7d879..23d96f4298a3d909c0a248f30e9c9f3e19a32080 100755 (executable)
@@ -198,7 +198,7 @@ bool Model_Update::addModified(FeaturePtr theFeature, FeaturePtr theReason) {
       }
     }
   }
-  // proccess also results
+  // process also results
   std::list<ResultPtr> allResults; // list of this feature and results
   ModelAPI_Tools::allResults(theFeature, allResults);
   std::list<ResultPtr>::iterator aRes = allResults.begin();
@@ -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 features 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);
@@ -331,7 +331,7 @@ void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessag
       if ((*anObjIter)->groupName() == ModelAPI_ResultParameter::group()) {
         myIsParamUpdated = true;
       }
-      // on undo/redo, abort do not update persisten features
+      // on undo/redo, abort do not update persistent features
       FeaturePtr anUpdated = std::dynamic_pointer_cast<ModelAPI_Feature>(*anObjIter);
       if (anUpdated.get()) {
         if (addModified(anUpdated, FeaturePtr()))
@@ -395,7 +395,7 @@ void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessag
       }
       myIsFinish = false;
     }
-    // processed features must be only on finish, so clear anyway (to avoid reimport on load)
+    // processed features must be only on finish, so clear anyway (to avoid re-import on load)
     myProcessOnFinish.clear();
 
     // #2156: current must be sketch, left after the macro execution
@@ -483,7 +483,7 @@ void Model_Update::processFeatures(const bool theFlushRedisplay)
   }
 }
 
-// collects all the feautres this feature depends on: reasons
+// collects all the features this feature depends on: reasons
 static void allReasons(FeaturePtr theFeature, std::set<FeaturePtr>& theReasons) {
   std::list<std::pair<std::string, std::list<std::shared_ptr<ModelAPI_Object> > > > aDeps;
   theFeature->data()->referencesToObjects(aDeps);
@@ -690,7 +690,7 @@ bool Model_Update::processFeature(FeaturePtr theFeature)
     theFeature->data()->execState(ModelAPI_StateDone);
 
   // this checking must be after the composite feature sub-elements processing:
-  // composite feature status may depend on it's subelements
+  // composite feature status may depend on it's sub-elements
   if ((theFeature->data()->execState() == ModelAPI_StateInvalidArgument || isReferencedInvalid) &&
     theFeature->getKind() != "Part") {
       // don't disable Part because it will make disabled all the features