Salome HOME
Copyright update 2020
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Recover.cpp
index 1721e05b6ba21634de84ff9e295d6f6f4bbb3f83..1d620d1d2b373d1646f35234a4dc5423513e2444 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -34,6 +34,7 @@
 #include <GeomAlgoAPI_Tools.h>
 
 FeaturesPlugin_Recover::FeaturesPlugin_Recover()
+  : myClearListOnTypeChange(true)
 {
 }
 
@@ -43,7 +44,16 @@ void FeaturesPlugin_Recover::initAttributes()
   data()->addAttribute(RECOVERED_ENTITIES(), ModelAPI_AttributeRefList::typeId());
 
   data()->addAttribute(METHOD(), ModelAPI_AttributeString::typeId());
+  if (!string(METHOD())->isInitialized()) {
+    myClearListOnTypeChange = false;
+    data()->blockSendAttributeUpdated(true, false);
+    string(METHOD())->setValue(METHOD_DEFAULT());
+    data()->blockSendAttributeUpdated(false, false);
+    myClearListOnTypeChange = true;
+  }
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), METHOD());
+  // set default method for recovering
+  string(METHOD())->setValue(METHOD_DEFAULT());
 }
 
 void FeaturesPlugin_Recover::execute()
@@ -87,6 +97,6 @@ void FeaturesPlugin_Recover::execute()
 
 void FeaturesPlugin_Recover::attributeChanged(const std::string& theID)
 {
-  if (theID == METHOD())
+  if (theID == METHOD() && myClearListOnTypeChange)
     reflist(RECOVERED_ENTITIES())->clear();
 }