diff --git a/Modules/IGTUI/Qmitk/QmitkTrackingDeviceConfigurationWidget.cpp b/Modules/IGTUI/Qmitk/QmitkTrackingDeviceConfigurationWidget.cpp
index 8bb257b6bd..c3ef981984 100644
--- a/Modules/IGTUI/Qmitk/QmitkTrackingDeviceConfigurationWidget.cpp
+++ b/Modules/IGTUI/Qmitk/QmitkTrackingDeviceConfigurationWidget.cpp
@@ -1,341 +1,339 @@
/*=========================================================================
Program: Medical Imaging & Interaction Toolkit
Language: C++
Date: $Date: 2009-05-12 19:14:45 +0200 (Di, 12 Mai 2009) $
Version: $Revision: 1.12 $
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 "QmitkTrackingDeviceConfigurationWidget.h"
#include "mitkClaronTrackingDevice.h"
#include "mitkNDITrackingDevice.h"
#include "mitkSerialCommunication.h"
#include "qscrollbar.h"
const std::string QmitkTrackingDeviceConfigurationWidget::VIEW_ID = "org.mitk.views.trackingdeviceconfigurationwidget";
QmitkTrackingDeviceConfigurationWidget::QmitkTrackingDeviceConfigurationWidget(QWidget* parent, Qt::WindowFlags f)
: QWidget(parent, f)
{
m_Controls = NULL;
CreateQtPartControl(this);
CreateConnections();
//reset a few things
ResetOutput();
AddOutput("
NDI Polaris selected");
this->m_TrackingDeviceConfigurated = false;
- this->SetGUIStyle(QmitkTrackingDeviceConfigurationWidget::SIMPLE);
-
m_AdvancedUserControl = true;
}
void QmitkTrackingDeviceConfigurationWidget::SetGUIStyle(QmitkTrackingDeviceConfigurationWidget::Style style)
{
switch(style)
{
case QmitkTrackingDeviceConfigurationWidget::SIMPLE:
//move all UI elements to an empty dummy layout
//m_Controls->dummyLayout->addItem(m_Controls->mainLayout);
m_Controls->dummyLayout->addWidget(m_Controls->widget_title_label);
m_Controls->dummyLayout->addWidget(m_Controls->choose_tracking_device_label);
m_Controls->dummyLayout->addWidget(m_Controls->polaris_label);
m_Controls->dummyLayout->addWidget( m_Controls->aurora_label);
m_Controls->dummyLayout->addWidget(m_Controls->aurora_label);
m_Controls->dummyLayout->addWidget(m_Controls->microntracker_label);
m_Controls->dummyLayout->addWidget(m_Controls->m_testConnectionMicronTracker);
m_Controls->dummyLayout->addWidget(m_Controls->m_outputTextMicronTracker);
m_Controls->dummyLayout->addWidget(m_Controls->m_outputTextAurora);
m_Controls->dummyLayout->addWidget(m_Controls->m_testConnectionAurora);
m_Controls->dummyLayout->addWidget(m_Controls->m_outputTextPolaris);
m_Controls->dummyLayout->addWidget(m_Controls->m_testConnectionPolaris);
m_Controls->dummyLayout->addWidget(m_Controls->m_polarisTrackingModeBox);
m_Controls->dummyLayout->addWidget(m_Controls->m_finishedLine);
m_Controls->dummyLayout->addWidget(m_Controls->line);
m_Controls->dummyLayout->addWidget(m_Controls->configuration_finished_label);
m_Controls->dummyLayout->addItem(m_Controls->horizontalLayout_4);
m_Controls->mainLayout->removeItem(m_Controls->horizontalLayout_4);
m_Controls->dummyLayout->addWidget(m_Controls->configuration_finished_label);
m_Controls->dummyLayout->addItem(m_Controls->verticalSpacer_2);
m_Controls->verticalLayout_3->removeItem(m_Controls->verticalSpacer_2);
m_Controls->dummyLayout->addItem(m_Controls->horizontalSpacer_9);
m_Controls->horizontalLayout_9->removeItem(m_Controls->horizontalSpacer_9);
m_Controls->dummyLayout->addItem(m_Controls->horizontalSpacer_3);
m_Controls->horizontalLayout_11->removeItem(m_Controls->horizontalSpacer_3);
m_Controls->dummyLayout->addItem(m_Controls->verticalSpacer_3);
m_Controls->verticalLayout_7->removeItem(m_Controls->verticalSpacer_3);
m_Controls->dummyLayout->addItem(m_Controls->verticalSpacer_4);
m_Controls->verticalLayout_10->removeItem(m_Controls->verticalSpacer_4);
m_Controls->dummyLayout->addItem(m_Controls->horizontalSpacer_10);
m_Controls->verticalLayout_10->removeItem(m_Controls->horizontalSpacer_10);
//set height to min
m_Controls->m_outputTextPolaris->setMinimumHeight(0);
m_Controls->m_outputTextPolaris->setMaximumHeight(0);
m_Controls->m_outputTextMicronTracker->setMinimumHeight(0);
m_Controls->m_outputTextMicronTracker->setMaximumHeight(0);
m_Controls->m_outputTextAurora->setMinimumHeight(0);
m_Controls->m_outputTextAurora->setMaximumHeight(0);
m_Controls->m_finishedButton->setMinimumHeight(0);
m_Controls->m_finishedButton->setMaximumHeight(0);
m_Controls->m_resetButton->setMinimumHeight(0);
m_Controls->m_resetButton->setMaximumHeight(0);
//set the height of the tracking device combo box
m_Controls->m_trackingDeviceChooser->setMinimumHeight(50);
//move back the used elemets to the main layout
m_Controls->simpleLayout->addWidget(m_Controls->m_trackingDeviceChooser);
m_Controls->simpleLayout->addWidget(m_Controls->m_TrackingSystemWidget);
m_Controls->mainWidget->setCurrentIndex(1);
this->setMaximumHeight(150);
this->EnableAdvancedUserControl(false);
break;
case QmitkTrackingDeviceConfigurationWidget::ADVANCED:
//default at the moment => start settings are advanced
break;
}
}
QmitkTrackingDeviceConfigurationWidget::~QmitkTrackingDeviceConfigurationWidget()
{
}
void QmitkTrackingDeviceConfigurationWidget::CreateQtPartControl(QWidget *parent)
{
if (!m_Controls)
{
// create GUI widgets
m_Controls = new Ui::QmitkTrackingDeviceConfigurationWidgetControls;
m_Controls->setupUi(parent);
}
}
void QmitkTrackingDeviceConfigurationWidget::CreateConnections()
{
if ( m_Controls )
{
connect( (QObject*)(m_Controls->m_trackingDeviceChooser), SIGNAL(currentIndexChanged(int)), this, SLOT(TrackingDeviceChanged()) );
connect( (QObject*)(m_Controls->m_testConnectionPolaris), SIGNAL(clicked()), this, SLOT(TestConnection()) );
connect( (QObject*)(m_Controls->m_testConnectionAurora), SIGNAL(clicked()), this, SLOT(TestConnection()) );
connect( (QObject*)(m_Controls->m_testConnectionMicronTracker), SIGNAL(clicked()), this, SLOT(TestConnection()) );
connect( (QObject*)(m_Controls->m_resetButton), SIGNAL(clicked()), this, SLOT(ResetByUser()) );
connect( (QObject*)(m_Controls->m_finishedButton), SIGNAL(clicked()), this, SLOT(Finished()) );
//set a few UI components depending on Windows / Linux
#ifdef WIN32
m_Controls->portTypeLabelPolaris->setVisible(false);
m_Controls->portTypePolaris->setVisible(false);
m_Controls->portTypeLabelAurora->setVisible(false);
m_Controls->portTypeAurora->setVisible(false);
#else
m_Controls->comPortLabelAurora->setText("Port Nr:");
m_Controls->m_comPortLabelPolaris->setText("Port Nr:");
m_Controls->m_portSpinBoxAurora->setPrefix("");
m_Controls->m_portSpinBoxPolaris->setPrefix("");
#endif
}
}
void QmitkTrackingDeviceConfigurationWidget::TrackingDeviceChanged()
{
//show the correspondig widget
m_Controls->m_TrackingSystemWidget->setCurrentIndex(m_Controls->m_trackingDeviceChooser->currentIndex());
//the new trackingdevice is not configurated yet
m_TrackingDeviceConfigurated = false;
//reset output
ResetOutput();
//print output
if (m_Controls->m_trackingDeviceChooser->currentIndex()==0) AddOutput("
NDI Polaris selected"); //NDI Polaris
else if (m_Controls->m_trackingDeviceChooser->currentIndex()==1) AddOutput("
NDI Aurora selected"); //NDI Aurora
else if (m_Controls->m_trackingDeviceChooser->currentIndex()==2) AddOutput("
Microntracker selected"); //ClaronTechnology MicronTracker 2
}
void QmitkTrackingDeviceConfigurationWidget::EnableUserReset(bool enable)
{
if (enable) m_Controls->m_resetButton->setVisible(true);
else m_Controls->m_resetButton->setVisible(false);
}
void QmitkTrackingDeviceConfigurationWidget::TestConnection()
{
//#### Step 1: construct a tracking device:
mitk::TrackingDevice::Pointer testTrackingDevice = ConstructTrackingDevice();
//#### Step 2: test connection and start tracking, generate output
AddOutput("
testing connection
...");
if (testTrackingDevice->OpenConnection())
{
AddOutput(" OK");
AddOutput("
testing tracking
...");
if (testTrackingDevice->StartTracking())
{
AddOutput(" OK");
if (!testTrackingDevice->StopTracking())AddOutput("
ERROR while stop tracking
");
}
else AddOutput(" ERROR!");
if (!testTrackingDevice->CloseConnection())AddOutput("
ERROR while closing connection
");
}
else AddOutput(" ERROR!");
}
void QmitkTrackingDeviceConfigurationWidget::Finished()
{
m_TrackingDevice = ConstructTrackingDevice();
m_Controls->m_TrackingSystemWidget->setEnabled(false);
m_Controls->m_trackingDeviceChooser->setEnabled(false);
m_Controls->choose_tracking_device_label->setEnabled(false);
m_Controls->configuration_finished_label->setText("\n
Configuration finished
"); this->m_TrackingDeviceConfigurated = true; emit TrackingDeviceConfigurationFinished(); } void QmitkTrackingDeviceConfigurationWidget::Reset() { m_TrackingDevice = NULL; m_Controls->m_TrackingSystemWidget->setEnabled(true); m_Controls->m_trackingDeviceChooser->setEnabled(true); m_Controls->choose_tracking_device_label->setEnabled(true); m_Controls->configuration_finished_label->setText("\n\nPress \"Finished\" to confirm configuration
"); this->m_TrackingDeviceConfigurated = false; emit TrackingDeviceConfigurationReseted(); } void QmitkTrackingDeviceConfigurationWidget::ResetByUser() { Reset(); } //######################### internal help methods ####################################### void QmitkTrackingDeviceConfigurationWidget::ResetOutput() { m_output.str(""); m_output <<"output:"; m_Controls->m_outputTextAurora->setHtml(QString(m_output.str().c_str())); m_Controls->m_outputTextPolaris->setHtml(QString(m_output.str().c_str())); m_Controls->m_outputTextMicronTracker->setHtml(QString(m_output.str().c_str())); } void QmitkTrackingDeviceConfigurationWidget::AddOutput(std::string s) { //print output m_output << s; m_Controls->m_outputTextAurora->setHtml(QString(m_output.str().c_str())); m_Controls->m_outputTextPolaris->setHtml(QString(m_output.str().c_str())); m_Controls->m_outputTextMicronTracker->setHtml(QString(m_output.str().c_str())); m_Controls->m_outputTextPolaris->verticalScrollBar()->setValue(m_Controls->m_outputTextPolaris->verticalScrollBar()->maximum()); m_Controls->m_outputTextAurora->verticalScrollBar()->setValue(m_Controls->m_outputTextAurora->verticalScrollBar()->maximum()); m_Controls->m_outputTextMicronTracker->verticalScrollBar()->setValue(m_Controls->m_outputTextMicronTracker->verticalScrollBar()->maximum()); repaint(); } mitk::TrackingDevice::Pointer QmitkTrackingDeviceConfigurationWidget::ConstructTrackingDevice() { mitk::TrackingDevice::Pointer returnValue; //#### Step 1: configure tracking device: if (m_Controls->m_trackingDeviceChooser->currentIndex()==0)//NDI Polaris { if(m_Controls->m_radioPolaris5D->isChecked()) //5D Tracking { //not yet in the open source part so we'll only get NULL here. returnValue = ConfigureNDI5DTrackingDevice(); } else //6D Tracking { returnValue = ConfigureNDI6DTrackingDevice(); returnValue->SetType(mitk::NDIPolaris); } } else if (m_Controls->m_trackingDeviceChooser->currentIndex()==1)//NDI Aurora { returnValue = ConfigureNDI6DTrackingDevice(); returnValue->SetType(mitk::NDIAurora); } else if (m_Controls->m_trackingDeviceChooser->currentIndex()==2)//ClaronTechnology MicronTracker 2 { returnValue = mitk::ClaronTrackingDevice::New(); } return returnValue; } mitk::TrackingDevice::Pointer QmitkTrackingDeviceConfigurationWidget::ConfigureNDI5DTrackingDevice() { return NULL; } mitk::TrackingDevice::Pointer QmitkTrackingDeviceConfigurationWidget::ConfigureNDI6DTrackingDevice() { mitk::NDITrackingDevice::Pointer tempTrackingDevice = mitk::NDITrackingDevice::New(); //build prefix (depends on linux/win) QString prefix = ""; #ifdef WIN32 prefix ="COM"; #else if (m_Controls->m_trackingDeviceChooser->currentIndex()==1) //Aurora prefix = m_Controls->portTypeAurora->currentText(); else //Polaris prefix = m_Controls->portTypePolaris->currentText(); #endif //get port int port = 0; if (m_Controls->m_trackingDeviceChooser->currentIndex()==1) port = m_Controls->m_portSpinBoxAurora->value(); else port = m_Controls->m_portSpinBoxPolaris->value(); //build port name string QString portName = prefix + QString::number(port); tempTrackingDevice->SetDeviceName(portName.toStdString()); //set the port name mitk::TrackingDevice::Pointer returnValue = static_cast