Salome HOME
Issue #761 - Check and error for unique parameter name
[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   /// list of references to the arguments of this expression
44   inline static const std::string& ARGUMENTS_ID()
45   {
46     static const std::string MY_VARIABLE_ID("arguments");
47     return MY_VARIABLE_ID;
48   }
49
50   /// Returns the kind of a feature
51   PARAMETERSPLUGIN_EXPORT virtual const std::string& getKind()
52   {
53     static std::string MY_KIND = ParametersPlugin_Parameter::ID();
54     return MY_KIND;
55   }
56
57   /// Pre-execution is not needed for parameter
58   PARAMETERSPLUGIN_EXPORT virtual bool isPreviewNeeded() const;
59
60   /// Creates a new part document if needed
61   PARAMETERSPLUGIN_EXPORT virtual void execute();
62
63   /// Request for initialization of data model of the feature: adding all attributes
64   PARAMETERSPLUGIN_EXPORT virtual void initAttributes();
65
66   PARAMETERSPLUGIN_EXPORT virtual bool isInHistory(); //false
67
68   PARAMETERSPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
69
70   /// Use plugin manager for features creation
71   ParametersPlugin_Parameter();
72
73  protected:
74   double evaluate(const std::string& theExpression, std::string& theError);
75   void updateName();
76   void updateExpression();
77
78  private:
79   std::shared_ptr<ParametersPlugin_PyInterp> myInterp;
80 };
81
82 #endif