Salome HOME
Sketch with the Fixed constraints only should be processed as usual sketch
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_RemoveSubShapes.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        FeaturesAPI_RemoveSubShapes.cpp
4 // Created:     09 June 2016
5 // Author:      Dmitry Bobylev
6
7 #include "FeaturesAPI_RemoveSubShapes.h"
8
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Tools.h>
11
12 //==================================================================================================
13 FeaturesAPI_RemoveSubShapes::FeaturesAPI_RemoveSubShapes(
14   const std::shared_ptr<ModelAPI_Feature>& theFeature)
15 : ModelHighAPI_Interface(theFeature)
16 {
17   initialize();
18 }
19
20 //==================================================================================================
21 FeaturesAPI_RemoveSubShapes::FeaturesAPI_RemoveSubShapes(
22   const std::shared_ptr<ModelAPI_Feature>& theFeature,
23   const ModelHighAPI_Selection& theBase)
24 : ModelHighAPI_Interface(theFeature)
25 {
26   if(initialize()) {
27     setBase(theBase);
28
29     execute();
30   }
31 }
32
33 //==================================================================================================
34 FeaturesAPI_RemoveSubShapes::~FeaturesAPI_RemoveSubShapes()
35 {
36
37 }
38
39 //==================================================================================================
40 void FeaturesAPI_RemoveSubShapes::setBase(const ModelHighAPI_Selection& theBase)
41 {
42   fillAttribute(theBase, mybase);
43
44   execute();
45 }
46
47 //==================================================================================================
48 void FeaturesAPI_RemoveSubShapes::setSubShapesToKeep(
49   const std::list<ModelHighAPI_Selection>& theSubShapes)
50 {
51   fillAttribute(theSubShapes, mysubshapes);
52
53   execute();
54 }
55
56 //==================================================================================================
57 void FeaturesAPI_RemoveSubShapes::dump(ModelHighAPI_Dumper& theDumper) const
58 {
59   FeaturePtr aBase = feature();
60   const std::string& aDocName = theDumper.name(aBase->document());
61
62   AttributeSelectionPtr anAttrBaseShape =
63     aBase->selection(FeaturesPlugin_RemoveSubShapes::BASE_SHAPE_ID());
64   AttributeSelectionListPtr anAttrSubShapes =
65     aBase->selectionList(FeaturesPlugin_RemoveSubShapes::SUBSHAPES_ID());
66
67   theDumper << aBase << " = model.addRemoveSubShapes(" << aDocName <<
68     ", " << anAttrBaseShape << ")" << std::endl;
69   theDumper << aBase << ".setSubShapesToKeep(" << anAttrSubShapes << ")" << std::endl;
70 }
71
72 //==================================================================================================
73 RemoveSubShapesPtr addRemoveSubShapes(const std::shared_ptr<ModelAPI_Document>& thePart,
74                                       const ModelHighAPI_Selection& theBase)
75 {
76   std::shared_ptr<ModelAPI_Feature> aFeature =
77     thePart->addFeature(FeaturesAPI_RemoveSubShapes::ID());
78   return RemoveSubShapesPtr(new FeaturesAPI_RemoveSubShapes(aFeature, theBase));
79 }