Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
mitkPythonService.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 #ifndef mitkPythonService_h
13 #define mitkPythonService_h
14 
15 #include <ctkAbstractPythonManager.h>
16 #include "mitkIPythonService.h"
17 #include <itkLightObject.h>
18 #include "mitkSurface.h"
19 
20 namespace mitk
21 {
25  class PythonService: public itk::LightObject, public mitk::IPythonService
26  {
27  public:
30  PythonService();
33  ~PythonService() override;
36  std::string Execute( const std::string& pythonCommand, int commandType = SINGLE_LINE_COMMAND ) override;
39  void ExecuteScript(const std::string &pathToPythonScript) override;
42  bool PythonErrorOccured() const override;
45  std::vector<PythonVariable> GetVariableStack() const override;
48  bool DoesVariableExist(const std::string& name) const override;
51  std::string GetVariable(const std::string& name) const override;
54  void AddPythonCommandObserver( PythonCommandObserver* observer ) override;
57  void RemovePythonCommandObserver( PythonCommandObserver* observer ) override;
60  void NotifyObserver( const std::string& command ) override;
63  bool IsSimpleItkPythonWrappingAvailable() override;
66  bool CopyToPythonAsSimpleItkImage( mitk::Image* image, const std::string& varName ) override;
69  mitk::Image::Pointer CopySimpleItkImageFromPython( const std::string& varName ) override;
72  bool IsOpenCvPythonWrappingAvailable() override;
75  bool CopyToPythonAsCvImage( mitk::Image* image, const std::string& varName ) override;
78  mitk::Image::Pointer CopyCvImageFromPython( const std::string& varName ) override;
81  bool IsVtkPythonWrappingAvailable() override;
84  bool CopyToPythonAsVtkPolyData( mitk::Surface* surface, const std::string& varName ) override;
87  mitk::Surface::Pointer CopyVtkPolyDataFromPython( const std::string& varName ) override;
90  ctkAbstractPythonManager* GetPythonManager() override;
91 
92  void AddRelativeSearchDirs(std::vector< std::string > dirs) override;
93 
94  void AddAbsoluteSearchDirs(std::vector< std::string > dirs) override;
95 
96  protected:
97 
98  private:
99  QList<PythonCommandObserver*> m_Observer;
100  ctkAbstractPythonManager m_PythonManager;
101  bool m_ItkWrappingAvailable;
102  bool m_OpenCVWrappingAvailable;
103  bool m_VtkWrappingAvailable;
104  bool m_ErrorOccured;
105  };
106 }
107 #endif
mitk::PythonService::ExecuteScript
void ExecuteScript(const std::string &pathToPythonScript) override
mitk::PythonService::GetVariableStack
std::vector< PythonVariable > GetVariableStack() const override
mitk::PythonService::IsVtkPythonWrappingAvailable
bool IsVtkPythonWrappingAvailable() override
mitk::IPythonService::SINGLE_LINE_COMMAND
static const int SINGLE_LINE_COMMAND
Definition: mitkIPythonService.h:60
mitk::IPythonService
Definition: mitkIPythonService.h:54
mitk::PythonService::CopyToPythonAsCvImage
bool CopyToPythonAsCvImage(mitk::Image *image, const std::string &varName) override
mitk::PythonCommandObserver
Definition: mitkIPythonService.h:43
mitk::PythonService::CopyToPythonAsSimpleItkImage
bool CopyToPythonAsSimpleItkImage(mitk::Image *image, const std::string &varName) override
mitk::Image
Image class for storing images.
Definition: mitkImage.h:69
mitk::PythonService::AddRelativeSearchDirs
void AddRelativeSearchDirs(std::vector< std::string > dirs) override
mitk::PythonService::~PythonService
~PythonService() override
empty implementation...
itk::SmartPointer< Self >
mitk::PythonService::AddAbsoluteSearchDirs
void AddAbsoluteSearchDirs(std::vector< std::string > dirs) override
mitk::PythonService::IsSimpleItkPythonWrappingAvailable
bool IsSimpleItkPythonWrappingAvailable() override
mitk::Surface
Class for storing surfaces (vtkPolyData).
Definition: mitkSurface.h:28
mitk::PythonService::GetVariable
std::string GetVariable(const std::string &name) const override
mitk::PythonService::GetPythonManager
ctkAbstractPythonManager * GetPythonManager() override
mitk::PythonService::DoesVariableExist
bool DoesVariableExist(const std::string &name) const override
mitk::PythonService::CopyCvImageFromPython
mitk::Image::Pointer CopyCvImageFromPython(const std::string &varName) override
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitkSurface.h
mitk::PythonService::RemovePythonCommandObserver
void RemovePythonCommandObserver(PythonCommandObserver *observer) override
mitk::PythonService::CopyToPythonAsVtkPolyData
bool CopyToPythonAsVtkPolyData(mitk::Surface *surface, const std::string &varName) override
mitk::PythonService::IsOpenCvPythonWrappingAvailable
bool IsOpenCvPythonWrappingAvailable() override
mitk::PythonService::NotifyObserver
void NotifyObserver(const std::string &command) override
mitk::PythonService::CopySimpleItkImageFromPython
mitk::Image::Pointer CopySimpleItkImageFromPython(const std::string &varName) override
mitk::PythonService::CopyVtkPolyDataFromPython
mitk::Surface::Pointer CopyVtkPolyDataFromPython(const std::string &varName) override
mitk::PythonService::Execute
std::string Execute(const std::string &pythonCommand, int commandType=SINGLE_LINE_COMMAND) override
mitk::PythonService
Definition: mitkPythonService.h:25
mitk::PythonService::AddPythonCommandObserver
void AddPythonCommandObserver(PythonCommandObserver *observer) override
mitk::PythonService::PythonErrorOccured
bool PythonErrorOccured() const override
mitkIPythonService.h
mitk::PythonService::PythonService
PythonService()
instantiate python manager here