Salome HOME
Put groups to the separated plugin: Collection
[modules/shaper.git] / src / CollectionAPI / CollectionAPI_Group.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        CollectionAPI_Group.cpp
4 // Created:     07 June 2016
5 // Author:      Dmitry Bobylev
6
7 #include "CollectionAPI_Group.h"
8
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Integer.h>
11 #include <ModelHighAPI_Selection.h>
12 #include <ModelHighAPI_Tools.h>
13
14 //==================================================================================================
15 CollectionAPI_Group::CollectionAPI_Group(const std::shared_ptr<ModelAPI_Feature>& theFeature)
16 : ModelHighAPI_Interface(theFeature)
17 {
18   initialize();
19 }
20
21 //==================================================================================================
22 CollectionAPI_Group::CollectionAPI_Group(const std::shared_ptr<ModelAPI_Feature>& theFeature,
23                                      const std::list<ModelHighAPI_Selection>& theGroupList)
24 : ModelHighAPI_Interface(theFeature)
25 {
26   if(initialize()) {
27     setGroupList(theGroupList);
28   }
29 }
30
31 //==================================================================================================
32 CollectionAPI_Group::~CollectionAPI_Group()
33 {
34
35 }
36
37 //==================================================================================================
38 void CollectionAPI_Group::setGroupList(const std::list<ModelHighAPI_Selection>& theGroupList)
39 {
40   fillAttribute(theGroupList, mygroupList);
41
42   execute();
43 }
44
45 //==================================================================================================
46 void CollectionAPI_Group::dump(ModelHighAPI_Dumper& theDumper) const
47 {
48   FeaturePtr aBase = feature();
49   const std::string& aDocName = theDumper.name(aBase->document());
50
51   AttributeSelectionListPtr anAttrList = aBase->selectionList(CollectionPlugin_Group::LIST_ID());
52
53   theDumper << aBase << " = model.addGroup(" << aDocName << ", " << anAttrList << ")" << std::endl;
54 }
55
56 //==================================================================================================
57 GroupPtr addGroup(const std::shared_ptr<ModelAPI_Document>& thePart,
58                   const std::list<ModelHighAPI_Selection>& theGroupList)
59 {
60   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(CollectionAPI_Group::ID());
61   return GroupPtr(new CollectionAPI_Group(aFeature, theGroupList));
62 }