Salome HOME
updated copyright message
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_MultiTranslation.h
1 // Copyright (C) 2014-2023  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 email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef FEATURESPLUGIN_MULTITRANSLATION_H_
21 #define FEATURESPLUGIN_MULTITRANSLATION_H_
22
23 #include <FeaturesPlugin.h>
24
25 #include <ModelAPI_Feature.h>
26
27 class GeomAPI_Dir;
28
29 /** \class FeaturesPlugin_MultiTranslation
30  *  \ingroup Plugins
31  *  \brief Feature for movement objects along one or two axes an arbitary number of times,
32  *         making a copy every time.
33  */
34 class FeaturesPlugin_MultiTranslation : public ModelAPI_Feature
35 {
36   public:
37   /// Multi-translation kind.
38   inline static const std::string& ID()
39   {
40     static const std::string MY_MULTITRANSLATION_ID("LinearCopy");
41     return MY_MULTITRANSLATION_ID;
42   }
43
44   /// Attribute name of referenced objects.
45   inline static const std::string& OBJECTS_LIST_ID()
46   {
47     static const std::string MY_OBJECTS_LIST_ID("main_objects");
48     return MY_OBJECTS_LIST_ID;
49   }
50
51   /// Attribute name of a first direction.
52   inline static const std::string& AXIS_FIRST_DIR_ID()
53   {
54     static const std::string MY_AXIS_FIRST_DIR_ID("axis_first_dir");
55     return MY_AXIS_FIRST_DIR_ID;
56   }
57
58   /// Attribute name of step for the first direction.
59   inline static const std::string& STEP_FIRST_DIR_ID()
60   {
61     static const std::string MY_STEP_FIRST_DIR_ID("step_first_dir");
62     return MY_STEP_FIRST_DIR_ID;
63   }
64
65   /// Attribute name of number of copies for the first direction.
66   inline static const std::string& NB_COPIES_FIRST_DIR_ID()
67   {
68     static const std::string MY_NB_COPIES_FIRST_DIR_ID("nb_first_dir");
69     return MY_NB_COPIES_FIRST_DIR_ID;
70   }
71
72   /// Attribute name for use second dir.
73   inline static const std::string& USE_SECOND_DIR_ID()
74   {
75     static const std::string MY_USE_SECOND_DIR_ID("use_second_dir");
76     return MY_USE_SECOND_DIR_ID;
77   }
78
79   /// Attribute name of a second direction.
80   inline static const std::string& AXIS_SECOND_DIR_ID()
81   {
82     static const std::string MY_AXIS_SECOND_DIR_ID("axis_second_dir");
83     return MY_AXIS_SECOND_DIR_ID;
84   }
85
86   /// Attribute name of step for the second direction.
87   inline static const std::string& STEP_SECOND_DIR_ID()
88   {
89     static const std::string MY_STEP_SECOND_DIR_ID("step_second_dir");
90     return MY_STEP_SECOND_DIR_ID;
91   }
92
93   /// Attribute name of number of copies for the second direction.
94   inline static const std::string& NB_COPIES_SECOND_DIR_ID()
95   {
96     static const std::string MY_NB_COPIES_SECOND_DIR_ID("nb_second_dir");
97     return MY_NB_COPIES_SECOND_DIR_ID;
98   }
99
100   /// \return the kind of a feature.
101   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
102   {
103     static std::string MY_KIND = FeaturesPlugin_MultiTranslation::ID();
104     return MY_KIND;
105   }
106
107   /// Performs the algorithm and stores results it in the data structure.
108   FEATURESPLUGIN_EXPORT virtual void execute();
109
110   /// Request for initialization of data model of the feature: adding all attributes.
111   FEATURESPLUGIN_EXPORT virtual void initAttributes();
112
113   /// Use plugin manager for features creation.
114   FeaturesPlugin_MultiTranslation();
115
116 private:
117   /// Fill axis, number of copies and distance for the given direction.
118   /// \returns \c false in case of errors.
119   bool paramsAlongDirection(const int theIndex,
120                             std::shared_ptr<GeomAPI_Dir>& theDir,
121                             double& theDistance,
122                             int& theQuantity);
123 };
124
125 #endif // FEATURESPLUGIN_MULTITRANSLATION_H_