Salome HOME
Issue #1834: Fix length of lines
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_Placement.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        FeaturesAPI_Placement.cpp
4 // Created:     07 June 2016
5 // Author:      Dmitry Bobylev
6
7 #include "FeaturesAPI_Placement.h"
8
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Tools.h>
11
12 //==================================================================================================
13 FeaturesAPI_Placement::FeaturesAPI_Placement(const std::shared_ptr<ModelAPI_Feature>& theFeature)
14 : ModelHighAPI_Interface(theFeature)
15 {
16   initialize();
17 }
18
19 //==================================================================================================
20 FeaturesAPI_Placement::FeaturesAPI_Placement(const std::shared_ptr<ModelAPI_Feature>& theFeature,
21                                              const std::list<ModelHighAPI_Selection>& theObjects,
22                                              const ModelHighAPI_Selection& theStartShape,
23                                              const ModelHighAPI_Selection& theEndShape,
24                                              const bool theReverseDirection,
25                                              const bool theCentering)
26 : ModelHighAPI_Interface(theFeature)
27 {
28   if(initialize()) {
29     fillAttribute(theObjects, myobjects);
30     fillAttribute(theStartShape, mystartShape);
31     fillAttribute(theEndShape, myendShape);
32     fillAttribute(theReverseDirection, myreverseDirection);
33     setCentering(theCentering);
34   }
35 }
36
37 //==================================================================================================
38 FeaturesAPI_Placement::~FeaturesAPI_Placement()
39 {
40
41 }
42
43 //==================================================================================================
44 void FeaturesAPI_Placement::setObjects(const std::list<ModelHighAPI_Selection>& theObjects)
45 {
46   fillAttribute(theObjects, myobjects);
47
48   execute();
49 }
50
51 //==================================================================================================
52 void FeaturesAPI_Placement::setStartShape(const ModelHighAPI_Selection& theStartShape)
53 {
54   fillAttribute(theStartShape, mystartShape);
55
56   execute();
57 }
58
59 //==================================================================================================
60 void FeaturesAPI_Placement::setEndShape(const ModelHighAPI_Selection& theEndShape)
61 {
62   fillAttribute(theEndShape, myendShape);
63
64   execute();
65 }
66
67 //==================================================================================================
68 void FeaturesAPI_Placement::setReverseDirection(const bool theReverseDirection)
69 {
70   fillAttribute(theReverseDirection, myreverseDirection);
71
72   execute();
73 }
74
75 //==================================================================================================
76 void FeaturesAPI_Placement::setCentering(const bool theCentering)
77 {
78   fillAttribute(theCentering, mycentering);
79
80   execute();
81 }
82
83 //==================================================================================================
84 void FeaturesAPI_Placement::dump(ModelHighAPI_Dumper& theDumper) const
85 {
86   FeaturePtr aBase = feature();
87   const std::string& aDocName = theDumper.name(aBase->document());
88
89   AttributeSelectionListPtr anAttrObjects =
90     aBase->selectionList(FeaturesPlugin_Placement::OBJECTS_LIST_ID());
91   AttributeSelectionPtr anAttrStartShape =
92     aBase->selection(FeaturesPlugin_Placement::START_SHAPE_ID());
93   AttributeSelectionPtr anAttrEndShape = aBase->selection(FeaturesPlugin_Placement::END_SHAPE_ID());
94   AttributeBooleanPtr anAttrReverse = aBase->boolean(FeaturesPlugin_Placement::REVERSE_ID());
95   AttributeBooleanPtr anAttrCentering = aBase->boolean(FeaturesPlugin_Placement::CENTERING_ID());
96
97   theDumper << aBase << " = model.addPlacement(" << aDocName << ", "
98             << anAttrObjects << ", " << anAttrStartShape << ", " << anAttrEndShape << ", "
99             << anAttrReverse << ", " << anAttrCentering << ")" << std::endl;
100 }
101
102 //==================================================================================================
103 PlacementPtr addPlacement(const std::shared_ptr<ModelAPI_Document>& thePart,
104                           const std::list<ModelHighAPI_Selection>& theObjects,
105                           const ModelHighAPI_Selection& theStartShape,
106                           const ModelHighAPI_Selection& theEndShape,
107                           const bool theReverseDirection,
108                           const bool theCentering)
109 {
110   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Placement::ID());
111   return PlacementPtr(new FeaturesAPI_Placement(aFeature,
112                                                 theObjects,
113                                                 theStartShape,
114                                                 theEndShape,
115                                                 theReverseDirection,
116                                                 theCentering));
117 }