diff --git a/Core/Code/DataManagement/mitkLine.h b/Core/Code/DataManagement/mitkLine.h index 1a55b657b9..991d58b3d7 100644 --- a/Core/Code/DataManagement/mitkLine.h +++ b/Core/Code/DataManagement/mitkLine.h @@ -1,428 +1,427 @@ /*=================================================================== 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 MITKLINE_H_HEADER_INCLUDED_C19C01E2 #define MITKLINE_H_HEADER_INCLUDED_C19C01E2 #include "mitkVector.h" #include #include #include #include namespace mitk { //##Documentation //## @brief Descibes a line //## @ingroup Geometry template class Line { public: Line() { m_Point.Fill(0); m_Direction.Fill(0); }; //##Documentation //## @brief Define line by point and direction //## //## Length of direction defines the the length of the line Line( const itk::Point& point, const itk::Vector& direction ) { this->m_Point = point; this->m_Direction = direction; } //##Documentation //## @brief Get start point of the line const itk::Point& GetPoint() const { return m_Point; } //##Documentation //## @brief Get start point of the line itk::Point& GetPoint() { return m_Point; } //##Documentation //## @brief Get point on the line with parameter @a t //## //## @return m_Point+t*m_Direction const itk::Point GetPoint(TCoordRep t) const { return m_Point+m_Direction*t; } //##Documentation //## @brief Set/change start point of the line void SetPoint( const itk::Point& point1 ) { - itk::Vector point2; + itk::Point point2; point2 = m_Point + m_Direction; - m_Point = point1; - m_Direction = point2 - point1; + m_Direction = point2.GetVectorFromOrigin() - point1.GetVectorFromOrigin(); } //##Documentation //## @brief Get the direction vector of the line const itk::Vector& GetDirection() const { return m_Direction; } //##Documentation //## @brief Get the direction vector of the line itk::Vector& GetDirection() { return m_Direction; } //##Documentation //## @brief Set the direction vector of the line void SetDirection( const itk::Vector& direction ) { m_Direction = direction; } //##Documentation //## @brief Define line by point and direction //## //## Length of direction defines the the length of the line void Set( const itk::Point& point, const itk::Vector& direction ) { this->m_Point = point; this->m_Direction = direction; } //##Documentation //## @brief Define line by two points void SetPoints( const itk::Point& point1, const itk::Point& point2 ) { this->m_Point = point1; //this->m_Direction.sub( point2, point1 ); m_Direction = point2 - point1; } //##Documentation //## @brief Set/change start point of the line void SetPoint1( const itk::Point& point1 ) { itk::Vector point2; point2 = m_Point + m_Direction; m_Point = point1; m_Direction = point2 - point1; } //##Documentation //## @brief Get start point of the line const itk::Point& GetPoint1() const { return m_Point; } //##Documentation //## @brief Set/change end point of the line void SetPoint2( const itk::Point& point2 ) { m_Direction = point2 - m_Point; } //##Documentation //## @brief Get end point of the line itk::Point GetPoint2() const { itk::Point point2; point2 = m_Point+m_Direction; return point2; } //##Documentation //## @brief Transform the line with a Transform void Transform(itk::Transform& transform) { m_Direction = transform.TransformVector(m_Direction); m_Point = transform.TransformPoint(m_Point); } //##Documentation //## @brief Transform the line with a matrix //## //## Only the direction will be changed, not the start point. void Transform( const itk::Matrix& matrix ) { m_Direction = matrix*m_Direction; } //##Documentation //## @brief Distance between two lines double Distance( const Line& line ) const; //##Documentation //## @brief Distance of a point from the line double Distance( const itk::Point& point ) const { itk::Vector diff; diff = Project(point)-point; return diff.GetNorm(); } //##Documentation //## @brief Project a point on the line itk::Point Project( const itk::Point& point ) const { if(m_Direction.GetNorm()==0) return this->m_Point; itk::Vector diff; diff = point-this->m_Point; itk::Vector normalizedDirection = m_Direction; normalizedDirection.Normalize(); normalizedDirection *= dot_product(diff.GetVnlVector(), normalizedDirection.GetVnlVector()); return this->m_Point + normalizedDirection; } //##Documentation //## @brief Test if a point is part of the line //## //## Length of the direction vector defines the length of the line bool IsPartOfStraightLine( const itk::Point& point ) const { if( Distance( point ) > eps ) return false; itk::Vector diff; diff = point - this->m_Point; if( diff*m_Direction < 0 ) return false; if( diff.GetSquaredNorm() <= m_Direction.GetSquaredNorm() ) return true; return false; } //##Documentation //## @brief Test if a point is part of the line (line having infinite length) bool IsPartOfLine( const itk::Point& point ) const { if ( Distance( point ) < eps ) return true; return false; } //##Documentation //## @brief Test if a lines is parallel to this line bool IsParallel( const Line& line) const { vnl_vector normal; normal = vnl_cross_3d( m_Direction.GetVnlVector(), line.GetDirection().GetVnlVector() ); if ( normal.squared_magnitude() < eps ) return true; return false; } //##Documentation //## @brief Test if a line is part of the line (line having infinite length) bool IsPartOfLine( const Line& line ) const { return ( Distance( line.GetPoint() ) < 0 ) && ( IsParallel( line ) ); } //##Documentation //## @brief Test if the two lines are identical //## //## Start point and direction and length of direction vector must be //## equal for identical lines. bool operator==( const Line& line ) const { itk::Vector diff; diff = GetPoint1()-line.GetPoint1(); if(diff.GetSquaredNorm() > eps) return false; diff = GetPoint2()-line.GetPoint2(); if(diff.GetSquaredNorm() > eps) return false; return true; } //##Documentation //## @brief Set the line by another line inline const Line& operator=( const Line& line ) { m_Point = line.GetPoint(); m_Direction = line.GetDirection(); return *this; } //##Documentation //## @brief Test if two lines are not identical //## //## \sa operator== bool operator!=( const Line& line ) const { return !((*this)==line); } //##Documentation //## @brief Calculates the intersection points of a straight line in 2D //## with a rectangle //## //## @param x1,y1,x2,y2 rectangle //## @param p,d straight line: p point on it, d direction of line //## @param s1 first intersection point (valid only if s_num>0) //## @param s2 second intersection point (valid only if s_num==2) //## @return number of intersection points (0<=s_num<=2) static int RectangleLineIntersection( TCoordRep x1, TCoordRep y1, TCoordRep x2, TCoordRep y2, itk::Point< TCoordRep, 2 > p, itk::Vector< TCoordRep, 2 > d, itk::Point< TCoordRep, 2 > &s1, itk::Point< TCoordRep, 2 > &s2 ) { int s_num; TCoordRep t; s_num=0; /*test if intersecting with the horizontal axis*/ if(fabs(d[0])>eps) { t=(x1-p[0])/d[0]; itk::Point l=p+d*t; if((l[1]>=y1) && (l[1]eps) { t=(x2-p[0])/d[0]; itk::Point l=p+d*t; if((l[1]>=y1) && (l[1]eps) { t=(y1-p[1])/d[1]; itk::Point l=p+d*t; if((l[0]>=x1) && (l[0]eps) { t=(y2-p[1])/d[1]; itk::Point l=p+d*t; if((l[0]>=x1) && (l[0]0) * \param s2 second intersection point (valid only if s_num==2) * \return number of intersection points (0<=s_num<=2) */ static int BoxLineIntersection( TCoordRep x1, TCoordRep y1, TCoordRep z1, TCoordRep x2, TCoordRep y2, TCoordRep z2, itk::Point< TCoordRep, 3 > p, itk::Vector< TCoordRep, 3 > d, itk::Point< TCoordRep, 3 > &s1, itk::Point< TCoordRep, 3 > &s2 ) { int num = 0; ScalarType box[6]; box[0] = x1; box[1] = x2; box[2] = y1; box[3] = y2; box[4] = z1; box[5] = z2; itk::Point< TCoordRep, 3 > point; int i, j; for ( i = 0; i < 6; ++i ) { j = i / 2; if ( fabs( d[j] ) > eps ) { ScalarType lambda = (box[i] - p[j]) / d[j]; point = p + d * lambda; int k = (j + 1) % 3; int l = (j + 2) % 3; if ( (point[k] >= box[k*2]) && (point[k] <= box[k*2+1]) && (point[l] >= box[l*2]) && (point[l] <= box[l*2+1]) ) { if ( num == 0 ) { s1 = point; } else { s2 = point; } ++num; } } } return num; } protected: itk::Point m_Point; itk::Vector m_Direction; }; typedef Line Line3D; } // namespace mitk #endif /* MITKLINE_H_HEADER_INCLUDED_C19C01E2 */ 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 33e0cf6084..71a9fc7f5b 100644 --- a/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupport.cpp +++ b/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupport.cpp @@ -1,338 +1,356 @@ /*=================================================================== 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. ===================================================================*/ // Blueberry #include #include //Mitk #include #include #include #include #include // Qmitk #include "UltrasoundSupport.h" -#include // Qt #include +#include +#include // Ultrasound #include "mitkUSDevice.h" #include "QmitkUSAbstractCustomWidget.h" #include #include #include "usServiceReference.h" #include "internal/org_mitk_gui_qt_ultrasound_Activator.h" const std::string UltrasoundSupport::VIEW_ID = "org.mitk.views.ultrasoundsupport"; void UltrasoundSupport::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_DeviceManagerWidget, SIGNAL(NewDeviceButtonClicked()), this, SLOT(OnClickedAddNewDevice()) ); // Change Widget Visibilities connect( m_Controls.m_DeviceManagerWidget, SIGNAL(NewDeviceButtonClicked()), this->m_Controls.m_NewVideoDeviceWidget, SLOT(CreateNewDevice()) ); // Init NewDeviceWidget connect( m_Controls.m_ActiveVideoDevices, SIGNAL(ServiceSelectionChanged(us::ServiceReferenceU)), this, SLOT(OnChangedActiveDevice()) ); connect( m_Controls.m_ShowImageStream, SIGNAL(clicked()), this, SLOT(OnChangedActiveDevice()) ); connect( m_Controls.m_NewVideoDeviceWidget, SIGNAL(Finished()), this, SLOT(OnNewDeviceWidgetDone()) ); // After NewDeviceWidget finished editing connect( m_Controls.m_FrameRate, SIGNAL(valueChanged(int)), this, SLOT(OnChangedFramerateLimit(int)) ); connect( m_Controls.m_FreezeButton, SIGNAL(clicked()), this, SLOT(OnClickedFreezeButton()) ); connect( m_Timer, SIGNAL(timeout()), this, SLOT(DisplayImage())); // Initializations m_Controls.m_NewVideoDeviceWidget->setVisible(false); std::string filter = "(&(" + us::ServiceConstants::OBJECTCLASS() + "=" + "org.mitk.services.UltrasoundDevice)(" + mitk::USDevice::GetPropertyKeys().US_PROPKEY_ISACTIVE + "=true))"; m_Controls.m_ActiveVideoDevices->Initialize( mitk::USDevice::GetPropertyKeys().US_PROPKEY_LABEL ,filter); m_Controls.m_ActiveVideoDevices->SetAutomaticallySelectFirstEntry(true); m_FrameCounter = 0; // Create Node for US Stream if (m_Node.IsNull()) { m_Node = mitk::DataNode::New(); m_Node->SetName("US Support Viewing Stream"); //create a dummy image (gray values 0..255) for correct initialization of level window, etc. mitk::Image::Pointer dummyImage = mitk::ImageGenerator::GenerateRandomImage(100, 100, 1, 1, 1, 1, 1, 255,0); m_Node->SetData(dummyImage); m_OldGeometry = dynamic_cast(dummyImage->GetGeometry()); } m_Controls.tabWidget->setTabEnabled(1, false); + +LoadUISettings(); } void UltrasoundSupport::OnClickedAddNewDevice() { m_Controls.m_NewVideoDeviceWidget->setVisible(true); m_Controls.m_DeviceManagerWidget->setVisible(false); m_Controls.m_Headline->setText("Add New Video Device:"); m_Controls.m_WidgetActiveDevices->setVisible(false); } void UltrasoundSupport::DisplayImage() { //Update device m_Device->Modified(); m_Device->Update(); //Only update the view if the image is shown if(m_Controls.m_ShowImageStream->isChecked()) { //Update data node mitk::Image::Pointer curOutput = m_Device->GetOutput(); m_Node->SetData(curOutput); // if the geometry changed: reinitialize the ultrasound image if(!mitk::Equal(m_OldGeometry.GetPointer(),curOutput->GetGeometry(),0.0001,false)) { mitk::IRenderWindowPart* renderWindow = this->GetRenderWindowPart(); if ( (renderWindow != NULL) && (curOutput->GetTimeGeometry()->IsValid()) && (m_Controls.m_ShowImageStream->isChecked()) ) { renderWindow->GetRenderingManager()->InitializeViews( curOutput->GetGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); renderWindow->GetRenderingManager()->RequestUpdateAll(); } m_CurrentImageWidth = curOutput->GetDimension(0); m_CurrentImageHeight = curOutput->GetDimension(1); m_OldGeometry = dynamic_cast(curOutput->GetGeometry()); } //if not: only update the view else { this->RequestRenderWindowUpdate(); } } //Update frame counter m_FrameCounter ++; if (m_FrameCounter >= 10) { int nMilliseconds = m_Clock.restart(); int fps = 10000.0f / (nMilliseconds ); m_Controls.m_FramerateLabel->setText("Current Framerate: "+ QString::number(fps) +" FPS"); m_FrameCounter = 0; } } void UltrasoundSupport::OnChangedFramerateLimit(int value) { m_Timer->stop(); m_Timer->setInterval(1000 / value); m_Timer->start(); } void UltrasoundSupport::OnClickedFreezeButton() { if ( m_Device->GetIsFreezed() ) { m_Device->SetIsFreezed(false); m_Controls.m_FreezeButton->setText("Freeze"); } else { m_Device->SetIsFreezed(true); m_Controls.m_FreezeButton->setText("Start Viewing Again"); } } void UltrasoundSupport::OnChangedActiveDevice() { //clean up and stop timer m_Timer->stop(); this->RemoveControlWidgets(); this->GetDataStorage()->Remove(m_Node); m_Node->ReleaseData(); //get current device, abort if it is invalid m_Device = m_Controls.m_ActiveVideoDevices->GetSelectedService(); if (m_Device.IsNull()) { MITK_WARN << "Selected device is not valid, aborting"; m_Controls.tabWidget->setTabEnabled(1, false); return; } //create the widgets for this device and enable the widget tab this->CreateControlWidgets(); m_Controls.tabWidget->setTabEnabled(1, true); //show node if the option is enabled if(m_Controls.m_ShowImageStream->isChecked()) {this->GetDataStorage()->Add(m_Node);} //start timer int interval = (1000 / m_Controls.m_FrameRate->value()); m_Timer->setInterval(interval); m_Timer->start(); } void UltrasoundSupport::OnNewDeviceWidgetDone() { m_Controls.m_NewVideoDeviceWidget->setVisible(false); m_Controls.m_DeviceManagerWidget->setVisible(true); m_Controls.m_Headline->setText("Ultrasound Devices:"); m_Controls.m_WidgetActiveDevices->setVisible(true); } void UltrasoundSupport::CreateControlWidgets() { m_ControlProbesWidget = new QmitkUSControlsProbesWidget(m_Device->GetControlInterfaceProbes(), m_Controls.m_ToolBoxControlWidgets); m_Controls.probesWidgetContainer->addWidget(m_ControlProbesWidget); // create b mode widget for current device m_ControlBModeWidget = new QmitkUSControlsBModeWidget(m_Device->GetControlInterfaceBMode(), m_Controls.m_ToolBoxControlWidgets); m_Controls.m_ToolBoxControlWidgets->addItem(m_ControlBModeWidget, "B Mode Controls"); if ( ! m_Device->GetControlInterfaceBMode() ) -{ -m_Controls.m_ToolBoxControlWidgets->setItemEnabled(m_Controls.m_ToolBoxControlWidgets->count()-1, false); -} +{m_Controls.m_ToolBoxControlWidgets->setItemEnabled(m_Controls.m_ToolBoxControlWidgets->count()-1, false);} // create doppler widget for current device m_ControlDopplerWidget = new QmitkUSControlsDopplerWidget(m_Device->GetControlInterfaceDoppler(), m_Controls.m_ToolBoxControlWidgets); m_Controls.m_ToolBoxControlWidgets->addItem(m_ControlDopplerWidget, "Doppler Controls"); if ( ! m_Device->GetControlInterfaceDoppler() ) -{ -m_Controls.m_ToolBoxControlWidgets->setItemEnabled(m_Controls.m_ToolBoxControlWidgets->count()-1, false); -} +{m_Controls.m_ToolBoxControlWidgets->setItemEnabled(m_Controls.m_ToolBoxControlWidgets->count()-1, false);} ctkPluginContext* pluginContext = mitk::PluginActivator::GetContext(); if ( pluginContext ) { -std::string filter = "(ork.mitk.services.UltrasoundCustomWidget.deviceClass=" + m_Device->GetDeviceClass() + ")"; + std::string filter = "(ork.mitk.services.UltrasoundCustomWidget.deviceClass=" + m_Device->GetDeviceClass() + ")"; -QString interfaceName ( us_service_interface_iid() ); -m_CustomWidgetServiceReference = pluginContext->getServiceReferences(interfaceName, QString::fromStdString(filter)); + QString interfaceName ( us_service_interface_iid() ); + m_CustomWidgetServiceReference = pluginContext->getServiceReferences(interfaceName, QString::fromStdString(filter)); + + if (m_CustomWidgetServiceReference.size() > 0) + { + m_ControlCustomWidget = pluginContext->getService + (m_CustomWidgetServiceReference.at(0))->CloneForQt(m_Controls.tab2); + m_ControlCustomWidget->SetDevice(m_Device); + m_Controls.m_ToolBoxControlWidgets->addItem(m_ControlCustomWidget, "Custom Controls"); + } + else + { + m_Controls.m_ToolBoxControlWidgets->addItem(new QWidget(m_Controls.m_ToolBoxControlWidgets), "Custom Controls"); + m_Controls.m_ToolBoxControlWidgets->setItemEnabled(m_Controls.m_ToolBoxControlWidgets->count()-1, false); + } -if (m_CustomWidgetServiceReference.size() > 0) -{ -m_ControlCustomWidget = pluginContext->getService -(m_CustomWidgetServiceReference.at(0))->CloneForQt(m_Controls.tab2); -m_ControlCustomWidget->SetDevice(m_Device); -m_Controls.m_ToolBoxControlWidgets->addItem(m_ControlCustomWidget, "Custom Controls"); -} -else -{ -m_Controls.m_ToolBoxControlWidgets->addItem(new QWidget(m_Controls.m_ToolBoxControlWidgets), "Custom Controls"); -m_Controls.m_ToolBoxControlWidgets->setItemEnabled(m_Controls.m_ToolBoxControlWidgets->count()-1, false); -} } // select first enabled control widget for ( int n = 0; n < m_Controls.m_ToolBoxControlWidgets->count(); ++n) { -if ( m_Controls.m_ToolBoxControlWidgets->isItemEnabled(n) ) -{ -m_Controls.m_ToolBoxControlWidgets->setCurrentIndex(n); -break; -} + if ( m_Controls.m_ToolBoxControlWidgets->isItemEnabled(n) ) + { + m_Controls.m_ToolBoxControlWidgets->setCurrentIndex(n); + break; + } } + } void UltrasoundSupport::RemoveControlWidgets() { if(!m_ControlProbesWidget) {return;} //widgets do not exist... nothing to do // remove all control widgets from the tool box widget while (m_Controls.m_ToolBoxControlWidgets->count() > 0) { -m_Controls.m_ToolBoxControlWidgets->removeItem(0); + m_Controls.m_ToolBoxControlWidgets->removeItem(0); } // remove probes widget (which is not part of the tool box widget) m_Controls.probesWidgetContainer->removeWidget(m_ControlProbesWidget); delete m_ControlProbesWidget; m_ControlProbesWidget = 0; delete m_ControlBModeWidget; m_ControlBModeWidget = 0; delete m_ControlDopplerWidget; m_ControlDopplerWidget = 0; // delete custom widget if it is present if ( m_ControlCustomWidget ) { -ctkPluginContext* pluginContext = mitk::PluginActivator::GetContext(); -delete m_ControlCustomWidget; m_ControlCustomWidget = 0; - -if ( m_CustomWidgetServiceReference.size() > 0 ) -{ -pluginContext->ungetService(m_CustomWidgetServiceReference.at(0)); -} + ctkPluginContext* pluginContext = mitk::PluginActivator::GetContext(); + delete m_ControlCustomWidget; m_ControlCustomWidget = 0; + if ( m_CustomWidgetServiceReference.size() > 0 ) + { + pluginContext->ungetService(m_CustomWidgetServiceReference.at(0)); + } } } void UltrasoundSupport::OnDeciveServiceEvent(const ctkServiceEvent event) { if ( m_Device.IsNull() || event.getType() != us::ServiceEvent::MODIFIED ) { return; } ctkServiceReference service = event.getServiceReference(); if ( m_Device->GetManufacturer() != service.getProperty(QString::fromStdString(mitk::USDevice::GetPropertyKeys().US_PROPKEY_MANUFACTURER)).toString().toStdString() && m_Device->GetName() != service.getProperty(QString::fromStdString(mitk::USDevice::GetPropertyKeys().US_PROPKEY_NAME)).toString().toStdString() ) { return; } if ( ! m_Device->GetIsActive() && m_Timer->isActive() ) { m_Timer->stop(); } if ( m_CurrentDynamicRange != service.getProperty(QString::fromStdString(mitk::USDevice::GetPropertyKeys().US_PROPKEY_BMODE_DYNAMIC_RANGE)).toDouble() ) { m_CurrentDynamicRange = service.getProperty(QString::fromStdString(mitk::USDevice::GetPropertyKeys().US_PROPKEY_BMODE_DYNAMIC_RANGE)).toDouble(); // update level window for the current dynamic range mitk::LevelWindow levelWindow; m_Node->GetLevelWindow(levelWindow); levelWindow.SetAuto(m_Image, true, true); m_Node->SetLevelWindow(levelWindow); } } UltrasoundSupport::UltrasoundSupport() : m_ControlCustomWidget(0), m_ControlBModeWidget(0), m_ControlProbesWidget(0), m_ImageAlreadySetToNode(false), m_CurrentImageWidth(0), m_CurrentImageHeight(0) { ctkPluginContext* pluginContext = mitk::PluginActivator::GetContext(); if ( pluginContext ) { -// to be notified about service event of an USDevice -pluginContext->connectServiceListener(this, "OnDeciveServiceEvent", -QString::fromStdString("(" + us::ServiceConstants::OBJECTCLASS() + "=" + us_service_interface_iid() + ")")); + // to be notified about service event of an USDevice + pluginContext->connectServiceListener(this, "OnDeciveServiceEvent", + QString::fromStdString("(" + us::ServiceConstants::OBJECTCLASS() + "=" + us_service_interface_iid() + ")")); } + } UltrasoundSupport::~UltrasoundSupport() { + StoreUISettings(); +} + +void UltrasoundSupport::StoreUISettings() +{ + QSettings settings; + settings.beginGroup(QString::fromStdString(VIEW_ID)); + settings.setValue("DisplayImage", QVariant(m_Controls.m_ShowImageStream->isChecked())); + settings.endGroup(); +} + +void UltrasoundSupport::LoadUISettings() +{ + QSettings settings; + settings.beginGroup(QString::fromStdString(VIEW_ID)); + m_Controls.m_ShowImageStream->setChecked(settings.value("DisplayImage", true).toBool()); + settings.endGroup(); } 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 66b3129622..7aba88af63 100644 --- a/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupport.h +++ b/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupport.h @@ -1,124 +1,129 @@ /*=================================================================== 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 UltrasoundSupport_h #define UltrasoundSupport_h #include #include #include "ui_UltrasoundSupportControls.h" #include "QmitkUSAbstractCustomWidget.h" #include "QmitkUSControlsBModeWidget.h" #include "QmitkUSControlsDopplerWidget.h" #include "QmitkUSControlsProbesWidget.h" #include #include /*! \brief UltrasoundSupport 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); UltrasoundSupport(); virtual ~UltrasoundSupport(); public slots: /* * \brief This is called when the newDeviceWidget is closed */ void OnNewDeviceWidgetDone(); protected slots: void OnClickedAddNewDevice(); void OnChangedFramerateLimit(int); void OnChangedActiveDevice(); void OnClickedFreezeButton(); void OnDeciveServiceEvent(const ctkServiceEvent event); /* * \brief This is the main imaging loop that is called regularily during the imaging process */ void DisplayImage(); protected: void CreateControlWidgets(); void RemoveControlWidgets(); - int m_FrameCounter; + /** The device that is currently used to aquire images */ + mitk::USDevice::Pointer m_Device; - /* - * \brief This timer triggers periodic updates to the pipeline - */ + /** This timer triggers periodic updates to the pipeline */ QTimer* m_Timer; - QTime m_Clock; + /** This clock is used to compute the framerate in the method DisplayImage(). */ + QTime m_Clock; - /* - * \brief The device that is currently used to aquire images - */ - mitk::USDevice::Pointer m_Device; + /** A counter to comute the framerate. */ + int m_FrameCounter; + + /** Stores the properties of some QWidgets (and the tool storage file name) to QSettings.*/ + void StoreUISettings(); + + /** Loads the properties of some QWidgets (and the tool storage file name) from QSettings.*/ + void LoadUISettings(); - /* - * \brief The node that we feed images into - */ + /** The node that we feed images into.*/ mitk::DataNode::Pointer m_Node; + /** The image that is hold by the node above.*/ mitk::Image::Pointer m_Image; + /** The old geometry of m_Image. It is needed to check if the geometry changed (e.g. because + * the zoom factor was modified) and the image needs to be reinitialized. */ mitk::Geometry3D::Pointer m_OldGeometry; Ui::UltrasoundSupportControls m_Controls; QmitkUSAbstractCustomWidget* m_ControlCustomWidget; QmitkUSControlsBModeWidget* m_ControlBModeWidget; QmitkUSControlsDopplerWidget* m_ControlDopplerWidget; QmitkUSControlsProbesWidget* m_ControlProbesWidget; QList m_CustomWidgetServiceReference; bool m_ImageAlreadySetToNode; unsigned int m_CurrentImageWidth; unsigned int m_CurrentImageHeight; double m_CurrentDynamicRange; }; #endif // UltrasoundSupport_h \ No newline at end of file