Medical Imaging Interaction Toolkit  2024.06.99-60d9b802
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 #ifdef snprintf
17 #undef snprintf
18 #endif
19 
20 #include <mitkIPythonService.h>
21 #include <mitkSurface.h>
22 #include <itkLightObject.h>
23 
24 namespace mitk
25 {
29  class PythonService: public itk::LightObject, public mitk::IPythonService
30  {
31  public:
34  PythonService();
37  ~PythonService() override;
40  std::string Execute( const std::string& pythonCommand, int commandType = SINGLE_LINE_COMMAND ) override;
43  void ExecuteScript(const std::string &pathToPythonScript) override;
46  bool PythonErrorOccured() const override;
49  std::vector<PythonVariable> GetVariableStack() const override;
52  bool DoesVariableExist(const std::string& name) const override;
55  std::string GetVariable(const std::string& name) const override;
58  void AddPythonCommandObserver( PythonCommandObserver* observer ) override;
61  void RemovePythonCommandObserver( PythonCommandObserver* observer ) override;
64  void NotifyObserver( const std::string& command ) override;
67  bool IsSimpleItkPythonWrappingAvailable() override;
70  bool CopyToPythonAsSimpleItkImage( mitk::Image* image, const std::string& varName ) override;
73  mitk::Image::Pointer CopySimpleItkImageFromPython( const std::string& varName ) override;
76  bool IsVtkPythonWrappingAvailable() override;
79  bool CopyToPythonAsVtkPolyData( mitk::Surface* surface, const std::string& varName ) override;
82  mitk::Surface::Pointer CopyVtkPolyDataFromPython( const std::string& varName ) override;
85  ctkAbstractPythonManager* GetPythonManager() override;
86 
87  void AddRelativeSearchDirs(std::vector< std::string > dirs) override;
88 
89  void AddAbsoluteSearchDirs(std::vector< std::string > dirs) override;
90 
91  protected:
92 
93  private:
94  QList<PythonCommandObserver*> m_Observer;
95  ctkAbstractPythonManager m_PythonManager;
96  bool m_ItkWrappingAvailable;
97  bool m_VtkWrappingAvailable;
98  bool m_ErrorOccured;
99  };
100 }
101 #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:62
mitk::IPythonService
Definition: mitkIPythonService.h:56
mitk::PythonCommandObserver
Definition: mitkIPythonService.h:45
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
Find image slices visible on a given plane.
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::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:29
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