Salome HOME
Issue #1806 : evaluation of expressions if no parameters defined.
[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
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
34     virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
35
36  protected:
37   /// Processes ObjectRenamed event.
38   void processObjectRenamedEvent(const std::shared_ptr<Events_Message>& theMessage);
39   /// Processes ReplaceParameter event.
40   void processReplaceParameterEvent(const std::shared_ptr<Events_Message>& theMessage);
41
42   /// Renames theOldName in theExpression by theNewName.
43   std::string renameInPythonExpression(const std::string& theExpression,
44                                        const std::string& theOldName,
45                                        const std::string& theNewName);
46   /// Renames theOldName in the expression attribute of theParameter by theNewName.
47   void renameInParameter(std::shared_ptr<ParametersPlugin_Parameter> theParameter,
48                          const std::string& theOldName,
49                          const std::string& theNewName);
50   /// Renames theOldName in the text fields of theAttribute by theNewName.
51   void renameInAttribute(std::shared_ptr<ModelAPI_Attribute> theAttribute,
52                          const std::string& theOldName,
53                          const std::string& theNewName);
54   /// Renames theOldName in all dependents of theResultParameter by theNewName.
55   void renameInDependents(std::shared_ptr<ModelAPI_ResultParameter> theResultParameter,
56                           const std::string& theOldName,
57                           const std::string& theNewName);
58 };
59
60 #endif /* SRC_PARAMETERSPLUGIN_PARAMETERSPLUGIN_EVALLISTENER_H_ */