1 // Copyright (C) 2014-2022 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef FeaturesPlugin_Translation_H_
21 #define FeaturesPlugin_Translation_H_
23 #include <FeaturesPlugin.h>
25 #include <ModelAPI_Feature.h>
29 /// \class FeaturesPlugin_Translation
31 /// \brief Feature for translation objects along the axis.
32 class FeaturesPlugin_Translation : public ModelAPI_Feature
36 inline static const std::string& ID()
38 static const std::string MY_TRANSLATION_ID("Translation");
39 return MY_TRANSLATION_ID;
42 /// Attribute name for creation method.
43 inline static const std::string& CREATION_METHOD()
45 static const std::string MY_CREATION_METHOD_ID("CreationMethod");
46 return MY_CREATION_METHOD_ID;
49 /// Attribute name for creation method "ByAxisAndDistance".
50 inline static const std::string& CREATION_METHOD_BY_DISTANCE()
52 static const std::string MY_CREATION_METHOD_ID("ByAxisAndDistance");
53 return MY_CREATION_METHOD_ID;
56 /// Attribute name for creation method "ByDimensions".
57 inline static const std::string& CREATION_METHOD_BY_DIMENSIONS()
59 static const std::string MY_CREATION_METHOD_ID("ByDimensions");
60 return MY_CREATION_METHOD_ID;
63 /// Attribute name for creation method "ByTwoPoints".
64 inline static const std::string& CREATION_METHOD_BY_TWO_POINTS()
66 static const std::string MY_CREATION_METHOD_ID("ByTwoPoints");
67 return MY_CREATION_METHOD_ID;
70 /// Attribute name of referenced objects.
71 inline static const std::string& OBJECTS_LIST_ID()
73 static const std::string MY_OBJECTS_LIST_ID("main_objects");
74 return MY_OBJECTS_LIST_ID;
77 /// Attribute name of an axis.
78 inline static const std::string& AXIS_OBJECT_ID()
80 static const std::string MY_AXIS_OBJECT_ID("axis_object");
81 return MY_AXIS_OBJECT_ID;
84 /// Attribute name of distance.
85 inline static const std::string& DISTANCE_ID()
87 static const std::string MY_DISTANCE_ID("distance");
88 return MY_DISTANCE_ID;
91 /// Attribute name of dimension in X.
92 inline static const std::string& DX_ID()
94 static const std::string MY_DX_ID("dx");
98 /// Attribute name of dimension in Y.
99 inline static const std::string& DY_ID()
101 static const std::string MY_DY_ID("dy");
105 /// Attribute name of dimension in Z.
106 inline static const std::string& DZ_ID()
108 static const std::string MY_DZ_ID("dz");
112 /// Attribute name of start point.
113 inline static const std::string& START_POINT_ID()
115 static const std::string MY_START_POINT_ID("start_point");
116 return MY_START_POINT_ID;
119 /// Attribute name of end point.
120 inline static const std::string& END_POINT_ID()
122 static const std::string MY_END_POINT_ID("end_point");
123 return MY_END_POINT_ID;
126 /// \return the kind of a feature.
127 FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
129 static std::string MY_KIND = FeaturesPlugin_Translation::ID();
133 /// Performs the algorithm and stores results it in the data structure.
134 FEATURESPLUGIN_EXPORT virtual void execute();
136 /// Request for initialization of data model of the feature: adding all attributes.
137 FEATURESPLUGIN_EXPORT virtual void initAttributes();
139 /// Use plugin manager for features creation.
140 FeaturesPlugin_Translation();
143 /// Calculate the translation using an axis and a distance.
144 std::shared_ptr<GeomAPI_Trsf> translationByAxisAndDistance();
146 /// Calculate the translation using three dimensions X, Y and Z
147 std::shared_ptr<GeomAPI_Trsf> translationByDimensions();
149 /// Calculate the translation usind two points
150 std::shared_ptr<GeomAPI_Trsf> translationByTwoPoints();
152 /// Perform the translation
153 void performTranslation(const std::shared_ptr<GeomAPI_Trsf>& theTrsf);