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