21#ifndef __vtkMRMLLayerDMPythonUtil_h
22#define __vtkMRMLLayerDMPythonUtil_h
23#include "vtkSlicerLayerDMModuleMRMLExport.h"
28#include <vtkPythonUtil.h>
29#include <vtkSmartPyObject.h>
46 void PrintSelf(ostream& os, vtkIndent indent)
override;
71 static vtkSmartPyObject
ToPyArgs(
const std::vector<PyObject*>& pyObjs);
76 static vtkSmartPyObject
ToPyArgs(vtkObjectBase* obj);
83 static vtkSmartPyObject
ToPyArgs(vtkObject* obj,
unsigned long eventId,
void* callData);
static PyObject * ToPyObject(vtkObjectBase *obj)
Convert a VTK object to a Python object.
static void PrintErrorTraceback(const vtkObject *object, const std::string &errorMsg)
Outputs a vtkErrorMacro containing the traceback in case it's not empty.
void PrintSelf(ostream &os, vtkIndent indent) override
static PyObject * CallPythonMethod(PyObject *object, const vtkSmartPyObject &pyArgs, const std::string &fName)
Call a named method on a Python object with arguments.
static vtkSmartPyObject ToPyArgs(const std::vector< PyObject * > &pyObjs)
Create a Python tuple from a vector of Python objects.
static vtkSmartPyObject ToPyArgs(vtkObjectBase *obj)
Create a Python tuple from a single VTK object.
static void DeletePythonObject(PyObject **destObject)
Safely delete a Python object with proper reference counting.
static vtkSmartPyObject ToPyArgs(vtkObject *obj, unsigned long eventId, void *callData)
Create a Python tuple for VTK event callback arguments.
static PyObject * RawPtrToPython(void *ptr)
Convert a raw C pointer to a Python object.
~vtkMRMLLayerDMPythonUtil() override
static bool IsValidPythonContext()
true is python is initialized and no error has occurred.
static std::string FormatExceptionTraceback()
returns the formatted exception string if any exception occurred. Can be used to warn on current erro...
static PyObject * ToPyObject(unsigned long value)
Convert an unsigned long value to a Python object.
static PyObject * CallPythonObject(PyObject *object, const vtkSmartPyObject &pyArgs)
Call a Python callable object with arguments.
static void SetPythonObject(PyObject **destObject, PyObject *object)
Safely set a Python object pointer with proper reference counting.
static std::string GetObjectStr(PyObject *object)
returns the input's PyObject's string representation as std::string. If the python environment is not...
vtkMRMLLayerDMPythonUtil()
static PyObject * ToPyObject(const std::string &value)
Convert a string value to a Python object.
static vtkMRMLLayerDMPythonUtil * New()
static PyObject * CastCallData(PyObject *object, int vtkType)
Cast call data to appropriate Python type based on VTK type.