14 #include <QVBoxLayout>
15 #include <QTreeWidget>
16 #include <QTreeWidgetItem>
25 BaseWidget(parent,
"frame_tree_widget",
"Frame Tree"),
26 mPatientService(patientService)
28 QVBoxLayout* layout =
new QVBoxLayout(
this);
31 this->setToolTip(
"A tree displaying relations between coordinate spaces");
32 mTreeWidget =
new QTreeWidget(
this);
33 layout->addWidget(mTreeWidget);
34 mTreeWidget->setHeaderLabels(QStringList() <<
"Frame");
37 connect(mPatientService.get(), SIGNAL(dataAddedOrRemoved()),
this, SLOT(dataLoadedSlot()));
40 void FrameTreeWidget::dataLoadedSlot()
42 for (std::map<QString, DataPtr>::iterator iter=mConnectedData.begin(); iter!=mConnectedData.end(); ++iter)
44 disconnect(iter->second.get(), SIGNAL(transformChanged()),
this, SLOT(
setModified()));
47 mConnectedData = mPatientService->getDatas();
49 for (std::map<QString, DataPtr>::iterator iter=mConnectedData.begin(); iter!=mConnectedData.end(); ++iter)
51 connect(iter->second.get(), SIGNAL(transformChanged()),
this, SLOT(
setModified()));
62 void FrameTreeWidget::rebuild()
67 QDomElement root = forest.getDocument().documentElement();
69 this->fill(mTreeWidget->invisibleRootItem(), root);
71 mTreeWidget->expandToDepth(10);
72 mTreeWidget->resizeColumnToContents(0);
75 void FrameTreeWidget::fill(QTreeWidgetItem* parent, QDomNode node)
77 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling())
79 QString frameName = child.toElement().tagName();
82 DataPtr data = mPatientService->getData(frameName);
84 frameName = data->getName();
86 QTreeWidgetItem* item =
new QTreeWidgetItem(parent, QStringList() << frameName);
87 this->fill(item, child);