Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F405
LoadSROMFileForWiredTools.patch
Public
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
wegner
Feb 5 2010, 7:15 PM
2010-02-05 19:15:11 (UTC+1)
Size
7 KB
Referenced Files
None
Subscribers
None
LoadSROMFileForWiredTools.patch
View Options
Index: mitk/Modules/IGT/IGTTrackingDevices/mitkNDITrackingDevice.cpp
===================================================================
--- mitk/Modules/IGT/IGTTrackingDevices/mitkNDITrackingDevice.cpp (revision 21248)
+++ mitk/Modules/IGT/IGTTrackingDevices/mitkNDITrackingDevice.cpp (working copy)
@@ -567,7 +567,54 @@
return true;
}
+bool mitk::NDITrackingDevice::InitializeWiredTools()
+{
+ NDIErrorCode returnvalue;
+ std::string portHandle;
+ returnvalue = m_DeviceProtocol->PHSR(OCCUPIED, &portHandle);
+ if (returnvalue != NDIOKAY)
+ {
+ this->SetErrorMessage("Could not obtain a list of port handles that are connected");
+ return false; // ToDo: Is this a fatal error?
+ }
+
+ /* if there are port handles that need to be initialized, initialize them. Furthermore instantiate tools for each handle that has no tool yet. */
+ std::string ph;
+
+ for (unsigned int i = 0; i < portHandle.size(); i += 2)
+ {
+ ph = portHandle.substr(i, 2);
+ mitk::NDIPassiveTool* pt = this->GetInternalTool(ph);
+ if ( pt == NULL) // if we already have a tool with this handle
+ continue;
+
+ returnvalue = m_DeviceProtocol->PVWR(&ph, pt->GetSROMData(), pt->GetSROMDataLength());
+ if (returnvalue != NDIOKAY)
+ {
+ this->SetErrorMessage((std::string("Could not write SROM file for tool '") + pt->GetToolName() + std::string("' to tracking device")).c_str());
+ return false;
+ }
+ returnvalue = m_DeviceProtocol->PINIT(&portHandle);
+ if (returnvalue != NDIOKAY)
+ {
+ this->SetErrorMessage((std::string("Could not initialize tool '") + pt->GetToolName()).c_str());
+ return false;
+ }
+ if (pt->IsEnabled() == true)
+ {
+ returnvalue = m_DeviceProtocol->PENA(&portHandle, pt->GetTrackingPriority()); // Enable tool
+ if (returnvalue != NDIOKAY)
+ {
+ this->SetErrorMessage((std::string("Could not enable port '") + portHandle +
+ std::string("' for tool '")+ pt->GetToolName() + std::string("'")).c_str());
+ return false;
+ }
+ }
+ }
+}
+
+
mitk::TrackingDeviceType mitk::NDITrackingDevice::TestConnection()
{
if (this->GetMode() != Setup)
Index: mitk/Modules/IGT/IGTTrackingDevices/mitkNDITrackingDevice.h
===================================================================
--- mitk/Modules/IGT/IGTTrackingDevices/mitkNDITrackingDevice.h (revision 21248)
+++ mitk/Modules/IGT/IGTTrackingDevices/mitkNDITrackingDevice.h (working copy)
@@ -87,6 +87,8 @@
*/
virtual bool CloseConnection();
+ bool InitializeWiredTools();
+
/**
* \brief TestConnection() tries to connect to a NDI tracking device on the current port/device and returns which device it has found
*
Index: mitk/Modules/IGTUI/Qmitk/QmitkNDIConfigurationWidget.cpp
===================================================================
--- mitk/Modules/IGTUI/Qmitk/QmitkNDIConfigurationWidget.cpp (revision 21248)
+++ mitk/Modules/IGTUI/Qmitk/QmitkNDIConfigurationWidget.cpp (working copy)
@@ -76,6 +76,7 @@
connect(m_Controls->m_DiscoverToolsBtn, SIGNAL(clicked()), this, SLOT(OnDiscoverTools()));
connect(m_Controls->m_AddToolBtn, SIGNAL(clicked()), this, SLOT(OnAddPassiveTool()));
connect(m_Controls->m_DisoverDevicesBtn, SIGNAL(clicked()), this, SLOT(OnDiscoverDevices()));
+ connect(m_Delegate, SIGNAL(dataChanged()), this, SLOT(UpdateTrackerFromToolTable()));
}
@@ -385,23 +386,27 @@
}
-//void QmitkNDIConfigurationWidget::UpdateTrackerFromToolTable()
-//{
-// if (m_Tracker.IsNull())
-// return;
-// QAbstractItemModel* model = m_Controls->m_ToolTable->model();
-// for (unsigned int i = 0; i < m_Controls->m_ToolTable->rowCount(), ++i)
-// {
-// mitk::NDIPassiveTool* t = dynamic_cast<mitk::NDIPassiveTool*>(m_Tracker->GetTool(i));
-// if (t == NULL)
-// continue;
-// t->SetToolName(model->data(model->index(i, 1)).toString().toLatin1());
-// QString romfile = model->data(model->index(i, QmitkNDIToolDelegate::SROMCol)).toString();
-// if (QFileInfo(romfile).exists())
-// t->LoadSROMFile(.toLatin1());
-//
-// }
-//}
+void QmitkNDIConfigurationWidget::UpdateTrackerFromToolTable()
+{
+ if (m_Tracker.IsNull())
+ return;
+ QAbstractItemModel* model = m_Controls->m_ToolTable->model();
+ for (unsigned int i = 0; i < m_Controls->m_ToolTable->rowCount(); ++i)
+ {
+ mitk::NDIPassiveTool* tool = dynamic_cast<mitk::NDIPassiveTool*> (m_Tracker->GetTool(i));
+ if (tool == NULL)
+ continue;
+ tool->SetToolName(model->data(model->index(i, 1)).toString().toLatin1());
+ QString romfile = model->data(model->index(i, QmitkNDIToolDelegate::SROMCol)).toString();
+ if (romfile.isEmpty())
+ continue;
+ //if (romfile == QString("<click to load SROM file>"))//default text; to be optimized with a modified or so
+ // continue;
+ if (QFileInfo(romfile).exists())
+ tool->LoadSROMFile(romfile.toLatin1());
+ }
+ m_Tracker->InitializeWiredTools();
+}
const QString QmitkNDIConfigurationWidget::GetToolType( unsigned int index ) const
@@ -477,4 +482,4 @@
void QmitkNDIConfigurationWidget::HideAddPassiveToolButton( bool on )
{
m_Controls->m_AddToolBtn->setHidden(on);
-}
\ No newline at end of file
+}
Index: mitk/Modules/IGTUI/Qmitk/QmitkNDIConfigurationWidget.h
===================================================================
--- mitk/Modules/IGTUI/Qmitk/QmitkNDIConfigurationWidget.h (revision 21248)
+++ mitk/Modules/IGTUI/Qmitk/QmitkNDIConfigurationWidget.h (working copy)
@@ -79,6 +79,7 @@
void OnDiscoverTools();
void OnDiscoverDevices();
void OnAddPassiveTool();
+ void UpdateTrackerFromToolTable();
protected:
typedef QMap<QString, mitk::TrackingDeviceType> PortDeviceMap; // key is port name (e.g. "COM1", "/dev/ttyS0"), value will be filled with the type of tracking device at this port
Index: mitk/Modules/IGTUI/Qmitk/QmitkNDIToolDelegate.cpp
===================================================================
--- mitk/Modules/IGTUI/Qmitk/QmitkNDIToolDelegate.cpp (revision 21248)
+++ mitk/Modules/IGTUI/Qmitk/QmitkNDIToolDelegate.cpp (working copy)
@@ -130,6 +130,7 @@
//model->setData(index, l->text(), mitk::FileNameRole);
//model->setData(index, l->text(), Qt::DisplayRole); // use for display too
model->setData(index, l->text()); // use for display too
+ emit dataChanged();
return;
}
case TypeCol:
@@ -158,6 +159,11 @@
default:
QStyledItemDelegate::setModelData(editor, model, index);
}
+
+ //if(QComboBox *comboBox = qobject_cast<QComboBox *>(sender()))
+ //{
+
+ //}
}
void QmitkNDIToolDelegate::commitAndCloseEditor()
Index: mitk/Modules/IGTUI/Qmitk/QmitkNDIToolDelegate.h
===================================================================
--- mitk/Modules/IGTUI/Qmitk/QmitkNDIToolDelegate.h (revision 21248)
+++ mitk/Modules/IGTUI/Qmitk/QmitkNDIToolDelegate.h (working copy)
@@ -83,6 +83,9 @@
/// \brief Fit an editor to some geometry (overwritten from QItemDelegate)
///
//void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
+
+ signals:
+ void dataChanged() const; //used to transfer the user defined information from List to Tools
private slots:
///
File Metadata
Details
Attached
Mime Type
application/octet-stream
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
389
Default Alt Text
LoadSROMFileForWiredTools.patch (7 KB)
Attached To
Mode
T3139: improve NDIConfigurationWidget
Attached
Detach File
Event Timeline
wegner
added a comment.
Feb 5 2010, 7:15 PM
2010-02-05 19:15:11 (UTC+1)
Comment Actions
LoadSROMFileForWiredTools
Log In to Comment