Public Types | Public Slots | Public Member Functions | Protected Member Functions | Protected Attributes

QmitkToolDistanceWidget Class Reference

QmitkToolDistanceWidget. More...

#include <QmitkToolDistanceWidget.h>

Collaboration diagram for QmitkToolDistanceWidget:
Collaboration graph
[legend]

List of all members.

Public Types

typedef QVector< QVector
< QLabel * > > 
DistanceLabelType

Public Slots

void SetDistanceLabelValuesInvalid ()
 This method set's all distance entries in the matrix to "---". Can be used e.g. if tracking is stopped.

Public Member Functions

 QmitkToolDistanceWidget (QWidget *parent)
 default constructor
virtual ~QmitkToolDistanceWidget ()
 default destructor
void ShowDistanceValues (itk::ProcessObject::DataObjectPointerArray &outputs)
 This method displays the matrix with the distances between the tracking source's outputs in a QGridLayout.
void CreateToolDistanceMatrix (itk::ProcessObject::DataObjectPointerArray &outputs)
 This method creates the initial distances matrix and labels it with the connected tool names.
void ClearDistanceMatrix ()
 This method clears the whole tool distances matrix.

Protected Member Functions

void CreateConnections ()
void CreateQtPartControl (QWidget *parent)

Protected Attributes

Ui::QmitkToolDistanceWidgetControlsm_Controls
 gui widgets

Detailed Description

QmitkToolDistanceWidget.

Widget for setting up and controlling an update timer in an IGT-Pipeline.

Definition at line 38 of file QmitkToolDistanceWidget.h.


Member Typedef Documentation

typedef QVector<QVector<QLabel*> > QmitkToolDistanceWidget::DistanceLabelType

Definition at line 43 of file QmitkToolDistanceWidget.h.


Constructor & Destructor Documentation

QmitkToolDistanceWidget::QmitkToolDistanceWidget ( QWidget *  parent )

default constructor

Definition at line 28 of file QmitkToolDistanceWidget.cpp.

References CreateQtPartControl().

: QWidget(parent), m_Controls(NULL), m_DistanceLabels(NULL)
{
  this->CreateQtPartControl( this );
}
QmitkToolDistanceWidget::~QmitkToolDistanceWidget (  ) [virtual]

default destructor

Definition at line 34 of file QmitkToolDistanceWidget.cpp.

References ClearDistanceMatrix(), and m_Controls.

{
  ClearDistanceMatrix();
  delete m_DistanceLabels;
  m_DistanceLabels = NULL;
  m_Controls = NULL;
}

Member Function Documentation

void QmitkToolDistanceWidget::ClearDistanceMatrix (  )

This method clears the whole tool distances matrix.

Definition at line 160 of file QmitkToolDistanceWidget.cpp.

References m_Controls, Ui_QmitkToolDistanceWidgetControls::m_GridLayout, and Ui_QmitkToolDistanceWidgetControls::m_StatusLabel.

Referenced by QmitkToolPairNavigationView::Disconnected(), and ~QmitkToolDistanceWidget().

  {

    while(m_Controls->m_GridLayout->count() > 0)
    {
      QWidget* widget = m_Controls->m_GridLayout->itemAt(0)->widget();
      m_Controls->m_GridLayout->removeWidget(widget);
      delete widget;
    }
   delete this->m_DistanceLabels;
   this->m_DistanceLabels = NULL;

   this->m_Controls->m_StatusLabel->setText(QString("For distance information please set up the connection again."));
 
  }
void QmitkToolDistanceWidget::CreateConnections (  ) [protected]

Definition at line 55 of file QmitkToolDistanceWidget.cpp.

Referenced by CreateQtPartControl().

{

}
void QmitkToolDistanceWidget::CreateQtPartControl ( QWidget *  parent ) [protected]

Definition at line 42 of file QmitkToolDistanceWidget.cpp.

References CreateConnections(), m_Controls, Ui_QmitkToolDistanceWidgetControls::m_StatusLabel, and Ui_QmitkToolDistanceWidgetControls::setupUi().

Referenced by QmitkToolDistanceWidget().

{
  if (!m_Controls)
  {
    // create GUI widgets
    m_Controls = new Ui::QmitkToolDistanceWidgetControls;
    m_Controls->setupUi(parent);
    m_Controls->m_StatusLabel->setText(QString("No tracking tools connected. Please set up a connection first."));

    this->CreateConnections();
  }
}
void QmitkToolDistanceWidget::CreateToolDistanceMatrix ( itk::ProcessObject::DataObjectPointerArray &  outputs )

