diff --git a/Modules/IGTUI/Qmitk/QmitkTrackingDeviceConfigurationWidgetControls.ui b/Modules/IGTUI/Qmitk/QmitkTrackingDeviceConfigurationWidgetControls.ui
index b2a4c30cc5..af461195fb 100644
--- a/Modules/IGTUI/Qmitk/QmitkTrackingDeviceConfigurationWidgetControls.ui
+++ b/Modules/IGTUI/Qmitk/QmitkTrackingDeviceConfigurationWidgetControls.ui
@@ -1,1045 +1,1045 @@
QmitkTrackingDeviceConfigurationWidgetControls
0
0
443
443
0
0
Form
-
0
0
-
-
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;">
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:600;">Tracking Device Configuration</span></p></body></html>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-weight:600;">Tracking Device Configuration</span></p></body></html>
-
Qt::Horizontal
40
20
-
+
-
+
+
+ Choose tracking device:
+
+
+
-
Qt::Horizontal
128
20
- -
-
-
- Choose tracking device:
-
-
-
-
0
0
-
Polaris
-
Aurora
-
MicronTracker
-
Optitrack
-
Qt::Horizontal
-
true
0
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;">
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; text-decoration: underline;">Polaris</span></p></body></html>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-weight:600;">Polaris</span></p></body></html>
-
-
-
-
Com Port:
-
COM
-
Auto Scan
-
Qt::Horizontal
40
20
-
-
Port Type:
-
-
/dev/ttyUSB
-
/dev/ttyS
-
Qt::Horizontal
40
20
-
0
0
Tracking Mode
-
false
5D
false
-
6D
true
-
Qt::Horizontal
62
20
-
Qt::Vertical
QSizePolicy::Expanding
158
17
-
-
120
50
120
80
120
0
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;" bgcolor="#000000">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> </span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> </span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:7pt; text-decoration: underline; color:#ffffff;">output:</span><span style=" font-size:8pt;"> </span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:7pt; color:#ffffff;">NDI Polaris selected</span><span style=" font-size:8pt;"> </span></p></body></html>
Qt::NoTextInteraction
-
120
0
120
16777215
Test Connection
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;">
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; text-decoration: underline;">Aurora</span></p></body></html>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-weight:600;">Aurora</span></p></body></html>
-
-
-
-
Com Port:
-
COM
-
Auto Scan
-
Qt::Horizontal
40
20
-
-
Port Type:
-
-
/dev/ttyUSB
-
/dev/ttyS
-
Qt::Horizontal
40
20
-
Qt::Vertical
20
40
-
-
120
50
120
80
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;" bgcolor="#000000">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> </span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> </span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; text-decoration: underline; color:#ffffff;">output:</span><span style=" font-size:8pt;"> </span></p></body></html>
Qt::NoTextInteraction
-
120
0
120
16777215
Test Connection
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;">
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; text-decoration: underline;">MicronTracker</span></p></body></html>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-weight:600;">MicronTracker</span></p></body></html>
-
-
-
Calibration File: <none>
-
-
Set Calibration File
-
Qt::Horizontal
40
20
-
Qt::Horizontal
40
20
-
Qt::Vertical
20
40
-
-
120
50
120
80
120
0
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;" bgcolor="#000000">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> </span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> </span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; text-decoration: underline; color:#ffffff;">output:</span><span style=" font-size:8pt;"> </span></p></body></html>
Qt::NoTextInteraction
-
120
0
120
16777215
120
0
test connection
-
0
0
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;">
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; text-decoration: underline;">Optitrack</span></p></body></html>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-weight:600;">Optitrack</span></p></body></html>
-
-
-
Calibration File: <none>
-
-
Set Calibration File
-
Qt::Horizontal
40
20
-
Camera Settings:
-
-
-
1
480
50
-
Exposition
-
-
250
200
-
Threshold
-
-
15
15
-
LED Power
-
Qt::Vertical
20
5
-
-
false
120
50
120
80
120
0
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;" bgcolor="#000000">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> </span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> </span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; text-decoration: underline; color:#ffffff;">output:</span><span style=" font-size:8pt;"> </span></p></body></html>
Qt::NoTextInteraction
-
120
0
120
16777215
120
0
test connection
-
-
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
- <html><head><meta name="qrichtext" content="1" /><style type="text/css">
- p, li { white-space: pre-wrap; }
- </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
- <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>
-
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+<html><head><meta name="qrichtext" content="1" /><style type="text/css">
+p, li { white-space: pre-wrap; }
+</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;">
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> </p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> </span></p>
+<p align="right" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Press "Finished" to confirm configuration</span> </p></body></html>
-
Qt::Vertical
20
14
-
Qt::Horizontal
-
-
Qt::Horizontal
40
20
-
Reset
-
Finished
-
0
-
Qt::Vertical
20
289
-
true
0
0
55
31
-
-
Qt::Vertical
20
269
-
16777215
0
-
Qt::Vertical
20
40
diff --git a/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTTrackingToolboxView.cpp b/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTTrackingToolboxView.cpp
index 05726856bd..fac6590c45 100644
--- a/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTTrackingToolboxView.cpp
+++ b/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTTrackingToolboxView.cpp
@@ -1,1253 +1,1253 @@
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
// Blueberry
#include
#include
// Qmitk
#include "QmitkMITKIGTTrackingToolboxView.h"
#include "QmitkStdMultiWidget.h"
// Qt
#include
#include
#include
// MITK
#include
#include
#include
#include
#include
#include
#include
#include
// vtk
#include
//for exceptions
#include
#include
const std::string QmitkMITKIGTTrackingToolboxView::VIEW_ID = "org.mitk.views.mitkigttrackingtoolbox";
QmitkMITKIGTTrackingToolboxView::QmitkMITKIGTTrackingToolboxView()
: QmitkFunctionality()
, m_Controls( 0 )
, m_MultiWidget( NULL )
{
m_TrackingTimer = new QTimer(this);
m_tracking = false;
m_logging = false;
m_loggedFrames = 0;
//initialize worker thread
m_WorkerThread = new QThread();
m_Worker = new QmitkMITKIGTTrackingToolboxViewWorker();
}
QmitkMITKIGTTrackingToolboxView::~QmitkMITKIGTTrackingToolboxView()
{
try
{
//clean up worker thread
if(m_WorkerThread) {delete m_WorkerThread;}
if(m_Worker) {delete m_Worker;}
//remove the tracking volume
this->GetDataStorage()->Remove(m_TrackingVolumeNode);
//remove the tool storage
if(m_toolStorage) {m_toolStorage->UnRegisterMicroservice();}
if(m_TrackingDeviceSource) {m_TrackingDeviceSource->UnRegisterMicroservice();}
}
catch(std::exception& e) {MITK_WARN << "Unexpected exception during clean up of tracking toolbox view: " << e.what();}
catch(...) {MITK_WARN << "Unexpected unknown error during clean up of tracking toolbox view!";}
this->StoreUISettings();
}
void QmitkMITKIGTTrackingToolboxView::CreateQtPartControl( QWidget *parent )
{
// build up qt view, unless already done
if ( !m_Controls )
{
// create GUI widgets from the Qt Designer's .ui file
m_Controls = new Ui::QmitkMITKIGTTrackingToolboxViewControls;
m_Controls->setupUi( parent );
//create connections
connect( m_Controls->m_LoadTools, SIGNAL(clicked()), this, SLOT(OnLoadTools()) );
connect( m_Controls->m_Connect, SIGNAL(clicked()), this, SLOT(OnConnect()) );
connect( m_Controls->m_Disconnect, SIGNAL(clicked()), this, SLOT(OnDisconnect()) );
connect( m_Controls->m_StartTracking, SIGNAL(clicked()), this, SLOT(OnStartTracking()) );
connect( m_Controls->m_StopTracking, SIGNAL(clicked()), this, SLOT(OnStopTracking()) );
connect( m_TrackingTimer, SIGNAL(timeout()), this, SLOT(UpdateTrackingTimer()));
connect( m_Controls->m_ChooseFile, SIGNAL(clicked()), this, SLOT(OnChooseFileClicked()));
connect( m_Controls->m_StartLogging, SIGNAL(clicked()), this, SLOT(StartLogging()));
connect( m_Controls->m_StopLogging, SIGNAL(clicked()), this, SLOT(StopLogging()));
connect( m_Controls->m_VolumeSelectionBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(OnTrackingVolumeChanged(QString)));
connect( m_Controls->m_ShowTrackingVolume, SIGNAL(clicked()), this, SLOT(OnShowTrackingVolumeChanged()));
connect( m_Controls->m_AutoDetectTools, SIGNAL(clicked()), this, SLOT(OnAutoDetectTools()));
connect( m_Controls->m_ResetTools, SIGNAL(clicked()), this, SLOT(OnResetTools()));
connect( m_Controls->m_AddSingleTool, SIGNAL(clicked()), this, SLOT(OnAddSingleTool()));
connect( m_Controls->m_NavigationToolCreationWidget, SIGNAL(NavigationToolFinished()), this, SLOT(OnAddSingleToolFinished()));
connect( m_Controls->m_NavigationToolCreationWidget, SIGNAL(Canceled()), this, SLOT(OnAddSingleToolCanceled()));
connect( m_Controls->m_csvFormat, SIGNAL(clicked()), this, SLOT(OnToggleFileExtension()));
connect( m_Controls->m_xmlFormat, SIGNAL(clicked()), this, SLOT(OnToggleFileExtension()));
//connections for the tracking device configuration widget
connect( m_Controls->m_configurationWidget, SIGNAL(TrackingDeviceSelectionChanged()), this, SLOT(OnTrackingDeviceChanged()));
connect( m_Controls->m_configurationWidget, SIGNAL(ProgressStarted()), this, SLOT(DisableOptionsButtons()));
connect( m_Controls->m_configurationWidget, SIGNAL(ProgressStarted()), this, SLOT(DisableTrackingConfigurationButtons()));
connect( m_Controls->m_configurationWidget, SIGNAL(ProgressStarted()), this, SLOT(DisableTrackingControls()));
connect( m_Controls->m_configurationWidget, SIGNAL(ProgressFinished()), this, SLOT(EnableOptionsButtons()));
connect( m_Controls->m_configurationWidget, SIGNAL(ProgressFinished()), this, SLOT(EnableTrackingConfigurationButtons()));
connect( m_Controls->m_configurationWidget, SIGNAL(ProgressFinished()), this, SLOT(EnableTrackingControls()));
//connect worker thread
connect(m_Worker, SIGNAL(AutoDetectToolsFinished(bool,QString)), this, SLOT(OnAutoDetectToolsFinished(bool,QString)) );
connect(m_Worker, SIGNAL(ConnectDeviceFinished(bool,QString)), this, SLOT(OnConnectFinished(bool,QString)) );
connect(m_Worker, SIGNAL(StartTrackingFinished(bool,QString)), this, SLOT(OnStartTrackingFinished(bool,QString)) );
connect(m_Worker, SIGNAL(StopTrackingFinished(bool,QString)), this, SLOT(OnStopTrackingFinished(bool,QString)) );
connect(m_Worker, SIGNAL(DisconnectDeviceFinished(bool,QString)), this, SLOT(OnDisconnectFinished(bool,QString)) );
connect(m_WorkerThread,SIGNAL(started()), m_Worker, SLOT(ThreadFunc()) );
//move the worker to the thread
m_Worker->moveToThread(m_WorkerThread);
//initialize widgets
m_Controls->m_configurationWidget->EnableAdvancedUserControl(false);
m_Controls->m_TrackingToolsStatusWidget->SetShowPositions(true);
m_Controls->m_TrackingToolsStatusWidget->SetTextAlignment(Qt::AlignLeft);
//initialize tracking volume node
m_TrackingVolumeNode = mitk::DataNode::New();
m_TrackingVolumeNode->SetName("TrackingVolume");
m_TrackingVolumeNode->SetBoolProperty("Backface Culling",true);
mitk::Color red;
red.SetRed(1);
m_TrackingVolumeNode->SetColor(red);
//initialize buttons
m_Controls->m_Connect->setEnabled(true);
m_Controls->m_Disconnect->setEnabled(false);
m_Controls->m_StartTracking->setEnabled(false);
m_Controls->m_StopTracking->setEnabled(false);
m_Controls->m_AutoDetectTools->setVisible(false); //only visible if tracking device is Aurora
//initialize tool storage
m_toolStorage = mitk::NavigationToolStorage::New(GetDataStorage());
m_toolStorage->SetName("TrackingToolbox Default Storage");
m_toolStorage->RegisterAsMicroservice("no tracking device");
//set home directory as default path for logfile
m_Controls->m_LoggingFileName->setText(QDir::toNativeSeparators(QDir::homePath()) + QDir::separator() + "logfile.csv");
//tracking device may be changed already by the persistence of the
//QmitkTrackingDeciveConfigurationWidget
this->OnTrackingDeviceChanged();
this->LoadUISettings();
//add tracking volume node only to data storage
this->GetDataStorage()->Add(m_TrackingVolumeNode);
if (!m_Controls->m_ShowTrackingVolume->isChecked()) m_TrackingVolumeNode->SetOpacity(0.0);
else m_TrackingVolumeNode->SetOpacity(0.25);
//Update List of available models for selected tool.
std::vector Compatibles = mitk::GetDeviceDataForLine( m_Controls->m_configurationWidget->GetTrackingDevice()->GetType());
m_Controls->m_VolumeSelectionBox->clear();
for(int i = 0; i < Compatibles.size(); i++)
{
m_Controls->m_VolumeSelectionBox->addItem(Compatibles[i].Model.c_str());
}
}
}
void QmitkMITKIGTTrackingToolboxView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget)
{
m_MultiWidget = &stdMultiWidget;
}
void QmitkMITKIGTTrackingToolboxView::StdMultiWidgetNotAvailable()
{
m_MultiWidget = NULL;
}
void QmitkMITKIGTTrackingToolboxView::OnLoadTools()
{
//read in filename
QString filename = QFileDialog::getOpenFileName(NULL,tr("Open Tool Storage"), "/", tr("Tool Storage Files (*.IGTToolStorage)"));
if (filename.isNull()) return;
//read tool storage from disk
std::string errorMessage = "";
mitk::NavigationToolStorageDeserializer::Pointer myDeserializer = mitk::NavigationToolStorageDeserializer::New(GetDataStorage());
// try-catch block for exceptions
try
{
this->ReplaceCurrentToolStorage(myDeserializer->Deserialize(filename.toStdString()),filename.toStdString());
}
catch(mitk::IGTException)
{
- std::string errormessage = "Error during deserializing. Problems with file,please check the file?";
- QMessageBox::warning(NULL, "IGTPlayer: Error", errormessage.c_str());
+ std::string errormessage = "Error during loading the tool storage file. Please only load tool storage files created with the NavigationToolManager view.";
+ QMessageBox::warning(NULL, "Tool Storage Loading Error", errormessage.c_str());
return;
}
if(m_toolStorage->isEmpty())
{
errorMessage = myDeserializer->GetErrorMessage();
MessageBox(errorMessage);
return;
}
//update label
UpdateToolStorageLabel(filename);
//update tool preview
m_Controls->m_TrackingToolsStatusWidget->RemoveStatusLabels();
m_Controls->m_TrackingToolsStatusWidget->PreShowTools(m_toolStorage);
//save filename for persistent storage
m_ToolStorageFilename = filename;
}
void QmitkMITKIGTTrackingToolboxView::OnResetTools()
{
this->ReplaceCurrentToolStorage(mitk::NavigationToolStorage::New(GetDataStorage()),"TrackingToolbox Default Storage");
m_Controls->m_TrackingToolsStatusWidget->RemoveStatusLabels();
QString toolLabel = QString("Loaded Tools: ");
m_Controls->m_toolLabel->setText(toolLabel);
m_ToolStorageFilename = "";
}
void QmitkMITKIGTTrackingToolboxView::OnConnect()
{
MITK_INFO << "Connect Clicked";
//check if everything is ready to start tracking
if (this->m_toolStorage.IsNull())
{
MessageBox("Error: No Tools Loaded Yet!");
return;
}
else if (this->m_toolStorage->GetToolCount() == 0)
{
MessageBox("Error: No Way To Track Without Tools!");
return;
}
//parse tracking device data
mitk::TrackingDeviceData data = mitk::DeviceDataUnspecified;
QString qstr = m_Controls->m_VolumeSelectionBox->currentText();
if ( (! qstr.isNull()) || (! qstr.isEmpty()) ) {
std::string str = qstr.toStdString();
data = mitk::GetDeviceDataByName(str); //Data will be set later, after device generation
}
//initialize worker thread
m_Worker->SetWorkerMethod(QmitkMITKIGTTrackingToolboxViewWorker::eConnectDevice);
m_Worker->SetTrackingDevice(this->m_Controls->m_configurationWidget->GetTrackingDevice());
m_Worker->SetInverseMode(m_Controls->m_InverseMode->isChecked());
m_Worker->SetNavigationToolStorage(this->m_toolStorage);
m_Worker->SetTrackingDeviceData(data);
//start worker thread
m_WorkerThread->start();
//disable buttons
this->m_Controls->m_MainWidget->setEnabled(false);
}
void QmitkMITKIGTTrackingToolboxView::OnConnectFinished(bool success, QString errorMessage)
{
m_WorkerThread->quit();
//enable buttons
this->m_Controls->m_MainWidget->setEnabled(true);
if (!success)
{
MITK_WARN << errorMessage.toStdString();
MessageBox(errorMessage.toStdString());
return;
}
//get data from worker thread
m_TrackingDeviceSource = m_Worker->GetTrackingDeviceSource();
m_TrackingDeviceData = m_Worker->GetTrackingDeviceData();
m_ToolVisualizationFilter = m_Worker->GetToolVisualizationFilter();
//enable/disable Buttons
m_Controls->m_Disconnect->setEnabled(true);
m_Controls->m_StartTracking->setEnabled(true);
m_Controls->m_StopTracking->setEnabled(false);
m_Controls->m_Connect->setEnabled(false);
DisableOptionsButtons();
DisableTrackingConfigurationButtons();
m_Controls->m_configurationWidget->ConfigurationFinished();
m_Controls->m_TrackingControlLabel->setText("Status: connected");
}
void QmitkMITKIGTTrackingToolboxView::OnDisconnect()
{
m_Worker->SetWorkerMethod(QmitkMITKIGTTrackingToolboxViewWorker::eDisconnectDevice);
m_WorkerThread->start();
m_Controls->m_MainWidget->setEnabled(false);
}
void QmitkMITKIGTTrackingToolboxView::OnDisconnectFinished(bool success, QString errorMessage)
{
m_WorkerThread->quit();
m_Controls->m_MainWidget->setEnabled(true);
if (!success)
{
MITK_WARN << errorMessage.toStdString();
MessageBox(errorMessage.toStdString());
return;
}
//enable/disable Buttons
m_Controls->m_Disconnect->setEnabled(false);
m_Controls->m_StartTracking->setEnabled(false);
m_Controls->m_StopTracking->setEnabled(false);
m_Controls->m_Connect->setEnabled(true);
EnableOptionsButtons();
EnableTrackingConfigurationButtons();
m_Controls->m_configurationWidget->Reset();
m_Controls->m_TrackingControlLabel->setText("Status: disconnected");
}
void QmitkMITKIGTTrackingToolboxView::OnStartTracking()
{
m_Worker->SetWorkerMethod(QmitkMITKIGTTrackingToolboxViewWorker::eStartTracking);
m_WorkerThread->start();
this->m_Controls->m_MainWidget->setEnabled(false);
}
void QmitkMITKIGTTrackingToolboxView::OnStartTrackingFinished(bool success, QString errorMessage)
{
m_WorkerThread->quit();
this->m_Controls->m_MainWidget->setEnabled(true);
if(!success)
{
MessageBox(errorMessage.toStdString());
MITK_WARN << errorMessage.toStdString();
return;
}
m_TrackingTimer->start(1000/(m_Controls->m_UpdateRate->value()));
m_Controls->m_TrackingControlLabel->setText("Status: tracking");
//connect the tool visualization widget
for(int i=0; iGetNumberOfOutputs(); i++)
{
m_Controls->m_TrackingToolsStatusWidget->AddNavigationData(m_TrackingDeviceSource->GetOutput(i));
}
m_Controls->m_TrackingToolsStatusWidget->ShowStatusLabels();
if (m_Controls->m_ShowToolQuaternions->isChecked()) {m_Controls->m_TrackingToolsStatusWidget->SetShowQuaternions(true);}
else {m_Controls->m_TrackingToolsStatusWidget->SetShowQuaternions(false);}
//show tracking volume
this->OnTrackingVolumeChanged(m_Controls->m_VolumeSelectionBox->currentText());
//enable/disable Buttons
m_Controls->m_Disconnect->setEnabled(true);
m_Controls->m_StartTracking->setEnabled(false);
m_Controls->m_StopTracking->setEnabled(true);
m_Controls->m_Connect->setEnabled(false);
m_tracking = true;
this->GlobalReinit();
}
void QmitkMITKIGTTrackingToolboxView::OnStopTracking()
{
if (!m_tracking) return;
m_TrackingTimer->stop();
m_Worker->SetWorkerMethod(QmitkMITKIGTTrackingToolboxViewWorker::eStopTracking);
m_WorkerThread->start();
m_Controls->m_MainWidget->setEnabled(false);
}
void QmitkMITKIGTTrackingToolboxView::OnStopTrackingFinished(bool success, QString errorMessage)
{
m_WorkerThread->quit();
m_Controls->m_MainWidget->setEnabled(true);
if(!success)
{
MessageBox(errorMessage.toStdString());
MITK_WARN << errorMessage.toStdString();
return;
}
m_Controls->m_TrackingControlLabel->setText("Status: connected");
if (m_logging) StopLogging();
m_Controls->m_TrackingToolsStatusWidget->RemoveStatusLabels();
m_Controls->m_TrackingToolsStatusWidget->PreShowTools(m_toolStorage);
m_tracking = false;
//enable/disable Buttons
m_Controls->m_Disconnect->setEnabled(true);
m_Controls->m_StartTracking->setEnabled(true);
m_Controls->m_StopTracking->setEnabled(false);
m_Controls->m_Connect->setEnabled(false);
this->GlobalReinit();
}
void QmitkMITKIGTTrackingToolboxView::OnTrackingDeviceChanged()
{
mitk::TrackingDeviceType Type;
if (m_Controls->m_configurationWidget->GetTrackingDevice().IsNotNull())
{
Type = m_Controls->m_configurationWidget->GetTrackingDevice()->GetType();
//enable controls because device is valid
m_Controls->m_TrackingToolsGoupBox->setEnabled(true);
m_Controls->m_TrackingControlsGroupBox->setEnabled(true);
}
else
{
Type = mitk::TrackingSystemNotSpecified;
MessageBox("Error: This tracking device is not included in this project. Please make sure that the device is installed and activated in your MITK build.");
m_Controls->m_TrackingToolsGoupBox->setEnabled(false);
m_Controls->m_TrackingControlsGroupBox->setEnabled(false);
return;
}
// Code to enable/disable device specific buttons
if (Type == mitk::NDIAurora) //Aurora
{
m_Controls->m_AutoDetectTools->setVisible(true);
m_Controls->m_AddSingleTool->setEnabled(false);
}
else //Polaris or Microntracker
{
m_Controls->m_AutoDetectTools->setVisible(false);
m_Controls->m_AddSingleTool->setEnabled(true);
}
// Code to select appropriate tracking volume for current type
std::vector Compatibles = mitk::GetDeviceDataForLine(Type);
m_Controls->m_VolumeSelectionBox->clear();
for(int i = 0; i < Compatibles.size(); i++)
{
m_Controls->m_VolumeSelectionBox->addItem(Compatibles[i].Model.c_str());
}
}
void QmitkMITKIGTTrackingToolboxView::OnTrackingVolumeChanged(QString qstr)
{
if (qstr.isNull()) return;
if (qstr.isEmpty()) return;
mitk::TrackingVolumeGenerator::Pointer volumeGenerator = mitk::TrackingVolumeGenerator::New();
std::string str = qstr.toStdString();
mitk::TrackingDeviceData data = mitk::GetDeviceDataByName(str);
m_TrackingDeviceData = data;
volumeGenerator->SetTrackingDeviceData(data);
volumeGenerator->Update();
mitk::Surface::Pointer volumeSurface = volumeGenerator->GetOutput();
m_TrackingVolumeNode->SetData(volumeSurface);
if (!m_Controls->m_ShowTrackingVolume->isChecked()) m_TrackingVolumeNode->SetOpacity(0.0);
else m_TrackingVolumeNode->SetOpacity(0.25);
GlobalReinit();
}
void QmitkMITKIGTTrackingToolboxView::OnShowTrackingVolumeChanged()
{
if (m_Controls->m_ShowTrackingVolume->isChecked())
{
OnTrackingVolumeChanged(m_Controls->m_VolumeSelectionBox->currentText());
m_TrackingVolumeNode->SetOpacity(0.25);
}
else
{
m_TrackingVolumeNode->SetOpacity(0.0);
}
}
void QmitkMITKIGTTrackingToolboxView::OnAutoDetectTools()
{
if (m_Controls->m_configurationWidget->GetTrackingDevice()->GetType() == mitk::NDIAurora)
{
DisableTrackingConfigurationButtons();
m_Worker->SetWorkerMethod(QmitkMITKIGTTrackingToolboxViewWorker::eAutoDetectTools);
m_Worker->SetTrackingDevice(m_Controls->m_configurationWidget->GetTrackingDevice().GetPointer());
m_Worker->SetDataStorage(this->GetDataStorage());
m_WorkerThread->start();
//disable controls until worker thread is finished
this->m_Controls->m_MainWidget->setEnabled(false);
}
}
void QmitkMITKIGTTrackingToolboxView::OnAutoDetectToolsFinished(bool success, QString errorMessage)
{
m_WorkerThread->quit();
//enable controls again
this->m_Controls->m_MainWidget->setEnabled(true);
if(!success)
{
MITK_WARN << errorMessage.toStdString();
MessageBox(errorMessage.toStdString());
EnableTrackingConfigurationButtons();
return;
}
mitk::NavigationToolStorage::Pointer autoDetectedStorage = m_Worker->GetNavigationToolStorage();
//save detected tools
this->ReplaceCurrentToolStorage(autoDetectedStorage,"Autodetected NDI Aurora Storage");
//update label
QString toolLabel = QString("Loaded Tools: ") + QString::number(m_toolStorage->GetToolCount()) + " Tools (Auto Detected)";
m_Controls->m_toolLabel->setText(toolLabel);
//update tool preview
m_Controls->m_TrackingToolsStatusWidget->RemoveStatusLabels();
m_Controls->m_TrackingToolsStatusWidget->PreShowTools(m_toolStorage);
EnableTrackingConfigurationButtons();
if (m_toolStorage->GetToolCount()>0)
{
//ask the user if he wants to save the detected tools
QMessageBox msgBox;
switch(m_toolStorage->GetToolCount())
{
case 1:
msgBox.setText("Found one tool!");
break;
default:
msgBox.setText("Found " + QString::number(m_toolStorage->GetToolCount()) + " tools!");
}
msgBox.setInformativeText("Do you want to save this tools as tool storage, so you can load them again?");
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
int ret = msgBox.exec();
if (ret == 16384) //yes
{
//ask the user for a filename
QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save File"),"/",tr("*.IGTToolStorage"));
//check for empty filename
if(fileName == "") {return;}
mitk::NavigationToolStorageSerializer::Pointer mySerializer = mitk::NavigationToolStorageSerializer::New();
//when Serialize method is used exceptions are thrown, need to be adapted
//try-catch block for exception handling in Serializer
try
{
mySerializer->Serialize(fileName.toStdString(),m_toolStorage);
}
catch(mitk::IGTException)
{
std::string errormessage = "Error during serialization. Please check the Zip file.";
QMessageBox::warning(NULL, "IGTPlayer: Error", errormessage.c_str());}
return;
}
else if (ret == 65536) //no
{
return;
}
}
}
void QmitkMITKIGTTrackingToolboxView::MessageBox(std::string s)
{
QMessageBox msgBox;
msgBox.setText(s.c_str());
msgBox.exec();
}
void QmitkMITKIGTTrackingToolboxView::UpdateTrackingTimer()
{
//update filter
m_ToolVisualizationFilter->Update();
MITK_DEBUG << "Number of outputs ToolVisualizationFilter: " << m_ToolVisualizationFilter->GetNumberOfIndexedOutputs();
MITK_DEBUG << "Number of inputs ToolVisualizationFilter: " << m_ToolVisualizationFilter->GetNumberOfIndexedInputs();
//update tool colors to show tool status
for(int i=0; iGetNumberOfIndexedOutputs(); i++)
{
mitk::NavigationData::Pointer currentTool = m_ToolVisualizationFilter->GetOutput(i);
if(currentTool->IsDataValid())
{this->m_toolStorage->GetTool(i)->GetDataNode()->SetColor(mitk::IGTColor_VALID);}
else
{this->m_toolStorage->GetTool(i)->GetDataNode()->SetColor(mitk::IGTColor_WARNING);}
}
//update logging
if (m_logging)
{
this->m_loggingFilter->Update();
m_loggedFrames = this->m_loggingFilter->GetRecordCounter();
this->m_Controls->m_LoggedFramesLabel->setText("Logged Frames: "+QString::number(m_loggedFrames));
//check if logging stopped automatically
if((m_loggedFrames>1)&&(!m_loggingFilter->GetRecording())){StopLogging();}
}
//refresh view and status widget
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
m_Controls->m_TrackingToolsStatusWidget->Refresh();
//code to better isolate bug 17713, could be removed when bug 17713 is fixed
static int i = 0;
static mitk::Point3D lastPositionTool1 = m_ToolVisualizationFilter->GetOutput(0)->GetPosition();
static itk::TimeStamp lastTimeStamp = m_ToolVisualizationFilter->GetOutput(0)->GetTimeStamp();
i++;
//every 20 frames: check if tracking is frozen
if(i>20)
{
i = 0;
if (m_ToolVisualizationFilter->GetOutput(0)->IsDataValid())
{
if (mitk::Equal(lastPositionTool1,m_ToolVisualizationFilter->GetOutput(0)->GetPosition(),0.000000001,false))
{
MITK_WARN << "Seems as tracking (of at least tool 1) is frozen which means that bug 17713 occurred. Restart tracking might help.";
//display further information to find the bug
MITK_WARN << "Timestamp of current navigation data: " << m_ToolVisualizationFilter->GetOutput(0)->GetTimeStamp();
MITK_WARN << "Timestamp of last navigation data (which holds the same values): " << lastTimeStamp;
}
lastPositionTool1 = m_ToolVisualizationFilter->GetOutput(0)->GetPosition();
lastTimeStamp = m_ToolVisualizationFilter->GetOutput(0)->GetTimeStamp();
}
}
}
void QmitkMITKIGTTrackingToolboxView::OnChooseFileClicked()
{
QDir currentPath = QFileInfo(m_Controls->m_LoggingFileName->text()).dir();
// if no path was selected (QDir would select current working dir then) or the
// selected path does not exist -> use home directory
if ( currentPath == QDir() || ! currentPath.exists() )
{
currentPath = QDir(QDir::homePath());
}
QString filename = QFileDialog::getSaveFileName(NULL,tr("Choose Logging File"), currentPath.absolutePath(), "*.*");
if (filename == "") return;
this->m_Controls->m_LoggingFileName->setText(filename);
this->OnToggleFileExtension();
}
// bug-16470: toggle file extension after clicking on radio button
void QmitkMITKIGTTrackingToolboxView::OnToggleFileExtension()
{
QString currentInputText = this->m_Controls->m_LoggingFileName->text();
QString currentFile = QFileInfo(currentInputText).baseName();
QDir currentPath = QFileInfo(currentInputText).dir();
if(currentFile.isEmpty())
{
currentFile = "logfile";
}
// Setting currentPath to default home path when currentPath is empty or it does not exist
if(currentPath == QDir() || !currentPath.exists())
{
currentPath = QDir::homePath();
}
// check if csv radio button is clicked
if(this->m_Controls->m_csvFormat->isChecked())
{
// you needn't add a seperator to the input text when currentpath is the rootpath
if(currentPath.isRoot())
{
this->m_Controls->m_LoggingFileName->setText(QDir::toNativeSeparators(currentPath.absolutePath()) + currentFile + ".csv");
}
else
{
this->m_Controls->m_LoggingFileName->setText(QDir::toNativeSeparators(currentPath.absolutePath()) + QDir::separator() + currentFile + ".csv");
}
}
// check if xml radio button is clicked
else if(this->m_Controls->m_xmlFormat->isChecked())
{
// you needn't add a seperator to the input text when currentpath is the rootpath
if(currentPath.isRoot())
{
this->m_Controls->m_LoggingFileName->setText(QDir::toNativeSeparators(currentPath.absolutePath()) + currentFile + ".xml");
}
else
{
this->m_Controls->m_LoggingFileName->setText(QDir::toNativeSeparators(currentPath.absolutePath()) + QDir::separator() + currentFile + ".xml");
}
}
}
void QmitkMITKIGTTrackingToolboxView::StartLogging()
{
if (m_ToolVisualizationFilter.IsNull())
{
MessageBox("Cannot activate logging without a connected device. Configure and connect a tracking device first.");
return;
}
if (!m_logging)
{
//initialize logging filter
m_loggingFilter = mitk::NavigationDataRecorder::New();
m_loggingFilter->SetRecordingMode(mitk::NavigationDataRecorder::NormalFile);
if (m_Controls->m_xmlFormat->isChecked()) m_loggingFilter->SetOutputFormat(mitk::NavigationDataRecorder::xml);
else if (m_Controls->m_csvFormat->isChecked()) m_loggingFilter->SetOutputFormat(mitk::NavigationDataRecorder::csv);
std::string filename = m_Controls->m_LoggingFileName->text().toStdString().c_str();
// this part has been changed in order to prevent crash of the program
if(!filename.empty())
m_loggingFilter->SetFileName(filename);
else if(filename.empty()){
std::string errormessage = "File name has not been set, please set the file name";
mitkThrowException(mitk::IGTIOException)<SetFileName(filename);
}
if (m_Controls->m_LoggingLimit->isChecked()){m_loggingFilter->SetRecordCountLimit(m_Controls->m_LoggedFramesLimit->value());}
//connect filter
for(int i=0; iGetNumberOfOutputs(); i++){m_loggingFilter->AddNavigationData(m_ToolVisualizationFilter->GetOutput(i));}
//start filter with try-catch block for exceptions
try
{
m_loggingFilter->StartRecording();
}
catch(mitk::IGTException)
{
std::string errormessage = "Error during start recording. Recorder already started recording?";
QMessageBox::warning(NULL, "IGTPlayer: Error", errormessage.c_str());
m_loggingFilter->StopRecording();
return;
}
//update labels / logging variables
this->m_Controls->m_LoggingLabel->setText("Logging ON");
this->m_Controls->m_LoggedFramesLabel->setText("Logged Frames: 0");
m_loggedFrames = 0;
m_logging = true;
DisableLoggingButtons();
}
}
void QmitkMITKIGTTrackingToolboxView::StopLogging()
{
if (m_logging)
{
//update label
this->m_Controls->m_LoggingLabel->setText("Logging OFF");
m_loggingFilter->StopRecording();
m_logging = false;
EnableLoggingButtons();
}
}
void QmitkMITKIGTTrackingToolboxView::OnAddSingleTool()
{
QString Identifier = "Tool#";
if (m_toolStorage.IsNotNull()) Identifier += QString::number(m_toolStorage->GetToolCount());
else Identifier += "0";
m_Controls->m_NavigationToolCreationWidget->Initialize(GetDataStorage(),Identifier.toStdString());
m_Controls->m_NavigationToolCreationWidget->SetTrackingDeviceType(m_Controls->m_configurationWidget->GetTrackingDevice()->GetType(),false);
m_Controls->m_TrackingToolsWidget->setCurrentIndex(1);
//disable tracking volume during tool editing
lastTrackingVolumeState = m_Controls->m_ShowTrackingVolume->isChecked();
if (lastTrackingVolumeState) m_Controls->m_ShowTrackingVolume->click();
GlobalReinit();
}
void QmitkMITKIGTTrackingToolboxView::OnAddSingleToolFinished()
{
m_Controls->m_TrackingToolsWidget->setCurrentIndex(0);
if (this->m_toolStorage.IsNull())
{
//this shouldn't happen!
MITK_WARN << "No ToolStorage available, cannot add tool, aborting!";
return;
}
m_toolStorage->AddTool(m_Controls->m_NavigationToolCreationWidget->GetCreatedTool());
m_Controls->m_TrackingToolsStatusWidget->PreShowTools(m_toolStorage);
QString toolLabel = QString("Loaded Tools: ");
//enable tracking volume again
if (lastTrackingVolumeState) m_Controls->m_ShowTrackingVolume->click();
GlobalReinit();
}
void QmitkMITKIGTTrackingToolboxView::OnAddSingleToolCanceled()
{
m_Controls->m_TrackingToolsWidget->setCurrentIndex(0);
//enable tracking volume again
if (lastTrackingVolumeState) m_Controls->m_ShowTrackingVolume->click();
GlobalReinit();
}
void QmitkMITKIGTTrackingToolboxView::GlobalReinit()
{
// get all nodes that have not set "includeInBoundingBox" to false
mitk::NodePredicateNot::Pointer pred = mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("includeInBoundingBox", mitk::BoolProperty::New(false)));
mitk::DataStorage::SetOfObjects::ConstPointer rs = this->GetDataStorage()->GetSubset(pred);
// calculate bounding geometry of these nodes
mitk::TimeGeometry::Pointer bounds = this->GetDataStorage()->ComputeBoundingGeometry3D(rs, "visible");
// initialize the views to the bounding geometry
mitk::RenderingManager::GetInstance()->InitializeViews(bounds);
}
void QmitkMITKIGTTrackingToolboxView::DisableLoggingButtons()
{
m_Controls->m_StartLogging->setEnabled(false);
m_Controls->m_LoggingFileName->setEnabled(false);
m_Controls->m_ChooseFile->setEnabled(false);
m_Controls->m_LoggingLimit->setEnabled(false);
m_Controls->m_LoggedFramesLimit->setEnabled(false);
m_Controls->m_csvFormat->setEnabled(false);
m_Controls->m_xmlFormat->setEnabled(false);
m_Controls->m_StopLogging->setEnabled(true);
}
void QmitkMITKIGTTrackingToolboxView::EnableLoggingButtons()
{
m_Controls->m_StartLogging->setEnabled(true);
m_Controls->m_LoggingFileName->setEnabled(true);
m_Controls->m_ChooseFile->setEnabled(true);
m_Controls->m_LoggingLimit->setEnabled(true);
m_Controls->m_LoggedFramesLimit->setEnabled(true);
m_Controls->m_csvFormat->setEnabled(true);
m_Controls->m_xmlFormat->setEnabled(true);
m_Controls->m_StopLogging->setEnabled(false);
}
void QmitkMITKIGTTrackingToolboxView::DisableOptionsButtons()
{
m_Controls->m_ShowTrackingVolume->setEnabled(false);
m_Controls->m_UpdateRate->setEnabled(false);
m_Controls->m_ShowToolQuaternions->setEnabled(false);
m_Controls->m_OptionsUpdateRateLabel->setEnabled(false);
}
void QmitkMITKIGTTrackingToolboxView::EnableOptionsButtons()
{
m_Controls->m_ShowTrackingVolume->setEnabled(true);
m_Controls->m_UpdateRate->setEnabled(true);
m_Controls->m_ShowToolQuaternions->setEnabled(true);
m_Controls->m_OptionsUpdateRateLabel->setEnabled(true);
}
void QmitkMITKIGTTrackingToolboxView::EnableTrackingControls()
{
m_Controls->m_TrackingControlsGroupBox->setEnabled(true);
}
void QmitkMITKIGTTrackingToolboxView::DisableTrackingControls()
{
m_Controls->m_TrackingControlsGroupBox->setEnabled(false);
}
void QmitkMITKIGTTrackingToolboxView::EnableTrackingConfigurationButtons()
{
m_Controls->m_AutoDetectTools->setEnabled(true);
if (m_Controls->m_configurationWidget->GetTrackingDevice()->GetType() != mitk::NDIAurora) m_Controls->m_AddSingleTool->setEnabled(true);
m_Controls->m_LoadTools->setEnabled(true);
m_Controls->m_ResetTools->setEnabled(true);
}
void QmitkMITKIGTTrackingToolboxView::DisableTrackingConfigurationButtons()
{
m_Controls->m_AutoDetectTools->setEnabled(false);
if (m_Controls->m_configurationWidget->GetTrackingDevice()->GetType() != mitk::NDIAurora) m_Controls->m_AddSingleTool->setEnabled(false);
m_Controls->m_LoadTools->setEnabled(false);
m_Controls->m_ResetTools->setEnabled(false);
}
void QmitkMITKIGTTrackingToolboxView::ReplaceCurrentToolStorage(mitk::NavigationToolStorage::Pointer newStorage, std::string newStorageName)
{
//first: get rid of the old one
m_toolStorage->UnLockStorage(); //only to be sure...
m_toolStorage->UnRegisterMicroservice();
m_toolStorage = NULL;
//now: replace by the new one
m_toolStorage = newStorage;
m_toolStorage->SetName(newStorageName);
m_toolStorage->RegisterAsMicroservice("no tracking device");
}
void QmitkMITKIGTTrackingToolboxView::StoreUISettings()
{
// persistence service does not directly work in plugins for now
// -> using QSettings
QSettings settings;
settings.beginGroup(QString::fromStdString(VIEW_ID));
// set the values of some widgets and attrbutes to the QSettings
settings.setValue("ShowTrackingVolume", QVariant(m_Controls->m_ShowTrackingVolume->isChecked()));
settings.setValue("toolStorageFilename", QVariant(m_ToolStorageFilename));
settings.setValue("VolumeSelectionBox", QVariant(m_Controls->m_VolumeSelectionBox->currentIndex()));
settings.endGroup();
}
void QmitkMITKIGTTrackingToolboxView::LoadUISettings()
{
// persistence service does not directly work in plugins for now
// -> using QSettings
QSettings settings;
settings.beginGroup(QString::fromStdString(VIEW_ID));
// set some widgets and attributes by the values from the QSettings
m_Controls->m_ShowTrackingVolume->setChecked(settings.value("ShowTrackingVolume", true).toBool());
m_Controls->m_VolumeSelectionBox->setCurrentIndex(settings.value("VolumeSelectionBox", 0).toInt());
m_ToolStorageFilename = settings.value("toolStorageFilename", QVariant("")).toString();
settings.endGroup();
// try to deserialize the tool storage from the given tool storage file name
if ( ! m_ToolStorageFilename.isEmpty() )
{
// try-catch block for exceptions
try
{
mitk::NavigationToolStorageDeserializer::Pointer myDeserializer = mitk::NavigationToolStorageDeserializer::New(GetDataStorage());
m_toolStorage->UnRegisterMicroservice();
m_toolStorage = myDeserializer->Deserialize(m_ToolStorageFilename.toStdString());
m_toolStorage->RegisterAsMicroservice("no tracking device");
//update label
UpdateToolStorageLabel(m_ToolStorageFilename);
//update tool preview
m_Controls->m_TrackingToolsStatusWidget->RemoveStatusLabels();
m_Controls->m_TrackingToolsStatusWidget->PreShowTools(m_toolStorage);
}
catch(mitk::IGTException)
{
MITK_WARN("QmitkMITKIGTTrackingToolBoxView") << "Error during restoring tools. Problems with file ("<OnResetTools(); //if there where errors reset the tool storage to avoid problems later on
}
}
}
void QmitkMITKIGTTrackingToolboxView::UpdateToolStorageLabel(QString pathOfLoadedStorage)
{
Poco::Path myPath = Poco::Path(pathOfLoadedStorage.toStdString()); //use this to seperate filename from path
QString toolLabel = QString("Loaded ") + QString::number(m_toolStorage->GetToolCount()) + " Tools from " + myPath.getFileName().c_str();
if (toolLabel.size() > 55) //if the tool storage name is to long trimm the string
{
toolLabel.resize(50);
toolLabel+="[...]";
}
m_Controls->m_toolLabel->setText(toolLabel);
}
void QmitkMITKIGTTrackingToolboxViewWorker::SetWorkerMethod(WorkerMethod w)
{
m_WorkerMethod = w;
}
void QmitkMITKIGTTrackingToolboxViewWorker::SetTrackingDevice(mitk::TrackingDevice::Pointer t)
{
m_TrackingDevice = t;
}
void QmitkMITKIGTTrackingToolboxViewWorker::SetDataStorage(mitk::DataStorage::Pointer d)
{
m_DataStorage = d;
}
void QmitkMITKIGTTrackingToolboxViewWorker::SetInverseMode(bool mode)
{
m_InverseMode = mode;
}
void QmitkMITKIGTTrackingToolboxViewWorker::SetTrackingDeviceData(mitk::TrackingDeviceData d)
{
m_TrackingDeviceData = d;
}
void QmitkMITKIGTTrackingToolboxViewWorker::SetNavigationToolStorage(mitk::NavigationToolStorage::Pointer n)
{
m_NavigationToolStorage = n;
}
void QmitkMITKIGTTrackingToolboxViewWorker::ThreadFunc()
{
switch(m_WorkerMethod)
{
case eAutoDetectTools:
this->AutoDetectTools();
break;
case eConnectDevice:
this->ConnectDevice();
break;
case eStartTracking:
this->StartTracking();
break;
case eStopTracking:
this->StopTracking();
break;
case eDisconnectDevice:
this->DisconnectDevice();
break;
default:
MITK_WARN << "Undefined worker method was set ... something went wrong!";
break;
}
}
void QmitkMITKIGTTrackingToolboxViewWorker::AutoDetectTools()
{
mitk::ProgressBar::GetInstance()->AddStepsToDo(4);
mitk::NavigationToolStorage::Pointer autoDetectedStorage = mitk::NavigationToolStorage::New(m_DataStorage);
mitk::NDITrackingDevice::Pointer currentDevice = dynamic_cast(m_TrackingDevice.GetPointer());
try
{
currentDevice->OpenConnection();
mitk::ProgressBar::GetInstance()->Progress();
currentDevice->StartTracking();
}
catch(mitk::Exception& e)
{
QString message = QString("Warning, can not auto-detect tools! (") + QString(e.GetDescription()) + QString(")");
//MessageBox(message.toStdString()); //TODO: give message to the user here!
MITK_WARN << message.toStdString();
mitk::ProgressBar::GetInstance()->Progress(4);
emit AutoDetectToolsFinished(false,message.toStdString().c_str());
return;
}
for (int i=0; iGetToolCount(); i++)
{
//create a navigation tool with sphere as surface
std::stringstream toolname;
toolname << "AutoDetectedTool" << i;
mitk::NavigationTool::Pointer newTool = mitk::NavigationTool::New();
newTool->SetSerialNumber(dynamic_cast(currentDevice->GetTool(i))->GetSerialNumber());
newTool->SetIdentifier(toolname.str());
newTool->SetTrackingDeviceType(mitk::NDIAurora);
mitk::DataNode::Pointer newNode = mitk::DataNode::New();
mitk::Surface::Pointer mySphere = mitk::Surface::New();
vtkSphereSource *vtkData = vtkSphereSource::New();
vtkData->SetRadius(3.0f);
vtkData->SetCenter(0.0, 0.0, 0.0);
vtkData->Update();
mySphere->SetVtkPolyData(vtkData->GetOutput());
vtkData->Delete();
newNode->SetData(mySphere);
newNode->SetName(toolname.str());
newTool->SetDataNode(newNode);
autoDetectedStorage->AddTool(newTool);
}
m_NavigationToolStorage = autoDetectedStorage;
currentDevice->StopTracking();
mitk::ProgressBar::GetInstance()->Progress();
currentDevice->CloseConnection();
emit AutoDetectToolsFinished(true,"");
mitk::ProgressBar::GetInstance()->Progress(4);
}
void QmitkMITKIGTTrackingToolboxViewWorker::ConnectDevice()
{
std::string message = "";
mitk::ProgressBar::GetInstance()->AddStepsToDo(10);
//build the IGT pipeline
mitk::TrackingDevice::Pointer trackingDevice = m_TrackingDevice;
trackingDevice->SetData(m_TrackingDeviceData);
//set device to rotation mode transposed becaus we are working with VNL style quaternions
if(m_InverseMode)
{trackingDevice->SetRotationMode(mitk::TrackingDevice::RotationTransposed);}
//Get Tracking Volume Data
mitk::TrackingDeviceData data = m_TrackingDeviceData;
mitk::ProgressBar::GetInstance()->Progress();
//Create Navigation Data Source with the factory class
mitk::TrackingDeviceSourceConfigurator::Pointer myTrackingDeviceSourceFactory = mitk::TrackingDeviceSourceConfigurator::New(m_NavigationToolStorage,trackingDevice);
m_TrackingDeviceSource = myTrackingDeviceSourceFactory->CreateTrackingDeviceSource(m_ToolVisualizationFilter);
mitk::ProgressBar::GetInstance()->Progress();
if ( m_TrackingDeviceSource.IsNull() )
{
message = std::string("Cannot connect to device: ") + myTrackingDeviceSourceFactory->GetErrorMessage();
emit ConnectDeviceFinished(false,QString(message.c_str()));
return;
}
//set filter to rotation mode transposed becaus we are working with VNL style quaternions
if(m_InverseMode)
m_ToolVisualizationFilter->SetRotationMode(mitk::NavigationDataObjectVisualizationFilter::RotationTransposed);
//First check if the created object is valid
if (m_TrackingDeviceSource.IsNull())
{
message = myTrackingDeviceSourceFactory->GetErrorMessage();
emit ConnectDeviceFinished(false,QString(message.c_str()));
return;
}
MITK_INFO << "Number of tools: " << m_TrackingDeviceSource->GetNumberOfOutputs();
mitk::ProgressBar::GetInstance()->Progress();
//The tools are maybe reordered after initialization, e.g. in case of auto-detected tools of NDI Aurora
mitk::NavigationToolStorage::Pointer toolsInNewOrder = myTrackingDeviceSourceFactory->GetUpdatedNavigationToolStorage();
if ((toolsInNewOrder.IsNotNull()) && (toolsInNewOrder->GetToolCount() > 0))
{
//so delete the old tools in wrong order and add them in the right order
//we cannot simply replace the tool storage because the new storage is
//not correctly initialized with the right data storage
m_NavigationToolStorage->DeleteAllTools();
for (int i=0; i < toolsInNewOrder->GetToolCount(); i++) {m_NavigationToolStorage->AddTool(toolsInNewOrder->GetTool(i));}
}
mitk::ProgressBar::GetInstance()->Progress();
//connect to device
try
{
m_TrackingDeviceSource->Connect();
mitk::ProgressBar::GetInstance()->Progress();
//Microservice registration:
m_TrackingDeviceSource->RegisterAsMicroservice();
m_NavigationToolStorage->UnRegisterMicroservice();
m_NavigationToolStorage->RegisterAsMicroservice(m_TrackingDeviceSource->GetMicroserviceID());
m_NavigationToolStorage->LockStorage();
}
catch (...) //todo: change to mitk::IGTException
{
message = "Error on connecting the tracking device.";
emit ConnectDeviceFinished(false,QString(message.c_str()));
return;
}
emit ConnectDeviceFinished(true,QString(message.c_str()));
mitk::ProgressBar::GetInstance()->Progress(10);
}
void QmitkMITKIGTTrackingToolboxViewWorker::StartTracking()
{
QString errorMessage = "";
try
{
m_TrackingDeviceSource->StartTracking();
}
catch (...) //todo: change to mitk::IGTException
{
errorMessage += "Error while starting the tracking device!";
emit StartTrackingFinished(false,errorMessage);
return;
}
//remember the original colors of the tools
m_OriginalColors = std::map();
for(int i=0; im_NavigationToolStorage->GetToolCount(); i++)
{
mitk::DataNode::Pointer currentToolNode = m_NavigationToolStorage->GetTool(i)->GetDataNode();
float c[3];
currentToolNode->GetColor(c);
mitk::Color color;
color.SetRed(c[0]);
color.SetGreen(c[1]);
color.SetBlue(c[2]);
m_OriginalColors[currentToolNode] = color;
}
emit StartTrackingFinished(true,errorMessage);
}
void QmitkMITKIGTTrackingToolboxViewWorker::StopTracking()
{
//stop tracking
try
{
m_TrackingDeviceSource->StopTracking();
}
catch(mitk::Exception& e)
{
emit StopTrackingFinished(false, e.GetDescription());
}
//restore the original colors of the tools
for(int i=0; im_NavigationToolStorage->GetToolCount(); i++)
{
mitk::DataNode::Pointer currentToolNode = m_NavigationToolStorage->GetTool(i)->GetDataNode();
if (m_OriginalColors.find(currentToolNode) == m_OriginalColors.end())
{MITK_WARN << "Cannot restore original color of tool " << m_NavigationToolStorage->GetTool(i)->GetToolName();}
else
{currentToolNode->SetColor(m_OriginalColors[currentToolNode]);}
}
//emit signal
emit StopTrackingFinished(true, "");
}
void QmitkMITKIGTTrackingToolboxViewWorker::DisconnectDevice()
{
try
{
if (m_TrackingDeviceSource->IsTracking()) {m_TrackingDeviceSource->StopTracking();}
m_TrackingDeviceSource->Disconnect();
m_TrackingDeviceSource->UnRegisterMicroservice();
m_NavigationToolStorage->UnLockStorage();
}
catch(mitk::Exception& e)
{
emit DisconnectDeviceFinished(false, e.GetDescription());
}
emit DisconnectDeviceFinished(true, "");
}
diff --git a/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTTrackingToolboxViewControls.ui b/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTTrackingToolboxViewControls.ui
index 6d4b536dbc..06f438d54c 100644
--- a/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTTrackingToolboxViewControls.ui
+++ b/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTTrackingToolboxViewControls.ui
@@ -1,700 +1,692 @@
QmitkMITKIGTTrackingToolboxViewControls
0
0
- 438
- 1001
+ 346
+ 997
0
0
QmitkTemplate
-
0
Tracking
-
0
0
0
300
16777215
280
-
0
0
-
-
+
+
+ 6
+ 75
+ true
+
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
-</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:600;">Tracking Tools</span></p></body></html>
+</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;">
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-weight:600;">Tracking Tools</span></p></body></html>
-
0
0
-
-
Loaded Tools: <none>
-
Qt::Horizontal
40
20
-
Auto Detection
-
200
150
-
-
Qt::Horizontal
40
20
-
120
0
Add Single Tool
-
-
Qt::Horizontal
40
20
- -
-
-
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
-<html><head><meta name="qrichtext" content="1" /><style type="text/css">
-p, li { white-space: pre-wrap; }
-</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
-<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; font-style:italic;">(only load tool storage files created </span></p>
-<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; font-style:italic;">with </span><span style=" font-size:8pt; font-style:italic;">the "NavigationToolManager")</span></p></body></html>
-
-
- Qt::AlignJustify|Qt::AlignVCenter
-
-
-
-
120
0
Load Tool Storage
-
-
Qt::Horizontal
40
20
-
120
0
Reset
-
-
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
-</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:600;">Tracking Control</span></p></body></html>
+</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;">
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-weight:600;">Tracking Control</span></p></body></html>
-
Status: <not configured>
-
-
Qt::Horizontal
40
20
-
120
0
Connect
-
-
Qt::Horizontal
40
20
-
120
0
Start Tracking
-
-
Qt::Horizontal
40
20
-
120
0
Stop Tracking
-
-
Qt::Horizontal
40
20
-
120
0
Disconnect
-
Qt::Vertical
20
40
Options
-
true
Show Tracking Volume
true
-
Select Model:
-
-
Qt::Horizontal
-
-
Update Rate (Times Per Second)
-
Qt::Horizontal
40
20
-
999
10
-
Show Tool Quaternions
-
Caution, only for backward compatibility:
-
Inverse mode (Quaternions are stored inverse)
-
Qt::Vertical
20
597
Logging
-
-
Filename:
-
-
Choose File
-
-
Limit Number Of Logged Frames:
-
Qt::Horizontal
40
20
-
1
9999
300
-
CSV format
true
-
XML format
-
Logging Status
-
Logging OFF
-
Logged Frames: 0
-
-
Qt::Horizontal
40
20
-
Start Logging
-
Stop Logging
-
Qt::Vertical
20
40
QmitkTrackingDeviceConfigurationWidget
QWidget
QmitkTrackingDeviceConfigurationWidget.h
1
QmitkToolTrackingStatusWidget
QWidget
QmitkToolTrackingStatusWidget.h
1
QmitkNavigationToolCreationWidget
QWidget
QmitkNavigationToolCreationWidget.h
1
diff --git a/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupportControls.ui b/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupportControls.ui
index f98460a6d5..7827f56d10 100644
--- a/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupportControls.ui
+++ b/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupportControls.ui
@@ -1,284 +1,284 @@
UltrasoundSupportControls
0
0
284
- 274
+ 552
0
0
QmitkTemplate
2
-
0
true
false
false
:/USUI/ultrasound01-probe-300ppi.png
:/USUI/ultrasound01-probe-300ppi.png:/USUI/ultrasound01-probe-300ppi.png
Device Management
0
-
-
-
- 12
+ 10
75
true
Ultrasound Devices:
-
-
-
-
10
75
true
- Active Ultrasound Devices:
+ Active Devices:
-
0
0
-
-
Show Image Stream
true
false
:/USUI/ultrasound02-scan-300ppi.png
:/USUI/ultrasound02-scan-300ppi-deactivated.png
:/USUI/ultrasound02-scan-300ppi.png:/USUI/ultrasound02-scan-300ppi.png
US Imaging
-
-
-
Qt::Vertical
20
40
-
Qt::Horizontal
-
Update Image Automatically
true
-
-
Freeze
:/USUI/system-lock-screen.png:/USUI/system-lock-screen.png
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; font-weight:600;">Framrate Settings:</span></p></body></html>
-
Current Framerate: 0 FPS
-
-
Framerate Limit:
-
Qt::Horizontal
40
20
-
1
50
30
QmitkUSDeviceManagerWidget
QWidget
QmitkUSDeviceManagerWidget.h
1
QmitkUSNewVideoDeviceWidget
QWidget
QmitkUSNewVideoDeviceWidget.h
1
QmitkServiceListWidget
QWidget
1