diff --git a/Modules/USUI/Qmitk/QmitkUSNewVideoDeviceWidget.H b/Modules/USUI/Qmitk/QmitkUSNewVideoDeviceWidget.H index b61cf7b20b..e5bbd923c9 100644 --- a/Modules/USUI/Qmitk/QmitkUSNewVideoDeviceWidget.H +++ b/Modules/USUI/Qmitk/QmitkUSNewVideoDeviceWidget.H @@ -1,116 +1,122 @@ /*=================================================================== 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 _QmitkUSNewVideoDeviceWidget_H_INCLUDED #define _QmitkUSNewVideoDeviceWidget_H_INCLUDED #include "mitkUSUIExports.h" #include "ui_QmitkUSNewVideoDeviceWidgetControls.h" #include "mitkUSVideoDevice.h" #include "mitkUSImageMetadata.h" //QT headers #include #include //mitk header /** * @brief TODO * * @ingroup USUI */ class MitkUSUI_EXPORT QmitkUSNewVideoDeviceWidget :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; QmitkUSNewVideoDeviceWidget(QWidget* p = 0, Qt::WindowFlags f1 = 0); virtual ~QmitkUSNewVideoDeviceWidget(); /* @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: void Finished(); public slots: /* \brief Activates the widget and displays the given device's Data to edit. */ void EditDevice(mitk::USDevice::Pointer device); /* \brief Activates the widget with fields empty. */ void CreateNewDevice(); protected slots: /* \brief Called, when the the user clicks the "Done" button (Labeled either "Add Device" or "Edit Device", depending on the situation. */ void OnClickedDone(); /* \brief Called, when the button "Cancel" was clicked */ void OnClickedCancel(); + /* + \brief Called, when the Use selects one of the Radiobuttons + */ + void OnDeviceTypeSelection(); + + protected: Ui::QmitkUSNewVideoDeviceWidgetControls* m_Controls; ///< member holding the UI elements of this widget /* \brief Constructs a ListItem from the given devie for display in the list of active devices */ QListWidgetItem* ConstructItemFromDevice(mitk::USDevice::Pointer device); /* \brief Initializes the Widget's ListItems with the given Metadata Object. */ void InitFields(mitk::USImageMetadata::Pointer); /* \brief Displays whether this widget is active or not. It gets activated by either sending a Signal to * the "CreateNewDevice" Slot or to the "EditDevice" Slot. If the user finishes editing the device, a * "EditingComplete" Signal is sent, and the widget is set to inactive again. Clicking Cancel also * deactivates it. */ bool m_Active; /** * \brief This is the device to edit. It is either the device transmitted in the "EditDevice" signal, or a new one * if the "CreateNewDevice slot was called. */ mitk::USVideoDevice::Pointer m_TargetDevice; }; #endif // _QmitkUSNewVideoDeviceWidget_H_INCLUDED diff --git a/Modules/USUI/Qmitk/QmitkUSNewVideoDeviceWidget.cpp b/Modules/USUI/Qmitk/QmitkUSNewVideoDeviceWidget.cpp index 0621a60400..ae03c68a42 100644 --- a/Modules/USUI/Qmitk/QmitkUSNewVideoDeviceWidget.cpp +++ b/Modules/USUI/Qmitk/QmitkUSNewVideoDeviceWidget.cpp @@ -1,137 +1,147 @@ /*=================================================================== 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 QmitkUSNewVideoDeviceWidget::VIEW_ID = "org.mitk.views.QmitkUSNewVideoDeviceWidget"; QmitkUSNewVideoDeviceWidget::QmitkUSNewVideoDeviceWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f) { m_Controls = NULL; CreateQtPartControl(this); } QmitkUSNewVideoDeviceWidget::~QmitkUSNewVideoDeviceWidget() { } //////////////////// INITIALIZATION ///////////////////// void QmitkUSNewVideoDeviceWidget::CreateQtPartControl(QWidget *parent) { if (!m_Controls) { // create GUI widgets m_Controls = new Ui::QmitkUSNewVideoDeviceWidgetControls; m_Controls->setupUi(parent); this->CreateConnections(); } } void QmitkUSNewVideoDeviceWidget::CreateConnections() { if ( m_Controls ) { connect( m_Controls->m_BtnDone, SIGNAL(clicked()), this, SLOT(OnClickedDone()) ); connect( m_Controls->m_BtnCancel, SIGNAL(clicked()), this, SLOT(OnClickedCancel()) ); + connect( m_Controls->m_RadioDeviceSource, SIGNAL(clicked()), this, SLOT(OnDeviceTypeSelection()) ); + connect( m_Controls->m_RadioFileSource, SIGNAL(clicked()), this, SLOT(OnDeviceTypeSelection()) ); + } + // Hide & show stuff + m_Controls->m_FilePathSelector->setVisible(false); } ///////////// Methods & Slots Handling Direct Interaction ///////////////// void QmitkUSNewVideoDeviceWidget::OnClickedDone(){ m_Active = false; MITK_INFO << "NewDeviceWidget: ClickedDone()"; // Assemble Metadata mitk::USImageMetadata::Pointer metadata = mitk::USImageMetadata::New(); metadata->SetDeviceComment(m_Controls->m_Comment->text().toStdString()); metadata->SetDeviceModel(m_Controls->m_Model->text().toStdString()); metadata->SetDeviceManufacturer(m_Controls->m_Manufacturer->text().toStdString()); metadata->SetProbeName(m_Controls->m_Probe->text().toStdString()); metadata->SetZoom(m_Controls->m_Zoom->text().toStdString()); // Create Device mitk::USVideoDevice::Pointer newDevice = mitk::USVideoDevice::New("C://Builds//MITK-superbuild//CMakeExternals//Source//MITK-Data//CommonTestData//bunny_320x240.avi", metadata); newDevice->Connect(); emit Finished(); } void QmitkUSNewVideoDeviceWidget::OnClickedCancel(){ m_TargetDevice = 0; m_Active = false; MITK_INFO << "NewDeviceWidget: OnClickedCancel()"; emit Finished(); } +void QmitkUSNewVideoDeviceWidget::OnDeviceTypeSelection(){ + m_Controls->m_FilePathSelector->setVisible(m_Controls->m_RadioFileSource->isChecked()); + m_Controls->m_DeviceSelector->setVisible(m_Controls->m_RadioDeviceSource->isChecked()); +} + ///////////////// Methods & Slots Handling Logic ////////////////////////// void QmitkUSNewVideoDeviceWidget::EditDevice(mitk::USDevice::Pointer device) { // If no VideoDevice is given, throw an exception if (device->GetClassName().compare("org.mitk.modules.us.USVideoDevice") != 0){ mitkThrow() << "NewVideoDevcieWidget recieved an incompatible Device Type to edit. Devicetype was: " << device->GetClassName(); } MITK_INFO << "NewDeviceWidget: EditDevice()"; m_TargetDevice = static_cast (device.GetPointer()); m_Active = true; } void QmitkUSNewVideoDeviceWidget::CreateNewDevice() { MITK_INFO << "NewDeviceWidget: CreateNewDevice()"; m_TargetDevice = 0; InitFields(mitk::USImageMetadata::New()); m_Active = true; } /////////////////////// HOUSEHOLDING CODE ///////////////////////////////// QListWidgetItem* QmitkUSNewVideoDeviceWidget::ConstructItemFromDevice(mitk::USDevice::Pointer device){ QListWidgetItem *result = new QListWidgetItem; std::string text = device->GetDeviceManufacturer() + "|" + device->GetDeviceModel(); result->setText(text.c_str()); return result; } void QmitkUSNewVideoDeviceWidget::InitFields(mitk::USImageMetadata::Pointer metadata){ this->m_Controls->m_Manufacturer->setText (metadata->GetDeviceManufacturer().c_str()); this->m_Controls->m_Model->setText (metadata->GetDeviceModel().c_str()); this->m_Controls->m_Comment->setText (metadata->GetDeviceComment().c_str()); this->m_Controls->m_Probe->setText (metadata->GetProbeName().c_str()); this->m_Controls->m_Zoom->setText (metadata->GetZoom().c_str()); } diff --git a/Modules/USUI/Qmitk/QmitkUSNewVideoDeviceWidgetControls.ui b/Modules/USUI/Qmitk/QmitkUSNewVideoDeviceWidgetControls.ui index 9d78d115d8..37174e6df2 100644 --- a/Modules/USUI/Qmitk/QmitkUSNewVideoDeviceWidgetControls.ui +++ b/Modules/USUI/Qmitk/QmitkUSNewVideoDeviceWidgetControls.ui @@ -1,134 +1,169 @@ QmitkUSNewVideoDeviceWidgetControls 0 0 405 - 271 + 404 0 0 QmitkUSNewVideoDeviceWidget - - - - - Add Device - - - + Metadata - + + + + + + 50 + false + true + + + + Device Information: + + + Manufacturer Model + + + + Comment + + + + + + + + + + + true + + + + Probe Information: + + + Probe Zoom - - + + + + + + + GroupBox + + + + - - - - Comment + + + + -1 + + + 10 + + + -1 - - - - - 50 - false - true - - + + - Device Information: + From Device: + + + true - - - - - true - - + + - Probe Information: + From File: - - - - Calibration + + + + Add Device Cancel