Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Scale.h
1 // Copyright (C) 2014-201x CEA/DEN, EDF R&D
2
3 // File:        FeaturesPlugin_Scale.h
4 // Created:     13 Jan 2017
5 // Author:      Clarisse Genrault (CEA)
6
7 #ifndef FEATURESPLUGIN_SCALE_H_
8 #define FEATURESPLUGIN_SCALE_H_
9
10 #include <FeaturesPlugin.h>
11
12 #include <ModelAPI_Feature.h>
13
14 #include <GeomAlgoAPI_Scale.h>
15
16 /** \class FeaturesPlugin_Scale
17  *  \ingroup Plugins
18  *  \brief Feature for changing the scale of an object.
19  */
20 class FeaturesPlugin_Scale : public ModelAPI_Feature
21 {
22  public:
23   /// Scale kind.
24   inline static const std::string& ID()
25   {
26     static const std::string MY_SCALE_ID("Scale");
27     return MY_SCALE_ID;
28   }
29
30   /// Attribute name for creation method.
31   inline static const std::string& CREATION_METHOD()
32   {
33     static const std::string MY_CREATION_METHOD_ID("CreationMethod");
34     return MY_CREATION_METHOD_ID;
35   }
36
37   /// Attribute name for creation method "ByFactor".
38   inline static const std::string& CREATION_METHOD_BY_FACTOR()
39   {
40     static const std::string MY_CREATION_METHOD_ID("ByFactor");
41     return MY_CREATION_METHOD_ID;
42   }
43
44   /// Attribute name for creation method "ByFactor".
45   inline static const std::string& CREATION_METHOD_BY_DIMENSIONS()
46   {
47     static const std::string MY_CREATION_METHOD_ID("ByDimensions");
48     return MY_CREATION_METHOD_ID;
49   }
50
51   /// Attribute name of referenced objects.
52   inline static const std::string& OBJECTS_LIST_ID()
53   {
54     static const std::string MY_OBJECTS_LIST_ID("main_objects");
55     return MY_OBJECTS_LIST_ID;
56   }
57
58   /// Attribute name of center point.
59   inline static const std::string& CENTER_POINT_ID()
60   {
61     static const std::string MY_CENTER_POINT_ID("center_point");
62     return MY_CENTER_POINT_ID;
63   }
64
65   /// Attribute name of scale factor.
66   inline static const std::string& SCALE_FACTOR_ID()
67   {
68     static const std::string MY_SCALE_FACTOR_ID("scale_factor");
69     return MY_SCALE_FACTOR_ID;
70   }
71
72   /// Attribute name of scale factor in X.
73   inline static const std::string& SCALE_FACTOR_X_ID()
74   {
75     static const std::string MY_SCALE_FACTOR_X_ID("scale_factor_x");
76     return MY_SCALE_FACTOR_X_ID;
77   }
78
79   /// Attribute name of scale factor in Y.
80   inline static const std::string& SCALE_FACTOR_Y_ID()
81   {
82     static const std::string MY_SCALE_FACTOR_Y_ID("scale_factor_y");
83     return MY_SCALE_FACTOR_Y_ID;
84   }
85
86   /// Attribute name of scale factor in Z.
87   inline static const std::string& SCALE_FACTOR_Z_ID()
88   {
89     static const std::string MY_SCALE_FACTOR_Z_ID("scale_factor_z");
90     return MY_SCALE_FACTOR_Z_ID;
91   }
92
93   /// \return the kind of a feature.
94   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
95   {
96     static std::string MY_KIND = FeaturesPlugin_Scale::ID();
97     return MY_KIND;
98   }
99
100   /// Creates a new part document if needed.
101   FEATURESPLUGIN_EXPORT virtual void execute();
102
103   /// Request for initialization of data model of the feature: adding all attributes.
104   FEATURESPLUGIN_EXPORT virtual void initAttributes();
105
106   /// Use plugin manager for features creation.
107   FeaturesPlugin_Scale();
108
109 private:
110   /// Perform scale using a central point and a value of the scale.
111   void performScaleByFactor();
112
113   /// Perform symmetry using a central point and three dimensions
114   void performScaleByDimensions();
115
116   /// Perform the naming
117   void loadNamingDS(GeomAlgoAPI_Scale& theScaleAlgo,
118                     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
119                     std::shared_ptr<GeomAPI_Shape> theBaseShape);
120 };
121
122 #endif // FEATURESPLUGIN_SCALE_H_