Medical Imaging Interaction Toolkit  2018.4.99-389bf124
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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 
15 
16 
18 : QWidget(parent), m_Controls(nullptr)
19 {
20  this->CreateQtPartControl( this );
21 }
22 
24 {
25  m_Controls = nullptr;
26 }
27 
28 
30 {
31  if (!m_Controls)
32  {
33  // create GUI widgets
34  m_Controls = new Ui::QmitkToolSelectionWidgetControls;
35  m_Controls->setupUi(parent);
36  this->CreateConnections();
37  }
38 }
39 
40 
42 {
43  connect ( m_Controls->m_UseToolCheckBox, SIGNAL(toggled(bool)), this, SLOT(CheckBoxToggled(bool)) );
44  //connect ( m_Controls->m_ToolSelectionComboBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(void SelectedToolChanged(int)) );
45 
46  //connect( (QObject*)(m_Controls->m_StartNavigationBtn), SIGNAL(clicked()), this, SLOT(OnStartTimer()) );
47  //connect( (QObject*)(m_Controls->m_StopNavigationBtn), SIGNAL(clicked()), this, SLOT(OnStopTimer()) );
48  //connect( m_Controls->m_UpdateRateSB, SIGNAL(valueChanged(int)), this, SLOT(OnChangeTimerInterval(int)) );
49 }
50 
51 
53 {
54  return m_Controls->m_ToolSelectionComboBox->currentIndex();
55 }
56 
57 void QmitkToolSelectionWidget::SetToolNames( const QStringList& toolNames )
58 {
59  m_Controls->m_ToolSelectionComboBox->addItems(toolNames);
60 }
61 
62 void QmitkToolSelectionWidget::AddToolName( const QString& toolName)
63 {
64  m_Controls->m_ToolSelectionComboBox->addItem(toolName);
65 }
66 
67 void QmitkToolSelectionWidget::ChangeToolName( int index, const QString& toolName )
68 {
69  m_Controls->m_ToolSelectionComboBox->insertItem(index, toolName);
70 }
71 
72 void QmitkToolSelectionWidget::RemoveToolName( const QString& toolName )
73 {
74  for(int i=0; i < m_Controls->m_ToolSelectionComboBox->count(); ++i)
75  {
76  if(m_Controls->m_ToolSelectionComboBox->itemText(i).compare(toolName) == 0)
77  m_Controls->m_ToolSelectionComboBox->removeItem(i);
78  }
79 }
80 
82 {
83  m_Controls->m_ToolSelectionComboBox->removeItem(index);
84 }
85 
87 {
88  m_Controls->m_ToolSelectionComboBox->clear();
89 }
90 
91 
93 {
94  m_Controls->m_UseToolCheckBox->setText(text);
95 }
96 
98 {
99  this->setEnabled( true );
100 }
101 
103 {
104  this->setEnabled( false );
105 }
106 
107 
109 {
110  if(checked)
111  m_Controls->m_ToolSelectionComboBox->setEnabled(false);
112  else
113  m_Controls->m_ToolSelectionComboBox->setEnabled(true);
114 
115  emit SignalUseTool(m_Controls->m_ToolSelectionComboBox->currentIndex(), checked);
116 }
117 
119 {
120  return m_Controls->m_UseToolCheckBox->isChecked();
121 }
void CreateConnections()
Creates this widget&#39;s signal slot connections.
bool IsSelectedToolActivated()
This method returns whether the use tool checkbox is checked or not.
~QmitkToolSelectionWidget() override
default destructor
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.
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.