From 26ba454a4127e528496e9efd637a7b7f7138634e Mon Sep 17 00:00:00 2001
From: Joseph Mirabel <jmirabel@laas.fr>
Date: Tue, 10 Mar 2015 18:17:31 +0100
Subject: [PATCH] Follow changes in gepetto-viewer package

* Use class graphics::WindowsManager to handle windows.
---
 CMakeLists.txt                             |   1 +
 idl/gepetto/viewer/graphical-interface.idl |   8 +-
 include/gepetto/viewer/corba/client.hh     |  19 +-
 include/gepetto/viewer/corba/se3.hh        |   2 +-
 src/CMakeLists.txt                         |   1 -
 src/client-cpp.cc                          |  22 +-
 src/corbaserver.cc                         |   5 +-
 src/graphical-interface.impl.cpp           | 737 ++++-----------------
 src/graphical-interface.impl.hh            |  66 +-
 src/server-private.cc                      |   2 +-
 src/server-private.hh                      |   2 +-
 src/server.cc                              |   6 +-
 src/server.hh                              |  18 +-
 src/test-client-cpp.cc                     |  10 +-
 14 files changed, 178 insertions(+), 721 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f7df518..3a0e756 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,6 +30,7 @@ SET(PROJECT_DESCRIPTION "Corba server for gepetto-viewer")
 SET(PROJECT_URL "")
 
 SET(${PROJECT_NAME}_HEADERS
+  include/gepetto/viewer/corba/server.hh
   include/gepetto/viewer/corba/client.hh
   include/gepetto/viewer/corba/se3.hh
   )
