Medical Imaging Interaction Toolkit  2024.06.00
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 <mitkImage.h>
17 #include <mitkSurface.h>
18 #include <MitkPythonExports.h>
19 
20 //for microservices
21 #include <mitkServiceInterface.h>
22 
23 #include <vector>
24 
25 
26 class ctkAbstractPythonManager;
27 
28 namespace mitk
29 {
35  {
36  std::string m_Name;
37  std::string m_Type;
38  std::string m_Value;
39  };
40 
46  {
47  public:
48  virtual void CommandExecuted(const std::string& pythonCommand) = 0;
49  };
50 
56  class MITKPYTHON_EXPORT IPythonService
57  {
58  public:
62  static const int SINGLE_LINE_COMMAND = 0;
66  static const int MULTI_LINE_COMMAND = 1;
70  static const int EVAL_COMMAND = 2;
71 
75  virtual std::string Execute( const std::string& pythonCommand, int commandType = SINGLE_LINE_COMMAND ) = 0;
78  virtual void ExecuteScript( const std::string& pathToPythonScript ) = 0;
81  virtual bool PythonErrorOccured() const = 0;
84  virtual std::vector<PythonVariable> GetVariableStack() const = 0;
87  virtual bool DoesVariableExist(const std::string& name) const = 0;
90  virtual std::string GetVariable(const std::string& name) const = 0;
93  virtual void AddPythonCommandObserver( PythonCommandObserver* observer ) = 0;
96  virtual void RemovePythonCommandObserver( PythonCommandObserver* observer ) = 0;
102  virtual void NotifyObserver( const std::string& command ) = 0;
103 
106  virtual bool IsSimpleItkPythonWrappingAvailable() = 0;
111  virtual bool CopyToPythonAsSimpleItkImage( mitk::Image* image, const std::string& varName ) = 0;
115  virtual mitk::Image::Pointer CopySimpleItkImageFromPython( const std::string& varName ) = 0;
116 
119  virtual bool IsVtkPythonWrappingAvailable() = 0;
122  virtual bool CopyToPythonAsVtkPolyData( mitk::Surface* surface, const std::string& varName ) = 0;
123 
125  virtual ctkAbstractPythonManager* GetPythonManager() = 0;
126 
129  virtual ~IPythonService(); // leer in mitkIPythonService.cpp implementieren
130 
131  // force us module loading by linking
132  static std::string ForceLoadModule();
133 
134  virtual void AddRelativeSearchDirs(std::vector< std::string > dirs) = 0;
135 
136  virtual void AddAbsoluteSearchDirs(std::vector< std::string > dirs) = 0;
137  };
138 }
139 
140 MITK_DECLARE_SERVICE_INTERFACE(mitk::IPythonService, "org.mitk.services.IPythonService")
141 
142 #endif
mitkImage.h
mitkServiceInterface.h
mitk::IPythonService
Definition: mitkIPythonService.h:56
mitk::PythonCommandObserver::CommandExecuted
virtual void CommandExecuted(const std::string &pythonCommand)=0
mitk::PythonCommandObserver
Definition: mitkIPythonService.h:45
mitk::Image
Image class for storing images.
Definition: mitkImage.h:69
itk::SmartPointer< Self >
mitk::Surface
Class for storing surfaces (vtkPolyData).
Definition: mitkSurface.h:28
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitkSurface.h
mitk::PythonVariable::m_Type
std::string m_Type
Definition: mitkIPythonService.h:37
mitk::PythonVariable::m_Value
std::string m_Value
Definition: mitkIPythonService.h:38
mitk::PythonVariable::m_Name
std::string m_Name
Definition: mitkIPythonService.h:36
MITK_DECLARE_SERVICE_INTERFACE
#define MITK_DECLARE_SERVICE_INTERFACE(IFace, IId)
Definition: mitkServiceInterface.h:26
mitk::PythonVariable
Definition: mitkIPythonService.h:34