diff --git a/Modules/IGTUI/Qmitk/QmitkNavigationDataSourceSelectionWidget.cpp b/Modules/IGTUI/Qmitk/QmitkNavigationDataSourceSelectionWidget.cpp index d103bc3528..0824098ff0 100644 --- a/Modules/IGTUI/Qmitk/QmitkNavigationDataSourceSelectionWidget.cpp +++ b/Modules/IGTUI/Qmitk/QmitkNavigationDataSourceSelectionWidget.cpp @@ -1,129 +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. ===================================================================*/ #include "QmitkNavigationDataSourceSelectionWidget.h" //mitk headers #include #include #include QmitkNavigationDataSourceSelectionWidget::QmitkNavigationDataSourceSelectionWidget(QWidget* parent, Qt::WindowFlags f) : QWidget(parent, f) { m_Controls = NULL; CreateQtPartControl(this); CreateConnections(); } QmitkNavigationDataSourceSelectionWidget::~QmitkNavigationDataSourceSelectionWidget() { } void QmitkNavigationDataSourceSelectionWidget::CreateQtPartControl(QWidget *parent) { if (!m_Controls) { // create GUI widgets m_Controls = new Ui::QmitkNavigationDataSourceSelectionWidgetControls; m_Controls->setupUi(parent); std::string empty = ""; m_Controls->m_NaviagationDataSourceWidget->Initialize(mitk::NavigationDataSource::US_PROPKEY_DEVICENAME,empty); } } void QmitkNavigationDataSourceSelectionWidget::CreateConnections() { if ( m_Controls ) { connect( (QObject*)(m_Controls->m_NaviagationDataSourceWidget), SIGNAL(ServiceSelectionChanged(mitk::ServiceReference)), this, SLOT(NavigationDataSourceSelected(mitk::ServiceReference)) ); } } void QmitkNavigationDataSourceSelectionWidget::NavigationDataSourceSelected(mitk::ServiceReference s) { if (!s) //no device selected { //reset everything m_CurrentSource = NULL; m_CurrentStorage = NULL; - emit NavigationDataSourceDeselected(); + emit NavigationDataSourceSelected(m_CurrentSource); return; } // Get Source m_CurrentSource = this->m_Controls->m_NaviagationDataSourceWidget->TranslateReference(s); std::string id = s.GetProperty(mitk::NavigationDataSource::US_PROPKEY_ID).ToString(); mitk::ModuleContext* context = mitk::GetModuleContext(); //Fill tool list for(int i = 0; i < m_CurrentSource->GetNumberOfOutputs(); i++) {new QListWidgetItem(tr(m_CurrentSource->GetOutput(i)->GetName()), m_Controls->m_ToolView);} // Create Filter for ToolStorage std::string filter = "(&(" + mitk::ServiceConstants::OBJECTCLASS() + "=" + mitk::NavigationToolStorage::US_INTERFACE_NAME + ")("+ mitk::NavigationToolStorage::US_PROPKEY_SOURCE_ID + "=" + id + "))"; // Get Storage std::list refs = context->GetServiceReferences(mitk::NavigationToolStorage::US_INTERFACE_NAME, filter); if (refs.size() == 0) return; //no storage was found m_CurrentStorage = context->GetService(refs.front()); if (m_CurrentStorage.IsNull()) { MITK_WARN << "Found an invalid storage object!"; return; } if (m_CurrentStorage->GetToolCount() != m_CurrentSource->GetNumberOfOutputs()) //there is something wrong with the storage { MITK_WARN << "Found a tool storage, but it has not the same number of tools like the NavigationDataSource. This storage won't be used because it isn't the right one."; m_CurrentStorage = NULL; } emit NavigationDataSourceSelected(m_CurrentSource); } mitk::NavigationDataSource::Pointer QmitkNavigationDataSourceSelectionWidget::GetSelectedNavigationDataSource() { return this->m_CurrentSource; } int QmitkNavigationDataSourceSelectionWidget::GetSelectedToolID() { return this->m_Controls->m_ToolView->currentIndex().row(); } mitk::NavigationTool::Pointer QmitkNavigationDataSourceSelectionWidget::GetSelectedNavigationTool() { if (this->m_CurrentStorage.IsNull()) return NULL; if (m_Controls->m_ToolView->currentIndex().row() >= m_CurrentStorage->GetToolCount()) return NULL; return this->m_CurrentStorage->GetTool(m_Controls->m_ToolView->currentIndex().row()); } mitk::NavigationToolStorage::Pointer QmitkNavigationDataSourceSelectionWidget::GetNavigationToolStorageOfSource() { return this->m_CurrentStorage; } \ No newline at end of file diff --git a/Modules/IGTUI/Qmitk/QmitkNavigationDataSourceSelectionWidget.h b/Modules/IGTUI/Qmitk/QmitkNavigationDataSourceSelectionWidget.h index 296edeb689..9ae8d256ad 100644 --- a/Modules/IGTUI/Qmitk/QmitkNavigationDataSourceSelectionWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkNavigationDataSourceSelectionWidget.h @@ -1,91 +1,91 @@ /*=================================================================== 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 QmitkNavigationDataSourceSelectionWidget_H #define QmitkNavigationDataSourceSelectionWidget_H //QT headers #include //mitk headers #include "MitkIGTUIExports.h" #include #include #include //ui header #include "ui_QmitkNavigationDataSourceSelectionWidgetControls.h" /** Documentation: * \brief This widget allows the user to select a NavigationDataSource. Tools of this Source are also shown and the user can select one of these tools. * \ingroup IGTUI */ class MitkIGTUI_EXPORT QmitkNavigationDataSourceSelectionWidget : public QWidget { Q_OBJECT public: static const std::string VIEW_ID; QmitkNavigationDataSourceSelectionWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); ~QmitkNavigationDataSourceSelectionWidget(); /** @return Returns the currently selected NavigationDataSource. Returns null if no source is selected at the moment. */ mitk::NavigationDataSource::Pointer GetSelectedNavigationDataSource(); /** @return Returns the ID of the currently selected tool. You can get the corresponding NavigationData when calling GetOutput(id) * on the source object. Returns -1 if there is no tool selected. */ int GetSelectedToolID(); /** @return Returns the NavigationTool of the current selected tool if a NavigationToolStorage is available. Returns NULL if * there is no storage available or if no tool is selected. */ mitk::NavigationTool::Pointer GetSelectedNavigationTool(); /** @return Returns the NavigationToolStorage of the currently selected NavigationDataSource. Returns NULL if there is no * source selected or if the source has no NavigationToolStorage assigned. */ mitk::NavigationToolStorage::Pointer GetNavigationToolStorageOfSource(); signals: - /** @brief This signal is emitted when a new navigation data source is selected. */ - void NavigationDataSourceSelected(mitk::NavigationDataSource::Pointer s); - /** @brief This signal is emitted when a navigation data source is deselected and no new one is selected. */ - void NavigationDataSourceDeselected(); - + /** @brief This signal is emitted when a new navigation data source is selected. + * @param n Holds the new selected navigation data source. Is null if the old source is deselected and no new source is selected. + */ + void NavigationDataSourceSelected(mitk::NavigationDataSource::Pointer n); + protected slots: void NavigationDataSourceSelected(mitk::ServiceReference s); protected: /// \brief Creation of the connections virtual void CreateConnections(); virtual void CreateQtPartControl(QWidget *parent); Ui::QmitkNavigationDataSourceSelectionWidgetControls* m_Controls; mitk::NavigationToolStorage::Pointer m_CurrentStorage; mitk::NavigationDataSource::Pointer m_CurrentSource; }; #endif \ No newline at end of file