This method creates the initial distances matrix and labels it with the connected tool names.

Definition at line 60 of file QmitkToolDistanceWidget.cpp.

References mitk::NavigationData::GetName(), m_Controls, Ui_QmitkToolDistanceWidgetControls::m_GridLayout, and Ui_QmitkToolDistanceWidgetControls::m_StatusLabel.

Referenced by QmitkToolPairNavigationView::StartNavigation().

{

  if(outputs.size() > 1)
  {
    this->show();

    mitk::NavigationData* navData; 


    if(m_DistanceLabels == NULL)
    {
      m_DistanceLabels = new DistanceLabelType;
    }

    if(m_DistanceLabels->isEmpty()) 
    {
      this->m_Controls->m_StatusLabel->setText("");

      QLabel* label;


      // labeling of matrix
      for (unsigned int i = 0; i < outputs.size()-1; i++)
      { 
        navData = dynamic_cast<mitk::NavigationData*>(outputs.at(i).GetPointer());
        label = new QLabel(navData->GetName(),this);
        label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
        this->m_Controls->m_GridLayout->addWidget(label,i+1,0);

        navData = dynamic_cast<mitk::NavigationData*>(outputs.at(i+1).GetPointer());
        label = new QLabel(navData->GetName(),this);
        label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
        this->m_Controls->m_GridLayout->addWidget(label,0,i+1);
      }


      for(unsigned int i = 0; i < outputs.size()-1; i++)
      {
        QVector<QLabel*>* rowDistances = new QVector<QLabel*>();

        for(unsigned int j = i+1; j < outputs.size(); j++) 
        {
          // distance labels initializing
          label = new QLabel(QString("---"), this);
          label->setFrameStyle(QFrame::Box | QFrame::Sunken);
          label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
          rowDistances->append(label);

          //initial distance label adding to the QGridLayout
          this->m_Controls->m_GridLayout->addWidget(label,i+1,j);
        }
        this->m_DistanceLabels->append(*rowDistances);
      }
    }
  }
  else
  {
    this->m_Controls->m_StatusLabel->setText(QString("For distance information please connect at least two tools"));
  }

}
void QmitkToolDistanceWidget::SetDistanceLabelValuesInvalid (  ) [slot]

This method set's all distance entries in the matrix to "---". Can be used e.g. if tracking is stopped.

Definition at line 176 of file QmitkToolDistanceWidget.cpp.

  {
    for(int i = 0; i < m_DistanceLabels->size(); i++)
    {
      for(int j= 0; j < m_DistanceLabels->at(i).size(); j++)
      {
        this->m_DistanceLabels->at(i).at(j)->setText(QString("---"));
      }
    }
  }
void QmitkToolDistanceWidget::ShowDistanceValues ( itk::ProcessObject::DataObjectPointerArray &  outputs )

This method displays the matrix with the distances between the tracking source's outputs in a QGridLayout.

Definition at line 125 of file QmitkToolDistanceWidget.cpp.

References QuadProgPP::distance(), mitk::NavigationData::GetPosition(), and mitk::NavigationData::IsDataValid().

Referenced by QmitkToolPairNavigationView::RenderScene().

  {

    mitk::NavigationData* navData; 
    mitk::NavigationData* nextNavData;

    for(int i=0; i < m_DistanceLabels->size(); i++)
    {
      int j = i+1;

      for(int k=0; k < m_DistanceLabels->at(i).size(); k++)
      {
        navData = dynamic_cast<mitk::NavigationData*>(outputs.at(i).GetPointer());
        nextNavData = dynamic_cast<mitk::NavigationData*>(outputs.at(j++).GetPointer());

        if(navData == NULL || nextNavData == NULL)
          return;

        mitk::NavigationData::PositionType::RealType distance =  navData->GetPosition().EuclideanDistanceTo(nextNavData->GetPosition());
        distance = floor(distance * 10.) / 10.;
        QString distanceStr;
        if(!navData->IsDataValid() || !nextNavData->IsDataValid()) 
        {
          distanceStr = "---";
        }
        else
        {
          distanceStr.setNum(distance);
          distanceStr += " mm";
        }
        this->m_DistanceLabels->at(i).at(k)->setText(distanceStr);
      }
    }
  }

Member Data Documentation


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines