Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_MultiTranslation.h
1 // Copyright (C) 2014-201x CEA/DEN, EDF R&D
2
3 // File:        FeaturesPlugin_MultiTranslation.h
4 // Created:     30 Jan 2017
5 // Author:      Clarisse Genrault (CEA)
6
7 #ifndef FEATURESPLUGIN_MULTITRANSLATION_H_
8 #define FEATURESPLUGIN_MULTITRANSLATION_H_
9
10 #include <FeaturesPlugin.h>
11
12 #include <GeomAlgoAPI_Translation.h>
13
14 #include <ModelAPI_Feature.h>
15
16 /** \class FeaturesPlugin_MultiTranslation
17  *  \ingroup Plugins
18  *  \brief Feature for movement objects along one or two axes an arbitary number of times,
19  *         making a copy every time.
20  */
21 class FeaturesPlugin_MultiTranslation : public ModelAPI_Feature
22 {
23   public:
24   /// Translation kind.
25   inline static const std::string& ID()
26   {
27     static const std::string MY_MULTITRANSLATION_ID("MultiTranslation");
28     return MY_MULTITRANSLATION_ID;
29   }
30
31   /// Attribute name of referenced objects.
32   inline static const std::string& OBJECTS_LIST_ID()
33   {
34     static const std::string MY_OBJECTS_LIST_ID("main_objects");
35     return MY_OBJECTS_LIST_ID;
36   }
37
38   /// Attribute name of a first direction.
39   inline static const std::string& AXIS_FIRST_DIR_ID()
40   {
41     static const std::string MY_AXIS_FIRST_DIR_ID("axis_first_dir");
42     return MY_AXIS_FIRST_DIR_ID;
43   }
44
45   /// Attribute name of step for the first direction.
46   inline static const std::string& STEP_FIRST_DIR_ID()
47   {
48     static const std::string MY_STEP_FIRST_DIR_ID("step_first_dir");
49     return MY_STEP_FIRST_DIR_ID;
50   }
51
52   /// Attribute name of number of copies for the first direction.
53   inline static const std::string& NB_COPIES_FIRST_DIR_ID()
54   {
55     static const std::string MY_NB_COPIES_FIRST_DIR_ID("nb_first_dir");
56     return MY_NB_COPIES_FIRST_DIR_ID;
57   }
58
59   /// Attribute name for use second dir.
60   inline static const std::string& USE_SECOND_DIR_ID()
61   {
62     static const std::string MY_USE_SECOND_DIR_ID("use_second_dir");
63     return MY_USE_SECOND_DIR_ID;
64   }
65
66   /// Attribute name of a second direction.
67   inline static const std::string& AXIS_SECOND_DIR_ID()
68   {
69     static const std::string MY_AXIS_SECOND_DIR_ID("axis_second_dir");
70     return MY_AXIS_SECOND_DIR_ID;
71   }
72
73   /// Attribute name of step for the second direction.
74   inline static const std::string& STEP_SECOND_DIR_ID()
75   {
76     static const std::string MY_STEP_SECOND_DIR_ID("step_second_dir");
77     return MY_STEP_SECOND_DIR_ID;
78   }
79
80   /// Attribute name of number of copies for the second direction.
81   inline static const std::string& NB_COPIES_SECOND_DIR_ID()
82   {
83     static const std::string MY_NB_COPIES_SECOND_DIR_ID("nb_second_dir");
84     return MY_NB_COPIES_SECOND_DIR_ID;
85   }
86
87   /// \return the kind of a feature.
88   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
89   {
90     static std::string MY_KIND = FeaturesPlugin_MultiTranslation::ID();
91     return MY_KIND;
92   }
93
94   /// Creates a new part document if needed.
95   FEATURESPLUGIN_EXPORT virtual void execute();
96
97   /// Request for initialization of data model of the feature: adding all attributes.
98   FEATURESPLUGIN_EXPORT virtual void initAttributes();
99
100   /// Use plugin manager for features creation.
101   FeaturesPlugin_MultiTranslation();
102
103 private:
104   /// Perform the multi translation in one direction.
105   void performOneDirection();
106
107   /// Perform the multi translation in two directions.
108   void performTwoDirection();
109
110   void loadNamingDS(std::list<std::shared_ptr<GeomAlgoAPI_Translation> > theListOfTranslationAlgo,
111                     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
112                     std::shared_ptr<GeomAPI_Shape> theBaseShape);
113 };
114
115 #endif // FEATURESPLUGIN_MULTITRANSLATION_H_