Salome HOME
5c3fa06324874a84077b3bf736ac4b8bbbb66046
[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_Tools.h>
10
11 //==================================================================================================
12 FeaturesAPI_Translation::FeaturesAPI_Translation(const std::shared_ptr<ModelAPI_Feature> & theFeature)
13 : ModelHighAPI_Interface(theFeature)
14 {
15   initialize();
16 }
17
18 //==================================================================================================
19 FeaturesAPI_Translation::FeaturesAPI_Translation(const std::shared_ptr<ModelAPI_Feature> & theFeature,
20                                                  const std::list<ModelHighAPI_Selection>& theMainObjects,
21                                                  const ModelHighAPI_Selection& theAxisObject,
22                                                  const ModelHighAPI_Double& theDistance)
23 : ModelHighAPI_Interface(theFeature)
24 {
25   if(initialize()) {
26     setMainObjects(theMainObjects);
27     setAxisObject(theAxisObject);
28     setDistance(theDistance);
29   }
30 }
31
32 //==================================================================================================
33 FeaturesAPI_Translation::~FeaturesAPI_Translation()
34 {
35
36 }
37
38 //==================================================================================================
39 void FeaturesAPI_Translation::setMainObjects(const std::list<ModelHighAPI_Selection>& theMainObjects)
40 {
41   fillAttribute(theMainObjects, mymainObjects);
42
43   execute();
44 }
45
46 //==================================================================================================
47 void FeaturesAPI_Translation::setAxisObject(const ModelHighAPI_Selection& theAxisObject)
48 {
49   fillAttribute(theAxisObject, myaxisObject);
50
51   execute();
52 }
53
54 //==================================================================================================
55 void FeaturesAPI_Translation::setDistance(const ModelHighAPI_Double& theDistance)
56 {
57   fillAttribute(theDistance, mydistance);
58
59   execute();
60 }
61
62 // TODO(spo): make add* as static functions of the class
63 //==================================================================================================
64 TranslationPtr addTranslation(const std::shared_ptr<ModelAPI_Document> & thePart,
65                               const std::list<ModelHighAPI_Selection>& theMainObjects,
66                               const ModelHighAPI_Selection& theAxisObject,
67                               const ModelHighAPI_Double& theDistance)
68 {
69   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Translation::ID());
70   return TranslationPtr(new FeaturesAPI_Translation(aFeature, theMainObjects, theAxisObject, theDistance));
71 }