SHAPER  9.12.0
InitializationPlugin_EvalListener.h
1 // Copyright (C) 2014-2023 CEA, EDF
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef SRC_INITIALIZATIONPLUGIN_EVALLISTENER_H_
21 #define SRC_INITIALIZATIONPLUGIN_EVALLISTENER_H_
22 
23 #include <InitializationPlugin.h>
24 #include <Events_Loop.h>
25 
26 class ModelAPI_Attribute;
27 class ModelAPI_Document;
28 class ModelAPI_Feature;
30 class InitializationPlugin_Parameter;
32 
39 {
40  public:
41  INITIALIZATIONPLUGIN_EXPORT InitializationPlugin_EvalListener();
42  INITIALIZATIONPLUGIN_EXPORT virtual ~InitializationPlugin_EvalListener();
43 
45  INITIALIZATIONPLUGIN_EXPORT
46  virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
47 
48  // performs the python call to initialize high level data model on internal data model creation
49  void initDataModel();
50 
51  protected:
53  double evaluate(std::shared_ptr<ModelAPI_Feature> theParameter,
54  const std::wstring& theExpression, std::string& theError,
55  std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
56  const bool theIsParameter = false);
57 
59  double evaluate(std::wstring& theVariable,
60  double theValueVariable,
61  std::shared_ptr<ModelAPI_Feature> theParameter,
62  const std::wstring& theExpression,
63  std::string& theError,
64  std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
65  bool theIsFirstTime);
66 
67 
69  void processEvaluationEvent(const std::shared_ptr<Events_Message>& theMessage);
70 
71  private:
72  std::shared_ptr<InitializationPlugin_PyInterp> myInterp;
73 };
74 
75 #endif /* SRC_INITIALIZATIONPLUGIN_INITIALIZATIONPLUGIN_EVALLISTENER_H_ */
Base interface for any event listener.
Definition: Events_Listener.h:37
Class which process the events from the event loop.
Definition: InitializationPlugin_EvalListener.h:39
virtual INITIALIZATIONPLUGIN_EXPORT void processEvent(const std::shared_ptr< Events_Message > &theMessage)
Reimplemented from Events_Listener::processEvent().
Definition: InitializationPlugin_EvalListener.cpp:93
void processEvaluationEvent(const std::shared_ptr< Events_Message > &theMessage)
Processes Evaluation event.
Definition: InitializationPlugin_EvalListener.cpp:267
double evaluate(std::shared_ptr< ModelAPI_Feature > theParameter, const std::wstring &theExpression, std::string &theError, std::list< std::shared_ptr< ModelAPI_ResultParameter > > &theParamsList, const bool theIsParameter=false)
Evaluates theExpression and returns its value.
Definition: InitializationPlugin_EvalListener.cpp:237
Helper class for using Python interpreter.
Definition: InitializationPlugin_PyInterp.h:36
Generic attribute of the Object.
Definition: ModelAPI_Attribute.h:34
Document for internal data structure of any object storage.
Definition: ModelAPI_Document.h:52
Feature function that represents the particular functionality of this operation.
Definition: ModelAPI_Feature.h:39
The construction element result of a feature.
Definition: ModelAPI_ResultParameter.h:34