diff --git a/Modules/US/USService/mitkUSDeviceService.cpp b/Modules/US/USService/mitkUSDeviceService.cpp index 375f1c6ba7..04fb71245c 100644 --- a/Modules/US/USService/mitkUSDeviceService.cpp +++ b/Modules/US/USService/mitkUSDeviceService.cpp @@ -1,49 +1,49 @@ /*=================================================================== 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 "mitkUSDeviceService.h" #include mitk::USDeviceService::USDeviceService() : itk::Object() { - + } mitk::USDeviceService::~USDeviceService() { } void mitk::USDeviceService::ActivateDevice (mitk::USDevice::Pointer device){ // Check if device is already active for(std::vector::iterator it = m_ActiveDevices.begin(); it != m_ActiveDevices.end(); ++it) { if (it->GetPointer() == device.GetPointer()) return; } // add device m_ActiveDevices.push_back(device); } void mitk::USDeviceService::DeactivateDevice (int index){ // m_ActiveDevices.erase(index); // Not yet supported } std::vector mitk::USDeviceService::GetActiveDevices(){ return m_ActiveDevices; } \ No newline at end of file diff --git a/Modules/USUI/Qmitk/QmitkUSDeviceManagerWidget.cpp b/Modules/USUI/Qmitk/QmitkUSDeviceManagerWidget.cpp index 608ec52445..2028f6fdea 100644 --- a/Modules/USUI/Qmitk/QmitkUSDeviceManagerWidget.cpp +++ b/Modules/USUI/Qmitk/QmitkUSDeviceManagerWidget.cpp @@ -1,81 +1,104 @@ /*=================================================================== 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 //QT headers //mitk headers //itk headers const std::string QmitkUSDeviceManagerWidget::VIEW_ID = "org.mitk.views.QmitkUSDeviceManagerWidget"; QmitkUSDeviceManagerWidget::QmitkUSDeviceManagerWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f) { m_Controls = NULL; CreateQtPartControl(this); } QmitkUSDeviceManagerWidget::~QmitkUSDeviceManagerWidget() { } //////////////////// INITIALIZATION ///////////////////// void QmitkUSDeviceManagerWidget::Initialize (mitk::USDeviceService::Pointer deviceService){ m_DeviceService = deviceService; } void QmitkUSDeviceManagerWidget::CreateQtPartControl(QWidget *parent) { if (!m_Controls) { // create GUI widgets m_Controls = new Ui::QmitkUSDeviceManagerWidgetControls; m_Controls->setupUi(parent); this->CreateConnections(); } } void QmitkUSDeviceManagerWidget::CreateConnections() { if ( m_Controls ) { - connect( m_Controls->m_BtnActivate, SIGNAL(clicked()), this, SLOT(OnClickedActivateDevice()) ); - connect( (QObject*)(m_Controls->m_BtnDisconnect), SIGNAL(clicked()),(QObject*) this, SLOT(OnClickedDisconnectDevice()) ); + connect( m_Controls->m_BtnActivate, SIGNAL(clicked()), this, SLOT(OnClickedActivateDevice()) ); + connect( m_Controls->m_BtnDisconnect, SIGNAL(clicked()), this, SLOT(OnClickedDisconnectDevice()) ); } } -///////////// Methods Handling Direct Interaction ///////////////// +///////////// Methods & Slots Handling Direct Interaction ///////////////// void QmitkUSDeviceManagerWidget::OnClickedActivateDevice(){ MITK_INFO << "Activated Device"; } void QmitkUSDeviceManagerWidget::OnClickedDisconnectDevice(){ MITK_INFO << "Disconnected Device"; } -///////////////// Methods Handling Logic ////////////////////////// \ No newline at end of file +///////////////// Methods & Slots Handling Logic ////////////////////////// + +void QmitkUSDeviceManagerWidget::OnDeviceServiceUpdated(){ + // Empty ListWidget + m_Controls->m_ConnectedDevices->clear(); + // get active Devices + std::vector devices = m_DeviceService->GetActiveDevices(); + + + for(std::vector::iterator it = devices.begin(); it != devices.end(); ++it) { + QListWidgetItem *newItem = ConstructItemFromDevice(it->GetPointer()); + m_Controls->m_ConnectedDevices->addItem(newItem); + } +} + + +/////////////////////// HOUSEHOLDING CODE ///////////////////////////////// + +QListWidgetItem* QmitkUSDeviceManagerWidget::ConstructItemFromDevice(mitk::USDevice::Pointer device){ + QListWidgetItem *result = new QListWidgetItem; + std::string text = device->GetDeviceManufacturer() + "|" + device->GetDeviceModel(); + result->setText(text.c_str()); + return result; +} \ No newline at end of file diff --git a/Modules/USUI/Qmitk/QmitkUSDeviceManagerWidget.h b/Modules/USUI/Qmitk/QmitkUSDeviceManagerWidget.h index 095c13735b..16145d205d 100644 --- a/Modules/USUI/Qmitk/QmitkUSDeviceManagerWidget.h +++ b/Modules/USUI/Qmitk/QmitkUSDeviceManagerWidget.h @@ -1,86 +1,98 @@ /*=================================================================== 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 _QmitkUSDeviceManagerWidget_H_INCLUDED #define _QmitkUSDeviceManagerWidget_H_INCLUDED #include "mitkUSUIExports.h" #include "ui_QmitkUSDeviceManagerWidgetControls.h" #include "mitkUSDeviceService.h" //QT headers #include +#include //mitk header /** * @brief TODO * * @ingroup USUI */ class MitkUSUI_EXPORT QmitkUSDeviceManagerWidget :public QWidget { //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; QmitkUSDeviceManagerWidget(QWidget* p = 0, Qt::WindowFlags f1 = 0); virtual ~QmitkUSDeviceManagerWidget(); void Initialize(mitk::USDeviceService::Pointer deviceService); /* @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(); signals: /*! \brief Sent, when the user clicks "Activate Device" */ void USDeviceActivated(); + public slots: + /*! + \brief Should be called from the Implementing bundle whenever changes to the DeviceService happen + */ + void OnDeviceServiceUpdated(); protected slots: /*! - \brief slot called when the "Connect Camera" button was pressed - * According to the selection in the camera combo box, the widget provides - * the desired instance of the ToFImageGrabber + \brief Called, when the Button Activate Device was clicked */ void OnClickedActivateDevice(); - void OnClickedDisconnectDevice(); - + /*! + \brief Called, when the Button Disconnect Device was clicked + */ + void OnClickedDisconnectDevice(); + + protected: Ui::QmitkUSDeviceManagerWidgetControls* m_Controls; ///< member holding the UI elements of this widget + /*! + \brief Constrcuts a ListItem from the given devie for display in the list of active devices + */ + QListWidgetItem* ConstructItemFromDevice(mitk::USDevice::Pointer device); private: mitk::USDeviceService::Pointer m_DeviceService; }; #endif // _QmitkUSDeviceManagerWidget_H_INCLUDED diff --git a/Modules/USUI/Qmitk/QmitkUSDeviceManagerWidgetControls.ui b/Modules/USUI/Qmitk/QmitkUSDeviceManagerWidgetControls.ui index 98ca1d117a..889a9ef7cb 100644 --- a/Modules/USUI/Qmitk/QmitkUSDeviceManagerWidgetControls.ui +++ b/Modules/USUI/Qmitk/QmitkUSDeviceManagerWidgetControls.ui @@ -1,57 +1,57 @@ QmitkUSDeviceManagerWidgetControls 0 0 405 231 0 0 QmitkToFConnection 11 Connected Devices: - - - Activate Device Disconnect Device + + + diff --git a/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupport.cpp b/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupport.cpp index 5f3e330aa2..5718404b17 100644 --- a/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupport.cpp +++ b/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupport.cpp @@ -1,104 +1,123 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ // Blueberry #include #include // Qmitk #include "UltrasoundSupport.h" // Qt #include +// Ultrasound +#include "mitkUSDevice.h" const std::string UltrasoundSupport::VIEW_ID = "org.mitk.views.ultrasoundsupport"; + void UltrasoundSupport::SetFocus() { m_Controls.buttonPerformImageProcessing->setFocus(); } void UltrasoundSupport::CreateQtPartControl( QWidget *parent ) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi( parent ); - connect( m_Controls.buttonPerformImageProcessing, SIGNAL(clicked()), this, SLOT(DoImageProcessing()) ); + connect( m_Controls.pushButton, SIGNAL(clicked()), this, SLOT(OnClickedAddNewDevice()) ); + connect( this, SIGNAL(DeviceServiceUpdated()), m_Controls.m_DeviceManagerWidget, SLOT(OnDeviceServiceUpdated()) ); + + // Initializations + m_DeviceService = mitk::USDeviceService::New(); + m_Controls.m_DeviceManagerWidget->Initialize(m_DeviceService); + MITK_INFO << "Initialized Plugin"; } -/* -void UltrasoundSupport::OnSelectionChanged( berry::IWorkbenchPart::Pointer , - const QList& nodes ) -{ - // iterate all selected objects, adjust warning visibility - foreach( mitk::DataNode::Pointer node, nodes ) - { - if( node.IsNotNull() && dynamic_cast(node->GetData()) ) - { - m_Controls.labelWarning->setVisible( false ); - m_Controls.buttonPerformImageProcessing->setEnabled( true ); - return; - } - } - m_Controls.labelWarning->setVisible( true ); - m_Controls.buttonPerformImageProcessing->setEnabled( false ); +void UltrasoundSupport::OnClickedAddNewDevice(){ + + // Debug: add fake Device + mitk::USDevice::Pointer newDevice; + newDevice = mitk::USDevice::New("Manufacturer", "Model", "Comment"); + m_DeviceService->ActivateDevice(newDevice); + + emit DeviceServiceUpdated(); } -*/ + + + + + + + + + + + + + + + + +/** EXAMPLE CODE FOR WORKING WITH DATANODES /// void UltrasoundSupport::DoImageProcessing() { MITK_INFO << "DO SUPM"; QList nodes = this->GetDataManagerSelection(); if (nodes.empty()) return; mitk::DataNode* node = nodes.front(); if (!node) { // Nothing selected. Inform the user and return QMessageBox::information( NULL, "Template", "Please load and select an image before starting image processing."); return; } // here we have a valid mitk::DataNode // a node itself is not very useful, we need its data item (the image) mitk::BaseData* data = node->GetData(); if (data) { // test if this data item is an image or not (could also be a surface or something totally different) mitk::Image* image = dynamic_cast( data ); if (image) { std::stringstream message; std::string name; message << "Performing image processing for image "; if (node->GetName(name)) { // a property called "name" was found for this DataNode message << "'" << name << "'"; } message << "."; MITK_INFO << message.str(); // actually do something here... } } } + +**/ diff --git a/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupport.h b/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupport.h index 4d881232a1..a9b6e817dd 100644 --- a/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupport.h +++ b/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupport.h @@ -1,67 +1,72 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef UltrasoundSupport_h #define UltrasoundSupport_h #include #include #include "ui_UltrasoundSupportControls.h" /*! \brief UltrasoundSupport \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. \sa QmitkFunctionality \ingroup ${plugin_target}_internal */ class UltrasoundSupport : public QmitkAbstractView { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: static const std::string VIEW_ID; virtual void CreateQtPartControl(QWidget *parent); + signals: + + void DeviceServiceUpdated(); + protected slots: - /// \brief Called when the user clicks the GUI button - void DoImageProcessing(); + void OnClickedAddNewDevice(); protected: virtual void SetFocus(); - /// \brief called by QmitkFunctionality when DataManager's selection has changed - // virtual void OnSelectionChanged( berry::IWorkbenchPart::Pointer source, - // const QList& nodes ); + + // Not necessary? + //const QList& nodes ); Ui::UltrasoundSupportControls m_Controls; + mitk::USDeviceService::Pointer m_DeviceService; + }; #endif // UltrasoundSupport_h diff --git a/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupportControls.ui b/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupportControls.ui index 55af7e365c..fd9034e991 100644 --- a/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupportControls.ui +++ b/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupportControls.ui @@ -1,101 +1,135 @@ UltrasoundSupportControls 0 0 467 461 0 0 QmitkTemplate 0 Device Manager + + + + + 12 + 75 + true + + + + Connected Devices: + + + + + + + Debug: Add Device To Service + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + US Imaging old QLabel { color: rgb(255, 0, 0) } Please select an image! Do image processing Do Something Qt::Vertical QSizePolicy::Expanding 17 348 QmitkUSDeviceManagerWidget QWidget
QmitkUSDeviceManagerWidget.h
1