2 * ParametersPlugin_EvalListener.h
4 * Created on: Apr 28, 2015
8 #ifndef SRC_PARAMETERSPLUGIN_EVALLISTENER_H_
9 #define SRC_PARAMETERSPLUGIN_EVALLISTENER_H_
11 #include <ParametersPlugin.h>
12 #include <Events_Loop.h>
14 class ModelAPI_Attribute;
15 class ModelAPI_Document;
16 class ModelAPI_Feature;
17 class ModelAPI_ResultParameter;
18 class ParametersPlugin_Parameter;
19 class ParametersPlugin_PyInterp;
22 * \class ParametersPlugin_EvalListener
24 * \brief Class which process the events from the event loop.
26 class ParametersPlugin_EvalListener : public Events_Listener
29 PARAMETERSPLUGIN_EXPORT ParametersPlugin_EvalListener();
30 PARAMETERSPLUGIN_EXPORT virtual ~ParametersPlugin_EvalListener();
32 /// Reimplemented from Events_Listener::processEvent().
33 PARAMETERSPLUGIN_EXPORT virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
36 /// Evaluates theExpression and returns its value.
37 double evaluate(std::shared_ptr<ModelAPI_Feature> theParameter,
38 const std::string& theExpression, std::string& theError);
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);
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);
65 std::shared_ptr<ParametersPlugin_PyInterp> myInterp;
68 #endif /* SRC_PARAMETERSPLUGIN_PARAMETERSPLUGIN_EVALLISTENER_H_ */