diff --git a/idl/gepetto/viewer/graphical-interface.idl b/idl/gepetto/viewer/graphical-interface.idl
index 1e5de67..4accef5 100644
--- a/idl/gepetto/viewer/graphical-interface.idl
+++ b/idl/gepetto/viewer/graphical-interface.idl
@@ -17,9 +17,9 @@ module corbaserver {
 //     the "refresh" function each time you want actualize position of the Viewer.
 //     This system is used to synchronize movement of all objects.
 
-typedef double Transform [7];
-typedef double Position [3];
-typedef double Color [4];
+typedef float Transform [7];
+typedef float Position [3];
+typedef float Color [4];
 
   /// Corba exception travelling through the Corba channel
   interface GraphicalInterface {
@@ -181,7 +181,7 @@ typedef double Color [4];
 
     /// Set a new configuration to a node. THIS CONFIGURATION WILL AFFECTIVE ONLY AFTER CALLING REFRESH FUNCTION!!!
     /// \param input nodeName : name of the node.
-    /// \param input configuration : Double[7] new configuration.
+    /// \param input configuration : Float[7] new configuration.
     boolean applyConfiguration(in string nodeName, in Transform configuration) raises (Error);
 
     /// Add Landmark at the center of a node
diff --git a/include/gepetto/viewer/corba/client.hh b/include/gepetto/viewer/corba/client.hh
index 375e6f9..b8f646d 100644
--- a/include/gepetto/viewer/corba/client.hh
+++ b/include/gepetto/viewer/corba/client.hh
@@ -24,12 +24,13 @@ private:
     CORBA::ORB_var orb_;
   gepetto::corbaserver::GraphicalInterface_var manager_;
 
-    static void se3ToCorba(CORBA::Double* corbaPosition, const se3::SE3& se3position);
+    static void se3ToCorba(CORBA::Float* corbaPosition, const se3::SE3& se3position);
 
 protected:
 
 public:
     typedef CORBA::ULong WindowID;
+    typedef float value_type;
 
     // Default constructor
     ClientCpp();
@@ -52,27 +53,27 @@ public:
     bool addSceneToWindow(const char* sceneName, const WindowID windowId) ;
 
 
-    bool addBox(const char* boxName, const float boxSize1, const float boxSize2, const float boxSize3, const double* color);
+    bool addBox(const char* boxName, const float boxSize1, const float boxSize2, const float boxSize3, const value_type* color);
     //bool addBox(const char* boxName, float boxSize1, float boxSize2, float boxSize3) ;
 
     //bool addCapsule(const char* capsuleName, float radius, float height) ;
-    bool addCapsule(const char* capsuleName, const float radius, const float height, const double* color);
+    bool addCapsule(const char* capsuleName, const float radius, const float height, const value_type* color);
 
     bool addMesh(const char* meshName, const char* meshPath) ;
 
     //bool addCone(const char* coneName, float radius, float height) ;
-    bool addCone(const char* coneName, const float radius, const float height, const double* color);
+    bool addCone(const char* coneName, const float radius, const float height, const value_type* color);
 
     //bool addCylinder(const char* cylinderName, float radius, float height) ;
-    bool addCylinder(const char* cylinderName, const float radius, const float height, const double* color);
+    bool addCylinder(const char* cylinderName, const float radius, const float height, const value_type* color);
 
     //bool addSphere(const char* sphereName, float radius) ;
-    bool addSphere(const char* sphereName, const float radius, const double* color);
+    bool addSphere(const char* sphereName, const float radius, const value_type* color);
 
-    bool addLine(const char* lineName, const double* pos1, const double* pos2, const double* color);
+    bool addLine(const char* lineName, const value_type* pos1, const value_type* pos2, const value_type* color);
 
-    bool addTriangleFace(const char* lineName, const double* pos1, const double* pos2, const double* pos3, const double* color);
-    bool addSquareFace(const char* lineName, const double* pos1, const double* pos2, const double* pos3, const double* pos4, const double* color);
+    bool addTriangleFace(const char* lineName, const value_type* pos1, const value_type* pos2, const value_type* pos3, const value_type* color);
+    bool addSquareFace(const char* lineName, const value_type* pos1, const value_type* pos2, const value_type* pos3, const value_type* pos4, const value_type* color);
 
     bool addURDF(const char* urdfName, const char* urdfPath, const char* urdfPackagePath);
 
diff --git a/include/gepetto/viewer/corba/se3.hh b/include/gepetto/viewer/corba/se3.hh
index 7ab1d4b..f9aa02c 100644
--- a/include/gepetto/viewer/corba/se3.hh
+++ b/include/gepetto/viewer/corba/se3.hh
@@ -124,7 +124,7 @@ private:
 Matrix3 rot;
 Vector3 trans;
 };
-typedef SE3Tpl<double,0> SE3;
+typedef SE3Tpl<float,0> SE3;
 } // namespace se3
 #endif // ifndef __se3_se3_hpp__
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index af4c72b..b093fd3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -33,7 +33,6 @@ ADD_LIBRARY(${LIBRARY_NAME}
   graphical-interfaceSK.cc
   graphical-interface.impl.cpp
   graphical-interface.impl.hh
-  server.hh
   server.cc
   server-private.cc
   server-private.hh
diff --git a/src/client-cpp.cc b/src/client-cpp.cc
index d862660..cdc9727 100644
--- a/src/client-cpp.cc
+++ b/src/client-cpp.cc
@@ -11,9 +11,9 @@
 namespace graphics { 
 namespace corbaServer {
 
-void ClientCpp::se3ToCorba(CORBA::Double* corbaPosition, const se3::SE3& se3position)
+void ClientCpp::se3ToCorba(CORBA::Float* corbaPosition, const se3::SE3& se3position)
 {
-    Eigen::Quaternion<double> q(se3position.rotation());
+    Eigen::Quaternion<value_type> q(se3position.rotation());
     corbaPosition[0] = se3position.translation()(0);
     corbaPosition[1] = se3position.translation()(1);
     corbaPosition[2] = se3position.translation()(2);    
@@ -110,7 +110,7 @@ bool ClientCpp::addSceneToWindow(const char* sceneName, const ClientCpp::WindowI
     return manager_->addBox(boxName, boxSize1, boxSize2, boxSize3);
 }*/
 
-bool ClientCpp::addBox(const char* boxName, const float boxSize1, const float boxSize2, const float boxSize3, const double* color)
+bool ClientCpp::addBox(const char* boxName, const float boxSize1, const float boxSize2, const float boxSize3, const value_type* color)
 {
     return manager_->addBox(boxName, boxSize1, boxSize2, boxSize3, color);
 }
@@ -120,7 +120,7 @@ bool ClientCpp::addBox(const char* boxName, const float boxSize1, const float bo
     return manager_->addCapsule(capsuleName, radius, height);
 }*/
 
-bool ClientCpp::addCapsule(const char* capsuleName, const float radius, const float height, const double* color)
+bool ClientCpp::addCapsule(const char* capsuleName, const float radius, const float height, const value_type* color)
 {
     return manager_->addCapsule(capsuleName, radius, height, color);
 }
@@ -135,7 +135,7 @@ bool ClientCpp::addMesh(const char* meshName, const char* meshPath)
     return manager_->addCone(coneName, radius, height);
 }*/
 
-bool ClientCpp::addCone(const char* coneName, const float radius, const float height, const double* color)
+bool ClientCpp::addCone(const char* coneName, const float radius, const float height, const value_type* color)
 {
     return manager_->addCone(coneName, radius, height, color);
 }
@@ -145,7 +145,7 @@ bool ClientCpp::addCone(const char* coneName, const float radius, const float he
     return manager_->addCylinder(cylinderName, radius, height);
 }*/
 
-bool ClientCpp::addCylinder(const char* cylinderName, const float radius, const float height, const double* color)
+bool ClientCpp::addCylinder(const char* cylinderName, const float radius, const float height, const value_type* color)
 {
     return manager_->addCylinder(cylinderName, radius, height, color);
 }
@@ -155,22 +155,22 @@ bool ClientCpp::addCylinder(const char* cylinderName, const float radius, const
     return manager_->addSphere(sphereName, radius);
 }*/
 
-bool ClientCpp::addSphere(const char* sphereName, const float radius, const double* color)
+bool ClientCpp::addSphere(const char* sphereName, const float radius, const value_type* color)
 {
     return manager_->addSphere(sphereName, radius, color);
 }
 
-bool ClientCpp::addLine(const char* lineName, const double* pos1, const double* pos2, const double* color)
+bool ClientCpp::addLine(const char* lineName, const value_type* pos1, const value_type* pos2, const value_type* color)
 {
     return manager_->addLine(lineName, pos1, pos2, color);
 }
 
-bool ClientCpp::addTriangleFace(const char* faceName, const double* pos1, const double* pos2, const double* pos3, const double* color)
+bool ClientCpp::addTriangleFace(const char* faceName, const value_type* pos1, const value_type* pos2, const value_type* pos3, const value_type* color)
 {
     return manager_->addTriangleFace(faceName, pos1, pos2, pos3, color);
 }
 
-bool ClientCpp::addSquareFace(const char* faceName, const double* pos1, const double* pos2, const double* pos3, const double* pos4, const double* color)
+bool ClientCpp::addSquareFace(const char* faceName, const value_type* pos1, const value_type* pos2, const value_type* pos3, const value_type* pos4, const value_type* color)
 {
     return manager_->addSquareFace(faceName, pos1, pos2, pos3, pos4, color);
 }
@@ -192,7 +192,7 @@ bool ClientCpp::addToGroup(const char* nodeName, const char* groupName)
 
 bool ClientCpp::applyConfiguration(const char* nodeName, const se3::SE3& se3position)
 {
-    CORBA::Double corbaPosition[7];
+    CORBA::Float corbaPosition[7];
     ClientCpp::se3ToCorba(corbaPosition, se3position);
     return manager_->applyConfiguration(nodeName, corbaPosition);
 }
diff --git a/src/corbaserver.cc b/src/corbaserver.cc
index d0e3317..d17bb01 100644
--- a/src/corbaserver.cc
+++ b/src/corbaserver.cc
@@ -9,14 +9,15 @@
 // See the COPYING file for more information.
 
 #include <iostream>
-#include "server.hh"
+#include "gepetto/viewer/corba/server.hh"
 
 using graphics::corbaServer::Server;
 
 int
 main (int argc, const char* argv[])
 {
-  Server server (argc, argv, true);
+  graphics::WindowsManagerPtr_t wm = graphics::WindowsManager::create ();
+  Server server (wm, argc, argv, true);
 
   server.startCorbaServer ();
   server.processRequest(true);
diff --git a/src/graphical-interface.impl.cpp b/src/graphical-interface.impl.cpp
index 4b42c2e..b6ab68c 100644
--- a/src/graphical-interface.impl.cpp
+++ b/src/graphical-interface.impl.cpp
@@ -14,160 +14,14 @@ namespace graphics {
     namespace impl {
 
       GraphicalInterface::GraphicalInterface (corbaServer::Server* server) :
-	windowManagers_ (), nodes_ (), groupNodes_ (), server_ (server),
-	mtx_ (), rate_ (20), newNodeConfigurations_ ()
+	windowsManager_ (server->windowsManager ())
       {
       }
 
-      osgVector4 GraphicalInterface::getColor (const std::string& colorName)
-      {
-	if (colorName == "blue")
-	  return osgVector4 (0.f, 0.f, 1.f, 1.f);
-	else if (colorName == "green")
-	  return osgVector4 (0.f, 1.f, 0.f, 1.f);
-	else if (colorName == "red")
-	  return osgVector4 (1.f, 0.f, 0.f, 1.f);
-	else if (colorName == "white")
-	  return osgVector4 (1.f, 1.f, 1.f, 1.f);
-	else
-	  return osgVector4 (0.f, 0.f, 0.f, 1.f);
-      }
-
-      osgVector4 GraphicalInterface::getColor (const double* colorCorba)
-      {
-	return osgVector4 (colorCorba[0], colorCorba[1], colorCorba[2],
-			  colorCorba[3]);
-      }
-
-      VisibilityMode GraphicalInterface::getVisibility
- (const std::string& visibilityName)
-      {
-	if (visibilityName == "OFF")
-	  return VISIBILITY_OFF;
-	else if (visibilityName == "ALWAYS_ON_TOP")
-	  return ALWAYS_ON_TOP;
-	else if (visibilityName == "ON")
-	  return VISIBILITY_ON;
-	else {
-	  std::cout << "Visibility mode not known, visibility mode can be"
-	    " \"ON\",\"OFF\" or \"ALWAYS_ON_TOP\"." << std::endl;
-	  std::cout << "Visibility mode set to default = \"ON\"." << std::endl;
-	  return VISIBILITY_ON;
-	}
-      }
-
-      WireFrameMode GraphicalInterface::getWire (const std::string& wireName)
-      {
-	if (wireName == "WIREFRAME")
-	  return WIREFRAME;
-	else if (wireName == "FILL_AND_WIREFRAME")
-	  return FILL_AND_WIREFRAME;
-	else if (wireName == "FILL")
-	  return FILL;
-	else {
-	  std::cout << "Wire mode not known, wire mode can be \"FILL\","
-	    "\"WIREFRAME\" or \"FILL_AND_WIREFRAME\"." << std::endl;
-	  std::cout << "Wire mode set to default = \"FILL\"." << std::endl;
-	  return FILL;
-	}
-      }
-
-      LightingMode GraphicalInterface::getLight (const std::string& lightName)
-      {
-	if (lightName == "OFF")
-	  return LIGHT_INFLUENCE_OFF;
-	else if (lightName == "ON")
-	  return LIGHT_INFLUENCE_ON;
-	else {
-	  std::cout << "Lighting mode not known, lighting mode can be "
-	    "\"ON\" or \"OFF\"." << std::endl;
-	  std::cout << "Lighting mode set to default = \"ON\"." << std::endl;
-	  return LIGHT_INFLUENCE_ON;
-	}
-      }
-
-      std::string GraphicalInterface::parentName (const std::string& name)
-      {
-	std::string Name (name);
-	std::string::iterator parentNameIt;
-	for (std::string::iterator i = Name.end (); (*i) != char ('/') &&
-	       i != Name.begin (); i--) {
-	  parentNameIt = i;
-	}
-	parentNameIt--;
-
-	std::string parentName;
-	for (std::string::iterator i = Name.begin (); i != parentNameIt; i++) {
-	  parentName.push_back (*i);
-	}
-
-	return parentName;
-      }
-
-      void GraphicalInterface::initParent (const std::string& nodeName,
-					  NodePtr_t node)
-      {
-	GroupNodePtr_t groupNode = groupNodes_
-	  [GraphicalInterface::parentName (nodeName)];
-	if (groupNode) {
-	  groupNode->addChild (node);
-	}
-      }
-
-      void GraphicalInterface::addNode (const std::string& nodeName,
-				       NodePtr_t node)
-      {
-	nodes_[nodeName] = node;
-      }
-
-      void GraphicalInterface::addGroup (const std::string& groupName,
-					 GroupNodePtr_t group)
-      {
-	groupNodes_[groupName] = group;
-	nodes_[groupName] = group;
-      }
-
-      void GraphicalInterface::threadRefreshing (WindowManagerPtr_t window)
-      {
-	while (!window->done ())
-	  {
-	    mtx_.lock ();
-	    window->frame ();
-	    mtx_.unlock ();
-	    boost::this_thread::sleep (boost::posix_time::milliseconds (rate_));
-	  }
-      }
-
-      osgQuat GraphicalInterface::corbaConfToOsgQuat
-      (const double* configurationCorba)
-      {
-	// configurationCorba = trans (x, y, z), quat (w, x, y, z)
-	// osgQuat = quat (x, y, z, w)
-	return osgQuat (configurationCorba[4], configurationCorba[5],
-			configurationCorba[6], configurationCorba[3]);
-      }
-
-      osgVector3 GraphicalInterface::corbaConfToOsgVec3
-      (const double* configurationCorba)
-      {
-	return osgVector3 (configurationCorba[0], configurationCorba[1],
-			   configurationCorba[2]);
-      }
-
-
-      //Public functions
-
       bool GraphicalInterface::setRate (CORBA::Long rate) throw (Error)
       {
 	try {
-	  if (rate <= 0) {
-	    std::cout << "You should specify a positive rate" << std::endl;
-	    return false;
-	  }
-	  else {
-	    rate_ = rate;
-	    return true;
-	  }
+          return windowsManager_->setRate (rate);
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
@@ -177,14 +31,7 @@ namespace graphics {
 	throw (Error)
       {
 	try {
-	  std::string windowName (windowNameCorba);
-          WindowManagerPtr_t newWindow = WindowManager::create ();
-          WindowID windowId = windowManagers_.size ();
-          windowManagers_.push_back (newWindow);
-          boost::thread refreshThread (boost::bind
-              (&GraphicalInterface::threadRefreshing,
-               this, newWindow));
-          return windowId;
+          return windowsManager_->createWindow (windowNameCorba);
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
@@ -193,320 +40,151 @@ namespace graphics {
       void GraphicalInterface::refresh () throw (Error)
       {
 	try {
-	  mtx_.lock ();
-	  //refresh scene with the new configuration
-	  for (std::list<NodeConfiguration>::iterator it =
-		 newNodeConfigurations_.begin ();
-	       it != newNodeConfigurations_.end (); it++) {
-	 (*it).node->applyConfiguration ( (*it).position, (*it).quat);
-	  }
-	  for (WindowManagers_t::iterator it = windowManagers_.begin ();
-              it!=windowManagers_.end (); ++it)
-            (*it)->frame ();
-	  mtx_.unlock ();
-	  newNodeConfigurations_.clear ();
+          return windowsManager_->refresh ();
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
       }
 
       void GraphicalInterface::createScene (const char* sceneNameCorba)
-	throw (Error)
+          throw (Error)
       {
 	try {
-	  std::string sceneName (sceneNameCorba);
-	  if (nodes_.find (sceneName) != nodes_.end ()) {
-	    std::ostringstream oss;
-	    oss << "A scene with name, \"" << sceneName << "\" already exists.";
-	      throw std::runtime_error (oss.str ());
-	  }
-	  else {
-	    GroupNodePtr_t mainNode = GroupNode::create (sceneName);
-	    addGroup (sceneName, mainNode);
-	  }
+          return windowsManager_->createScene (sceneNameCorba);
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
       }
 
-      void GraphicalInterface::createSceneWithFloor
-      (const char* sceneNameCorba) throw (Error)
-
-      {
-	try {
-	  std::string sceneName (sceneNameCorba);
-	  if (nodes_.find (sceneName) != nodes_.end ()) {
-	    std::ostringstream oss;
-	    oss << "A scene with name, \"" << sceneName << "\" already exists.";
-	      throw std::runtime_error (oss.str ());
-	  }
-	  else {
-	    GroupNodePtr_t mainNode = GroupNode::create (sceneName);
-	    addGroup (sceneName, mainNode);
-	    std::string floorName = sceneName + "/floor";
-	    LeafNodeGroundPtr_t floor = LeafNodeGround::create (floorName);
-	    addNode (floorName, floor);
-	    mainNode->addChild (floor);
-	  }
-	} catch (const std::exception& exc) {
-	  throw Error (exc.what ());
-	}
-      }
+      void GraphicalInterface::createSceneWithFloor (const char* sceneNameCorba)
+          throw (Error)
+          {
+              try {
+                  return windowsManager_->createSceneWithFloor (sceneNameCorba);
+              } catch (const std::exception& exc) {
+                  throw Error (exc.what ());
+              }
+          }
 
       bool GraphicalInterface::addSceneToWindow (const char* sceneNameCorba,
-						 WindowID windowId)
-	throw (Error)
+              WindowID windowId) throw (Error)
       {
-	try {
-	  std::string sceneName (sceneNameCorba);
-	  if ((windowId >= 0 || windowId < windowManagers_.size ()) &&
-	      groupNodes_.find (sceneName) != groupNodes_.end () ) {
-	    windowManagers_[windowId]->addNode (groupNodes_[sceneName]);
-	    return true;
-	  }
-	  else {
-	    std::cout << "Window ID \"" << windowId
-		      << "\" and/or scene name \"" << sceneName
-		      << "\" doesn't exist." << std::endl;
-	    return false;
-	  }
-	} catch (const std::exception& exc) {
-	  throw Error (exc.what ());
-	}
+          try {
+              return windowsManager_->addSceneToWindow (sceneNameCorba, windowId);
+          } catch (const std::exception& exc) {
+              throw Error (exc.what ());
+          }
       }
 
       bool GraphicalInterface::addBox (const char* boxNameCorba,
 				       const float boxSize1,
 				       const float boxSize2,
 				       const float boxSize3,
-				       const double* colorCorba) throw (Error)
+                       const value_type* colorCorba) throw (Error)
       {
-	try {
-	  std::string boxName (boxNameCorba);
-	  if (nodes_.find (boxName) != nodes_.end ()) {
-	    std::cout << "You need to chose an other name, \"" << boxName
-		      << "\" already exist." << std::endl;
-	    return false;
-	  }
-	  else {
-	    LeafNodeBoxPtr_t box = LeafNodeBox::create
-	      (boxName, osgVector3 (boxSize1, boxSize2, boxSize3),
-	       getColor (colorCorba));
-	    GraphicalInterface::initParent (boxName, box);
-	    addNode (boxName, box);
-	    return true;
-	  }
-	} catch (const std::exception& exc) {
-	  throw Error (exc.what ());
-	}
+          try {
+              return windowsManager_->addBox (boxNameCorba, boxSize1, boxSize2, boxSize3,
+                      colorCorba);
+          } catch (const std::exception& exc) {
+              throw Error (exc.what ());
+          }
       }
 
       bool GraphicalInterface::addCapsule (const char* capsuleNameCorba,
-					   const float radius,
-					   const float height,
-					   const double* colorCorba)
-	throw (Error)
+              const float radius,
+              const float height,
+              const value_type* colorCorba) throw (Error)
       {
-	try {
-	  const std::string capsuleName (capsuleNameCorba);
-	  if (nodes_.find (capsuleName) != nodes_.end ()) {
-	    std::cout << "You need to chose an other name, \""
-		      << capsuleName << "\" already exist." << std::endl;
-	    return false;
-	  }
-	  else {
-	    LeafNodeCapsulePtr_t capsule = LeafNodeCapsule::create
-	      (capsuleName, radius, height, getColor (colorCorba));
-	    GraphicalInterface::initParent (capsuleName, capsule);
-	    addNode (capsuleName, capsule);
-	    return true;
-	  }
-	} catch (const std::exception& exc) {
-	  throw Error (exc.what ());
-	}
+          try {
+              return windowsManager_->addCapsule (capsuleNameCorba, radius, height,
+                      colorCorba);
+          } catch (const std::exception& exc) {
+              throw Error (exc.what ());
+          }
       }
 
       bool GraphicalInterface::addMesh (const char* meshNameCorba,
 					const char* meshPathCorba) throw (Error)
       {
-	try {
-	  std::string meshName (meshNameCorba);
-	  std::string meshPath (meshPathCorba);
-	  if (nodes_.find (meshName) != nodes_.end ()) {
-	    std::cout << "You need to chose an other name, \"" << meshName
-		      << "\" already exist." << std::endl;
-	    return false;
-	  }
-	  else {
-	    try {
-	      LeafNodeColladaPtr_t mesh = LeafNodeCollada::create
-		(meshName, meshPath);
-	      GraphicalInterface::initParent (meshName, mesh);
-	      addNode (meshName, mesh);
-	      return true;
-	    } catch (const std::exception& exc) {
-	      std::cout << "Mesh \"" << meshPath << "\" not found." << std::endl;
-	      return false;
-	    }
-	  }
-	} catch (const std::exception& exc) {
-	  throw Error (exc.what ());
-	}
+          try {
+              return windowsManager_->addMesh (meshNameCorba, meshPathCorba);
+          } catch (const std::exception& exc) {
+              throw Error (exc.what ());
+          }
       }
 
       bool GraphicalInterface::addCone (const char* coneNameCorba,
 					const float radius, const float height,
-					const double*) throw (Error)
+					const value_type* colorCorba) throw (Error)
       {
-	try {
-	  std::string coneName (coneNameCorba);
-	  if (nodes_.find (coneName) != nodes_.end ()) {
-	    std::cout << "You need to chose an other name, \"" << coneName
-		      << "\" already exist." << std::endl;
-	    return false;
-	  }
-	  else {
-	    LeafNodeConePtr_t cone = LeafNodeCone::create
-	      (coneName, radius, height);
-	    GraphicalInterface::initParent (coneName, cone);
-	    addNode (coneName, cone);
-	    return true;
-	  }
-	} catch (const std::exception& exc) {
-	  throw Error (exc.what ());
-	}
+          try {
+              return windowsManager_->addCone (coneNameCorba, radius, height,
+                      colorCorba);
+          } catch (const std::exception& exc) {
+              throw Error (exc.what ());
+          }
       }
 
       bool GraphicalInterface::addCylinder (const char* cylinderNameCorba,
 					    const float radius,
 					    const float height,
-					    const double* colorCorba)
-	throw (Error)
+                        const value_type* colorCorba)
+          throw (Error)
       {
-	try {
-	  std::string cylinderName (cylinderNameCorba);
-	  if (nodes_.find (cylinderName) != nodes_.end ()) {
-	    std::cout << "You need to chose an other name, \"" << cylinderName
-		      << "\" already exist." << std::endl;
-	    return false;
-	  }
-	  else {
-	    LeafNodeCylinderPtr_t cylinder = LeafNodeCylinder::create
-	      (cylinderName, radius, height, getColor (colorCorba));
-	    GraphicalInterface::initParent (cylinderName, cylinder);
-	    addNode (cylinderName, cylinder);
-	    return true;
-	  }
-	} catch (const std::exception& exc) {
-	  throw Error (exc.what ());
-	}
+          try {
+              return windowsManager_->addCylinder (cylinderNameCorba, radius, height,
+                      colorCorba);
+          } catch (const std::exception& exc) {
+              throw Error (exc.what ());
+          }
       }
 
       bool GraphicalInterface::addSphere (const char* sphereNameCorba,
 					  const float radius,
-					  const double* colorCorba)
-	throw (Error)
+                      const value_type* colorCorba)
+          throw (Error)
       {
-	try {
-	  std::string sphereName (sphereNameCorba);
-	  if (nodes_.find (sphereName) != nodes_.end ()) {
-	    std::cout << "You need to chose an other name, \"" << sphereName
-		      << "\" already exist." << std::endl;
-	    return false;
-	  }
-	  else {
-	    LeafNodeSpherePtr_t sphere = LeafNodeSphere::create
-	      (sphereName, radius, getColor (colorCorba));
-	    GraphicalInterface::initParent (sphereName, sphere);
-	    addNode (sphereName, sphere);
-	    return true;
-	  }
-	} catch (const std::exception& exc) {
-	  throw Error (exc.what ());
-	}
+          try {
+              return windowsManager_->addSphere (sphereNameCorba, radius, colorCorba);
+          } catch (const std::exception& exc) {
+              throw Error (exc.what ());
+          }
       }
 
       bool GraphicalInterface::addLine (const char* lineNameCorba,
-					const double* posCorba1,
-					const double* posCorba2,
-					const double* colorCorba) throw (Error)
+					const value_type* posCorba1,
+					const value_type* posCorba2,
+					const value_type* colorCorba) throw (Error)
       {
-	try {
-	  std::string lineName (lineNameCorba);
-	  if (nodes_.find (lineName) != nodes_.end ()) {
-	    std::cout << "You need to chose an other name, \"" << lineName
-		      << "\" already exist." << std::endl;
-	    return false;
-	  }
-	  else {
-	    osgVector3 pos1 (posCorba1[0], posCorba1[1], posCorba1[2]);
-	    osgVector3 pos2 (posCorba2[0], posCorba2[1], posCorba2[2]);
-	    LeafNodeLinePtr_t line = LeafNodeLine::create
-	      (lineName, pos1, pos2, getColor (colorCorba));
-	    GraphicalInterface::initParent (lineName, line);
-	    addNode (lineName, line);
-	    return true;
-	  }
-	} catch (const std::exception& exc) {
-	  throw Error (exc.what ());
-	}
+          try {
+              return addLine ( lineNameCorba, posCorba1, posCorba2, colorCorba) ;
+          } catch (const std::exception& exc) {
+              throw Error (exc.what ());
+          }
       }
 
       bool GraphicalInterface::addTriangleFace (const char* faceNameCorba,
-						const double* posCorba1,
-						const double* posCorba2,
-						const double* posCorba3,
-						const double* colorCorba)
-	throw (Error)
+						const value_type* posCorba1,
+						const value_type* posCorba2,
+						const value_type* posCorba3,
+						const value_type* colorCorba) throw (Error)
       {
 	try {
-	  std::string faceName (faceNameCorba);
-	  if (nodes_.find (faceName) != nodes_.end ()) {
-	    std::cout << "You need to chose an other name, \"" << faceName
-		      << "\" already exist." << std::endl;
-	    return false;
-	  }
-	  else {
-	    osgVector3 pos1 (posCorba1[0], posCorba1[1], posCorba1[2]);
-	    osgVector3 pos2 (posCorba2[0], posCorba2[1], posCorba2[2]);
-	    osgVector3 pos3 (posCorba3[0], posCorba3[1], posCorba3[2]);
-	    LeafNodeFacePtr_t face = LeafNodeFace::create
-	      (faceName, pos1, pos2, pos3, getColor (colorCorba));
-	    GraphicalInterface::initParent (faceName, face);
-	    addNode (faceName, face);
-	    return true;
-	  }
+      return addTriangleFace ( faceNameCorba, posCorba1, posCorba2, posCorba3, colorCorba) ;
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
       }
 
       bool GraphicalInterface::addSquareFace (const char* faceNameCorba,
-					      const double* posCorba1,
-					      const double* posCorba2,
-					      const double* posCorba3,
-					      const double* posCorba4,
-					      const double* colorCorba)
-	throw (Error)
+					      const value_type* posCorba1,
+					      const value_type* posCorba2,
+					      const value_type* posCorba3,
+					      const value_type* posCorba4,
+					      const value_type* colorCorba) throw (Error)
       {
 	try {
-	  std::string faceName (faceNameCorba);
-	  if (nodes_.find (faceName) != nodes_.end ()) {
-	    std::cout << "You need to chose an other name, \"" << faceName
-		      << "\" already exist." << std::endl;
-	    return false;
-	  }
-	  else {
-	    osgVector3 pos1 (posCorba1[0], posCorba1[1], posCorba1[2]);
-	    osgVector3 pos2 (posCorba2[0], posCorba2[1], posCorba2[2]);
-	    osgVector3 pos3 (posCorba3[0], posCorba3[1], posCorba3[2]);
-	    osgVector3 pos4 (posCorba4[0], posCorba4[1], posCorba4[2]);
-	    LeafNodeFacePtr_t face = LeafNodeFace::create
-	      (faceName, pos1, pos2, pos3, pos3, getColor (colorCorba));
-	    GraphicalInterface::initParent (faceName, face);
-	    addNode (faceName, face);
-	    return true;
-	  }
+      return addSquareFace ( faceNameCorba, posCorba1, posCorba2, posCorba3, posCorba4, colorCorba) ;
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
@@ -515,14 +193,7 @@ namespace graphics {
       void GraphicalInterface::getNodeList () throw (Error)
       {
 	try {
-	  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;
-	  std::cout << "List of GroupNodes :" << std::endl;
-	  for (std::map<std::string, GroupNodePtr_t>::iterator it=
-		 groupNodes_.begin (); it!=groupNodes_.end (); ++it)
-	    std::cout << "   " << it->first << std::endl;
+      return getNodeList ();
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
@@ -531,11 +202,7 @@ namespace graphics {
       void GraphicalInterface::getWindowList () throw (Error)
       {
 	try {
-	  std::cout << "List of Windows :" << std::endl;
-          size_t rank = 0;
-	  for (WindowManagers_t::iterator it = windowManagers_.begin ();
-              it!=windowManagers_.end (); ++it)
-	    std::cout << rank << " - " << (*it)->getViewerClone ()->getSlave (0)._camera->getGraphicsContext ()->getTraits ()->windowName << std::endl;
+      return getWindowList ();
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
@@ -544,18 +211,7 @@ namespace graphics {
       bool GraphicalInterface::createGroup (const char* groupNameCorba) throw (Error)
       {
 	try {
-	  const std::string groupName (groupNameCorba);
-	  if (nodes_.find (groupName) != nodes_.end ()) {
-	    std::cout << "You need to chose an other name, \"" << groupName
-		      << "\" already exist." << std::endl;
-	    return false;
-	  }
-	  else {
-	    GroupNodePtr_t groupNode = GroupNode::create (groupName);
-	    GraphicalInterface::initParent (groupName, groupNode);
-	    addGroup (groupName, groupNode);
-	    return true;
-	  }
+      return createGroup ( groupNameCorba) ;
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
@@ -563,60 +219,20 @@ namespace graphics {
 
       bool GraphicalInterface::addURDF (const char* urdfNameCorba,
 					const char* urdfPathCorba,
-					const char* urdfPackagePathCorba)
-	throw (Error)
+					const char* urdfPackagePathCorba) throw (Error)
       {
 	try {
-	  const std::string urdfName (urdfNameCorba);
-	  const std::string urdfPath (urdfPathCorba);
-	  const std::string urdfPackagePath (urdfPackagePathCorba);
-	  if (nodes_.find (urdfName) != nodes_.end ()) {
-	    std::cout << "You need to chose an other name, \"" << urdfName
-		      << "\" already exist." << std::endl;
-	    return false;
-	  }
-	  else {
-	    GroupNodePtr_t urdf = urdfParser::parse
-	 (urdfName, urdfPath, urdfPackagePath);
-	    NodePtr_t link;
-	    for (int i=0; i< urdf->getNumOfChildren (); i++) {
-	      link = urdf->getChild (i);
-	      nodes_[link->getID ()] = link;
-	    }
-	    GraphicalInterface::initParent (urdfName, urdf);
-	    addGroup (urdfName, urdf);
-	    return true;
-	  }
+      return addURDF ( urdfNameCorba, urdfPathCorba, urdfPackagePathCorba) ;
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
       }
 
-      bool GraphicalInterface::addUrdfCollision
-      (const char* urdfNameCorba, const char* urdfPathCorba,
+      bool GraphicalInterface::addUrdfCollision (const char* urdfNameCorba, const char* urdfPathCorba,
        const char* urdfPackagePathCorba) throw (Error)
       {
 	try {
-	  const std::string urdfName (urdfNameCorba);
-	  const std::string urdfPath (urdfPathCorba);
-	  const std::string urdfPackagePath (urdfPackagePathCorba);
-	  if (nodes_.find (urdfName) != nodes_.end ()) {
-	    std::cout << "You need to chose an other name, \"" << urdfName
-		      << "\" already exist." << std::endl;
-	    return false;
-	  }
-	  else {
-	    GroupNodePtr_t urdf = urdfParser::parse
-	      (urdfName, urdfPath, urdfPackagePath, "collision");
-	    NodePtr_t link;
-	    for (int i=0; i< urdf->getNumOfChildren (); i++) {
-	      link = urdf->getChild (i);
-	      nodes_[link->getID ()] = link;
-	    }
-	    GraphicalInterface::initParent (urdfName, urdf);
-	    addGroup (urdfName, urdf);
-	    return true;
-	  }
+      return addUrdfCollision ( urdfNameCorba, urdfPathCorba, urdfPackagePathCorba) ;
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
@@ -625,88 +241,29 @@ namespace graphics {
       void GraphicalInterface::addUrdfObjects (const char* urdfNameCorba,
 					       const char* urdfPathCorba,
 					       const char* urdfPackagePathCorba,
-					       bool visual)
-	throw (Error)
+					       bool visual) throw (Error)
       {
 	try {
-	  const std::string urdfName (urdfNameCorba);
-	  const std::string urdfPath (urdfPathCorba);
-	  const std::string urdfPackagePath (urdfPackagePathCorba);
-	  if (urdfName == "") {
-	    throw std::runtime_error ("Parameter nodeName cannot be empty in "
-				      "idl request addUrdfObjects.");
-	  }
-	  if (nodes_.find (urdfName) != nodes_.end ()) {
-	    std::ostringstream oss;
-	    oss << "You need to chose an other name, \"" << urdfName
-		<< "\" already exist.";
-	    throw std::runtime_error (oss.str ());
-	  }
-	  GroupNodePtr_t urdf = urdfParser::parse
-	    (urdfName, urdfPath, urdfPackagePath,
-	     visual ? "visual" : "collision", "object");
-	  NodePtr_t link;
-	  for (int i=0; i< urdf->getNumOfChildren (); i++) {
-	    link = urdf->getChild (i);
-	    nodes_[link->getID ()] = link;
-	  }
-	  GraphicalInterface::initParent (urdfName, urdf);
-	  addGroup (urdfName, urdf);
+      return addUrdfObjects ( urdfNameCorba, urdfPathCorba, urdfPackagePathCorba, visual) ;
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
       }
 
       bool GraphicalInterface::addToGroup (const char* nodeNameCorba,
-					   const char* groupNameCorba)
-	throw (Error)
+					   const char* groupNameCorba) throw (Error)
       {
 	try {
-	  const std::string nodeName (nodeNameCorba);
-	  const std::string groupName (groupNameCorba);
-	  if (nodes_.find (nodeName) == nodes_.end () ||
-	      groupNodes_.find (groupName) == groupNodes_.end ()) {
-	    std::cout << "Node name \"" << nodeName << "\" and/or groupNode \""
-		      << groupName << "\" doesn't exist." << std::endl;
-	    return false;
-	  }
-	  else {
-	    groupNodes_[groupName]->addChild (nodes_[nodeName]);
-	    return true;
-	  }
+      return addToGroup ( nodeNameCorba, groupNameCorba) ;
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
       }
 
-      bool GraphicalInterface::applyConfiguration
-      (const char* nodeNameCorba, const double* configurationCorba)
-	throw (Error)
+      bool GraphicalInterface::applyConfiguration (const char* nodeNameCorba, const value_type* configurationCorba) throw (Error)
       {
 	try {
-	  const std::string nodeName (nodeNameCorba);
-	  if (nodes_.find (nodeName) == nodes_.end ()) {
-	    //no node named nodeName
-	    std::cout << "No Node named \"" << nodeName << "\"" << std::endl;
-	    return false;
-	  }
-	  else {
-	    NodeConfiguration newNodeConfiguration;
-	    newNodeConfiguration.node = nodes_[nodeName];
-	    try {
-	      newNodeConfiguration.position =
-		GraphicalInterface::corbaConfToOsgVec3 (configurationCorba);
-	      newNodeConfiguration.quat =
-		GraphicalInterface::corbaConfToOsgQuat (configurationCorba);
-	    } catch (const std::exception& exc) {
-	      std::cout << "Error when converting configuration, configuration "
-		"should be DOUBLE[7] = [transX, transY, transZ, quatW, quatX,"
-		"quatY, quatZ]" <<std::endl;
-	      return false;
-	    }
-	    newNodeConfigurations_.push_back (newNodeConfiguration);
-	    return true;
-	  }
+      return applyConfiguration ( nodeNameCorba, configurationCorba) ;
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
@@ -716,147 +273,75 @@ namespace graphics {
 					    float size) throw (Error)
       {
 	try {
-	  const std::string nodeName (nodeNameCorba);
-	  if (nodes_.find (nodeName) == nodes_.end ()) {
-	    std::cout << "Node \"" << nodeName << "\" doesn't exist."
-		      << std::endl;
-	    return false;
-	  }
-	  nodes_[nodeName]->addLandmark (size);
-	  return true;
+      return addLandmark ( nodeNameCorba, size) ;
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
       }
 
 
-      bool GraphicalInterface::deleteLandmark (const char* nodeNameCorba)
-	throw (Error)
+      bool GraphicalInterface::deleteLandmark (const char* nodeNameCorba) throw (Error)
       {
 	try {
-	  const std::string nodeName (nodeNameCorba);
-	  if (nodes_.find (nodeName) == nodes_.end ()) {
-	    std::cout << "Node \"" << nodeName << "\" doesn't exist."
-		      << std::endl;
-	    return false;
-	  }
-	  nodes_[nodeName]->deleteLandmark ();
-	  return true;
+      return deleteLandmark ( nodeNameCorba) ;
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
       }
 
       bool GraphicalInterface::setVisibility (const char* nodeNameCorba,
-					      const char* visibilityModeCorba)
-	throw (Error)
+					      const char* visibilityModeCorba) throw (Error)
       {
 	try {
-	  const std::string nodeName (nodeNameCorba);
-	  const std::string visibilityMode (visibilityModeCorba);
-	  VisibilityMode visibility =  getVisibility (visibilityMode);
-	  if (nodes_.find (nodeName) == nodes_.end ()) {
-	    std::cout << "Node \"" << nodeName << "\" doesn't exist."
-		      << std::endl;
-	    return false;
-	  }
-	  nodes_[nodeName]->setVisibilityMode (visibility);
-	  return true;
+      return setVisibility ( nodeNameCorba, visibilityModeCorba) ;
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
       }
 
       bool GraphicalInterface::setWireFrameMode (const char* nodeNameCorba,
-						 const char* wireFrameModeCorba)
-	throw (Error)
+						 const char* wireFrameModeCorba) throw (Error)
       {
 	try {
-	  const std::string nodeName (nodeNameCorba);
-	  const std::string wireFrameMode (wireFrameModeCorba);
-	  WireFrameMode wire = getWire (wireFrameMode);
-	  if (nodes_.find (nodeName) == nodes_.end ()) {
-	    std::cout << "Node \"" << nodeName << "\" doesn't exist."
-		      << std::endl;
-	    return false;
-	  }
-	  nodes_[nodeName]->setWireFrameMode (wire);
-	  return true;
+      return setWireFrameMode ( nodeNameCorba, wireFrameModeCorba) ;
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
       }
 
       bool GraphicalInterface::setLightingMode (const char* nodeNameCorba,
-						const char* lightingModeCorba)
-	throw (Error)
+						const char* lightingModeCorba) throw (Error)
       {
 	try {
-	  const std::string nodeName (nodeNameCorba);
-	  const std::string lightingMode (lightingModeCorba);
-	  LightingMode light = getLight (lightingMode);
-	  if (nodes_.find (nodeName) == nodes_.end ()) {
-	    std::cout << "Node \"" << nodeName << "\" doesn't exist."
-		      << std::endl;
-	    return false;
-	  }
-	  nodes_[nodeName]->setLightingMode (light);
-	  return true;
+      return setLightingMode ( nodeNameCorba, lightingModeCorba) ;
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
       }
 
       bool GraphicalInterface::startCapture (const WindowID windowId, const char* filename,
-          const char* extension)
-        throw (Error)
+          const char* extension) throw (Error)
       {
 	try {
-	  if (windowId >= 0 || windowId < windowManagers_.size ()) {
-	    windowManagers_[windowId]->startCapture
-              (std::string (filename), std::string (extension));
-	    return true;
-	  }
-	  else {
-	    std::cout << "Window ID " << windowId
-		      << " doesn't exist." << std::endl;
-	    return false;
-	  }
+      return startCapture ( windowId, filename, extension) ;
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
       }
 
-      bool GraphicalInterface::stopCapture (const WindowID windowId)
-        throw (Error)
+      bool GraphicalInterface::stopCapture (const WindowID windowId) throw (Error)
       {
 	try {
-	  if (windowId >= 0 || windowId < windowManagers_.size ()) {
-	    windowManagers_[windowId]->stopCapture ();
-	    return true;
-	  }
-	  else {
-	    std::cout << "Window ID " << windowId
-		      << " doesn't exist." << std::endl;
-	    return false;
-	  }
+      return stopCapture ( windowId) ;
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
       }
 
-      bool GraphicalInterface::writeNodeFile (const WindowID windowId, const char* filename)
-        throw (Error)
+      bool GraphicalInterface::writeNodeFile (const WindowID windowId, const char* filename) throw (Error)
       {
 	try {
-	  if (windowId >= 0 || windowId < windowManagers_.size ()) {
-	    return windowManagers_[windowId]->writeNodeFile (std::string (filename));
-	  }
-	  else {
-	    std::cout << "Window ID " << windowId
-		      << " doesn't exist." << std::endl;
-	    return false;
-	  }
+      return writeNodeFile ( windowId, filename) ;
 	} catch (const std::exception& exc) {
 	  throw Error (exc.what ());
 	}
diff --git a/src/graphical-interface.impl.hh b/src/graphical-interface.impl.hh
index 628b1e0..2aa9c45 100644
--- a/src/graphical-interface.impl.hh
+++ b/src/graphical-interface.impl.hh
@@ -10,26 +10,8 @@
 #define SCENEVIEWER_CORBASERVER_GRAPHICALINTERFACE_HH
 
 #include <omniORB4/CORBA.h>
-#include <boost/thread.hpp>
-#include <boost/thread/mutex.hpp>
-
-#include <gepetto/viewer/window-manager.h>
-#include <gepetto/viewer/node.h>
-#include <gepetto/viewer/group-node.h>
-#include <gepetto/viewer/leaf-node-box.h>
-#include <gepetto/viewer/leaf-node-capsule.h>
-#include <gepetto/viewer/leaf-node-cone.h>
-#include <gepetto/viewer/leaf-node-cylinder.h>
-#include <gepetto/viewer/leaf-node-line.h>
-#include <gepetto/viewer/leaf-node-face.h>
-#include <gepetto/viewer/leaf-node-sphere.h>
-#include <gepetto/viewer/macros.h>
-#include <gepetto/viewer/config-osg.h>
-#include <gepetto/viewer/leaf-node-ground.h>
-#include <gepetto/viewer/leaf-node-collada.h>
-#include <gepetto/viewer/urdf-parser.h>
-
-#include "server.hh"
+
+#include "gepetto/viewer/corba/server.hh"
 #include "graphical-interface.hh"
 
 namespace graphics {
@@ -42,35 +24,15 @@ struct NodeConfiguration {
     osgQuat quat;
 };
 
+using graphics::WindowsManagerPtr_t;
 class GraphicalInterface :
     public virtual POA_gepetto::corbaserver::GraphicalInterface
 {
 private:
+    WindowsManagerPtr_t windowsManager_;
     typedef gepetto::Error Error;
     typedef CORBA::ULong WindowID;
-    typedef std::vector <WindowManagerPtr_t> WindowManagers_t;
-    WindowManagers_t windowManagers_;
-    std::map<std::string, NodePtr_t> nodes_;
-    std::map<std::string, GroupNodePtr_t> groupNodes_;
-    corbaServer::Server* server_;
-    boost::mutex mtx_;
-    int rate_;
-    std::list<NodeConfiguration> newNodeConfigurations_;
-
-    static osgVector4 getColor(const std::string& colorName);
-    static osgVector4 getColor(const double* color);
-    static std::string parentName(const std::string& name);
-    static VisibilityMode getVisibility(const std::string& visibilityName);
-    static WireFrameMode getWire(const std::string& wireName);
-    static LightingMode getLight(const std::string& lightName);
-    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);
-    void threadRefreshing(WindowManagerPtr_t window);
-    static osgQuat corbaConfToOsgQuat(const double* configurationCorba);
-    static osgVector3 corbaConfToOsgVec3(const double* configurationCorba);
-
-protected:
+    typedef graphics::WindowsManager::value_type value_type;
 
 public:
     /**
@@ -91,22 +53,22 @@ public:
   virtual bool addSceneToWindow(const char* sceneNameCorba, const WindowID windowId)  throw (Error);
 
 
-  virtual bool addBox(const char* boxName, float boxSize1, float boxSize2, float boxSize3, const double* color) throw (Error);
+  virtual bool addBox(const char* boxName, float boxSize1, float boxSize2, float boxSize3, const value_type* color) throw (Error);
 
-  virtual bool addCapsule(const char* capsuleName, float radius, float height, const double* color) throw (Error);
+  virtual bool addCapsule(const char* capsuleName, float radius, float height, const value_type* color) throw (Error);
 
   virtual bool addMesh(const char* meshNameCorba, const char* meshPathCorba)  throw (Error);
 
-  virtual bool addCone(const char* coneName, float radius, float height, const double* color) throw (Error);
+  virtual bool addCone(const char* coneName, float radius, float height, const value_type* color) throw (Error);
 
-  virtual bool addCylinder(const char* cylinderName, float radius, float height, const double* color) throw (Error);
+  virtual bool addCylinder(const char* cylinderName, float radius, float height, const value_type* color) throw (Error);
 
-  virtual bool addSphere(const char* sphereName, float radius, const double* color) throw (Error);
+  virtual bool addSphere(const char* sphereName, float radius, const value_type* color) throw (Error);
 
-  virtual bool addLine(const char* lineName, const double* pos1, const double* pos2, const double* color) throw (Error);
+  virtual bool addLine(const char* lineName, const value_type* pos1, const value_type* pos2, const value_type* color) throw (Error);
 
-  virtual bool addSquareFace(const char* faceName, const double* pos1, const double* pos2, const double* pos3, const double* pos4, const double* color) throw (Error);
-  virtual bool addTriangleFace(const char* faceName, const double* pos1, const double* pos2, const double* pos3, const double* color) throw (Error);
+  virtual bool addSquareFace(const char* faceName, const value_type* pos1, const value_type* pos2, const value_type* pos3, const value_type* pos4, const value_type* color) throw (Error);
+  virtual bool addTriangleFace(const char* faceName, const value_type* pos1, const value_type* pos2, const value_type* pos3, const value_type* color) throw (Error);
 
   virtual bool addURDF(const char* urdfNameCorba, const char* urdfPathCorba, const char* urdfPackagePathCorba) throw (Error);
 
@@ -124,7 +86,7 @@ public:
   virtual bool createGroup(const char* groupNameCorba)  throw (Error);
   virtual bool addToGroup(const char* nodeNameCorba, const char* groupNameCorba)  throw (Error);
 
-  virtual bool applyConfiguration(const char* nodeNameCorba, const double* configuration)  throw (Error);
+  virtual bool applyConfiguration(const char* nodeNameCorba, const value_type* configuration)  throw (Error);
 
   virtual bool addLandmark(const char* nodeNameCorba, float size) throw (Error);
   virtual bool deleteLandmark(const char* nodeNameCorba) throw (Error);
diff --git a/src/server-private.cc b/src/server-private.cc
index e70e97d..ea5db2c 100644
--- a/src/server-private.cc
+++ b/src/server-private.cc
@@ -13,7 +13,7 @@
 
 #include "graphical-interface.impl.hh"
 #include "server-private.hh"
-#include "fwd.hh"
+#include "gepetto/viewer/corba/fwd.hh"
 
 namespace graphics
 {
diff --git a/src/server-private.hh b/src/server-private.hh
index 396ca6b..6961fbe 100644
--- a/src/server-private.hh
+++ b/src/server-private.hh
@@ -12,7 +12,7 @@
 # define SCENVIEWER_CORBASERVER_SERVER_PRIVATE_HH
 
 # include "graphical-interface.impl.hh"
-# include "fwd.hh"
+# include "gepetto/viewer/corba/fwd.hh"
 
 namespace graphics
 {
diff --git a/src/server.cc b/src/server.cc
index 783a83a..9a95940 100644
--- a/src/server.cc
+++ b/src/server.cc
@@ -12,11 +12,10 @@
 #include <pthread.h>
 #include <iostream>
 #include <stdexcept>
-#include "server.hh"
 
+#include "gepetto/viewer/corba/server.hh"
 #include "server-private.hh"
 
-
 namespace graphics
 {
   namespace corbaServer
@@ -42,7 +41,8 @@ namespace graphics
     //} // end of anonymous namespace.
 
 
-    Server::Server(int argc, const char *argv[], bool inMultiThread)
+    Server::Server(WindowsManagerPtr_t wm, int argc, const char *argv[],
+        bool inMultiThread) : windowsManager_ (wm)
     {
       private_ = new impl::Server;
 
diff --git a/src/server.hh b/src/server.hh
index 65d418b..54c614f 100644
--- a/src/server.hh
+++ b/src/server.hh
@@ -11,13 +11,16 @@
 #ifndef SCENEVIEWER_CORBASERVER_SERVER_HH
 # define SCENEVIEWER_CORBASERVER_SERVER_HH
 
-
-#include "fwd.hh"
+#include "gepetto/viewer/corba/fwd.hh"
+#include <gepetto/viewer/windows-manager.h>
 
 namespace graphics
 {
   namespace corbaServer
   {
+    using graphics::WindowsManager;
+    using graphics::WindowsManagerPtr_t;
+
     /// Implementation of Hpp module Corba server.
 
     ///  This class initializes the Corba server and starts the following Corba interface implementations.
@@ -50,6 +53,7 @@ namespace graphics
     {
     public:
       /// Constructor
+      /// \param the object that handles CORBA requests.
       /// \param argc, argv parameter to feed ORB initialization.
       /// \param multiThread whether the server may process request using
       ///        multithred policy.
@@ -59,7 +63,8 @@ namespace graphics
       /// \note It is highly recommended not to enable multi-thread policy in
       ///       CORBA request processing if this library is run from an openGL
       ///       based GUI, since OpenGL does not support multithreading.
-      Server (int argc, const char* argv[], bool multiThread = false);
+      Server (WindowsManagerPtr_t windowsManager, int argc,
+          const char* argv[], bool multiThread = false);
 
       /// \brief Shutdown CORBA server
       ~Server ();
@@ -74,8 +79,10 @@ namespace graphics
       ///             returns.
       int processRequest (bool loop);
 
-      //core::ProblemSolverPtr_t problemSolver () const;
-      //core::ProblemSolverPtr_t problemSolver ();
+      WindowsManagerPtr_t windowsManager () const
+      {
+        return windowsManager_;
+      }
 
     private:
 
@@ -92,6 +99,7 @@ namespace graphics
 
       impl::Server* private_;
 
+      WindowsManagerPtr_t windowsManager_;
     };
 
   } // end of namespace corbaServer.
diff --git a/src/test-client-cpp.cc b/src/test-client-cpp.cc
index 8690b2f..4dfb52e 100644
--- a/src/test-client-cpp.cc
+++ b/src/test-client-cpp.cc
@@ -29,12 +29,12 @@ int main(int, const char **)
 
     sleep(5);
 
-    //vector<double> tri01 (3);
+    //vector<float> tri01 (3);
 
-    double pos1[3]= {1.,0.,0.};
-    double pos2[3] = {0.,1.,0.};
-    double pos3[3]= {0.,1.,1.};
-    double color[4] = {1.,1.,1.,1.};
+    float pos1[3]= {1.,0.,0.};
+    float pos2[3] = {0.,1.,0.};
+    float pos3[3]= {0.,1.,1.};
+    float color[4] = {1.,1.,1.,1.};
     client.addTriangleFace("scene1/triangle", pos1, pos2, pos3, color);
 
     sleep(15);
-- 
GitLab