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 738f09a5ef..0a4e9bf78e 100644 --- a/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupport.cpp +++ b/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupport.cpp @@ -1,216 +1,203 @@ /*========================================================================= 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 //Mitk #include "mitkDataNode.h" // Qmitk #include "UltrasoundSupport.h" #include // Qt #include // Ultrasound #include "mitkUSDevice.h" const std::string UltrasoundSupport::VIEW_ID = "org.mitk.views.ultrasoundsupport"; - - - void UltrasoundSupport::SetFocus() { - // m_Controls.buttonPerformImageProcessing->setFocus(); + m_Controls.m_AddDevice->setFocus(); } void UltrasoundSupport::CreateQtPartControl( QWidget *parent ) { m_Timer = new QTimer(this); // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi( parent ); connect( m_Controls.m_AddDevice, SIGNAL(clicked()), this, SLOT(OnClickedAddNewDevice()) ); // Change Widget Visibilities connect( m_Controls.m_AddDevice, SIGNAL(clicked()), this->m_Controls.m_NewVideoDeviceWidget, SLOT(CreateNewDevice()) ); // Init NewDeviceWidget connect( m_Controls.m_NewVideoDeviceWidget, SIGNAL(Finished()), this, SLOT(OnNewDeviceWidgetDone()) ); // After NewDeviceWidget finished editing connect( m_Controls.m_BtnView, SIGNAL(clicked()), this, SLOT(OnClickedViewDevice()) ); connect( m_Timer, SIGNAL(timeout()), this, SLOT(DisplayImage())); //connect (m_Controls.m_ActiveVideoDevices, SIGNAL()) // Initializations m_Controls.m_NewVideoDeviceWidget->setVisible(false); std::string filter = "(&(" + mitk::ServiceConstants::OBJECTCLASS() + "=" + "org.mitk.services.UltrasoundDevice)(IsActive=true))"; m_Controls.m_ActiveVideoDevices->Initialize(filter); m_Node = mitk::DataNode::New(); - m_Node->SetName("US-Image 0"); + m_Node->SetName("US Image Stream"); this->GetDataStorage()->Add(m_Node); } void UltrasoundSupport::OnClickedAddNewDevice() { MITK_INFO << "USSUPPORT: OnClickedAddNewDevice()"; m_Controls.m_NewVideoDeviceWidget->setVisible(true); m_Controls.m_DeviceManagerWidget->setVisible(false); m_Controls.m_AddDevice->setVisible(false); m_Controls.m_Headline->setText("Add New Device:"); } void UltrasoundSupport::DisplayImage() { - + MITK_INFO << "USSUPPORT: DisplayImage()"; //QList nodes = this->GetDataManagerSelection(); // if (nodes.empty()) return; m_Device->UpdateOutputData(0); mitk::USImage::Pointer image = m_Device->GetOutput(); + //m_Node->Initialize(); m_Node->SetData(image); + this->RequestRenderWindowUpdate(); /* int i; for (i = 1; i < 10; i++) { device->Update(); if ((i % 3) == 0 ) { node = mitk::DataNode::New(); image = device->GetOutput(); node->SetData(image); std::ostringstream oss; oss << "US-Image " << i; node->SetName(oss.str()); this->GetDataStorage()->Add(node); } }*/ //// 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... // } //} } void UltrasoundSupport::OnClickedViewDevice() { MITK_INFO << "USSUPPORT: OnClickedViewDevice()"; m_Device = m_Controls.m_ActiveVideoDevices->GetSelectedDevice(); if (m_Device.IsNull()){ m_Timer->stop(); return; } - m_Timer->start(); + m_Timer->start(100); } void UltrasoundSupport::OnNewDeviceWidgetDone() { MITK_INFO << "USSUPPORT: OnNewDeviceWidgetDone()"; m_Controls.m_NewVideoDeviceWidget->setVisible(false); m_Controls.m_DeviceManagerWidget->setVisible(true); m_Controls.m_AddDevice->setVisible(true); m_Controls.m_Headline->setText("Connected Devices:"); } - - - - - - - - - - - - /** 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 f17dc0ef46..2ffb46bc06 100644 --- a/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupport.h +++ b/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupport.h @@ -1,82 +1,91 @@ /*========================================================================= 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. + This plugin provides functionality to manage Ultrasound devices, create video devices and to view device images. \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: + + virtual void SetFocus(); static const std::string VIEW_ID; virtual void CreateQtPartControl(QWidget *parent); - signals: - - void DeviceServiceUpdated(); + signals: public slots: + /* + * \brief This is called when the newDeviceWidget is closed + */ void OnNewDeviceWidgetDone(); protected slots: void OnClickedAddNewDevice(); void OnClickedViewDevice(); + /* + * \brief This is the main imaging loop that is called regularily during the imaging process + */ void DisplayImage(); protected: - - virtual void SetFocus(); + /* + * \brief This timer triggers periodic updates to the pipeline + */ QTimer *m_Timer; + /* + * \brief The device that is currently used to quire images + */ mitk::USDevice::Pointer m_Device; + /* + * \brief The node that we feed images into + */ mitk::DataNode::Pointer m_Node; - - // Not necessary? - //const QList& nodes ); Ui::UltrasoundSupportControls m_Controls; }; #endif // UltrasoundSupport_h