Salome HOME
Issue #818 - Deletion of a parameter used in a feature -- Replace parameters
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_Parameter.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        ParametersPlugin_Parameter.h
4 // Created:     23 MArch 2015
5 // Author:      sbh
6
7 #ifndef PARAMETERSPLUGIN_PARAMETER_H_
8 #define PARAMETERSPLUGIN_PARAMETER_H_
9
10 #include "ParametersPlugin.h"
11 #include <ModelAPI_Feature.h>
12
13 #include <memory>
14
15 class ParametersPlugin_PyInterp;
16
17 class ParametersPlugin_Parameter : public ModelAPI_Feature
18 {
19  public:
20   virtual ~ParametersPlugin_Parameter();
21
22   /// Extrusion kind
23   inline static const std::string& ID()
24   {
25     static const std::string MY_PARAMETER_ID("Parameter");
26     return MY_PARAMETER_ID;
27   }
28   /// attribute name of references sketch entities list, it should contain a sketch result or
29   /// a pair a sketch result to sketch face
30   inline static const std::string& VARIABLE_ID()
31   {
32     static const std::string MY_VARIABLE_ID("variable");
33     return MY_VARIABLE_ID;
34   }
35
36   /// attribute name of extrusion size
37   inline static const std::string& EXPRESSION_ID()
38   {
39     static const std::string MY_EXPRESSION_ID("expression");
40     return MY_EXPRESSION_ID;
41   }
42
43   /// attribute name of extrusion size
44   inline static const std::string& EXPRESSION_ERROR_ID()
45   {
46     static const std::string MY_EXPRESSION_ERROR_ID("ExpressionError");
47     return MY_EXPRESSION_ERROR_ID;
48   }
49
50   /// list of references to the arguments of this expression
51   inline static const std::string& ARGUMENTS_ID()
52   {
53     static const std::string MY_ARGUMENTS_ID("arguments");
54     return MY_ARGUMENTS_ID;
55   }
56
57   /// Returns the kind of a feature
58   PARAMETERSPLUGIN_EXPORT virtual const std::string& getKind()
59   {
60     static std::string MY_KIND = ParametersPlugin_Parameter::ID();
61     return MY_KIND;
62   }
63
64   /// Pre-execution is not needed for parameter
65   PARAMETERSPLUGIN_EXPORT virtual bool isPreviewNeeded() const;
66
67   /// Creates a new part document if needed
68   PARAMETERSPLUGIN_EXPORT virtual void execute();
69
70   /// Request for initialization of data model of the feature: adding all attributes
71   PARAMETERSPLUGIN_EXPORT virtual void initAttributes();
72
73   PARAMETERSPLUGIN_EXPORT virtual bool isInHistory(); //false
74
75   PARAMETERSPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
76
77   /// Use plugin manager for features creation
78   ParametersPlugin_Parameter();
79
80  protected:
81   double evaluate(const std::string& theExpression, std::string& theError);
82   void updateName();
83   void updateExpression();
84
85  private:
86   std::shared_ptr<ParametersPlugin_PyInterp> myInterp;
87 };
88
89 #endif