Medical Imaging Interaction Toolkit  2023.12.99-ed252ae7
Medical Imaging Interaction Toolkit
mitk::IPythonService Class Referenceabstract

#include <mitkIPythonService.h>

Inheritance diagram for mitk::IPythonService:

Public Member Functions

virtual std::string Execute (const std::string &pythonCommand, int commandType=SINGLE_LINE_COMMAND)=0
 
virtual void ExecuteScript (const std::string &pathToPythonScript)=0
 Executes a python script. More...
 
virtual bool PythonErrorOccured () const =0
 
virtual std::vector< PythonVariableGetVariableStack () const =0
 
virtual bool DoesVariableExist (const std::string &name) const =0
 
virtual std::string GetVariable (const std::string &name) const =0
 
virtual void AddPythonCommandObserver (PythonCommandObserver *observer)=0
 adds a command observer which is informed after a command was issued with "Execute" More...
 
virtual void RemovePythonCommandObserver (PythonCommandObserver *observer)=0
 removes a specific command observer More...
 
virtual void NotifyObserver (const std::string &command)=0
 
virtual bool IsSimpleItkPythonWrappingAvailable ()=0
 
virtual bool CopyToPythonAsSimpleItkImage (mitk::Image *image, const std::string &varName)=0
 
virtual mitk::Image::Pointer CopySimpleItkImageFromPython (const std::string &varName)=0
 
virtual bool IsVtkPythonWrappingAvailable ()=0
 
virtual bool CopyToPythonAsVtkPolyData (mitk::Surface *surface, const std::string &varName)=0
 
virtual ctkAbstractPythonManager * GetPythonManager ()=0
 
virtual ~IPythonService ()
 nothing to do here More...
 
virtual void AddRelativeSearchDirs (std::vector< std::string > dirs)=0
 
virtual void AddAbsoluteSearchDirs (std::vector< std::string > dirs)=0
 

Static Public Member Functions

static std::string ForceLoadModule ()
 

Static Public Attributes

static const int SINGLE_LINE_COMMAND
 
static const int MULTI_LINE_COMMAND
 
static const int EVAL_COMMAND
 

Detailed Description

The central service for issuing Python Code The class also enables to transfer mitk images to python as itk::Image and vice versa

See also
IPythonService::GetVariableStack()

Definition at line 56 of file mitkIPythonService.h.

Constructor & Destructor Documentation

◆ ~IPythonService()

virtual mitk::IPythonService::~IPythonService ( )
virtual

nothing to do here

Member Function Documentation

◆ AddAbsoluteSearchDirs()

virtual void mitk::IPythonService::AddAbsoluteSearchDirs ( std::vector< std::string >  dirs)
pure virtual

Implemented in mitk::PythonService.

◆ AddPythonCommandObserver()

virtual void mitk::IPythonService::AddPythonCommandObserver ( PythonCommandObserver observer)
pure virtual

adds a command observer which is informed after a command was issued with "Execute"

Implemented in mitk::PythonService.

◆ AddRelativeSearchDirs()

virtual void mitk::IPythonService::AddRelativeSearchDirs ( std::vector< std::string >  dirs)
pure virtual

Implemented in mitk::PythonService.

◆ CopySimpleItkImageFromPython()

virtual mitk::Image::Pointer mitk::IPythonService::CopySimpleItkImageFromPython ( const std::string &  varName)
pure virtual

copies an itk image from the python process that is named "varName"

Returns
the image or 0 if copying was not possible

Implemented in mitk::PythonService.

◆ CopyToPythonAsSimpleItkImage()

virtual bool mitk::IPythonService::CopyToPythonAsSimpleItkImage ( mitk::Image image,
const std::string &  varName 
)
pure virtual

copies an mitk image as itk image into the python interpreter process the image will be available as "varName" in python if everythin worked

Returns
true if image was copied, else false

Implemented in mitk::PythonService.

◆ CopyToPythonAsVtkPolyData()

