diff --git a/include/gepetto/viewer/corba/windows-manager.h b/include/gepetto/viewer/corba/windows-manager.h index 468c3f6d94df5173d77eedbc1ee92ffec1d602a5..894c9d6cbb3b956761044ffe8295691754e26bc6 100644 --- a/include/gepetto/viewer/corba/windows-manager.h +++ b/include/gepetto/viewer/corba/windows-manager.h @@ -57,6 +57,7 @@ namespace graphics { static VisibilityMode getVisibility(const std::string& visibilityName); static WireFrameMode getWire(const std::string& wireName); static LightingMode getLight(const std::string& lightName); + NodePtr_t find (const std::string name, GroupNodePtr_t group = GroupNodePtr_t()); void initParent(const std::string& nodeName, NodePtr_t node); void addNode(const std::string& nodeName, NodePtr_t node); void addGroup(const std::string& groupName, GroupNodePtr_t group); diff --git a/src/windows-manager.cpp b/src/windows-manager.cpp index a8b52dcf9fa5909867f635f8203a1d073c087995..f09812d95e37223c45f1587bba0c2450b3ffd788 100644 --- a/src/windows-manager.cpp +++ b/src/windows-manager.cpp @@ -142,6 +142,22 @@ namespace graphics { return parentName; } + NodePtr_t WindowsManager::find (const std::string name, GroupNodePtr_t group) + { + std::map<std::string, NodePtr_t>::iterator it + = nodes_.find (name); + if (it == nodes_.end ()) { + std::string::size_type slash = name.find_first_of ('/'); + if (slash == std::string::npos) + return NodePtr_t (); + std::map<std::string, GroupNodePtr_t>::iterator itg + = groupNodes_.find (name.substr (0, slash)); + if (itg == groupNodes_.end ()) + return NodePtr_t (); + return find (name.substr (slash + 1), itg->second); + } + return it->second; + } void WindowsManager::initParent (const std::string& nodeName, NodePtr_t node) @@ -755,14 +771,15 @@ namespace graphics { const value_type* configurationCorba) { const std::string nodeName (nodeNameCorba); - if (nodes_.find (nodeName) == nodes_.end ()) { + NodePtr_t updatedNode = find (nodeName); + if (!updatedNode) { //no node named nodeName std::cout << "No Node named \"" << nodeName << "\"" << std::endl; return false; } else { NodeConfiguration newNodeConfiguration; - newNodeConfiguration.node = nodes_[nodeName]; + newNodeConfiguration.node = updatedNode; try { newNodeConfiguration.position = WindowsManager::corbaConfToOsgVec3 (configurationCorba);