19 #include <QGridLayout>
20 #include <itkDataObject.h>
28 : QWidget(parent), m_Controls(NULL), m_DistanceLabels(NULL)
36 delete m_DistanceLabels;
37 m_DistanceLabels = NULL;
46 m_Controls =
new Ui::QmitkToolDistanceWidgetControls;
48 m_Controls->m_StatusLabel->setText(QString(
"No tracking tools connected. Please set up a connection first."));
62 if(outputs.size() > 1)
69 if(m_DistanceLabels == NULL)
74 if(m_DistanceLabels->isEmpty())
82 for (
unsigned int i = 0; i < outputs.size()-1; i++)
85 label =
new QLabel(navData->
GetName(),
this);
86 label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
87 this->
m_Controls->m_GridLayout->addWidget(label,i+1,0);
90 label =
new QLabel(navData->
GetName(),
this);
91 label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
92 this->
m_Controls->m_GridLayout->addWidget(label,0,i+1);
96 for(
unsigned int i = 0; i < outputs.size()-1; i++)
98 QVector<QLabel*>* rowDistances =
new QVector<QLabel*>();
100 for(
unsigned int j = i+1; j < outputs.size(); j++)
103 label =
new QLabel(QString(
"---"),
this);
104 label->setFrameStyle(QFrame::Box | QFrame::Sunken);
105 label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
106 rowDistances->append(label);
109 this->
m_Controls->m_GridLayout->addWidget(label,i+1,j);
111 this->m_DistanceLabels->append(*rowDistances);
117 this->
m_Controls->m_StatusLabel->setText(QString(
"For distance information please connect at least two tools"));
130 for(
int i=0; i < m_DistanceLabels->size(); i++)
134 for(
int k=0; k < m_DistanceLabels->at(i).size(); k++)
139 if(navData == NULL || nextNavData == NULL)
142 mitk::NavigationData::PositionType::RealType distance = navData->
GetPosition().EuclideanDistanceTo(nextNavData->
GetPosition());
143 distance = floor(distance * 10.) / 10.;
151 distanceStr.setNum(distance);
152 distanceStr +=
" mm";
154 this->m_DistanceLabels->at(i).at(k)->setText(distanceStr);
164 QWidget* widget =
m_Controls->m_GridLayout->itemAt(0)->widget();
165 m_Controls->m_GridLayout->removeWidget(widget);
168 delete this->m_DistanceLabels;
169 this->m_DistanceLabels = NULL;
171 this->
m_Controls->m_StatusLabel->setText(QString(
"For distance information please set up the connection again."));
177 for(
int i = 0; i < m_DistanceLabels->size(); i++)
179 for(
int j= 0; j < m_DistanceLabels->at(i).size(); j++)
181 this->m_DistanceLabels->at(i).at(j)->setText(QString(
"---"));
virtual const char * GetName() const
returns the name of the NavigationData object
virtual bool IsDataValid() const
returns true if the object contains valid data
virtual PositionType GetPosition() const
returns position of the NavigationData object