]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Make features enabled/disabled in the correct way
authormpv <mpv@opencascade.com>
Wed, 13 May 2015 08:57:56 +0000 (11:57 +0300)
committermpv <mpv@opencascade.com>
Wed, 13 May 2015 08:57:56 +0000 (11:57 +0300)
src/Model/Model_Document.cpp
src/Model/Model_Update.cpp

index 238b0f3e624669cd1a21872bb1a4e8b26754b31e..b5ee4b75bc2d2a5a0f3dcbd8f397c172260b402d 100644 (file)
@@ -599,6 +599,7 @@ FeaturePtr Model_Document::addFeature(std::string theID)
       // event: feature is added
       static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
       ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent);
+      aFeature->setDisabled(false); // by default created feature is enabled
       setCurrentFeature(aFeature); // after all this feature stays in the document, so make it current
     } else { // feature must be executed
        // no creation event => updater not working, problem with remove part
@@ -998,14 +999,16 @@ void Model_Document::setCurrentFeature(std::shared_ptr<ModelAPI_Feature> theCurr
   for(int a = aSize - 1; a >= 0; a--) {
     FeaturePtr aFeature = 
       std::dynamic_pointer_cast<ModelAPI_Feature>(object(ModelAPI_Feature::group(), a, true));
+
+    // check this before passed become enabled: the current feature is enabled!
+    if (aFeature == theCurrent) aPassed = true;
+
     if (aFeature->setDisabled(!aPassed)) {
       // state of feature is changed => so feature become updated
       static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
       ModelAPI_EventCreator::get()->sendUpdated(aFeature, anUpdateEvent);
 
     }
-    // check this only after passed become enabled: the current feature is enabled!
-    if (aFeature == theCurrent) aPassed = true;
   }
 }
 
index 93f50a171d7ac840e913fa6281c2569ea63888d1..72daf20829c10024238150077734432246a84ebb 100644 (file)
@@ -234,6 +234,8 @@ ModelAPI_ExecState stateByReference(ObjectPtr theTarget, const ModelAPI_ExecStat
 void Model_Update::updateArguments(FeaturePtr theFeature) {
   static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
 
+  if (theFeature->isDisabled()) // nothing to do with disabled feature
+    return;
   bool aJustUpdated = false;
   ModelAPI_ExecState aState = ModelAPI_StateDone;
   // check the parameters: values can be changed
@@ -299,6 +301,9 @@ void Model_Update::updateFeature(FeaturePtr theFeature)
 {
   // check all features this feature depended on (recursive call of updateFeature)
   static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
+
+  if (theFeature->isDisabled()) // nothing to do with disabled feature
+    return;
   bool aJustUpdated = false;
 
   if (theFeature) {