Salome HOME
Issue #3122: Move Measurement item to Inspection menu
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Recover.cpp
index 4cebf871bb4201c544d3d1964a212d918e23b981..9082ea1684e52a6cc5d77e15f4de911fba3f2fa9 100644 (file)
@@ -24,6 +24,7 @@
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_AttributeRefList.h>
 #include <ModelAPI_AttributeBoolean.h>
+#include <ModelAPI_AttributeString.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_Result.h>
@@ -33,6 +34,7 @@
 #include <GeomAlgoAPI_Tools.h>
 
 FeaturesPlugin_Recover::FeaturesPlugin_Recover()
+  : myClearListOnTypeChange(true)
 {
 }
 
@@ -41,6 +43,17 @@ void FeaturesPlugin_Recover::initAttributes()
   data()->addAttribute(BASE_FEATURE(), ModelAPI_AttributeReference::typeId());
   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()
@@ -81,3 +94,9 @@ void FeaturesPlugin_Recover::execute()
 
   removeResults(aResultIndex);
 }
+
+void FeaturesPlugin_Recover::attributeChanged(const std::string& theID)
+{
+  if (theID == METHOD() && myClearListOnTypeChange)
+    reflist(RECOVERED_ENTITIES())->clear();
+}