Medical Imaging Interaction Toolkit  2022.04.99-194dd5d8
Medical Imaging Interaction Toolkit
mitkIPythonService.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 mitkIPythonService_h
13 #define mitkIPythonService_h
14 
15 // mitk
16 #include <MitkPythonExports.h>
17 #include "mitkImage.h"
18 //for microservices
19 #include <mitkServiceInterface.h>
20 #include "mitkSurface.h"
21 #include <vector>
22 
23 
24 class ctkAbstractPythonManager;
25 
26 namespace mitk
27 {
33  {
34  std::string m_Name;
35  std::string m_Type;
36  std::string m_Value;
37  };
38 
44  {
45  public:
46  virtual void CommandExecuted(const std::string& pythonCommand) = 0;
47  };
48 
55  {
56  public:
60  static const int SINGLE_LINE_COMMAND = 0;
64  static const int MULTI_LINE_COMMAND = 1;
68  static const int EVAL_COMMAND = 2;
69 
73  virtual std::string Execute( const std::string& pythonCommand, int commandType = SINGLE_LINE_COMMAND ) = 0;
76  virtual void ExecuteScript( const std::string& pathToPythonScript ) = 0;
79  virtual bool PythonErrorOccured() const = 0;
82  virtual std::vector<PythonVariable> GetVariableStack() const = 0;
85  virtual bool DoesVariableExist(const std::string& name) const = 0;
88  virtual std::string GetVariable(const std::string& name) const = 0;
91  virtual void AddPythonCommandObserver( PythonCommandObserver* observer ) = 0;
94  virtual void RemovePythonCommandObserver( PythonCommandObserver* observer ) = 0;
100  virtual void NotifyObserver( const std::string& command ) = 0;
101 
104  virtual bool IsSimpleItkPythonWrappingAvailable() = 0;
109  virtual bool CopyToPythonAsSimpleItkImage( mitk::Image* image, const std::string& varName ) = 0;
113  virtual mitk::Image::Pointer CopySimpleItkImageFromPython( const std::string& varName ) = 0;
114 
117  virtual bool IsOpenCvPythonWrappingAvailable() = 0;
120  virtual bool CopyToPythonAsCvImage( mitk::Image* image, const std::string& varName ) = 0;
123  virtual mitk::Image::Pointer CopyCvImageFromPython( const std::string& varName ) = 0;
124 
127  virtual bool IsVtkPythonWrappingAvailable() = 0;
130  virtual bool CopyToPythonAsVtkPolyData( mitk::Surface* surface, const std::string& varName ) = 0;
133  virtual mitk::Surface::Pointer CopyVtkPolyDataFromPython( const std::string& varName ) = 0;
134 
136  virtual ctkAbstractPythonManager* GetPythonManager() = 0;
137 
140  virtual ~IPythonService(); // leer in mitkIPythonService.cpp implementieren
141 
142  // force us module loading by linking
143  static std::string ForceLoadModule();
144 
145  virtual void AddRelativeSearchDirs(std::vector< std::string > dirs) = 0;
146 
147  virtual void AddAbsoluteSearchDirs(std::vector< std::string > dirs) = 0;
148  };
149 }
150 
151 MITK_DECLARE_SERVICE_INTERFACE(mitk::IPythonService, "org.mitk.services.IPythonService")
152 
153 #endif
Class for storing surfaces (vtkPolyData).
Definition: mitkSurface.h:28
#define MITK_DECLARE_SERVICE_INTERFACE(IFace, IId)
#define MITKPYTHON_EXPORT
DataCollection - Class to facilitate loading/accessing structured data.
Image class for storing images.
Definition: mitkImage.h:69