Utility class for Python/C++ interoperability in VTK MRML Layer Displayable Manager.
More...
|
| static PyObject * | CallPythonMethod (PyObject *object, const vtkSmartPyObject &pyArgs, const std::string &fName) |
| | Call a named method on a Python object with arguments.
|
| |
| static PyObject * | CallPythonObject (PyObject *object, const vtkSmartPyObject &pyArgs) |
| | Call a Python callable object with arguments.
|
| |
| static PyObject * | CastCallData (PyObject *object, int vtkType) |
| | Cast call data to appropriate Python type based on VTK type.
|
| |
| static void | DeletePythonObject (PyObject **destObject) |
| | Safely delete a Python object with proper reference counting.
|
| |
| static std::string | FormatExceptionTraceback () |
| | returns the formatted exception string if any exception occurred. Can be used to warn on current errors without swallowing the exception.
|
| |
| static std::string | GetObjectStr (PyObject *object) |
| | returns the input's PyObject's string representation as std::string. If the python environment is not initialized, returns empty string. If the input object is nullptr, returns "None" If the input object string representation fails, return "INVALID_OBJECT_STR" Calling this method doesn't change the current python error stack.
|
| |
| static int | IsTypeOf (const char *type) |
| |
| static bool | IsValidPythonContext () |
| | true is python is initialized and no error has occurred.
|
| |
| static vtkMRMLLayerDMPythonUtil * | New () |
| |
| static void | PrintErrorTraceback (const vtkObject *object, const std::string &errorMsg) |
| | Outputs a vtkErrorMacro containing the traceback in case it's not empty.
|
| |
| static PyObject * | RawPtrToPython (void *ptr) |
| | Convert a raw C pointer to a Python object.
|
| |
| static vtkMRMLLayerDMPythonUtil * | SafeDownCast (vtkObject *o) |
| |
| static void | SetPythonObject (PyObject **destObject, PyObject *object) |
| | Safely set a Python object pointer with proper reference counting.
|
| |
| static vtkSmartPyObject | ToPyArgs (const std::vector< PyObject * > &pyObjs) |
| | Create a Python tuple from a vector of Python objects.
|
| |
| static vtkSmartPyObject | ToPyArgs (vtkObject *obj, unsigned long eventId, void *callData) |
| | Create a Python tuple for VTK event callback arguments.
|
| |
| static vtkSmartPyObject | ToPyArgs (vtkObjectBase *obj) |
| | Create a Python tuple from a single VTK object.
|
| |
| static PyObject * | ToPyObject (const std::string &value) |
| | Convert a string value to a Python object.
|
| |
| static PyObject * | ToPyObject (unsigned long value) |
| | Convert an unsigned long value to a Python object.
|
| |
| static PyObject * | ToPyObject (vtkObjectBase *obj) |
| | Convert a VTK object to a Python object.
|
| |
Utility class for Python/C++ interoperability in VTK MRML Layer Displayable Manager.
This class provides a collection of static utility methods for converting between VTK C++ objects and Python objects, managing Python object lifecycles, and calling Python methods from C++. It serves as a bridge layer for Python integration in the Layer Displayable Manager module.
Definition at line 41 of file vtkMRMLLayerDMPythonUtil.h.
| static void vtkMRMLLayerDMPythonUtil::PrintErrorTraceback |
( |
const vtkObject * | object, |
|
|
const std::string & | errorMsg ) |
|
static |
Outputs a vtkErrorMacro containing the traceback in case it's not empty.
Does nothing if the python environment is not initialized. Should be used by Methods that cannot properly forward Python results back to the interpreter to avoid silent errors happening in the Python layer (or errors being raised in unrelated parts of the executable).
This method doesn't swallow the underlying python exception. Python level exceptions should be handled at the python level where they are raised to avoid silent errors from happening.