diff --git a/Modules/IGTUI/Qmitk/QmitkFiducialRegistrationWidget.cpp b/Modules/IGTUI/Qmitk/QmitkFiducialRegistrationWidget.cpp index 8c068c0fe3..ed08a08ffe 100644 --- a/Modules/IGTUI/Qmitk/QmitkFiducialRegistrationWidget.cpp +++ b/Modules/IGTUI/Qmitk/QmitkFiducialRegistrationWidget.cpp @@ -1,174 +1,180 @@ /*========================================================================= 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 "QmitkFiducialRegistrationWidget.h" #define FRW_LOG MITK_INFO("Fiducial Registration Widget") #define FRW_WARN MITK_WARN("Fiducial Registration Widget") #define FRW_DEBUG MITK_DEBUG("Fiducial Registration Widget") /* VIEW MANAGEMENT */ QmitkFiducialRegistrationWidget::QmitkFiducialRegistrationWidget(QWidget* parent) : QWidget(parent), m_Controls(NULL),m_MultiWidget(NULL), m_ImageFiducialsNode(NULL), m_TrackerFiducialsNode(NULL) { CreateQtPartControl(this); } QmitkFiducialRegistrationWidget::~QmitkFiducialRegistrationWidget() { m_Controls = NULL; } void QmitkFiducialRegistrationWidget::CreateQtPartControl(QWidget *parent) { if (!m_Controls) { // create GUI widgets m_Controls = new Ui::QmitkFiducialRegistrationWidget; m_Controls->setupUi(parent); // hide additional image fiducial button m_Controls->m_AddImageFiducialBtn->setHidden(true); this->CreateConnections(); } } void QmitkFiducialRegistrationWidget::CreateConnections() { connect( (QObject*)(m_Controls->m_AddTrackingFiducialBtn), SIGNAL(clicked()), this, SIGNAL(AddedTrackingFiducial()) ); connect( (QObject*)(m_Controls->m_AddImageFiducialBtn), SIGNAL(clicked()), this, SIGNAL(AddedImageFiducial()) ); connect( (QObject*)(m_Controls->m_RegisterFiducialsBtn), SIGNAL(clicked()), this, SIGNAL(PerformFiducialRegistration()) ); connect( (QObject*)(m_Controls->m_UseICPRegistration), SIGNAL(toggled(bool)), this, SIGNAL(FindFiducialCorrespondences(bool)) ); } void QmitkFiducialRegistrationWidget::SetWidgetAppearanceMode(WidgetAppearanceMode widgetMode) { if (widgetMode==LANDMARKMODE) { this->HideContinousRegistrationRadioButton(true); this->HideStaticRegistrationRadioButton(true); this->HideUseICPRegistrationCheckbox(true); this->HideImageFiducialButton(false); this->m_Controls->registrationGroupBox->setTitle(""); this->m_Controls->sourceLandmarksGroupBox->setTitle("Target/Reference landmarks"); this->m_Controls->targetLandmarksGroupBox->setTitle("Source Landmarks"); this->m_Controls->m_AddImageFiducialBtn->setText("Add target landmark"); this->m_Controls->m_AddTrackingFiducialBtn->setText("Add source landmark"); } else if (widgetMode==FIDUCIALMODE) { this->HideContinousRegistrationRadioButton(false); this->HideStaticRegistrationRadioButton(false); this->HideUseICPRegistrationCheckbox(false); this->HideImageFiducialButton(true); this->m_Controls->registrationGroupBox->setTitle("Select fiducials in image and OR (world)"); this->m_Controls->sourceLandmarksGroupBox->setTitle("Image fiducials"); this->m_Controls->targetLandmarksGroupBox->setTitle("OR fiducials"); this->m_Controls->m_AddImageFiducialBtn->setText("Add image fiducial"); this->m_Controls->m_AddTrackingFiducialBtn->setText("Add current instrument position"); } } void QmitkFiducialRegistrationWidget::SetQualityDisplayText( QString text ) { if (text == NULL) return; m_Controls->m_RegistrationQualityDisplay->setText(text); // set text on the QLabel } bool QmitkFiducialRegistrationWidget::UseICPIsChecked() { if(m_Controls->m_UseICPRegistration->isChecked()) return true; else return false; } void QmitkFiducialRegistrationWidget::SetImageFiducialsNode( mitk::DataNode::Pointer imageFiducialsNode ) { if(imageFiducialsNode.IsNull()) { FRW_WARN<< "tracker fiducial node is NULL"; return; } if(m_MultiWidget == NULL) { FRW_WARN<< "stdMultiWidget is NULL"; return; } m_Controls->m_RegistrationImagePoints->SetMultiWidget(m_MultiWidget); // pass multiWidget to pointListWidget m_Controls->m_RegistrationImagePoints->SetPointSetNode(imageFiducialsNode); // pass node to pointListWidget } void QmitkFiducialRegistrationWidget::SetTrackerFiducialsNode( mitk::DataNode::Pointer trackerFiducialsNode ) { if(trackerFiducialsNode.IsNull()) { FRW_WARN<< "tracker fiducial node is NULL"; return; } if(m_MultiWidget == NULL) { FRW_WARN<< "stdMultiWidget is NULL"; return; } m_Controls->m_RegistrationTrackingPoints->SetMultiWidget(m_MultiWidget); // pass multiWidget to pointListWidget m_Controls->m_RegistrationTrackingPoints->SetPointSetNode(trackerFiducialsNode); // pass node to pointListWidget } void QmitkFiducialRegistrationWidget::SetMultiWidget( QmitkStdMultiWidget* multiWidget ) { m_MultiWidget=multiWidget; } mitk::DataNode::Pointer QmitkFiducialRegistrationWidget::GetImageFiducialsNode() { return m_ImageFiducialsNode; } mitk::DataNode::Pointer QmitkFiducialRegistrationWidget::GetTrackerFiducialsNode() { return m_TrackerFiducialsNode; } void QmitkFiducialRegistrationWidget::HideStaticRegistrationRadioButton( bool on ) { m_Controls->m_rbStaticRegistration->setHidden(on); } void QmitkFiducialRegistrationWidget::HideContinousRegistrationRadioButton( bool on ) { m_Controls->m_rbContinousRegistration->setHidden(on); } void QmitkFiducialRegistrationWidget::HideUseICPRegistrationCheckbox( bool on ) { m_Controls->m_UseICPRegistration->setHidden(on); } void QmitkFiducialRegistrationWidget::HideImageFiducialButton( bool on ) { m_Controls->m_AddImageFiducialBtn->setHidden(on); } + +void QmitkFiducialRegistrationWidget::HideTrackingFiducialButton( bool on ) +{ + m_Controls->m_AddTrackingFiducialBtn->setHidden(on); +} + diff --git a/Modules/IGTUI/Qmitk/QmitkFiducialRegistrationWidget.h b/Modules/IGTUI/Qmitk/QmitkFiducialRegistrationWidget.h index 5df90dc306..0c31ff3ea1 100644 --- a/Modules/IGTUI/Qmitk/QmitkFiducialRegistrationWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkFiducialRegistrationWidget.h @@ -1,92 +1,94 @@ /*========================================================================= 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 _QmitkFiducialRegistrationWidget_H_INCLUDED #define _QmitkFiducialRegistrationWidget_H_INCLUDED #include "ui_QmitkFiducialRegistrationWidget.h" #include "QmitkStdMultiWidget.h" #include "MitkIGTUIExports.h" /*! * \brief IGT Fiducial Registration Widget * * Widget used to set fiducial landmarks in the image and to confirm the corresponding landmarks on the world object (patient/phantom). * * SetImageFiducialsNode(), SetTrackerFiducialsNode() and SetMultiWidget() must be called, otherwise QmitkPointListWidget can not work. * * * * \sa IGT */ class MitkIGTUI_EXPORT QmitkFiducialRegistrationWidget : public QWidget { Q_OBJECT // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) public: QmitkFiducialRegistrationWidget(QWidget* parent); virtual ~QmitkFiducialRegistrationWidget(); /*! \brief enumeration to specify the appearance of the widget. 'FIDUCIALMODE' is likely to be used for (tracking) fiducial based registration purposes 'LANDMARKMODE' can be used for any kind of landmark based registration (source landmarks -> target/reference landmarks) */ enum WidgetAppearanceMode { FIDUCIALMODE, LANDMARKMODE }; /*! \brief set the appearance mode of this widget 'FIDUCIALMODE' adapts the widget for (tracking) fiducial based registration purposes 'LANDMARKMODE' adapts the widget for landmark based registration (source landmarks -> target/reference landmarks) */ void SetWidgetAppearanceMode(WidgetAppearanceMode widgetMode); void SetMultiWidget(QmitkStdMultiWidget* multiWidget); ///< Set the default stdMultiWidget (needed for the PointListwidget) void SetImageFiducialsNode(mitk::DataNode::Pointer imageFiducialsNode); ///< specify data tree node for the image fiducials void SetTrackerFiducialsNode(mitk::DataNode::Pointer trackerFiducialsNode); ///< specify data tree node for the tracker fiducials mitk::DataNode::Pointer GetImageFiducialsNode(); ///< returns data tree node for the image fiducials mitk::DataNode::Pointer GetTrackerFiducialsNode(); ///< returns data tree node for the tracker fiducials void SetQualityDisplayText(QString text); ///< sets specific text on the UI (useful to display FRE/TRE...) bool UseICPIsChecked(); ///< returns true if automatic correspondences search is activated else false void HideStaticRegistrationRadioButton(bool on); ///< show or hide "static Fiducial Registration" radio button in the UI void HideContinousRegistrationRadioButton(bool on); ///< show or hide "hybrid continuous Fiducial Registration" radio button in the UI void HideUseICPRegistrationCheckbox(bool on); ///< show or hide "Find fiducial correspondences (needs 6+ fiducial pairs)" check box in the UI void HideImageFiducialButton(bool on); ///< show or hide "Add image fiducial" button in the UI + void HideTrackingFiducialButton(bool on); ///< show or hide "Add tracking fiducial" button in the UI + signals: void AddedTrackingFiducial(); ///< signal if a world instrument position was added to a tracking space fiducial void AddedImageFiducial(); ///< signal if an image position was added to a image space fiducial void PerformFiducialRegistration(); ///< signal if all fiducial were added and registration can be performed void FindFiducialCorrespondences(bool on); ///< signal if automatic correspondences search is toggled protected: void CreateQtPartControl(QWidget *parent); void CreateConnections(); Ui::QmitkFiducialRegistrationWidget* m_Controls; ///< gui widget QmitkStdMultiWidget* m_MultiWidget; mitk::DataNode::Pointer m_ImageFiducialsNode; mitk::DataNode::Pointer m_TrackerFiducialsNode; }; #endif // _QmitkFiducialRegistrationWidget_H_INCLUDED diff --git a/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.cpp b/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.cpp index c012803294..0aa58f23b5 100644 --- a/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.cpp +++ b/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.cpp @@ -1,225 +1,225 @@ /*========================================================================= 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_ShowQuaternions = false; m_Alignment = Qt::AlignHCenter; m_Style = QmitkToolTrackingStatusWidget::VerticalUpperStyle; } void QmitkToolTrackingStatusWidget::SetStyle(QmitkToolTrackingStatusWidget::Style newStyle) { m_Style = newStyle; } void QmitkToolTrackingStatusWidget::SetShowPositions(bool enable) { m_ShowPositions = enable; } void QmitkToolTrackingStatusWidget::SetShowQuaternions(bool enable) { m_ShowQuaternions = 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 = ""; QString quat = ""; if (m_ShowPositions) { mitk::Point3D position = navData->GetPosition(); pos = " [" + QString::number(position[0]) + ";" + QString::number(position[1]) + ";" + QString::number(position[2]) + "]"; } if (m_ShowQuaternions) { mitk::Quaternion quaternion = navData->GetOrientation(); quat = " / [qx:" + QString::number(quaternion.x()) + ";qy:" + QString::number(quaternion.y()) + ";qz:" + QString::number(quaternion.z()) + ";qr:" + QString::number(quaternion.r()) + "]"; } - if(name.compare(m_StatusLabels->at(i)->objectName()) == 0) - { - m_StatusLabels->at(i)->setText(name+pos+quat); + + if(!(m_StatusLabels->at(i)->text() == name+pos+quat)) + m_StatusLabels->at(i)->setText(name+pos+quat); + 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() { RemoveGuiLabels(); 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()); label = new QLabel(name, this); label->setObjectName(name); label->setAlignment(m_Alignment | Qt::AlignVCenter); label->setFrameStyle(QFrame::Panel | QFrame::Sunken); m_StatusLabels->append(label); if (m_Style == QmitkToolTrackingStatusWidget::VerticalUpperStyle) m_Controls->m_VerticalLayout->addWidget(m_StatusLabels->at(i)); else m_Controls->m_GridLayout->addWidget(m_StatusLabels->at(i),0,i); } } void QmitkToolTrackingStatusWidget::PreShowTools(mitk::NavigationToolStorage::Pointer toolStorage) { QLabel* label; for(unsigned int i = 0; i < toolStorage->GetToolCount(); i++) { QString name(toolStorage->GetTool(i)->GetToolName().c_str()); label = new QLabel(name, this); label->setObjectName(name); label->setAlignment(m_Alignment | Qt::AlignVCenter); label->setFrameStyle(QFrame::Panel | QFrame::Sunken); if (m_Style == QmitkToolTrackingStatusWidget::VerticalUpperStyle) m_Controls->m_VerticalLayout->addWidget(label); else m_Controls->m_GridLayout->addWidget(label); } } void QmitkToolTrackingStatusWidget::RemoveStatusLabels() { //remove GUI elements RemoveGuiLabels(); //clear members if(m_StatusLabels != NULL && m_StatusLabels->size() > 0) { delete m_StatusLabels; m_StatusLabels = new QVector< QLabel* >(); } if(m_NavigationDatas != NULL && m_NavigationDatas->size() > 0) { delete m_NavigationDatas; m_NavigationDatas = new std::vector(); } } void QmitkToolTrackingStatusWidget::RemoveGuiLabels() { while(m_Controls->m_GridLayout->count() > 0 || m_Controls->m_VerticalLayout->count() > 0) { if (m_Controls->m_GridLayout->count() > 0) { QWidget* actWidget = m_Controls->m_GridLayout->itemAt(0)->widget(); m_Controls->m_GridLayout->removeWidget(actWidget); delete actWidget; } else if (m_Controls->m_VerticalLayout->count() > 0) { QWidget* actWidget = m_Controls->m_VerticalLayout->itemAt(0)->widget(); m_Controls->m_VerticalLayout->removeWidget(actWidget); delete actWidget; } } } diff --git a/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.h b/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.h index f3272764e9..c2f632a71f 100644 --- a/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.h @@ -1,133 +1,135 @@ /*========================================================================= 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 #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; enum Style { GridLowerStyle, VerticalUpperStyle }; /*! \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); - + /*! + \brief Adds the NavigationData to the existing ones. + */ 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 Enables / disables if the tool quaternions are shown. Default is off.*/ void SetShowQuaternions(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); /** @brief Sets the alignment style of this widget: * GridLowerStyle: Tool labels are at the lower side of the widget in grid alignment * VerticalUpperStyle: Tool labels are at the upper side in a vertical alignment (default) */ void SetStyle(QmitkToolTrackingStatusWidget::Style newStyle); /** @brief Shows tool labels for the tools in the tool storage. This method can be called BEFORE connecting the navigation data to * make a preview of the tools. */ void PreShowTools(mitk::NavigationToolStorage::Pointer toolStorage); 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; bool m_ShowQuaternions; Qt::AlignmentFlag m_Alignment; QmitkToolTrackingStatusWidget::Style m_Style; void RemoveGuiLabels(); }; #endif // _QmitkToolTrackingStatusWidget_H_INCLUDED diff --git a/Modules/IGTUI/Qmitk/QmitkTrackingSourcesCheckBoxPanelWidget.cpp b/Modules/IGTUI/Qmitk/QmitkTrackingSourcesCheckBoxPanelWidget.cpp index 54fa2a2535..f637ab064b 100644 --- a/Modules/IGTUI/Qmitk/QmitkTrackingSourcesCheckBoxPanelWidget.cpp +++ b/Modules/IGTUI/Qmitk/QmitkTrackingSourcesCheckBoxPanelWidget.cpp @@ -1,247 +1,277 @@ /*========================================================================= 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 "QmitkTrackingSourcesCheckBoxPanelWidget.h" - +#include QmitkTrackingSourcesCheckBoxPanelWidget::QmitkTrackingSourcesCheckBoxPanelWidget(QWidget* parent) : QWidget(parent), m_Controls(NULL), m_SourceCheckboxes(NULL), m_NavigationDatas(NULL), m_SelectedIds(NULL) { this->CreateQtPartControl( this ); m_SourceCheckboxes = new TrackingSourcesCheckboxes(); } QmitkTrackingSourcesCheckBoxPanelWidget::~QmitkTrackingSourcesCheckBoxPanelWidget() { delete m_SelectedIds; delete m_SourceCheckboxes; delete m_NavigationDatas; } void QmitkTrackingSourcesCheckBoxPanelWidget::CreateQtPartControl(QWidget *parent) { if (!m_Controls) { // create GUI widgets m_Controls = new Ui::QmitkTrackingSourcesCheckBoxPanelWidgetControls; m_Controls->setupUi(parent); this->CreateConnections(); } } void QmitkTrackingSourcesCheckBoxPanelWidget::CreateConnections() { connect( (QPushButton*) m_Controls->m_ActionButton, SIGNAL(toggled(bool)), this, SLOT(OnPerformActionClicked(bool)) ) ; connect( (QPushButton*) m_Controls->m_ActionButton, SIGNAL(clicked()), this, SLOT(OnPerformActionClicked()) ) ; } void QmitkTrackingSourcesCheckBoxPanelWidget::SetNavigationDatas(std::vector* navDatas) { if( navDatas != NULL ) m_NavigationDatas = navDatas; } void QmitkTrackingSourcesCheckBoxPanelWidget::AddNavigationData(mitk::NavigationData::Pointer nd) { - if(m_NavigationDatas == NULL) - m_NavigationDatas = new std::vector(); + if(m_NavigationDatas == NULL) + m_NavigationDatas = new std::vector(); - if( nd.IsNotNull() ) - m_NavigationDatas->push_back(nd); + if( nd.IsNotNull() ) + m_NavigationDatas->push_back(nd); } +bool QmitkTrackingSourcesCheckBoxPanelWidget::IsActionButtonChecked(){ + return m_Controls->m_ActionButton->isChecked(); +} const std::vector* QmitkTrackingSourcesCheckBoxPanelWidget::GetSelectedTrackingSourcesIDs() { if(m_SelectedIds == NULL) m_SelectedIds = new std::vector(); else m_SelectedIds->clear(); for (unsigned int i=0; i < m_SourceCheckboxes->size(); i++) { if(m_SourceCheckboxes->at(i)->isChecked()) m_SelectedIds->push_back(i); } return m_SelectedIds; } void QmitkTrackingSourcesCheckBoxPanelWidget::ClearPanel() { 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_SourceCheckboxes != NULL) m_SourceCheckboxes->clear(); if(m_NavigationDatas != NULL) m_NavigationDatas->clear(); - - + + } void QmitkTrackingSourcesCheckBoxPanelWidget::ClearSelectedIDs() { if(m_SelectedIds != NULL && !m_SelectedIds->empty()) m_SelectedIds->clear(); } void QmitkTrackingSourcesCheckBoxPanelWidget::ShowSourceCheckboxes() { if( m_SourceCheckboxes != NULL ) m_SourceCheckboxes->clear(); if( m_NavigationDatas == NULL ) return; QCheckBox* checkBox; int row = 0; int column; for(unsigned int i=0; i < m_NavigationDatas->size(); i++) // puts a radiobutton for every tracking source output in a 2 columns QGridLayout { column = i % 4; if( i>0 && i%4==0 ) row++; QString name(m_NavigationDatas->at(i).GetPointer()->GetName()); checkBox = new QCheckBox(name, this); connect( checkBox, SIGNAL(toggled(bool)), this , SLOT(OnCheckboxClicked(bool)) ); m_SourceCheckboxes->push_back(checkBox); m_Controls->m_GridLayout->addWidget(checkBox,row,column); } } void QmitkTrackingSourcesCheckBoxPanelWidget::EnableCheckboxes(bool enable) { for(unsigned int i=0; i< m_SourceCheckboxes->size(); i++) { m_SourceCheckboxes->at(i)->setEnabled(enable); } } void QmitkTrackingSourcesCheckBoxPanelWidget::SelectAll() { for(unsigned int i=0; i< m_SourceCheckboxes->size(); i++) { m_SourceCheckboxes->at(i)->setChecked(true); } } void QmitkTrackingSourcesCheckBoxPanelWidget::DeselectAll() { for(unsigned int i=0; i< m_SourceCheckboxes->size(); i++) { m_SourceCheckboxes->at(i)->setChecked(false); } } void QmitkTrackingSourcesCheckBoxPanelWidget::SelectCheckbox(unsigned int idx) { m_SourceCheckboxes->at(idx)->setChecked(true); } void QmitkTrackingSourcesCheckBoxPanelWidget::DeselectCheckbox(unsigned int idx) { m_SourceCheckboxes->at(idx)->setChecked(false); } void QmitkTrackingSourcesCheckBoxPanelWidget::OnCheckboxClicked(bool checked) { QCheckBox* sender = qobject_cast< QCheckBox* > (QObject::sender()); if( sender == NULL ) throw std::invalid_argument("No sender found!"); int idx = -1; for(unsigned int i=0 ;i < m_SourceCheckboxes->size(); i++) { if(sender == m_SourceCheckboxes->at(i)) { idx=i; - break; + break; } } if(idx>-1) { if(checked) emit Selected(idx); else emit Deselected(idx); } } void QmitkTrackingSourcesCheckBoxPanelWidget::SetInfoText(QString text) { m_Controls->m_InfoLabel->setText(text); } void QmitkTrackingSourcesCheckBoxPanelWidget::SetActionPerformButtonText(QString text) { m_Controls->m_ActionButton->setText(text); } void QmitkTrackingSourcesCheckBoxPanelWidget::HideActionPerformButton(bool hide) { if(hide) m_Controls->m_ActionButton->hide(); else m_Controls->m_ActionButton->show(); } void QmitkTrackingSourcesCheckBoxPanelWidget::SetActionPerformButtonCheckable(bool checkable) { if(checkable) m_Controls->m_ActionButton->setCheckable(true); else m_Controls->m_ActionButton->setCheckable(false); } void QmitkTrackingSourcesCheckBoxPanelWidget::OnPerformActionClicked(bool toggled) { + if(this->GetSelectedTrackingSourcesIDs()->empty()) + { + m_Controls->m_ActionButton->setChecked(false); + return; + } + if(toggled) + { + bool invalidND = false; + + for(int i=0; i < this->GetSelectedTrackingSourcesIDs()->size(); ++i) + { + if(!(m_NavigationDatas->at(this->GetSelectedTrackingSourcesIDs()->at(i))->IsDataValid())) + invalidND = true; + } + + if(invalidND) + { + QMessageBox::warning(NULL, "Invalid Tracking Data", "One or more instruments are in invalid tracking state! Requested action can not be performed!"); + m_Controls->m_ActionButton->setChecked(false); + return; + } emit PerformAction(); + } else emit StopAction(); } void QmitkTrackingSourcesCheckBoxPanelWidget::OnPerformActionClicked() { + if(this->GetSelectedTrackingSourcesIDs()->empty()){ + m_Controls->m_ActionButton->setChecked(false); + return; + } + emit Action(); } \ No newline at end of file diff --git a/Modules/IGTUI/Qmitk/QmitkTrackingSourcesCheckBoxPanelWidget.h b/Modules/IGTUI/Qmitk/QmitkTrackingSourcesCheckBoxPanelWidget.h index 0c80f4e335..c5aced4882 100644 --- a/Modules/IGTUI/Qmitk/QmitkTrackingSourcesCheckBoxPanelWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkTrackingSourcesCheckBoxPanelWidget.h @@ -1,156 +1,161 @@ /*========================================================================= 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 _QmitkTrackingSourcesCheckBoxPanelWidget_H_INCLUDED #define _QmitkTrackingSourcesCheckBoxPanelWidget_H_INCLUDED #include "ui_QmitkTrackingSourcesCheckBoxPanelWidgetControls.h" #include "MitkIGTUIExports.h" #include #include /*! \brief QmitkTrackingSourcesCheckBoxPanelWidget Widget for setting up and controlling an update timer in an IGT-Pipeline. */ class MitkIGTUI_EXPORT QmitkTrackingSourcesCheckBoxPanelWidget : 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< QCheckBox* > TrackingSourcesCheckboxes; /// vector with checkboxes for all set NDs /*! \brief default constructor */ QmitkTrackingSourcesCheckBoxPanelWidget( QWidget* parent ); /*! \brief default destructor */ virtual ~QmitkTrackingSourcesCheckBoxPanelWidget(); /*! \brief Shows the checkboxes */ void ShowSourceCheckboxes(); /*! \brief Sets the ND for this widget */ void SetNavigationDatas(std::vector* navDatas); /*! \brief Adds a ND. */ void AddNavigationData(mitk::NavigationData::Pointer nd); /** \brief Sets this widget's info text. */ void SetInfoText(QString text); /** \brief Sets this widget's action perform button text. */ void SetActionPerformButtonText(QString text); /** \brief Sets whether the action perform button is checkable or not. */ void SetActionPerformButtonCheckable(bool checkable); /** \brief Hides or shows the action perfom button. */ void HideActionPerformButton(bool hide); /** \brief Returns the selected tracking sources IDs. */ const std::vector* GetSelectedTrackingSourcesIDs(); /** \brief Selects all checkboxes in this widget. */ void SelectAll(); /** \brief Deselects all checkboxes in this widget. */ void DeselectAll(); /** \brief Selets the checkbox at the given position. */ void SelectCheckbox(unsigned int idx); /** \brief Deselects the checkbox at the given position */ void DeselectCheckbox(unsigned int idx); /** \brief Enables or disabless the checkboxes in this widget. */ void EnableCheckboxes(bool enable); /** \brief Clears the vector that holds the selected IDs */ void ClearSelectedIDs(); + /** + \brief Returns whether this widgets "perform action" button is checked + */ + bool IsActionButtonChecked(); + signals: void Selected(int id); /// when a checkbox is selected void Deselected(int id); /// when a checkbox is deselected void PerformAction(); /// when action perfom button is pressed void StopAction(); /// when action perform button is released void Action(); /// when action perfom button is clicked public slots: void ClearPanel(); /// clearing checkboxes from panel protected slots: void OnCheckboxClicked(bool checked); void OnPerformActionClicked(bool toggled); void OnPerformActionClicked(); protected: void CreateConnections(); void CreateQtPartControl( QWidget *parent ); Ui::QmitkTrackingSourcesCheckBoxPanelWidgetControls* m_Controls; ///< gui widgets private: TrackingSourcesCheckboxes* m_SourceCheckboxes; std::vector* m_NavigationDatas; std::vector* m_SelectedIds; }; #endif // _QmitkTrackingSourcesCheckBoxPanelWidget_H_INCLUDED diff --git a/Modules/QmitkExt/btnClear.xpm b/Modules/QmitkExt/btnClear.xpm index 3a7bb238e1..45a4deb47a 100644 --- a/Modules/QmitkExt/btnClear.xpm +++ b/Modules/QmitkExt/btnClear.xpm @@ -1,18 +1,46 @@ /* XPM */ static const char * btnClear_xpm[] = { -"12 10 5 1", -" g None", -". g #000000", -"+ g #FFFFFF", -"@ g #C3C3C3", -"# g #7F7F7F", -" .....", -" .++@..", -" .++@.#.", -" .....#. ", -" .++@.. ", -" . ..... ", -" . ", -"..... ", -" . ", -" . "}; +"13 9 34 1", +" c None", +". c #090909", +"+ c #080808", +"@ c #000000", +"# c #0D0D0D", +"$ c #ECECEC", +"% c #FFFFFF", +"& c #FCFCFC", +"* c #E6E6E6", +"= c #0B0B0B", +"- c #FBFBFB", +"; c #F5F5F5", +"> c #CDCDCD", +", c #FEFEFE", +"' c #FAFAFA", +") c #F4F4F4", +"! c #0C0C0C", +"~ c #CCCCCC", +"{ c #D8D8D8", +"] c #050505", +"^ c #F3F3F3", +"/ c #FDFDFD", +"( c #CBCBCB", +"_ c #010101", +": c #040404", +"< c #D4D4D4", +"[ c #D1D1D1", +"} c #C9C9C9", +"| c #EAEAEA", +"1 c #EEEEEE", +"2 c #F8F8F8", +"3 c #020202", +"4 c #0F0F0F", +"5 c #111111", +" .+@@#+@@", +" .$%%&*%=@", +" @-%;%%%@>@", +" @%,;%')!~{]", +" @^/%&''!>(@ ", +"@#_@:@:@<[@ ", +"@%%,%%&]}@ ", +"!|%/12%3@ ", +"@]@.45@@ "}; diff --git a/Modules/QmitkExt/btnClearAll.xpm b/Modules/QmitkExt/btnClearAll.xpm deleted file mode 100644 index 2c82fcbd0f..0000000000 --- a/Modules/QmitkExt/btnClearAll.xpm +++ /dev/null @@ -1,46 +0,0 @@ -/* XPM */ -static const char * btnClearAll_xpm[] = { -"13 9 34 1", -" c None", -". c #090909", -"+ c #080808", -"@ c #000000", -"# c #0D0D0D", -"$ c #ECECEC", -"% c #FFFFFF", -"& c #FCFCFC", -"* c #E6E6E6", -"= c #0B0B0B", -"- c #FBFBFB", -"; c #F5F5F5", -"> c #CDCDCD", -", c #FEFEFE", -"' c #FAFAFA", -") c #F4F4F4", -"! c #0C0C0C", -"~ c #CCCCCC", -"{ c #D8D8D8", -"] c #050505", -"^ c #F3F3F3", -"/ c #FDFDFD", -"( c #CBCBCB", -"_ c #010101", -": c #040404", -"< c #D4D4D4", -"[ c #D1D1D1", -"} c #C9C9C9", -"| c #EAEAEA", -"1 c #EEEEEE", -"2 c #F8F8F8", -"3 c #020202", -"4 c #0F0F0F", -"5 c #111111", -" .+@@#+@@", -" .$%%&*%=@", -" @-%;%%%@>@", -" @%,;%')!~{]", -" @^/%&''!>(@ ", -"@#_@:@:@<[@ ", -"@%%,%%&]}@ ", -"!|%/12%3@ ", -"@]@.45@@ "}; diff --git a/Modules/QmitkExt/btnClear.xpm b/Modules/QmitkExt/btnClearOne.xpm similarity index 85% copy from Modules/QmitkExt/btnClear.xpm copy to Modules/QmitkExt/btnClearOne.xpm index 3a7bb238e1..d71939e4e9 100644 --- a/Modules/QmitkExt/btnClear.xpm +++ b/Modules/QmitkExt/btnClearOne.xpm @@ -1,18 +1,18 @@ /* XPM */ -static const char * btnClear_xpm[] = { +static const char * btnClearOne_xpm[] = { "12 10 5 1", " g None", ". g #000000", "+ g #FFFFFF", "@ g #C3C3C3", "# g #7F7F7F", " .....", " .++@..", " .++@.#.", " .....#. ", " .++@.. ", " . ..... ", " . ", "..... ", " . ", " . "};