diff --git a/idl/gepetto/viewer/graphical-interface.idl b/idl/gepetto/viewer/graphical-interface.idl index 9489eaee3dad25240f5c75fd755bc87fb851627c..f871956cdb6947ba0015250abcd807da8a68cfa8 100644 --- a/idl/gepetto/viewer/graphical-interface.idl +++ b/idl/gepetto/viewer/graphical-interface.idl @@ -6,6 +6,9 @@ module gepetto { string msg; }; + /// Sequence of names + typedef sequence <string> Names_t; + module corbaserver { // Comments : @@ -40,10 +43,10 @@ typedef float Color [4]; /// Print names of nodes on the SceneViewer-corbaserver terminal. - void getNodeList() raises (Error); + Names_t getNodeList() raises (Error); /// Print names of windows on the SceneViewer-corbaserver terminal. - void getWindowList() raises (Error); + Names_t getWindowList() raises (Error); /// Create a group node. /// \param input sceneName : name of the group. diff --git a/src/graphical-interface.impl.cpp b/src/graphical-interface.impl.cpp index 3394473a92d45b57f7ce9f80a85e1b8c1251d94b..2473704d621f42399d41fcc1bd28c3ab95df2c87 100644 --- a/src/graphical-interface.impl.cpp +++ b/src/graphical-interface.impl.cpp @@ -13,6 +13,8 @@ namespace graphics { namespace corbaServer { namespace impl { + using gepetto::Names_t; + GraphicalInterface::GraphicalInterface (corbaServer::Server* server) : windowsManager_ (server->windowsManager ()) { @@ -238,19 +240,37 @@ namespace graphics { - void GraphicalInterface::getNodeList () throw (Error) + Names_t* GraphicalInterface::getNodeList () throw (Error) { try { - windowsManager_->getNodeList (); + std::vector<std::string> nodes (windowsManager_->getNodeList ()); + ULong size = (ULong) nodes.size (); + char** nameList = Names_t::allocbuf(size); + Names_t *nodeNames = new Names_t (size, size, nameList); + for (std::size_t i=0; i<nodes.size (); ++i) { + nameList [i] = (char*) malloc + (sizeof(char) * (nodes [i].size () + 1)); + strcpy (nameList [i], nodes [i].c_str ()); + } + return nodeNames; } catch (const std::exception& exc) { throw Error (exc.what ()); } } - void GraphicalInterface::getWindowList () throw (Error) + Names_t* GraphicalInterface::getWindowList () throw (Error) { try { - windowsManager_->getWindowList (); + std::vector<std::string> windows (windowsManager_->getWindowList ()); + ULong size = (ULong) windows.size (); + char** nameList = Names_t::allocbuf(size); + Names_t *windowNames = new Names_t (size, size, nameList); + for (std::size_t i=0; i<windows.size (); ++i) { + nameList [i] = (char*) malloc + (sizeof(char) * (windows [i].size () + 1)); + strcpy (nameList [i], windows [i].c_str ()); + } + return windowNames; } catch (const std::exception& exc) { throw Error (exc.what ()); } diff --git a/src/graphical-interface.impl.hh b/src/graphical-interface.impl.hh index 5e47276247c1aa04d3821129448b309e2ff1fa5b..04e806a16d8d0dc2779a98dbbd4bfaf62d29a552 100644 --- a/src/graphical-interface.impl.hh +++ b/src/graphical-interface.impl.hh @@ -40,8 +40,8 @@ public: */ GraphicalInterface (corbaServer::Server* server); - virtual void getNodeList() throw (Error); - virtual void getWindowList() throw (Error); + virtual gepetto::Names_t* getNodeList() throw (Error); + virtual gepetto::Names_t* getWindowList() throw (Error); virtual bool setRate(CORBA::Long rate) throw (Error); virtual void refresh() throw (Error); diff --git a/src/windows-manager.cpp b/src/windows-manager.cpp index 12b47e9224fff9ff6c6acfbba1530d43c95e34bf..a8b52dcf9fa5909867f635f8203a1d073c087995 100644 --- a/src/windows-manager.cpp +++ b/src/windows-manager.cpp @@ -581,10 +581,8 @@ namespace graphics { std::vector<std::string> WindowsManager::getNodeList () { std::vector<std::string> l; - std::cout << "List of Nodes :" << std::endl; for (std::map<std::string, NodePtr_t>::iterator it=nodes_.begin (); it!=nodes_.end (); ++it) { - std::cout << " " << it->first << std::endl; l.push_back (it->first); } return l; @@ -605,11 +603,8 @@ namespace graphics { std::vector<std::string> WindowsManager::getWindowList () { std::vector<std::string> l; - std::cout << "List of Windows :" << std::endl; - size_t rank = 0; for (WindowManagerVector_t::iterator it = windowManagers_.begin (); it!=windowManagers_.end (); ++it) { - std::cout << rank << " - " << (*it)->getViewerClone ()->getCamera()->getGraphicsContext ()->getTraits ()->windowName << std::endl; l.push_back ((*it)->getViewerClone ()->getCamera()->getGraphicsContext ()->getTraits ()->windowName); } return l;