Salome HOME
Merge remote-tracking branch 'remotes/origin/HighLevelDump'
[modules/shaper.git] / src / BuildAPI / BuildAPI_SubShapes.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        BuildAPI_SubShapes.cpp
4 // Created:     09 June 2016
5 // Author:      Dmitry Bobylev
6
7 #include "BuildAPI_SubShapes.h"
8
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Tools.h>
11
12 //==================================================================================================
13 BuildAPI_SubShapes::BuildAPI_SubShapes(const std::shared_ptr<ModelAPI_Feature>& theFeature)
14 : ModelHighAPI_Interface(theFeature)
15 {
16   initialize();
17 }
18
19 //==================================================================================================
20 BuildAPI_SubShapes::BuildAPI_SubShapes(const std::shared_ptr<ModelAPI_Feature>& theFeature,
21                                        const ModelHighAPI_Selection& theBaseShape,
22                                        const std::list<ModelHighAPI_Selection>& theSubShapes)
23 : ModelHighAPI_Interface(theFeature)
24 {
25   if(initialize()) {
26     fillAttribute(theBaseShape, mybaseShape);
27     setSubShapes(theSubShapes);
28   }
29 }
30
31 //==================================================================================================
32 BuildAPI_SubShapes::~BuildAPI_SubShapes()
33 {
34
35 }
36
37 //==================================================================================================
38 void BuildAPI_SubShapes::setBaseShape(const ModelHighAPI_Selection& theBaseShape)
39 {
40   fillAttribute(theBaseShape, mybaseShape);
41
42   execute();
43 }
44
45 //==================================================================================================
46 void BuildAPI_SubShapes::setSubShapes(const std::list<ModelHighAPI_Selection>& theSubShapes)
47 {
48   fillAttribute(theSubShapes, mysubShapes);
49
50   execute();
51 }
52
53 //==================================================================================================
54 void BuildAPI_SubShapes::dump(ModelHighAPI_Dumper& theDumper) const
55 {
56   FeaturePtr aBase = feature();
57   std::string aPartName = theDumper.name(aBase->document());
58
59   theDumper << aBase << " = model.addSubShapes(" << aPartName << ", "
60             << aBase->selection(BuildPlugin_SubShapes::BASE_SHAPE_ID()) << ", "
61             << aBase->selectionList(BuildPlugin_SubShapes::SUBSHAPES_ID()) << ")" << std::endl;
62 }
63
64 //==================================================================================================
65 SubShapesPtr addSubShapes(const std::shared_ptr<ModelAPI_Document>& thePart,
66                           const ModelHighAPI_Selection& theBaseShape,
67                           const std::list<ModelHighAPI_Selection>& theSubShapes)
68 {
69   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(BuildAPI_SubShapes::ID());
70   return SubShapesPtr(new BuildAPI_SubShapes(aFeature, theBaseShape, theSubShapes));
71 }