Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "QmitkTrackingDeviceConfigurationWidget.h"
00019 #include "mitkClaronTrackingDevice.h"
00020 #include "mitkNDITrackingDevice.h"
00021 #include "mitkSerialCommunication.h"
00022 #include "qscrollbar.h"
00023
00024 const std::string QmitkTrackingDeviceConfigurationWidget::VIEW_ID = "org.mitk.views.trackingdeviceconfigurationwidget";
00025
00026 QmitkTrackingDeviceConfigurationWidget::QmitkTrackingDeviceConfigurationWidget(QWidget* parent, Qt::WindowFlags f)
00027 : QWidget(parent, f)
00028 {
00029 m_Controls = NULL;
00030 CreateQtPartControl(this);
00031 CreateConnections();
00032
00033
00034 ResetOutput();
00035 AddOutput("<br>NDI Polaris selected");
00036 }
00037
00038
00039 QmitkTrackingDeviceConfigurationWidget::~QmitkTrackingDeviceConfigurationWidget()
00040 {
00041 }
00042
00043 void QmitkTrackingDeviceConfigurationWidget::CreateQtPartControl(QWidget *parent)
00044 {
00045 if (!m_Controls)
00046 {
00047
00048 m_Controls = new Ui::QmitkTrackingDeviceConfigurationWidgetControls;
00049 m_Controls->setupUi(parent);
00050 }
00051 }
00052
00053 void QmitkTrackingDeviceConfigurationWidget::CreateConnections()
00054 {
00055 if ( m_Controls )
00056 {
00057 connect( (QObject*)(m_Controls->m_trackingDeviceChooser), SIGNAL(currentIndexChanged(int)), this, SLOT(TrackingDeviceChanged()) );
00058 connect( (QObject*)(m_Controls->m_testConnectionPolaris), SIGNAL(clicked()), this, SLOT(TestConnection()) );
00059 connect( (QObject*)(m_Controls->m_testConnectionAurora), SIGNAL(clicked()), this, SLOT(TestConnection()) );
00060 connect( (QObject*)(m_Controls->m_testConnectionMicronTracker), SIGNAL(clicked()), this, SLOT(TestConnection()) );
00061 connect( (QObject*)(m_Controls->m_resetButton), SIGNAL(clicked()), this, SLOT(ResetByUser()) );
00062 connect( (QObject*)(m_Controls->m_finishedButton), SIGNAL(clicked()), this, SLOT(Finished()) );
00063 }
00064 }
00065
00066 void QmitkTrackingDeviceConfigurationWidget::TrackingDeviceChanged()
00067 {
00068
00069 m_Controls->m_TrackingSystemWidget->setCurrentIndex(m_Controls->m_trackingDeviceChooser->currentIndex());
00070
00071
00072 m_TrackingDeviceConfigurated = false;
00073
00074
00075 ResetOutput();
00076
00077
00078 if (m_Controls->m_trackingDeviceChooser->currentIndex()==0) AddOutput("<br>NDI Polaris selected");
00079 else if (m_Controls->m_trackingDeviceChooser->currentIndex()==1) AddOutput("<br>NDI Aurora selected");
00080 else if (m_Controls->m_trackingDeviceChooser->currentIndex()==2) AddOutput("<br>Microntracker selected");
00081 }
00082
00083 void QmitkTrackingDeviceConfigurationWidget::EnableUserReset(bool enable)
00084 {
00085 if (enable) m_Controls->m_resetButton->setVisible(true);
00086 else m_Controls->m_resetButton->setVisible(false);
00087 }
00088
00089 void QmitkTrackingDeviceConfigurationWidget::TestConnection()
00090 {
00091
00092 mitk::TrackingDevice::Pointer testTrackingDevice = ConstructTrackingDevice();
00093
00094
00095 AddOutput("<br>testing connection <br> ...");
00096 if (testTrackingDevice->OpenConnection())
00097 {
00098 AddOutput(" OK");
00099 AddOutput("<br>testing tracking <br> ...");
00100 if (testTrackingDevice->StartTracking())
00101 {
00102 AddOutput(" OK");
00103 if (!testTrackingDevice->StopTracking())AddOutput("<br>ERROR while stop tracking<br>");
00104 }
00105 else AddOutput(" ERROR!");
00106 if (!testTrackingDevice->CloseConnection())AddOutput("<br>ERROR while closing connection<br>");
00107 }
00108 else AddOutput(" ERROR!");
00109 }
00110
00111 void QmitkTrackingDeviceConfigurationWidget::Finished()
00112 {
00113 m_TrackingDevice = ConstructTrackingDevice();
00114 m_Controls->m_TrackingSystemWidget->setEnabled(false);
00115 m_Controls->m_trackingDeviceChooser->setEnabled(false);
00116 m_Controls->choose_tracking_device_label->setEnabled(false);
00117 m_Controls->configuration_finished_label->setText("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\np, li { white-space: pre-wrap; }\n</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n<p align=\"right\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;\"><span style=\" font-weight:600;\">Configuration finished</span></p></body></html>");
00118 emit TrackingDeviceConfigurationFinished();
00119 }
00120
00121 void QmitkTrackingDeviceConfigurationWidget::Reset()
00122 {
00123 m_TrackingDevice = NULL;
00124 m_Controls->m_TrackingSystemWidget->setEnabled(true);
00125 m_Controls->m_trackingDeviceChooser->setEnabled(true);
00126 m_Controls->choose_tracking_device_label->setEnabled(true);
00127 m_Controls->configuration_finished_label->setText("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\np, li { white-space: pre-wrap; }\n</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n<p align=\"right\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;\"><span style=\" font-weight:600;\">Press \"Finished\" to confirm configuration</span></p></body></html>");
00128 emit TrackingDeviceConfigurationReseted();
00129 }
00130
00131 void QmitkTrackingDeviceConfigurationWidget::ResetByUser()
00132 {
00133 Reset();
00134 }
00135
00136
00137 void QmitkTrackingDeviceConfigurationWidget::ResetOutput()
00138 {
00139 m_output.str("");
00140 m_output <<"<body style=\" font-family:\'MS Shell Dlg 2\'; font-size:7pt; font-weight:400; font-style:normal;\" bgcolor=black><span style=\"color:#ffffff;\"><u>output:</u>";
00141 m_Controls->m_outputTextAurora->setHtml(QString(m_output.str().c_str()));
00142 m_Controls->m_outputTextPolaris->setHtml(QString(m_output.str().c_str()));
00143 m_Controls->m_outputTextMicronTracker->setHtml(QString(m_output.str().c_str()));
00144 }
00145 void QmitkTrackingDeviceConfigurationWidget::AddOutput(std::string s)
00146 {
00147
00148 m_output << s;
00149 m_Controls->m_outputTextAurora->setHtml(QString(m_output.str().c_str()));
00150 m_Controls->m_outputTextPolaris->setHtml(QString(m_output.str().c_str()));
00151 m_Controls->m_outputTextMicronTracker->setHtml(QString(m_output.str().c_str()));
00152 m_Controls->m_outputTextPolaris->verticalScrollBar()->setValue(m_Controls->m_outputTextPolaris->verticalScrollBar()->maximum());
00153 m_Controls->m_outputTextAurora->verticalScrollBar()->setValue(m_Controls->m_outputTextAurora->verticalScrollBar()->maximum());
00154 m_Controls->m_outputTextMicronTracker->verticalScrollBar()->setValue(m_Controls->m_outputTextMicronTracker->verticalScrollBar()->maximum());
00155 repaint();
00156 }
00157 mitk::TrackingDevice::Pointer QmitkTrackingDeviceConfigurationWidget::ConstructTrackingDevice()
00158 {
00159 mitk::TrackingDevice::Pointer returnValue;
00160
00161 if (m_Controls->m_trackingDeviceChooser->currentIndex()==0)
00162 {
00163 if(m_Controls->m_radioPolaris5D->isChecked())
00164 {
00165
00166 returnValue = ConfigureNDI5DTrackingDevice();
00167 }
00168 else
00169 {
00170 returnValue = ConfigureNDI6DTrackingDevice();
00171 returnValue->SetType(mitk::NDIPolaris);
00172 }
00173 }
00174 else if (m_Controls->m_trackingDeviceChooser->currentIndex()==1)
00175 {
00176 returnValue = ConfigureNDI6DTrackingDevice();
00177 returnValue->SetType(mitk::NDIAurora);
00178 }
00179 else if (m_Controls->m_trackingDeviceChooser->currentIndex()==2)
00180 {
00181 returnValue = mitk::ClaronTrackingDevice::New();
00182 }
00183 return returnValue;
00184 }
00185
00186 mitk::TrackingDevice::Pointer QmitkTrackingDeviceConfigurationWidget::ConfigureNDI5DTrackingDevice()
00187 {
00188 return NULL;
00189 }
00190
00191 mitk::TrackingDevice::Pointer QmitkTrackingDeviceConfigurationWidget::ConfigureNDI6DTrackingDevice()
00192 {
00193 mitk::NDITrackingDevice::Pointer tempTrackingDevice = mitk::NDITrackingDevice::New();
00194 int comPort = 0;
00195 if (m_Controls->m_trackingDeviceChooser->currentIndex()==1) comPort = m_Controls->m_comPortSpinBoxAurora->value();
00196 else comPort = m_Controls->m_comPortSpinBoxPolaris->value();
00197 tempTrackingDevice->SetPortNumber(static_cast<mitk::SerialCommunication::PortNumber>(comPort));
00198 mitk::TrackingDevice::Pointer returnValue = static_cast<mitk::TrackingDevice*>(tempTrackingDevice);
00199 return returnValue;
00200 }
00201
00202 mitk::TrackingDevice::Pointer QmitkTrackingDeviceConfigurationWidget::GetTrackingDevice()
00203 {
00204 return this->m_TrackingDevice;
00205 }
00206