Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkToolSelectionWidget.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
18 
19 
20 
22 : QWidget(parent), m_Controls(nullptr)
23 {
24  this->CreateQtPartControl( this );
25 }
26 
28 {
29  m_Controls = nullptr;
30 }
31 
32 
34 {
35  if (!m_Controls)
36  {
37  // create GUI widgets
38  m_Controls = new Ui::QmitkToolSelectionWidgetControls;
39  m_Controls->setupUi(parent);
40  this->CreateConnections();
41  }
42 }
43 
44 
46 {
47  connect ( m_Controls->m_UseToolCheckBox, SIGNAL(toggled(bool)), this, SLOT(CheckBoxToggled(bool)) );
48  //connect ( m_Controls->m_ToolSelectionComboBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(void SelectedToolChanged(int)) );
49 
50  //connect( (QObject*)(m_Controls->m_StartNavigationBtn), SIGNAL(clicked()), this, SLOT(OnStartTimer()) );
51  //connect( (QObject*)(m_Controls->m_StopNavigationBtn), SIGNAL(clicked()), this, SLOT(OnStopTimer()) );
52  //connect( m_Controls->m_UpdateRateSB, SIGNAL(valueChanged(int)), this, SLOT(OnChangeTimerInterval(int)) );
53 }
54 
55 
57 {
58  return m_Controls->m_ToolSelectionComboBox->currentIndex();
59 }
60 
61 void QmitkToolSelectionWidget::SetToolNames( const QStringList& toolNames )
62 {
63  m_Controls->m_ToolSelectionComboBox->addItems(toolNames);
64 }
65 
66 void QmitkToolSelectionWidget::AddToolName( const QString& toolName)
67 {
68  m_Controls->m_ToolSelectionComboBox->addItem(toolName);
69 }
70 
71 void QmitkToolSelectionWidget::ChangeToolName( int index, const QString& toolName )
72 {
73  m_Controls->m_ToolSelectionComboBox->insertItem(index, toolName);
74 }
75 
76 void QmitkToolSelectionWidget::RemoveToolName( const QString& toolName )
77 {
78  for(int i=0; i < m_Controls->m_ToolSelectionComboBox->count(); ++i)
79  {
80  if(m_Controls->m_ToolSelectionComboBox->itemText(i).compare(toolName) == 0)
81  m_Controls->m_ToolSelectionComboBox->removeItem(i);
82  }
83 }
84 
86 {
87  m_Controls->m_ToolSelectionComboBox->removeItem(index);
88 }
89 
91 {
92  m_Controls->m_ToolSelectionComboBox->clear();
93 }
94 
95 
97 {
98  m_Controls->m_UseToolCheckBox->setText(text);
99 }
100 
102 {
103  this->setEnabled( true );
104 }
105 
107 {
108  this->setEnabled( false );
109 }
110 
111 
113 {
114  if(checked)
115  m_Controls->m_ToolSelectionComboBox->setEnabled(false);
116  else
117  m_Controls->m_ToolSelectionComboBox->setEnabled(true);
118 
119  emit SignalUseTool(m_Controls->m_ToolSelectionComboBox->currentIndex(), checked);
120 }
121 
123 {
124  return m_Controls->m_UseToolCheckBox->isChecked();
125 }
void CreateConnections()
Creates this widget's signal slot connections.
bool IsSelectedToolActivated()
This method returns whether the use tool checkbox is checked or not.
void CreateQtPartControl(QWidget *parent)
void ChangeToolName(int index, const QString &toolName)
This method changes the tool name in the combobox at the given position.
Ui::QmitkToolSelectionWidgetControls * m_Controls
gui widgets
void AddToolName(const QString &toolName)
This method adds a single tool name at the end of the tool combobox. This method should be used after...
void SetToolNames(const QStringList &toolNames)
This method sets the list with names of the available tools to the combobox. This method should be us...
void SignalUseTool(int index, bool use)
This signal is emitted when the checkbox is toggled. It provides the current selected tool id and whe...
void RemoveToolName(const QString &toolName)
This method removes a single tool name from the combobox by name.
void ClearToolNames()
This method clears all tool names from the combobox.
void DisableWidget()
Disables this widget.
int GetCurrentSelectedIndex()
This method returns the current selected index from the tool combobox.
virtual ~QmitkToolSelectionWidget()
default destructor
void SetCheckboxtText(const QString &text)
This method sets the text of the use tool checkbox.
void CheckBoxToggled(bool checked)
Slot which emits the SingalUseTool() after providing it with the tool id.
QmitkToolSelectionWidget(QWidget *parent)
default constructor
void EnableWidget()
Enables this widget.