Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 #ifndef mitkPythonService_h
17 #define mitkPythonService_h
18 
19 #include "mitkIPythonService.h"
20 #include <itkLightObject.h>
21 #include <ctkAbstractPythonManager.h>
22 #include "mitkSurface.h"
23 
24 namespace mitk
25 {
29  class PythonService: public itk::LightObject, public mitk::IPythonService
30  {
31  public:
34  PythonService();
40  std::string Execute( const std::string& pythonCommand, int commandType = SINGLE_LINE_COMMAND );
43  void ExecuteScript(const std::string &pathToPythonScript);
46  bool PythonErrorOccured() const;
49  std::vector<PythonVariable> GetVariableStack() const;
52  bool DoesVariableExist(const std::string& name) const;
61  void NotifyObserver( const std::string& command );
67  bool CopyToPythonAsSimpleItkImage( mitk::Image* image, const std::string& varName );
70  mitk::Image::Pointer CopySimpleItkImageFromPython( const std::string& varName );
76  bool CopyToPythonAsCvImage( mitk::Image* image, const std::string& varName );
79  mitk::Image::Pointer CopyCvImageFromPython( const std::string& varName );
85  bool CopyToPythonAsVtkPolyData( mitk::Surface* surface, const std::string& varName );
88  mitk::Surface::Pointer CopyVtkPolyDataFromPython( const std::string& varName );
91  ctkAbstractPythonManager* GetPythonManager();
92  protected:
93  QString GetTempDataFileName(const std::string &ext) const;
94  private:
95  QList<PythonCommandObserver*> m_Observer;
96  ctkAbstractPythonManager m_PythonManager;
97  static const QString m_TmpDataFileName;
98  bool m_ItkWrappingAvailable;
99  bool m_OpenCVWrappingAvailable;
100  bool m_VtkWrappingAvailable;
101  bool m_ErrorOccured;
102  };
103 }
104 #endif
Class for storing surfaces (vtkPolyData).
Definition: mitkSurface.h:32
bool DoesVariableExist(const std::string &name) const
bool CopyToPythonAsVtkPolyData(mitk::Surface *surface, const std::string &varName)
ctkAbstractPythonManager * GetPythonManager()
mitk::Surface::Pointer CopyVtkPolyDataFromPython(const std::string &varName)
DataCollection - Class to facilitate loading/accessing structured data.
void RemovePythonCommandObserver(PythonCommandObserver *observer)
void NotifyObserver(const std::string &command)
bool PythonErrorOccured() const
std::string Execute(const std::string &pythonCommand, int commandType=SINGLE_LINE_COMMAND)
std::vector< PythonVariable > GetVariableStack() const
static const int SINGLE_LINE_COMMAND
bool CopyToPythonAsSimpleItkImage(mitk::Image *image, const std::string &varName)
Image class for storing images.
Definition: mitkImage.h:76
~PythonService()
empty implementation...
mitk::Image::Pointer CopyCvImageFromPython(const std::string &varName)
bool CopyToPythonAsCvImage(mitk::Image *image, const std::string &varName)
QString GetTempDataFileName(const std::string &ext) const
void ExecuteScript(const std::string &pathToPythonScript)
mitk::Image::Pointer CopySimpleItkImageFromPython(const std::string &varName)
PythonService()
instantiate python manager here
void AddPythonCommandObserver(PythonCommandObserver *observer)