1 // Copyright (C) 2014-2022 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef SRC_PARAMETERSPLUGIN_EVALLISTENER_H_
21 #define SRC_PARAMETERSPLUGIN_EVALLISTENER_H_
23 #include <ParametersPlugin.h>
24 #include <Events_Loop.h>
26 class ModelAPI_Attribute;
27 class ModelAPI_Document;
28 class ModelAPI_Feature;
29 class ModelAPI_ResultParameter;
30 class ParametersPlugin_Parameter;
33 * \class ParametersPlugin_EvalListener
35 * \brief Class which process the events from the event loop.
37 class ParametersPlugin_EvalListener : public Events_Listener
39 /// map of old names, that were valid for perameres, but now parameter name is changed to invalid
40 /// stored not shared pointers to features to avoid memory keeping on the feature delete
41 std::map<ParametersPlugin_Parameter*, std::wstring> myOldNames;
43 PARAMETERSPLUGIN_EXPORT ParametersPlugin_EvalListener();
44 PARAMETERSPLUGIN_EXPORT virtual ~ParametersPlugin_EvalListener();
46 /// Reimplemented from Events_Listener::processEvent().
47 PARAMETERSPLUGIN_EXPORT
48 virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
51 /// Processes ObjectRenamed event.
52 void processObjectRenamedEvent(const std::shared_ptr<Events_Message>& theMessage);
53 /// Processes ReplaceParameter event.
54 void processReplaceParameterEvent(const std::shared_ptr<Events_Message>& theMessage);
56 /// Renames theOldName in theExpression by theNewName.
57 std::wstring renameInPythonExpression(const std::wstring& theExpression,
58 const std::wstring& theOldName,
59 const std::wstring& theNewName);
60 /// Renames theOldName in the expression attribute of theParameter by theNewName.
61 void renameInParameter(std::shared_ptr<ParametersPlugin_Parameter> theParameter,
62 const std::wstring& theOldName,
63 const std::wstring& theNewName);
64 /// Renames theOldName in the text fields of theAttribute by theNewName.
65 void renameInAttribute(std::shared_ptr<ModelAPI_Attribute> theAttribute,
66 const std::wstring& theOldName,
67 const std::wstring& theNewName);
68 /// Renames theOldName in all dependents of theResultParameter by theNewName.
69 void renameInDependents(std::shared_ptr<ModelAPI_ResultParameter> theResultParameter,
70 const std::wstring& theOldName,
71 const std::wstring& theNewName);
74 #endif /* SRC_PARAMETERSPLUGIN_PARAMETERSPLUGIN_EVALLISTENER_H_ */