diff --git a/Modules/IGTUI/Qmitk/QmitkToolSelectionWidget.cpp b/Modules/IGTUI/Qmitk/QmitkToolSelectionWidget.cpp new file mode 100644 index 0000000000..6d3973b761 --- /dev/null +++ b/Modules/IGTUI/Qmitk/QmitkToolSelectionWidget.cpp @@ -0,0 +1,126 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-03-21 19:27:37 +0100 (Sa, 21 Mrz 2009) $ +Version: $Revision: 16719 $ + +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. + +=========================================================================*/ + +#include "QmitkToolSelectionWidget.h" + + + +QmitkToolSelectionWidget::QmitkToolSelectionWidget(QWidget* parent) +: QWidget(parent), m_Controls(NULL) +{ + this->CreateQtPartControl( this ); +} + +QmitkToolSelectionWidget::~QmitkToolSelectionWidget() +{ + m_Controls = NULL; +} + + +void QmitkToolSelectionWidget::CreateQtPartControl(QWidget *parent) +{ + if (!m_Controls) + { + // create GUI widgets + m_Controls = new Ui::QmitkToolSelectionWidgetControls; + m_Controls->setupUi(parent); + this->CreateConnections(); + } +} + + +void QmitkToolSelectionWidget::CreateConnections() +{ + connect ( m_Controls->m_UseToolCheckBox, SIGNAL(toggled(bool)), this, SLOT(CheckBoxToggled(bool)) ); + //connect ( m_Controls->m_ToolSelectionComboBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(void SelectedToolChanged(int)) ); + + //connect( (QObject*)(m_Controls->m_StartNavigationBtn), SIGNAL(clicked()), this, SLOT(OnStartTimer()) ); + //connect( (QObject*)(m_Controls->m_StopNavigationBtn), SIGNAL(clicked()), this, SLOT(OnStopTimer()) ); + //connect( m_Controls->m_UpdateRateSB, SIGNAL(valueChanged(int)), this, SLOT(OnChangeTimerInterval(int)) ); +} + + +int QmitkToolSelectionWidget::GetCurrentSelectedIndex() +{ + return m_Controls->m_ToolSelectionComboBox->currentIndex(); +} + +void QmitkToolSelectionWidget::SetToolNames( const QStringList& toolNames ) +{ + m_Controls->m_ToolSelectionComboBox->addItems(toolNames); +} + +void QmitkToolSelectionWidget::AddToolName( const QString& toolName) +{ + m_Controls->m_ToolSelectionComboBox->addItem(toolName); +} + +void QmitkToolSelectionWidget::ChangeToolName( int index, const QString& toolName ) +{ + m_Controls->m_ToolSelectionComboBox->insertItem(index, toolName); +} + +void QmitkToolSelectionWidget::RemoveToolName( const QString& toolName ) +{ + for(int i=0; i < m_Controls->m_ToolSelectionComboBox->count(); ++i) + { + if(m_Controls->m_ToolSelectionComboBox->itemText(i).compare(toolName) == 0) + m_Controls->m_ToolSelectionComboBox->removeItem(i); + } +} + +void QmitkToolSelectionWidget::RemoveToolName( int index ) +{ + m_Controls->m_ToolSelectionComboBox->removeItem(index); +} + +void QmitkToolSelectionWidget::ClearToolNames() +{ + m_Controls->m_ToolSelectionComboBox->clear(); +} + + +void QmitkToolSelectionWidget::SetCheckboxtText( const QString& text) +{ + m_Controls->m_UseToolCheckBox->setText(text); +} + +void QmitkToolSelectionWidget::EnableWidget() +{ + this->setEnabled( true ); +} + +void QmitkToolSelectionWidget::DisableWidget() +{ + this->setEnabled( false ); +} + + +void QmitkToolSelectionWidget::CheckBoxToggled(bool checked) +{ + if(checked) + m_Controls->m_ToolSelectionComboBox->setEnabled(false); + else + m_Controls->m_ToolSelectionComboBox->setEnabled(true); + + emit SignalUseTool(m_Controls->m_ToolSelectionComboBox->currentIndex(), checked); +} + +bool QmitkToolSelectionWidget::IsSelectedToolActivated() +{ + return m_Controls->m_UseToolCheckBox->isChecked(); +} diff --git a/Modules/IGTUI/Qmitk/QmitkToolSelectionWidget.h b/Modules/IGTUI/Qmitk/QmitkToolSelectionWidget.h new file mode 100644 index 0000000000..afa5f32afc --- /dev/null +++ b/Modules/IGTUI/Qmitk/QmitkToolSelectionWidget.h @@ -0,0 +1,134 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-03-21 19:27:37 +0100 (Sa, 21 Mrz 2009) $ +Version: $Revision: 16719 $ + +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 _QmitkToolSelectionWidget_H_INCLUDED +#define _QmitkToolSelectionWidget_H_INCLUDED + +#include "ui_QmitkToolSelectionWidgetControls.h" +#include "MitkIGTUIExports.h" + +#include + + +/*! +\brief QmitkToolSelectionWidget + +Widget for tool selection in an IGT Plugin. Provides a combobx which can be filled with the tool names ( SetToolNames() or AddToolName() ) of a tracking source and a checkbox +whose text can be set with AddCheckBoxText(). Toggeling of the checkbox should be used to activate or inactivate a specific action for the selected tool in the IGT Plugin. + +*/ +class MitkIGTUI_EXPORT QmitkToolSelectionWidget : public QWidget +{ + Q_OBJECT // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) +public: + + + /*! + \brief default constructor + */ + QmitkToolSelectionWidget( QWidget* parent ); + + /*! + \brief default destructor + */ + virtual ~QmitkToolSelectionWidget(); + + /*! + \brief This method returns the current selected index from the tool combobox. + */ + int GetCurrentSelectedIndex(); + + /*! + \brief This method sets the list with names of the available tools to the combobox. This method should be used after the initilization of the tracking source. For correct use make sure that the tool names are in the same order as the tools from the tracking source. + */ + void SetToolNames( const QStringList& toolNames ); + + /*! + \brief This method adds a single tool name at the end of the tool combobox. This method should be used after a tool has been added manually to the tracking source. + */ + void AddToolName( const QString& toolName); + + + /*! + \brief This method changes the tool name in the combobox at the given position. + */ + void ChangeToolName( int index, const QString& toolName ); + + /*! + \brief This method removes a single tool name from the combobox by name. + */ + void RemoveToolName( const QString& toolName ); + + /*! + \brief This method removes a single tool name from the combobox by index. + */ + void RemoveToolName( int index ); + + /*! + \brief This method clears all tool names from the combobox. + */ + void ClearToolNames(); + + /*! + \brief This method sets the text of the use tool checkbox. + */ + void SetCheckboxtText( const QString& text); + + /*! + \brief This method returns whether the use tool checkbox is checked or not. + */ + bool IsSelectedToolActivated(); + +signals: + /*! + \brief This signal is emitted when the checkbox is toggled. It provides the current selected tool id and whether it has been selected or deselected. + */ + void SignalUseTool(int index, bool use); + /*! + \brief This signal is emitted when a different tool is selected in the combo box. + */ + void SignalSelectedToolChanged(int index); + +public slots: + /*! + \brief Enables this widget. + */ + void EnableWidget(); + /*! + \brief Disables this widget. + */ + void DisableWidget(); + + + protected slots: + /*! + \brief Slot which emits the SingalUseTool() after providing it with the tool id. + */ + void CheckBoxToggled(bool checked); + + +protected: +/*! + \brief Creates this widget's signal slot connections. + */ + void CreateConnections(); + void CreateQtPartControl( QWidget *parent ); + Ui::QmitkToolSelectionWidgetControls* m_Controls; ///< gui widgets + +}; +#endif // _QmitkToolSelectionWidget_H_INCLUDED + diff --git a/Modules/IGTUI/Qmitk/QmitkToolSelectionWidgetControls.ui b/Modules/IGTUI/Qmitk/QmitkToolSelectionWidgetControls.ui new file mode 100644 index 0000000000..5427269fcc --- /dev/null +++ b/Modules/IGTUI/Qmitk/QmitkToolSelectionWidgetControls.ui @@ -0,0 +1,57 @@ + + + QmitkToolSelectionWidgetControls + + + + 0 + 0 + 629 + 43 + + + + Form + + + + + + + + Select Tool: + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + use tool for something + + + + + + + + + + + + diff --git a/Modules/IGTUI/files.cmake b/Modules/IGTUI/files.cmake index 96cf6a9ef8..3d14e93b40 100644 --- a/Modules/IGTUI/files.cmake +++ b/Modules/IGTUI/files.cmake @@ -1,54 +1,57 @@ SET(CPP_FILES Qmitk/QmitkTrackingDeviceWidget.cpp Qmitk/QmitkTrackingDeviceConfigurationWidget.cpp Qmitk/QmitkNDIConfigurationWidget.cpp Qmitk/QmitkFiducialRegistrationWidget.cpp Qmitk/QmitkNDIToolDelegate.cpp Qmitk/QmitkNavigationToolManagementWidget.cpp Qmitk/QmitkIGTLoggerWidget.cpp Qmitk/QmitkUpdateTimerWidget.cpp Qmitk/QmitkToolDistanceWidget.cpp Qmitk/QmitkToolTrackingStatusWidget.cpp Qmitk/QmitkTrackingSourcesCheckBoxPanelWidget.cpp Qmitk/QmitkIGTPlayerWidget.cpp Qmitk/QmitkIGTConnectionWidget.cpp + Qmitk/QmitkToolSelectionWidget.cpp ) SET(UI_FILES Qmitk/QmitkNavigationToolManagementWidgetControls.ui Qmitk/QmitkTrackingDeviceConfigurationWidgetControls.ui Qmitk/QmitkNDIConfigurationWidget.ui Qmitk/QmitkFiducialRegistrationWidget.ui Qmitk/QmitkIGTLoggerWidgetControls.ui Qmitk/QmitkUpdateTimerWidgetControls.ui Qmitk/QmitkToolDistanceWidgetControls.ui Qmitk/QmitkToolTrackingStatusWidgetControls.ui Qmitk/QmitkTrackingSourcesCheckBoxPanelWidgetControls.ui Qmitk/QmitkIGTPlayerWidgetControls.ui Qmitk/QmitkIGTConnectionWidgetControls.ui + Qmitk/QmitkToolSelectionWidgetControls.ui ) SET(MOC_H_FILES Qmitk/QmitkNavigationToolManagementWidget.h Qmitk/QmitkTrackingDeviceWidget.h Qmitk/QmitkTrackingDeviceConfigurationWidget.h Qmitk/QmitkNDIConfigurationWidget.h Qmitk/QmitkFiducialRegistrationWidget.h Qmitk/QmitkNDIToolDelegate.h Qmitk/QmitkIGTLoggerWidget.h Qmitk/QmitkUpdateTimerWidget.h Qmitk/QmitkToolDistanceWidget.h Qmitk/QmitkToolTrackingStatusWidget.h Qmitk/QmitkTrackingSourcesCheckBoxPanelWidget.h Qmitk/QmitkIGTPlayerWidget.h Qmitk/QmitkIGTConnectionWidget.h + Qmitk/QmitkToolSelectionWidget.h ) SET(QRC_FILES resources/IGTUI.qrc )