]> SALOME platform Git repositories - modules/shaper.git/blob - src/FeaturesAPI/FeaturesAPI_Translation.cpp
Salome HOME
Issue #1834: Fix length of lines
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_Translation.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        FeaturesAPI_Translation.cpp
4 // Created:     07 June 2016
5 // Author:      Dmitry Bobylev
6
7 #include "FeaturesAPI_Translation.h"
8
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Tools.h>
11
12 //==================================================================================================
13 FeaturesAPI_Translation::FeaturesAPI_Translation(
14   const std::shared_ptr<ModelAPI_Feature>& theFeature)
15 : ModelHighAPI_Interface(theFeature)
16 {
17   initialize();
18 }
19
20 //==================================================================================================
21 FeaturesAPI_Translation::FeaturesAPI_Translation(
22   const std::shared_ptr<ModelAPI_Feature>& theFeature,
23   const std::list<ModelHighAPI_Selection>& theMainObjects,
24   const ModelHighAPI_Selection& theAxisObject,
25   const ModelHighAPI_Double& theDistance)
26 : ModelHighAPI_Interface(theFeature)
27 {
28   if(initialize()) {
29     fillAttribute(theMainObjects, mymainObjects);
30     fillAttribute(theAxisObject, myaxisObject);
31     setDistance(theDistance);
32   }
33 }
34
35 //==================================================================================================
36 FeaturesAPI_Translation::~FeaturesAPI_Translation()
37 {
38
39 }
40
41 //==================================================================================================
42 void FeaturesAPI_Translation::setMainObjects(
43   const std::list<ModelHighAPI_Selection>& theMainObjects)
44 {
45   fillAttribute(theMainObjects, mymainObjects);
46
47   execute();
48 }
49
50 //==================================================================================================
51 void FeaturesAPI_Translation::setAxisObject(const ModelHighAPI_Selection& theAxisObject)
52 {
53   fillAttribute(theAxisObject, myaxisObject);
54
55   execute();
56 }
57
58 //==================================================================================================
59 void FeaturesAPI_Translation::setDistance(const ModelHighAPI_Double& theDistance)
60 {
61   fillAttribute(theDistance, mydistance);
62
63   execute();
64 }
65
66 //==================================================================================================
67 void FeaturesAPI_Translation::dump(ModelHighAPI_Dumper& theDumper) const
68 {
69   FeaturePtr aBase = feature();
70   const std::string& aDocName = theDumper.name(aBase->document());
71
72   AttributeSelectionListPtr anAttrObjects =
73     aBase->selectionList(FeaturesPlugin_Translation::OBJECTS_LIST_ID());
74   AttributeSelectionPtr anAttrAxis =
75     aBase->selection(FeaturesPlugin_Translation::AXIS_OBJECT_ID());
76   AttributeDoublePtr anAttrDistance = aBase->real(FeaturesPlugin_Translation::DISTANCE_ID());
77
78   theDumper << aBase << " = model.addTranslation(" << aDocName << ", "
79             << anAttrObjects << ", " << anAttrAxis << ", " << anAttrDistance << ")" << std::endl;
80 }
81
82 //==================================================================================================
83 TranslationPtr addTranslation(const std::shared_ptr<ModelAPI_Document>& thePart,
84                               const std::list<ModelHighAPI_Selection>& theMainObjects,
85                               const ModelHighAPI_Selection& theAxisObject,
86                               const ModelHighAPI_Double& theDistance)
87 {
88   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Translation::ID());
89   return TranslationPtr(new FeaturesAPI_Translation(aFeature, theMainObjects, 
90                                                     theAxisObject, theDistance));
91 }