diff --git a/Modules/USUI/mitkUSUIActivator.cpp b/Modules/USUI/mitkUSUIActivator.cpp index dff91c202c..06d9d4fd9b 100644 --- a/Modules/USUI/mitkUSUIActivator.cpp +++ b/Modules/USUI/mitkUSUIActivator.cpp @@ -1,64 +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. ===================================================================*/ #include "mitkUSUIActivator.h" -#include "mitkUSUICustomWidgetFactory.h" #include "QmitkUSControlsCustomVideoDeviceWidget.h" #include "QmitkUSControlsCustomDiPhASDeviceWidget.h" mitk::USUIActivator::USUIActivator() - : m_CustomWidgetFactory(0), m_CustomVideoDeviceWidget(0) { } mitk::USUIActivator::~USUIActivator() { - delete m_CustomWidgetFactory; - delete m_CustomVideoDeviceWidget; } void mitk::USUIActivator::Load(us::ModuleContext* context) { - // create a custom video device widget, which will be used as - // a prototype for the custom widget factory - - if (!m_CustomVideoDeviceWidget) - { - m_CustomVideoDeviceWidget = new QmitkUSControlsCustomVideoDeviceWidget(); - } - - // create a factory for custom widgets, using the video device - // widget as a prototype - if (!m_CustomWidgetFactory) - { - m_CustomWidgetFactory = new mitk::USUICustomWidgetFactory(m_CustomVideoDeviceWidget); - } - - // register the custom widget factory as a microservice - m_ServiceRegistration = m_CustomWidgetFactory->RegisterService(context); + m_USCustomWidgets.push_back(new QmitkUSControlsCustomVideoDeviceWidget()); + m_USCustomWidgets.push_back(new QmitkUSControlsCustomDiPhASDeviceWidget()); } void mitk::USUIActivator::Unload(us::ModuleContext* /*context*/) { - m_ServiceRegistration.Unregister(); - m_ServiceRegistration = 0; - - delete m_CustomWidgetFactory; - m_CustomWidgetFactory = 0; - - delete m_CustomVideoDeviceWidget; - m_CustomVideoDeviceWidget = 0; + for (auto &elem : m_USCustomWidgets) + { + delete elem; + } } diff --git a/Modules/USUI/mitkUSUIActivator.h b/Modules/USUI/mitkUSUIActivator.h index 663871d4b0..acb2046638 100644 --- a/Modules/USUI/mitkUSUIActivator.h +++ b/Modules/USUI/mitkUSUIActivator.h @@ -1,65 +1,61 @@ /*=================================================================== 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 __mitkUSUIActivator_h #define __mitkUSUIActivator_h #include "QmitkUSAbstractCustomWidget.h" // Microservices #include #include -class QmitkUSControlsCustomVideoDeviceWidget; - namespace mitk { class USUICustomWidgetFactory; /** * \brief Module activator for the USUI module. * Registers custom widget for mitk::USVideoDevice as microservice. */ class USUIActivator : public us::ModuleActivator { public: USUIActivator(); virtual ~USUIActivator(); /** * Custom video device widget is registered as a micro service on module * load. A plugin can get this widget then when using a * mitk::USVideoDevice. */ void Load(us::ModuleContext* context) override; /** * Custom video device widget is deregistered from micro service on module * unload. */ void Unload(us::ModuleContext* context) override; protected: - us::ServiceRegistration m_ServiceRegistration; - USUICustomWidgetFactory* m_CustomWidgetFactory; - QmitkUSControlsCustomVideoDeviceWidget* m_CustomVideoDeviceWidget; + std::vector m_USCustomWidgets; ///< Contains the currently available US custom controls widgets which are loaded on Load() }; } // namespace mitk US_EXPORT_MODULE_ACTIVATOR(mitk::USUIActivator) #endif // __mitkUSUIActivator_h