Salome HOME
Rename SketchPlugin features "Translation", "Rotation", "Mirror" and FeaturesPlugin...
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_MultiTranslation.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef FEATURESPLUGIN_MULTITRANSLATION_H_
22 #define FEATURESPLUGIN_MULTITRANSLATION_H_
23
24 #include <FeaturesPlugin.h>
25
26 #include <GeomAlgoAPI_Translation.h>
27
28 #include <ModelAPI_Feature.h>
29
30 /** \class FeaturesPlugin_MultiTranslation
31  *  \ingroup Plugins
32  *  \brief Feature for movement objects along one or two axes an arbitary number of times,
33  *         making a copy every time.
34  */
35 class FeaturesPlugin_MultiTranslation : public ModelAPI_Feature
36 {
37   public:
38   /// Multi-translation kind.
39   inline static const std::string& ID()
40   {
41     static const std::string MY_MULTITRANSLATION_ID("LinearCopy");
42     return MY_MULTITRANSLATION_ID;
43   }
44
45   /// Attribute name of referenced objects.
46   inline static const std::string& OBJECTS_LIST_ID()
47   {
48     static const std::string MY_OBJECTS_LIST_ID("main_objects");
49     return MY_OBJECTS_LIST_ID;
50   }
51
52   /// Attribute name of a first direction.
53   inline static const std::string& AXIS_FIRST_DIR_ID()
54   {
55     static const std::string MY_AXIS_FIRST_DIR_ID("axis_first_dir");
56     return MY_AXIS_FIRST_DIR_ID;
57   }
58
59   /// Attribute name of step for the first direction.
60   inline static const std::string& STEP_FIRST_DIR_ID()
61   {
62     static const std::string MY_STEP_FIRST_DIR_ID("step_first_dir");
63     return MY_STEP_FIRST_DIR_ID;
64   }
65
66   /// Attribute name of number of copies for the first direction.
67   inline static const std::string& NB_COPIES_FIRST_DIR_ID()
68   {
69     static const std::string MY_NB_COPIES_FIRST_DIR_ID("nb_first_dir");
70     return MY_NB_COPIES_FIRST_DIR_ID;
71   }
72
73   /// Attribute name for use second dir.
74   inline static const std::string& USE_SECOND_DIR_ID()
75   {
76     static const std::string MY_USE_SECOND_DIR_ID("use_second_dir");
77     return MY_USE_SECOND_DIR_ID;
78   }
79
80   /// Attribute name of a second direction.
81   inline static const std::string& AXIS_SECOND_DIR_ID()
82   {
83     static const std::string MY_AXIS_SECOND_DIR_ID("axis_second_dir");
84     return MY_AXIS_SECOND_DIR_ID;
85   }
86
87   /// Attribute name of step for the second direction.
88   inline static const std::string& STEP_SECOND_DIR_ID()
89   {
90     static const std::string MY_STEP_SECOND_DIR_ID("step_second_dir");
91     return MY_STEP_SECOND_DIR_ID;
92   }
93
94   /// Attribute name of number of copies for the second direction.
95   inline static const std::string& NB_COPIES_SECOND_DIR_ID()
96   {
97     static const std::string MY_NB_COPIES_SECOND_DIR_ID("nb_second_dir");
98     return MY_NB_COPIES_SECOND_DIR_ID;
99   }
100
101   /// \return the kind of a feature.
102   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
103   {
104     static std::string MY_KIND = FeaturesPlugin_MultiTranslation::ID();
105     return MY_KIND;
106   }
107
108   /// Creates a new part document if needed.
109   FEATURESPLUGIN_EXPORT virtual void execute();
110
111   /// Request for initialization of data model of the feature: adding all attributes.
112   FEATURESPLUGIN_EXPORT virtual void initAttributes();
113
114   /// Use plugin manager for features creation.
115   FeaturesPlugin_MultiTranslation();
116
117 private:
118   /// Perform the multi translation in one direction.
119   void performOneDirection();
120
121   /// Perform the multi translation in two directions.
122   void performTwoDirection();
123
124   void loadNamingDS(std::list<std::shared_ptr<GeomAlgoAPI_Translation> > theListOfTranslationAlgo,
125                     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
126                     std::shared_ptr<GeomAPI_Shape> theBaseShape);
127 };
128
129 #endif // FEATURESPLUGIN_MULTITRANSLATION_H_