diff --git a/Modules/AwesomeMapperService/mitkAwesomeMapperService.cpp b/Modules/AwesomeMapperService/mitkAwesomeMapperService.cpp index 732297376a..b3fed4ec63 100644 --- a/Modules/AwesomeMapperService/mitkAwesomeMapperService.cpp +++ b/Modules/AwesomeMapperService/mitkAwesomeMapperService.cpp @@ -1,57 +1,73 @@ /*=================================================================== 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 "mitkAwesomeMapperService.h" -#include "mitkMapper.h" #include +#include #include #include #include -mitk::AwesomeMapperService::AwesomeMapperService() +mitk::AwesomeMapperService::AwesomeMapperService(MapperSlotId id) { - RegisterAtServiceRegistry(mitk::Image::GetStaticNameOfClass(), 1, 200); + m_Reg = RegisterAtServiceRegistry(mitk::Image::GetStaticNameOfClass(), id, 200); } +mitk::AwesomeMapperService::~AwesomeMapperService() {} + vtkProp *mitk::AwesomeMapperService::GetVtkProp(mitk::BaseRenderer *renderer) { vtkSmartPointer src = vtkSphereSource::New(); src->SetCenter(0.0, 0.0, 0.0); src->SetRadius(20); vtkSmartPointer mapper = vtkPolyDataMapper::New(); mapper->SetInputConnection(src->GetOutputPort()); vtkSmartPointer actor = vtkActor::New(); actor->SetMapper(mapper); return actor; } +void mitk::AwesomeMapperService::UnRegisterFromServiceRegistry() +{ + m_Reg.Unregister(); +} + class AwesomeMapperServiceActivator : public us::ModuleActivator { public: - AwesomeMapperServiceActivator() : m_Service(nullptr) {} - ~AwesomeMapperServiceActivator() override {} - void Load(us::ModuleContext *context) override { m_Service = std::make_shared(); } + void Load(us::ModuleContext *context) override + { + m_Service2D = std::make_unique(mitk::BaseRenderer::Standard2D); + m_Service3D = std::make_unique(mitk::BaseRenderer::Standard3D); + } - void Unload(us::ModuleContext *) override {} + void Unload(us::ModuleContext *) override + { + m_Service2D->UnRegisterFromServiceRegistry(); + m_Service2D = nullptr; + m_Service3D->UnRegisterFromServiceRegistry(); + m_Service3D = nullptr; + } private: - std::shared_ptr m_Service; + std::unique_ptr m_Service2D; + std::unique_ptr m_Service3D; }; US_EXPORT_MODULE_ACTIVATOR(AwesomeMapperServiceActivator) diff --git a/Modules/AwesomeMapperService/mitkAwesomeMapperService.h b/Modules/AwesomeMapperService/mitkAwesomeMapperService.h index e072edde6c..228dfc7e3d 100644 --- a/Modules/AwesomeMapperService/mitkAwesomeMapperService.h +++ b/Modules/AwesomeMapperService/mitkAwesomeMapperService.h @@ -1,38 +1,41 @@ /*=================================================================== 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 MITKAWESOMEMAPPERSERVICE_H #define MITKAWESOMEMAPPERSERVICE_H #include "MitkAwesomeMapperServiceExports.h" -#include "mitkVtkMapper.h" +#include namespace mitk { class MITKAWESOMEMAPPERSERVICE_EXPORT AwesomeMapperService : public VtkMapper { public: /** Standard class typedefs. */ mitkClassMacro(AwesomeMapperService, VtkMapper); /** Method for creation through the object factory. */ itkFactorylessNewMacro(Self) itkCloneMacro(Self) - - AwesomeMapperService(); - ~AwesomeMapperService() = default; + + AwesomeMapperService(MapperSlotId id = BaseRenderer::Standard2D); + ~AwesomeMapperService(); virtual vtkProp *GetVtkProp(mitk::BaseRenderer *renderer) override; + void UnRegisterFromServiceRegistry(); + private: + us::ServiceRegistration m_Reg; }; } #endif