19 #include <QMessageBox>
23 : QWidget(parent), m_Controls(NULL), m_SourceCheckboxes(NULL), m_NavigationDatas(NULL), m_SelectedIds(NULL)
32 delete m_SourceCheckboxes;
33 delete m_NavigationDatas;
41 m_Controls =
new Ui::QmitkTrackingSourcesCheckBoxPanelWidgetControls;
57 if( navDatas != NULL )
58 m_NavigationDatas = navDatas;
64 if(m_NavigationDatas == NULL)
65 m_NavigationDatas =
new std::vector<mitk::NavigationData::Pointer>();
68 m_NavigationDatas->push_back(nd);
72 return m_Controls->m_ActionButton->isChecked();
78 if(m_SelectedIds == NULL)
79 m_SelectedIds =
new std::vector<int>();
81 m_SelectedIds->clear();
83 for (
unsigned int i=0; i < m_SourceCheckboxes->size(); i++)
85 if(m_SourceCheckboxes->at(i)->isChecked())
86 m_SelectedIds->push_back(i);
96 QWidget* actWidget =
m_Controls->m_GridLayout->itemAt(0)->widget();
97 m_Controls->m_GridLayout->removeWidget(actWidget);
101 if(m_SourceCheckboxes != NULL)
102 m_SourceCheckboxes->clear();
104 if(m_NavigationDatas != NULL)
105 m_NavigationDatas->clear();
112 if(m_SelectedIds != NULL && !m_SelectedIds->empty())
113 m_SelectedIds->clear();
118 if( m_SourceCheckboxes != NULL )
119 m_SourceCheckboxes->clear();
121 if( m_NavigationDatas == NULL )
129 for(
unsigned int i=0; i < m_NavigationDatas->size(); i++)
135 QString name(m_NavigationDatas->at(i).GetPointer()->GetName());
137 checkBox =
new QCheckBox(name,
this);
139 connect( checkBox, SIGNAL(toggled(
bool)),
this , SLOT(
OnCheckboxClicked(
bool)) );
141 m_SourceCheckboxes->push_back(checkBox);
142 m_Controls->m_GridLayout->addWidget(checkBox,row,column);
150 for(
unsigned int i=0; i< m_SourceCheckboxes->size(); i++)
152 m_SourceCheckboxes->at(i)->setEnabled(enable);
158 for(
unsigned int i=0; i< m_SourceCheckboxes->size(); i++)
160 m_SourceCheckboxes->at(i)->setChecked(
true);
166 for(
unsigned int i=0; i< m_SourceCheckboxes->size(); i++)
168 m_SourceCheckboxes->at(i)->setChecked(
false);
174 m_SourceCheckboxes->at(idx)->setChecked(
true);
179 m_SourceCheckboxes->at(idx)->setChecked(
false);
185 QCheckBox* sender = qobject_cast< QCheckBox* > (QObject::sender());
188 throw std::invalid_argument(
"No sender found!");
192 for(
unsigned int i=0 ;i < m_SourceCheckboxes->size(); i++)
194 if(sender == m_SourceCheckboxes->at(i))
233 m_Controls->m_ActionButton->setCheckable(
true);
235 m_Controls->m_ActionButton->setCheckable(
false);
242 m_Controls->m_ActionButton->setChecked(
false);
248 bool invalidND =
false;
252 if(!(m_NavigationDatas->at(this->GetSelectedTrackingSourcesIDs()->at(i))->IsDataValid()))
258 QMessageBox::warning(NULL,
"Invalid Tracking Data",
"One or more instruments are in invalid tracking state! Requested action can not be performed!");
259 m_Controls->m_ActionButton->setChecked(
false);
271 m_Controls->m_ActionButton->setChecked(
false);
itk::SmartPointer< Self > Pointer