diff --git a/Modules/USUI/Qmitk/QmitkUSDeviceListWidget.cpp b/Modules/USUI/Qmitk/QmitkUSDeviceListWidget.cpp deleted file mode 100644 index 75acd872b2..0000000000 --- a/Modules/USUI/Qmitk/QmitkUSDeviceListWidget.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/*=================================================================== - -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. - -===================================================================*/ - -//#define _USE_MATH_DEFINES -#include -#include - -//QT headers -#include - -//mitk headers - - -//itk headers - -//microservices -#include -#include -#include - - -const std::string QmitkUSDeviceListWidget::VIEW_ID = "org.mitk.views.QmitkUSDeviceListWidget"; - -QmitkUSDeviceListWidget::QmitkUSDeviceListWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f) -{ - m_Controls = NULL; - CreateQtPartControl(this); - - // get ModuleContext - mitk::Module* mitkUS = mitk::ModuleRegistry::GetModule("MitkUS"); - m_MitkUSContext = mitkUS->GetModuleContext(); - -} - -QmitkUSDeviceListWidget::~QmitkUSDeviceListWidget() -{ - -} - -//////////////////// INITIALIZATION ///////////////////// - -void QmitkUSDeviceListWidget::CreateQtPartControl(QWidget *parent) -{ - if (!m_Controls) - { - // create GUI widgets - m_Controls = new Ui::QmitkUSDeviceListWidgetControls; - m_Controls->setupUi(parent); - this->CreateConnections(); - } -} - -void QmitkUSDeviceListWidget::CreateConnections() -{ - if ( m_Controls ) - { - connect( m_Controls->m_DeviceList, SIGNAL(currentItemChanged( QListWidgetItem *, QListWidgetItem *)), this, SLOT(OnDeviceSelectionChanged()) ); - } -} - -void QmitkUSDeviceListWidget::Initialize(std::string filter) -{ - m_Filter = filter; - m_MitkUSContext->AddServiceListener(this, &QmitkUSDeviceListWidget::OnServiceEvent, m_Filter); -} - - -///////////////////////// Getter & Setter ///////////////////////////////// - -mitk::USDevice::Pointer QmitkUSDeviceListWidget::GetSelectedDevice() -{ - return this->GetDeviceForListItem(this->m_Controls->m_DeviceList->currentItem()); -} - -///////////// Methods & Slots Handling Direct Interaction ///////////////// - - -void QmitkUSDeviceListWidget::OnDeviceSelectionChanged(){ - mitk::USDevice::Pointer device = this->GetDeviceForListItem(this->m_Controls->m_DeviceList->currentItem()); - if (device.IsNull()) return; - emit (DeviceSelected(device)); -} - - -///////////////// Methods & Slots Handling Logic ////////////////////////// - -void QmitkUSDeviceListWidget::OnServiceEvent(const mitk::ServiceEvent event){ - // Empty ListWidget - this->m_ListContent.clear(); - m_Controls->m_DeviceList->clear(); - - - - // get Active Devices - std::vector devices = this->GetAllRegisteredDevices(); - // Transfer them to the List - for(std::vector::iterator it = devices.begin(); it != devices.end(); ++it) - { - QListWidgetItem *newItem = ConstructItemFromDevice(it->GetPointer()); - //Add new item to QListWidget - m_Controls->m_DeviceList->addItem(newItem); - // Construct link and add to internal List for reference - QmitkUSDeviceListWidget::DeviceListLink link; - link.device = it->GetPointer(); - link.item = newItem; - m_ListContent.push_back(link); - } -} - - -/////////////////////// HOUSEHOLDING CODE ///////////////////////////////// - -QListWidgetItem* QmitkUSDeviceListWidget::ConstructItemFromDevice(mitk::USDevice::Pointer device){ - QListWidgetItem *result = new QListWidgetItem; - std::string text = device->GetDeviceManufacturer() + "|" + device->GetDeviceModel(); - - if (device->GetIsActive()) - { - result->foreground().setColor(Qt::blue); - text += "|(ON)"; - } else text += "|(OFF)"; - - result->setText(text.c_str()); - - return result; -} - - -mitk::USDevice::Pointer QmitkUSDeviceListWidget::GetDeviceForListItem(QListWidgetItem* item) -{ - for(std::vector::iterator it = m_ListContent.begin(); it != m_ListContent.end(); ++it) - { - if (item == it->item) return it->device; - } - return 0; -} - - -std::vector QmitkUSDeviceListWidget::GetAllRegisteredDevices(){ - - //Get Service References - std::list serviceRefs = m_MitkUSContext->GetServiceReferences(m_Filter); - - // Convert Service References to US Devices - std::vector* result = new std::vector; - std::list::const_iterator iterator; - for (iterator = serviceRefs.begin(); iterator != serviceRefs.end(); ++iterator) - { - mitk::USDevice::Pointer device = m_MitkUSContext->GetService(*iterator); - if (device) result->push_back(device); - } - - return *result; -} \ No newline at end of file diff --git a/Modules/USUI/Qmitk/QmitkUSDeviceListWidget.h b/Modules/USUI/Qmitk/QmitkUSDeviceListWidget.h deleted file mode 100644 index 4cdbd671c4..0000000000 --- a/Modules/USUI/Qmitk/QmitkUSDeviceListWidget.h +++ /dev/null @@ -1,158 +0,0 @@ -/*=================================================================== - -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 _QmitkUSDeviceListWidget_H_INCLUDED -#define _QmitkUSDeviceListWidget_H_INCLUDED - -#include "MitkUSUIExports.h" -#include "ui_QmitkUSDeviceListWidgetControls.h" -#include "mitkUSDevice.h" -#include - -//QT headers -#include -#include - -//mitk header - -//Microservices -#include "usServiceReference.h" -#include "usModuleContext.h" -#include "usServiceEvent.h" -#include "usServiceTrackerCustomizer.h" - -/** -* @brief TODO -* -* @ingroup USUI -*/ -class MitkUSUI_EXPORT QmitkUSDeviceListWidget :public QWidget //, public mitk::ServiceTrackerCustomizer<> // this extension is necessary if one wants to use ServiceTracking instead of filtering -{ - - //this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) - Q_OBJECT - - public: - - static const std::string VIEW_ID; - - QmitkUSDeviceListWidget(QWidget* p = 0, Qt::WindowFlags f1 = 0); - virtual ~QmitkUSDeviceListWidget(); - - /* @brief This method is part of the widget an needs not to be called seperately. */ - virtual void CreateQtPartControl(QWidget *parent); - /* @brief This method is part of the widget an needs not to be called seperately. (Creation of the connections of main and control widget.)*/ - virtual void CreateConnections(); - - /* - * \brief Initializes the connection to the registry. The string filter is an LDAP parsable String, compare mitk::ModuleContext for examples on filtering. - */ - void Initialize(std::string filter); - - /* - * \brief Returns the currently selected device, or null if none is selected. - */ - mitk::USDevice::Pointer GetSelectedDevice(); - - /* - *\brief This Function listens to ServiceRegistry changes and updates the - * list of devices accordingly. - */ - void OnServiceEvent(const mitk::ServiceEvent event); - - - - signals: - - /* - *\brief Emitted when a new device mathing the filter connects - */ - void DeviceConnected(mitk::USDevice::Pointer); - /* - *\brief Emitted directly before device matching the filter disconnects - */ - void DeviceDisconnected(mitk::USDevice::Pointer); - /* - *\brief Emitted when a new device mathing the filter changes it's state. This does of now only compromise changes to activity. - */ - void DeviceChanged(mitk::USDevice::Pointer); - - /* - *\brief Emitted the user selects a device from the list - */ - void DeviceSelected(mitk::USDevice::Pointer); - - - - public slots: - - protected slots: - - /* - \brief Called, when the selection in the devicelist changes - */ - void OnDeviceSelectionChanged(); - - - protected: - - Ui::QmitkUSDeviceListWidgetControls* m_Controls; ///< member holding the UI elements of this widget - - /* - * \brief Internal Structure used to link devices to their QListWidget Items - */ - struct DeviceListLink { - mitk::USDevice::Pointer device; - QListWidgetItem* item; - }; - - /* - * \brief Contains a list of currently active devices and their entires in the list. This is wiped with every ServiceRegistryEvent. - */ - std::vector m_ListContent; - - /* - * \brief Constructs a ListItem from the given device for display in the list of active devices. - */ - QListWidgetItem* ConstructItemFromDevice(mitk::USDevice::Pointer device); - - /* - * \brief Returns the device corresponding to the given ListEntry or null if none was found (which really shouldnt happen). - */ - mitk::USDevice::Pointer GetDeviceForListItem(QListWidgetItem* item); - - //mitk::ServiceTracker ConstructServiceTracker(); - - /* - * \brief Returns a List of US Devices that are currently connected by querying the service registry. - */ - std::vector GetAllRegisteredDevices(); - - - - - private: - - mitk::ModuleContext* m_MitkUSContext; - std::string m_Filter; - - - - - -}; - -#endif // _QmitkUSDeviceListWidget_H_INCLUDED diff --git a/Modules/USUI/Qmitk/QmitkUSDeviceListWidgetControls.ui b/Modules/USUI/Qmitk/QmitkUSDeviceListWidgetControls.ui deleted file mode 100644 index 4d36c2bb5e..0000000000 --- a/Modules/USUI/Qmitk/QmitkUSDeviceListWidgetControls.ui +++ /dev/null @@ -1,31 +0,0 @@ - - - QmitkUSDeviceListWidgetControls - - - - 0 - 0 - 323 - 231 - - - - - 0 - 0 - - - - QmitkUSDeviceListWidget - - - - - - - - - - - diff --git a/Modules/USUI/files.cmake b/Modules/USUI/files.cmake index fb6be5c93c..0747fcff17 100644 --- a/Modules/USUI/files.cmake +++ b/Modules/USUI/files.cmake @@ -1,22 +1,19 @@ set(CPP_FILES Qmitk/QmitkUSDeviceManagerWidget.cpp Qmitk/QmitkUSNewVideoDeviceWidget.cpp - Qmitk/QmitkUSDeviceListWidget.cpp ) set(UI_FILES - Qmitk/QmitkUSDeviceListWidgetControls.ui Qmitk/QmitkUSDeviceManagerWidgetControls.ui Qmitk/QmitkUSNewVideoDeviceWidgetControls.ui ) set(MOC_H_FILES Qmitk/QmitkUSDeviceManagerWidget.h - Qmitk/QmitkUSDeviceListWidget.h Qmitk/QmitkUSNewVideoDeviceWidget.h ) # uncomment the following line if you want to use Qt resources set(QRC_FILES # resources/QmitkToFUtilWidget.qrc )