virtual bool mitk::IPythonService::CopyToPythonAsVtkPolyData ( mitk::Surface surface,
const std::string &  varName 
)
pure virtual
See also
CopyToPythonAsItkImage()

Implemented in mitk::PythonService.

◆ DoesVariableExist()

virtual bool mitk::IPythonService::DoesVariableExist ( const std::string &  name) const
pure virtual
Returns
true if a variable with this name is defined in the main namespace, false otherwise

Implemented in mitk::PythonService.

◆ Execute()

virtual std::string mitk::IPythonService::Execute ( const std::string &  pythonCommand,
int  commandType = SINGLE_LINE_COMMAND 
)
pure virtual

Executes a python command.

Returns
A variant containing the return value as string of the python code (if any)

Implemented in mitk::PythonService.

◆ ExecuteScript()

virtual void mitk::IPythonService::ExecuteScript ( const std::string &  pathToPythonScript)
pure virtual

Executes a python script.

Implemented in mitk::PythonService.

◆ ForceLoadModule()

static std::string mitk::IPythonService::ForceLoadModule ( )
static

◆ GetPythonManager()

virtual ctkAbstractPythonManager* mitk::IPythonService::GetPythonManager ( )
pure virtual
Returns
the ctk abstract python manager instance

Implemented in mitk::PythonService.

◆ GetVariable()

virtual std::string mitk::IPythonService::GetVariable ( const std::string &  name) const
pure virtual
Returns
value of variable with this name as string, empty string if variable does not exist

Implemented in mitk::PythonService.

◆ GetVariableStack()

virtual std::vector<PythonVariable> mitk::IPythonService::GetVariableStack ( ) const
pure virtual
Returns
The list of variables in the main namespace

Implemented in mitk::PythonService.

◆ IsSimpleItkPythonWrappingAvailable()

virtual bool mitk::IPythonService::IsSimpleItkPythonWrappingAvailable ( )
pure virtual
Returns
true, if itk wrapping is available, false otherwise

Implemented in mitk::PythonService.

◆ IsVtkPythonWrappingAvailable()

virtual bool mitk::IPythonService::IsVtkPythonWrappingAvailable ( )
pure virtual
Returns
true, if vtk wrapping is available, false otherwise

Implemented in mitk::PythonService.

◆ NotifyObserver()

virtual void mitk::IPythonService::NotifyObserver ( const std::string &  command)
pure virtual

notify all observer. this should only be used if it can be garantueed that the current python interpreter instance got another command from anywhere else the the Execute() method of this service, e.g. the shell widget uses this function since it does not use Execute()

Implemented in mitk::PythonService.

◆ PythonErrorOccured()

virtual bool mitk::IPythonService::PythonErrorOccured ( ) const
pure virtual
Returns
true if the last call to Execute...() resulted in an error, false otherwise

Implemented in mitk::PythonService.

◆ RemovePythonCommandObserver()

virtual void mitk::IPythonService::RemovePythonCommandObserver ( PythonCommandObserver observer)
pure virtual

removes a specific command observer

Implemented in mitk::PythonService.

Member Data Documentation

◆ EVAL_COMMAND

const int mitk::IPythonService::EVAL_COMMAND
static

Constant representing a single line command x which is run as "eval(x)"

See also
IPythonService::Execute()

Definition at line 70 of file mitkIPythonService.h.

◆ MULTI_LINE_COMMAND

const int mitk::IPythonService::MULTI_LINE_COMMAND
static

Constant representing a command in which the commands are seperated by new lines, i.e. "\\n"

See also
IPythonService::Execute()

Definition at line 66 of file mitkIPythonService.h.

◆ SINGLE_LINE_COMMAND

const int mitk::IPythonService::SINGLE_LINE_COMMAND
static

Constant representing a single line command

See also
IPythonService::Execute()

Definition at line 62 of file mitkIPythonService.h.


The documentation for this class was generated from the following file: