Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Translation.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_Translation_H_
22 #define FeaturesPlugin_Translation_H_
23
24 #include <FeaturesPlugin.h>
25
26 #include <ModelAPI_Feature.h>
27
28 #include <GeomAlgoAPI_Translation.h>
29
30 /// \class FeaturesPlugin_Translation
31 /// \ingroup Plugins
32 /// \brief Feature for translation objects along the axis.
33 class FeaturesPlugin_Translation : public ModelAPI_Feature
34 {
35  public:
36   /// Translation kind.
37   inline static const std::string& ID()
38   {
39     static const std::string MY_TRANSLATION_ID("Translation");
40     return MY_TRANSLATION_ID;
41   }
42
43   /// Attribute name for creation method.
44   inline static const std::string& CREATION_METHOD()
45   {
46     static const std::string MY_CREATION_METHOD_ID("CreationMethod");
47     return MY_CREATION_METHOD_ID;
48   }
49
50   /// Attribute name for creation method "ByAxisAndDistance".
51   inline static const std::string& CREATION_METHOD_BY_DISTANCE()
52   {
53     static const std::string MY_CREATION_METHOD_ID("ByAxisAndDistance");
54     return MY_CREATION_METHOD_ID;
55   }
56
57   /// Attribute name for creation method "ByDimensions".
58   inline static const std::string& CREATION_METHOD_BY_DIMENSIONS()
59   {
60     static const std::string MY_CREATION_METHOD_ID("ByDimensions");
61     return MY_CREATION_METHOD_ID;
62   }
63
64   /// Attribute name for creation method "ByTwoPoints".
65   inline static const std::string& CREATION_METHOD_BY_TWO_POINTS()
66   {
67     static const std::string MY_CREATION_METHOD_ID("ByTwoPoints");
68     return MY_CREATION_METHOD_ID;
69   }
70
71   /// Attribute name of referenced objects.
72   inline static const std::string& OBJECTS_LIST_ID()
73   {
74     static const std::string MY_OBJECTS_LIST_ID("main_objects");
75     return MY_OBJECTS_LIST_ID;
76   }
77
78   /// Attribute name of an axis.
79   inline static const std::string& AXIS_OBJECT_ID()
80   {
81     static const std::string MY_AXIS_OBJECT_ID("axis_object");
82     return MY_AXIS_OBJECT_ID;
83   }
84
85   /// Attribute name of distance.
86   inline static const std::string& DISTANCE_ID()
87   {
88     static const std::string MY_DISTANCE_ID("distance");
89     return MY_DISTANCE_ID;
90   }
91
92   /// Attribute name of dimension in X.
93   inline static const std::string& DX_ID()
94   {
95     static const std::string MY_DX_ID("dx");
96     return MY_DX_ID;
97   }
98
99   /// Attribute name of dimension in Y.
100   inline static const std::string& DY_ID()
101   {
102     static const std::string MY_DY_ID("dy");
103     return MY_DY_ID;
104   }
105
106   /// Attribute name of dimension in Z.
107   inline static const std::string& DZ_ID()
108   {
109     static const std::string MY_DZ_ID("dz");
110     return MY_DZ_ID;
111   }
112
113   /// Attribute name of start point.
114   inline static const std::string& START_POINT_ID()
115   {
116     static const std::string MY_START_POINT_ID("start_point");
117     return MY_START_POINT_ID;
118   }
119
120   /// Attribute name of end point.
121   inline static const std::string& END_POINT_ID()
122   {
123     static const std::string MY_END_POINT_ID("end_point");
124     return MY_END_POINT_ID;
125   }
126
127   /// \return the kind of a feature.
128   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
129   {
130     static std::string MY_KIND = FeaturesPlugin_Translation::ID();
131     return MY_KIND;
132   }
133
134   /// Creates a new part document if needed.
135   FEATURESPLUGIN_EXPORT virtual void execute();
136
137   /// Request for initialization of data model of the feature: adding all attributes.
138   FEATURESPLUGIN_EXPORT virtual void initAttributes();
139
140   /// Use plugin manager for features creation.
141   FeaturesPlugin_Translation();
142
143 private:
144   ///Perform the translation using an axis and a distance.
145   void performTranslationByAxisAndDistance();
146
147   ///Perform the translation using three dimensions X, Y and Z
148   void performTranslationByDimensions();
149
150   ///Perform the translation usind two points
151   void performTranslationByTwoPoints();
152
153   void loadNamingDS(GeomAlgoAPI_Translation& theTranslationAlgo,
154                     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
155                     std::shared_ptr<GeomAPI_Shape> theBaseShape);
156 };
157
158 #endif