Salome HOME
Documentation fixes.
[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_ResultParameter;
17 class ParametersPlugin_Parameter;
18 class ParametersPlugin_PyInterp;
19
20 /**
21  * \class ParametersPlugin_EvalListener
22  * \ingroup Plugins
23  * \brief Class which process the events from the event loop.
24  */
25 class ParametersPlugin_EvalListener : public Events_Listener
26 {
27  public:
28   PARAMETERSPLUGIN_EXPORT ParametersPlugin_EvalListener();
29   PARAMETERSPLUGIN_EXPORT virtual ~ParametersPlugin_EvalListener();
30
31   /// Reimplemented from Events_Listener::processEvent().
32   PARAMETERSPLUGIN_EXPORT virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
33
34  protected:
35   /// Evaluates theExpression and returns its value.
36   double evaluate(const std::string& theExpression, std::string& theError, 
37                   const std::shared_ptr<ModelAPI_Document>& theDocument);
38
39   /// Processes Evaluation event.
40   void processEvaluationEvent(const std::shared_ptr<Events_Message>& theMessage);
41   /// Processes ObjectRenamed event.
42   void processObjectRenamedEvent(const std::shared_ptr<Events_Message>& theMessage);
43   /// Processes ReplaceParameter event.
44   void processReplaceParameterEvent(const std::shared_ptr<Events_Message>& theMessage);
45
46   /// Renames theOldName in theExpression by theNewName.
47   std::string renameInPythonExpression(const std::string& theExpression,
48                                        const std::string& theOldName,
49                                        const std::string& theNewName);
50   /// Renames theOldName in the expression attribute of theParameter by theNewName.
51   void renameInParameter(std::shared_ptr<ParametersPlugin_Parameter> theParameter,
52                          const std::string& theOldName,
53                          const std::string& theNewName);
54   /// Renames theOldName in the text fields of theAttribute by theNewName.
55   void renameInAttribute(std::shared_ptr<ModelAPI_Attribute> theAttribute,
56                          const std::string& theOldName,
57                          const std::string& theNewName);
58   /// Renames theOldName in all dependents of theResultParameter by theNewName.
59   void renameInDependents(std::shared_ptr<ModelAPI_ResultParameter> theResultParameter,
60                           const std::string& theOldName,
61                           const std::string& theNewName);
62
63  private:
64   std::shared_ptr<ParametersPlugin_PyInterp> myInterp;
65 };
66
67 #endif /* SRC_PARAMETERSPLUGIN_PARAMETERSPLUGIN_EVALLISTENER_H_ */