![]() |
ImFusion C++ SDK 4.4.0
|
#include <ImFusion/Python/PythonInterpreter.h>
Starts an embedded Python interpreter and provides factories for registering algorithms from Python. More...
Starts an embedded Python interpreter and provides factories for registering algorithms from Python.
This class should only be used by the PythonPlugin.
Public Member Functions | |
| PythonInterpreter (const std::string &libpythonPath, const std::string &imfusionInterpreterDLLPath, const std::wstring &pythonExecutable, const std::string &envName) | |
| Does not initialize or start the interpreter yet. | |
| ~PythonInterpreter () override | |
| Stops the interpreter if it was started. | |
| std::string | version () const override |
| Returns the Python version of this interpreter (e.g. "3.6"). | |
| const std::string & | bridgeDirectory () const override |
| Returns the runtime directory from where interpreter bridge plugins can be loaded. | |
| std::unique_ptr< GILScopeGuard > | gil_scoped_acquire () override |
| std::unique_ptr< GILScopeGuard > | gil_scoped_release () override |
| std::vector< std::shared_ptr< Data > > | eval (const std::string &expr, const dict &localData=dict()) override |
| Evaluates a Python expression via pybind11::eval, passing it a set of local data, and returns a vector of Data returned by the expression. | |
| void | eval_file (std::string filename) override |
| Calls pybind11::eval_file Raises an exception on error. | |
| void | exec (std::string expr) override |
| Calls pybind11::exec Raises an exception on error. | |
| void | start () override |
| Starts the interpreter and imports the imfusion module. | |
| std::unique_ptr< ImFusionPlugin > | createFactoriesPlugin () override |
| void | createInteractiveConsole (MainWindowBase *main) override |
| Creates an interactive console widget in the MainWindow. | |
| void | destroyInteractiveConsole (MainWindowBase *main) |
| void | setApplicationController (ApplicationController &app) override |
Additional Inherited Members | |
| Public Types inherited from ImFusion::PythonInterpreterInterface | |
| using | dict = std::unordered_map<std::string, std::shared_ptr<Data>> |
| Protected Member Functions inherited from ImFusion::PythonInterpreterInterface | |
| PythonInterpreterInterface (const std::string &) | |
|
overridevirtual |
Returns the Python version of this interpreter (e.g. "3.6").
Implements ImFusion::PythonInterpreterInterface.
|
overridevirtual |
Returns the runtime directory from where interpreter bridge plugins can be loaded.
Implements ImFusion::PythonInterpreterInterface.
|
overridevirtual |
Implements ImFusion::PythonInterpreterInterface.
|
overridevirtual |
Implements ImFusion::PythonInterpreterInterface.
|
overridevirtual |
Evaluates a Python expression via pybind11::eval, passing it a set of local data, and returns a vector of Data returned by the expression.
The Python expression is expected to return a Data or a list/tuple/dictionary of Data that are bound. Throws a C++ exception if the expression raises a Python exception.
Implements ImFusion::PythonInterpreterInterface.
|
overridevirtual |
Calls pybind11::eval_file Raises an exception on error.
Implements ImFusion::PythonInterpreterInterface.
|
overridevirtual |
Calls pybind11::exec Raises an exception on error.
Implements ImFusion::PythonInterpreterInterface.
|
overridevirtual |
Starts the interpreter and imports the imfusion module.
Throws a runtime_error if interpreter or module could not be initialized
Implements ImFusion::PythonInterpreterInterface.
|
overridevirtual |
Implements ImFusion::PythonInterpreterInterface.
|
overridevirtual |
Creates an interactive console widget in the MainWindow.
The widget is added to a layout with the object name of "logViewerContainer". If no such widget exists in main, the console is launch in a separate window.
What kind of widget is created depends on the PythonSettings::consoleType setting value. With the default value of PythonSettings::NoConsole, no widget is created.
The created widget has an object name of "pythonConsoleWidget". Any existing "pythonConsoleWidget" is deleted when this method is called.
Implements ImFusion::PythonInterpreterInterface.
|
overridevirtual |
Implements ImFusion::PythonInterpreterInterface.