Salome HOME
Task 2.5. Combination operations on Groups (issue #2935)
[modules/shaper.git] / src / CollectionPlugin / CollectionPlugin_GroupAddition.cpp
diff --git a/src/CollectionPlugin/CollectionPlugin_GroupAddition.cpp b/src/CollectionPlugin/CollectionPlugin_GroupAddition.cpp
new file mode 100644 (file)
index 0000000..1c3795d
--- /dev/null
@@ -0,0 +1,45 @@
+// Copyright (C) 2014-2019  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "CollectionPlugin_GroupAddition.h"
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_ResultGroup.h>
+
+CollectionPlugin_GroupAddition::CollectionPlugin_GroupAddition()
+{
+}
+
+void CollectionPlugin_GroupAddition::initAttributes()
+{
+  data()->addAttribute(CollectionPlugin_Group::LIST_ID(),
+                       ModelAPI_AttributeSelectionList::typeId());
+}
+
+void CollectionPlugin_GroupAddition::execute()
+{
+  if (results().empty() || firstResult()->isDisabled()) { // just create result if not exists
+    ResultPtr aGroup = document()->createGroup(data());
+    setResult(aGroup);
+  }
+}