diff --git a/Modules/Python/Testing/mitkPythonTest.cpp b/Modules/Python/Testing/mitkPythonTest.cpp index 01bcbcc9e9..9be9f6f6b6 100644 --- a/Modules/Python/Testing/mitkPythonTest.cpp +++ b/Modules/Python/Testing/mitkPythonTest.cpp @@ -1,35 +1,33 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include #include #include #include -#include +#include int mitkPythonTest(int /*argc*/, char* /*argv*/[]) { - MITK_TEST_BEGIN("DICOMTestingSanity") + MITK_TEST_BEGIN("PythonTest") - mitk::ModuleContext* context = mitk::GetModuleContext(); - mitk::ServiceReference serviceRef = context->GetServiceReference(); - mitk::IPythonService* _PythonService = context->GetService(serviceRef); + itk::SmartPointer _PythonService(new mitk::PythonService()); std::string result = _PythonService->Execute( "5+5", mitk::IPythonService::EVAL_COMMAND ); MITK_TEST_CONDITION( result == "10", "Testing if running python code 5+5 results in 10" ) MITK_TEST_END() } diff --git a/Modules/Python/mitkPythonService.h b/Modules/Python/mitkPythonService.h index 73a4ad6e2a..f0f6ef525b 100644 --- a/Modules/Python/mitkPythonService.h +++ b/Modules/Python/mitkPythonService.h @@ -1,94 +1,95 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkPythonService_h #define mitkPythonService_h #include "mitkIPythonService.h" #include #include #include "mitkSurface.h" +#include "mitkPythonExports.h" namespace mitk { /// /// implementation of the IPythonService using ctkabstractpythonmanager /// \see IPythonService - class PythonService: public itk::LightObject, public mitk::IPythonService + class MITK_PYTHON_EXPORT PythonService: public itk::LightObject, public mitk::IPythonService { public: /// /// instantiate python manager here PythonService(); /// /// empty implementation... ~PythonService(); /// /// \see IPythonService::Execute() std::string Execute( const std::string& pythonCommand, int commandType = SINGLE_LINE_COMMAND ); /// /// \see IPythonService::GetVariableStack() std::vector GetVariableStack() const; /// /// \see IPythonService::AddPythonCommandObserver() void AddPythonCommandObserver( PythonCommandObserver* observer ); /// /// \see IPythonService::RemovePythonCommandObserver() void RemovePythonCommandObserver( PythonCommandObserver* observer ); /// /// \see IPythonService::NotifyObserver() void NotifyObserver( const std::string& command ); /// /// \see IPythonService::IsItkPythonWrappingAvailable() bool IsItkPythonWrappingAvailable(); /// /// \see IPythonService::CopyToPythonAsItkImage() bool CopyToPythonAsItkImage( mitk::Image* image, const std::string& varName ); /// /// \see IPythonService::CopyItkImageFromPython() mitk::Image::Pointer CopyItkImageFromPython( const std::string& varName ); /// /// \see IPythonService::IsOpenCvPythonWrappingAvailable() bool IsOpenCvPythonWrappingAvailable(); /// /// \see IPythonService::CopyToPythonAsCvImage() bool CopyToPythonAsCvImage( mitk::Image* image, const std::string& varName ); /// /// \see IPythonService::CopyCvImageFromPython() mitk::Image::Pointer CopyCvImageFromPython( const std::string& varName ); /// /// \see IPythonService::IsVtkPythonWrappingAvailable() bool IsVtkPythonWrappingAvailable(); /// /// \see IPythonService::CopyToPythonAsVtkPolyData() bool CopyToPythonAsVtkPolyData( mitk::Surface* surface, const std::string& varName ); /// /// \see IPythonService::CopyVtkPolyDataFromPython() mitk::Surface::Pointer CopyVtkPolyDataFromPython( const std::string& varName ); /// /// \return the ctk abstract python manager instance ctkAbstractPythonManager* GetPythonManager(); protected: QString GetTempImageName(const std::string &ext) const; private: QList m_Observer; ctkAbstractPythonManager m_PythonManager; static const QString m_TmpImageName; bool m_ItkWrappingAvailable; bool m_OpenCVWrappingAvailable; bool m_VtkWrappingAvailable; }; } #endif