Salome HOME
Improvement #635: Move maximum functionality to API class
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Group.cpp
index 3a9a07a15f86442317430e73d8f91c8a06ac2a11..98c6266ef83756dc29e10aac3e2b208c5ceebb08 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        FeaturesPlugin_Group.cpp
 // Created:     08 Oct 2014
 // Author:      Sergey BELASH
@@ -8,6 +10,9 @@
 #include <ModelAPI_Document.h>
 #include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_ResultGroup.h>
+
 
 using namespace std;
 
@@ -17,16 +22,14 @@ FeaturesPlugin_Group::FeaturesPlugin_Group()
 
 void FeaturesPlugin_Group::initAttributes()
 {
-  data()->addAttribute(FeaturesPlugin_Group::NAME_ID(), ModelAPI_AttributeString::type());
-  data()->addAttribute(FeaturesPlugin_Group::TYPE_ID(), ModelAPI_AttributeInteger::type());
-  data()->addAttribute(FeaturesPlugin_Group::LIST_ID(), ModelAPI_AttributeString::type());
+  //data()->addAttribute(FeaturesPlugin_Group::NAME_ID(), ModelAPI_AttributeString::typeId());
+  data()->addAttribute(FeaturesPlugin_Group::LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
 }
 
 void FeaturesPlugin_Group::execute()
 {
-  AttributeIntegerPtr aTypeAttr = boost::dynamic_pointer_cast<ModelAPI_AttributeInteger>(
-      data()->attribute(FeaturesPlugin_Group::TYPE_ID()));
-  if (!aTypeAttr)
-    return;
-  int aType = aTypeAttr->value();
+  if (results().empty()) { // just create result if not exists
+    ResultPtr aGroup = document()->createGroup(data());
+    setResult(aGroup);
+  }
 }