diff --git a/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.cpp b/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.cpp index 11bdda4815..46bfb1c4ec 100644 --- a/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.cpp +++ b/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.cpp @@ -1,141 +1,162 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-03-21 19:27:37 +0100 (Sa, 21 Mrz 2009) $ Version: $Revision: 16719 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "QmitkToolTrackingStatusWidget.h" QmitkToolTrackingStatusWidget::QmitkToolTrackingStatusWidget(QWidget* parent) : QWidget(parent), m_Controls(NULL), m_StatusLabels (NULL), m_NavigationDatas(NULL) { this->CreateQtPartControl( this ); + m_ShowPositions = false; + m_Alignment = Qt::AlignHCenter; +} + +void QmitkToolTrackingStatusWidget::SetShowPositions(bool enable) +{ + m_ShowPositions = enable; +} + +void QmitkToolTrackingStatusWidget::SetTextAlignment(Qt::AlignmentFlag alignment) +{ + m_Alignment = alignment; } QmitkToolTrackingStatusWidget::~QmitkToolTrackingStatusWidget() { //m_Controls = NULL; delete m_StatusLabels; delete m_NavigationDatas; } void QmitkToolTrackingStatusWidget::CreateQtPartControl(QWidget *parent) { if (!m_Controls) { // create GUI widgets m_Controls = new Ui::QmitkToolTrackingStatusWidgetControls; m_Controls->setupUi(parent); this->CreateConnections(); } } void QmitkToolTrackingStatusWidget::CreateConnections() { } void QmitkToolTrackingStatusWidget::SetNavigationDatas(std::vector* navDatas) { m_NavigationDatas = navDatas; } void QmitkToolTrackingStatusWidget::AddNavigationData(mitk::NavigationData::Pointer nd) { if(m_NavigationDatas == NULL) m_NavigationDatas = new std::vector(); m_NavigationDatas->push_back(nd); } void QmitkToolTrackingStatusWidget::Refresh() { if(m_NavigationDatas == NULL || m_NavigationDatas->size() <= 0) return; mitk::NavigationData* navData; for(unsigned int i = 0; i < m_NavigationDatas->size(); i++) { navData = m_NavigationDatas->at(i).GetPointer(); QString name(navData->GetName()); + QString pos = ""; + if (m_ShowPositions) + { + mitk::Point3D position = navData->GetPosition(); + pos = " [" + QString::number(position[0]) + ";" + QString::number(position[1]) + ";" + QString::number(position[2]) + "]"; + } if(name.compare(m_StatusLabels->at(i)->text()) == 0) { + m_StatusLabels->at(i)->setText(name+pos); if(navData->IsDataValid()) m_StatusLabels->at(i)->setStyleSheet("QLabel{background-color: #8bff8b }"); + else m_StatusLabels->at(i)->setStyleSheet("QLabel{background-color: #ff7878 }"); } } } void QmitkToolTrackingStatusWidget::ShowStatusLabels() { if(m_NavigationDatas == NULL || m_NavigationDatas->size() <= 0) return; m_StatusLabels = new QVector(); mitk::NavigationData* navData; QLabel* label; for(unsigned int i = 0; i < m_NavigationDatas->size(); i++) { navData = m_NavigationDatas->at(i).GetPointer(); QString name(navData->GetName()); + std::cout << "Name: " <setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); + label->setAlignment(m_Alignment | Qt::AlignVCenter); label->setFrameStyle(QFrame::Panel | QFrame::Sunken); m_StatusLabels->append(label); m_Controls->m_GridLayout->addWidget(m_StatusLabels->at(i),0,i); } } void QmitkToolTrackingStatusWidget::RemoveStatusLabels() { while(m_Controls->m_GridLayout->count() > 0) { QWidget* actWidget = m_Controls->m_GridLayout->itemAt(0)->widget(); m_Controls->m_GridLayout->removeWidget(actWidget); delete actWidget; } if(m_StatusLabels != NULL && m_StatusLabels->size() > 0) m_StatusLabels->clear(); if(m_NavigationDatas != NULL && m_NavigationDatas->size() > 0) m_NavigationDatas->clear(); } diff --git a/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.h b/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.h index ab8bb69cb6..f75006fa97 100644 --- a/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.h @@ -1,97 +1,107 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-03-21 19:27:37 +0100 (Sa, 21 Mrz 2009) $ Version: $Revision: 16719 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _QmitkToolTrackingStatusWidget_H_INCLUDED #define _QmitkToolTrackingStatusWidget_H_INCLUDED #include "ui_QmitkToolTrackingStatusWidgetControls.h" #include "MitkIGTUIExports.h" #include #include #include /*! \brief QmitkToolTrackingStatusWidget Widget for setting up and controlling an update timer in an IGT-Pipeline. */ class MitkIGTUI_EXPORT QmitkToolTrackingStatusWidget : public QWidget { Q_OBJECT // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) public: typedef std::vector< mitk::NavigationData::Pointer > NavigationDataPointerArray; /*! \brief default constructor */ QmitkToolTrackingStatusWidget( QWidget* parent ); /*! \brief default destructor */ virtual ~QmitkToolTrackingStatusWidget(); /*! \brief Sets up the labels in this widget's QGridLayout for showing the track status of the tracking tools */ void ShowStatusLabels(); /*! \brief Sets the ND for this widget */ void SetNavigationDatas(std::vector* navDatas); void AddNavigationData(mitk::NavigationData::Pointer nd); /*! \brief Changes background color of status labels (green or red) to show if actual navigation data of each tool is valid. */ void Refresh(); /*! \brief Removes all status labels. */ void RemoveStatusLabels(); + /** @brief Enables / disables if the tool positions are shown. Default is off.*/ + void SetShowPositions(bool enable); + + /** @brief Sets the text alignment of the tool labels. Default is center. Example: Use Qt::AlignLeft for left alignment. */ + void SetTextAlignment(Qt::AlignmentFlag alignment); + protected: void CreateConnections(); void CreateQtPartControl( QWidget *parent ); Ui::QmitkToolTrackingStatusWidgetControls* m_Controls; ///< gui widgets private: /*! \brief Vector for all tool tracking status labels. */ QVector< QLabel* >* m_StatusLabels; std::vector* m_NavigationDatas; + bool m_ShowPositions; + + Qt::AlignmentFlag m_Alignment; + }; #endif // _QmitkToolTrackingStatusWidget_H_INCLUDED diff --git a/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidgetControls.ui b/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidgetControls.ui index bb7560bf33..103463f0f3 100644 --- a/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidgetControls.ui +++ b/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidgetControls.ui @@ -1,37 +1,37 @@ QmitkToolTrackingStatusWidgetControls 0 0 361 - 177 + 195 Form + + + Qt::Vertical 20 40 - - -