Salome HOME
Fix for the issue #1444 : correct checking of upper and lower parameters, current...
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_EvalListener.h
1 /*
2  * ParametersPlugin_EvalListener.h
3  *
4  *  Created on: Apr 28, 2015
5  *      Author: sbh
6  */
7
8 #ifndef SRC_PARAMETERSPLUGIN_EVALLISTENER_H_
9 #define SRC_PARAMETERSPLUGIN_EVALLISTENER_H_
10
11 #include <ParametersPlugin.h>
12 #include <Events_Loop.h>
13
14 class ModelAPI_Attribute;
15 class ModelAPI_Document;
16 class ModelAPI_Feature;
17 class ModelAPI_ResultParameter;
18 class ParametersPlugin_Parameter;
19 class ParametersPlugin_PyInterp;
20
21 /**
22  * \class ParametersPlugin_EvalListener
23  * \ingroup Plugins
24  * \brief Class which process the events from the event loop.
25  */
26 class ParametersPlugin_EvalListener : public Events_Listener
27 {
28  public:
29   PARAMETERSPLUGIN_EXPORT ParametersPlugin_EvalListener();
30   PARAMETERSPLUGIN_EXPORT virtual ~ParametersPlugin_EvalListener();
31
32   /// Reimplemented from Events_Listener::processEvent().
33   PARAMETERSPLUGIN_EXPORT virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
34
35  protected:
36   /// Evaluates theExpression and returns its value.
37    double evaluate(std::shared_ptr<ModelAPI_Feature> theParameter,
38                   const std::string& theExpression, std::string& theError);
39
40   /// Processes Evaluation event.
41   void processEvaluationEvent(const std::shared_ptr<Events_Message>& theMessage);
42   /// Processes ObjectRenamed event.
43   void processObjectRenamedEvent(const std::shared_ptr<Events_Message>& theMessage);
44   /// Processes ReplaceParameter event.
45   void processReplaceParameterEvent(const std::shared_ptr<Events_Message>& theMessage);
46
47   /// Renames theOldName in theExpression by theNewName.
48   std::string renameInPythonExpression(const std::string& theExpression,
49                                        const std::string& theOldName,
50                                        const std::string& theNewName);
51   /// Renames theOldName in the expression attribute of theParameter by theNewName.
52   void renameInParameter(std::shared_ptr<ParametersPlugin_Parameter> theParameter,
53                          const std::string& theOldName,
54                          const std::string& theNewName);
55   /// Renames theOldName in the text fields of theAttribute by theNewName.
56   void renameInAttribute(std::shared_ptr<ModelAPI_Attribute> theAttribute,
57                          const std::string& theOldName,
58                          const std::string& theNewName);
59   /// Renames theOldName in all dependents of theResultParameter by theNewName.
60   void renameInDependents(std::shared_ptr<ModelAPI_ResultParameter> theResultParameter,
61                           const std::string& theOldName,
62                           const std::string& theNewName);
63
64  private:
65   std::shared_ptr<ParametersPlugin_PyInterp> myInterp;
66 };
67
68 #endif /* SRC_PARAMETERSPLUGIN_PARAMETERSPLUGIN_EVALLISTENER_H_ */