37 for (
unsigned i=0; i<mWidgets.size(); ++i)
39 boost::shared_ptr<SingleMetricWidget> w = boost::dynamic_pointer_cast<SingleMetricWidget>(mWidgets[i]);
40 if(w && w->getData() && data && w->getData()->getUid() == data->getUid())
43 return boost::shared_ptr<QWidget>();
48 mWidgets.push_back(widget);
58 retval->mSelf = retval;
59 retval->insertTopNode();
68 this->createVisibilityProperty();
69 this->createModeProperty();
76 void TreeRepository::createVisibilityProperty()
78 QStringList allNodeTypes = QStringList() <<
"data" <<
"metric" <<
"image" <<
"model" <<
"tool" <<
"view";
81 "Select visible node types",
88 void TreeRepository::createModeProperty()
90 QStringList allModes = QStringList() <<
"spaces" <<
"flat";
121 void TreeRepository::startListen()
129 void TreeRepository::stopListen()
144 for (
unsigned i=0; i<mNodes.size(); ++i)
146 if (mNodes[i]->getUid()==uid)
154 std::vector<TreeNodePtr> all = this->
getNodes();
155 for (
unsigned i=0; i<all.size(); ++i)
156 if (all[i]->getUid() ==
"node::invisible_top")
169 return mWidgetTypeRepository;
174 return mModeProperty->getValue();
179 return mVisibilityProperty->getValue();
184 return mVisibilityProperty->getValueRange();
187 void TreeRepository::insertTopNode()
195 void TreeRepository::rebuild()
198 for (
unsigned i=0; i<mNodes.size(); ++i)
199 disconnect(mNodes[i].get(), &
TreeNode::changed,
this, &TreeRepository::onChanged);
202 this->insertTopNode();
204 QStringList groups = QStringList() <<
"tool" <<
"data" <<
"space" <<
"view";
205 for (
unsigned i=0; i<groups.size(); ++i)
206 this->insertGroupNode(groups[i]);
208 this->insertSpaceNode(CoordinateSystem(
csREF));
210 std::map<QString, DataPtr> source = this->
getServices()->patient()->getDatas();
211 for (std::map<QString, DataPtr>::const_iterator iter = source.begin(); iter != source.end(); ++iter)
213 this->insertDataNode(iter->second);
215 for (std::map<QString, DataPtr>::const_iterator iter = source.begin(); iter != source.end(); ++iter)
217 QString space = iter->second->getParentSpace();
220 if (source.count(space))
222 this->insertSpaceNode(CoordinateSystem(
csDATA, space));
227 std::map<QString, ToolPtr> tools = this->
getServices()->tracking()->getTools();
228 for (std::map<QString, ToolPtr>::const_iterator iter = tools.begin(); iter != tools.end(); ++iter)
230 this->insertToolNode(iter->second);
233 for (
unsigned i=0; i<this->
getServices()->view()->groupCount(); ++i)
235 this->appendNode(
new ViewGroupTreeNode(mSelf, i));
242 void TreeRepository::insertGroupNode(QString groupname)
246 if (groupname==
"view")
247 this->appendNode(
new ViewServiceTreeNode(mSelf));
249 this->appendNode(
new GroupTreeNode(mSelf, groupname));
254 return this->
getNode(QString(
"group_%1").arg(groupname));
257 void TreeRepository::insertToolNode(
ToolPtr tool)
259 if (this->
getNode(tool->getUid()))
264 void TreeRepository::insertDataNode(
DataPtr data)
266 if (this->
getNode(data->getUid()))
269 this->appendNode(
new DataTreeNode(mSelf, data));
271 this->appendNode(
new ShowVolumeDataTreeNode(mSelf, data));
272 this->appendNode(
new ShowSlice2DDataTreeNode(mSelf, data));
273 this->appendNode(
new ShowSlice3DDataTreeNode(mSelf, data));
276 void TreeRepository::appendNode(TreeNode* rawNode)
281 if (!this->
getNode(node->getUid()))
287 mNodes.push_back(node);
291 void TreeRepository::onChanged()
293 TreeNode* node =
dynamic_cast<TreeNode*
>(sender());
298 void TreeRepository::insertSpaceNode(CoordinateSystem space)
300 if (this->
getNode(space.toString()) || this->getNode(space.mRefObject))
302 this->appendNode(
new SpaceTreeNode(mSelf, space));