Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Translation.h
1 // Copyright (C) 2014-2016 CEA/DEN, EDF R&D
2
3 // File:        FeaturesPlugin_Translation.h
4 // Created:     8 June 2015
5 // Author:      Dmitry Bobylev
6 //
7 // Modified by Clarisse Genrault (CEA) : 17 Nov 2016
8
9 #ifndef FeaturesPlugin_Translation_H_
10 #define FeaturesPlugin_Translation_H_
11
12 #include <FeaturesPlugin.h>
13
14 #include <ModelAPI_Feature.h>
15
16 #include <GeomAlgoAPI_Translation.h>
17
18 /// \class FeaturesPlugin_Translation
19 /// \ingroup Plugins
20 /// \brief Feature for translation objects along the axis.
21 class FeaturesPlugin_Translation : public ModelAPI_Feature
22 {
23  public:
24   /// Translation kind.
25   inline static const std::string& ID()
26   {
27     static const std::string MY_TRANSLATION_ID("Translation");
28     return MY_TRANSLATION_ID;
29   }
30
31   /// Attribute name for creation method.
32   inline static const std::string& CREATION_METHOD()
33   {
34     static const std::string MY_CREATION_METHOD_ID("CreationMethod");
35     return MY_CREATION_METHOD_ID;
36   }
37
38   /// Attribute name for creation method "ByAxisAndDistance".
39   inline static const std::string& CREATION_METHOD_BY_DISTANCE()
40   {
41     static const std::string MY_CREATION_METHOD_ID("ByAxisAndDistance");
42     return MY_CREATION_METHOD_ID;
43   }
44
45   /// Attribute name for creation method "ByDimensions".
46   inline static const std::string& CREATION_METHOD_BY_DIMENSIONS()
47   {
48     static const std::string MY_CREATION_METHOD_ID("ByDimensions");
49     return MY_CREATION_METHOD_ID;
50   }
51
52   /// Attribute name of referenced objects.
53   inline static const std::string& OBJECTS_LIST_ID()
54   {
55     static const std::string MY_OBJECTS_LIST_ID("main_objects");
56     return MY_OBJECTS_LIST_ID;
57   }
58
59   /// Attribute name of an axis.
60   inline static const std::string& AXIS_OBJECT_ID()
61   {
62     static const std::string MY_AXIS_OBJECT_ID("axis_object");
63     return MY_AXIS_OBJECT_ID;
64   }
65
66   /// Attribute name of distance.
67   inline static const std::string& DISTANCE_ID()
68   {
69     static const std::string MY_DISTANCE_ID("distance");
70     return MY_DISTANCE_ID;
71   }
72
73   /// Attribute name of dimension in X.
74   inline static const std::string& DX_ID()
75   {
76     static const std::string MY_DX_ID("dx");
77     return MY_DX_ID;
78   }
79
80   /// Attribute name of dimension in Y.
81   inline static const std::string& DY_ID()
82   {
83     static const std::string MY_DY_ID("dy");
84     return MY_DY_ID;
85   }
86
87   /// Attribute name of dimension in Z.
88   inline static const std::string& DZ_ID()
89   {
90     static const std::string MY_DZ_ID("dz");
91     return MY_DZ_ID;
92   }
93
94   /// \return the kind of a feature.
95   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
96   {
97     static std::string MY_KIND = FeaturesPlugin_Translation::ID();
98     return MY_KIND;
99   }
100
101   /// Creates a new part document if needed.
102   FEATURESPLUGIN_EXPORT virtual void execute();
103
104   /// Request for initialization of data model of the feature: adding all attributes.
105   FEATURESPLUGIN_EXPORT virtual void initAttributes();
106
107   /// Use plugin manager for features creation.
108   FeaturesPlugin_Translation();
109
110 private:
111   ///Perform the translation using an axis and a distance.
112   void performTranslationByAxisAndDistance();
113
114   ///Perform the translation using three dimensions X, Y and Z
115   void performTranslationByDimensions();
116
117   void loadNamingDS(GeomAlgoAPI_Translation& theTranslationAlgo,
118                     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
119                     std::shared_ptr<GeomAPI_Shape> theBaseShape);
120 };
121
122 #endif