Revision: 7003
          http://playerstage.svn.sourceforge.net/playerstage/?rev=7003&view=rev
Author:   natepak
Date:     2008-09-02 11:56:30 +0000 (Tue, 02 Sep 2008)

Log Message:
-----------
Updates to the GUI

Modified Paths:
--------------
    code/gazebo/trunk/server/Model.cc
    code/gazebo/trunk/server/Model.hh
    code/gazebo/trunk/server/gui/Gui.cc
    code/gazebo/trunk/server/gui/Toolbar.cc
    code/gazebo/trunk/server/gui/Toolbar.hh
    code/gazebo/trunk/server/physics/Body.cc
    code/gazebo/trunk/server/physics/Body.hh

Modified: code/gazebo/trunk/server/Model.cc
===================================================================
--- code/gazebo/trunk/server/Model.cc   2008-09-02 01:21:56 UTC (rev 7002)
+++ code/gazebo/trunk/server/Model.cc   2008-09-02 11:56:30 UTC (rev 7003)
@@ -614,6 +614,13 @@
 }
 
 
////////////////////////////////////////////////////////////////////////////////
+/// Get a map of all the bodies
+const std::map<std::string, Body*> *Model::GetBodies() const
+{
+  return &(this->bodies);
+}
+ 
+////////////////////////////////////////////////////////////////////////////////
 /// Get a body by name
 Body *Model::GetBody(const std::string &name)
 {

Modified: code/gazebo/trunk/server/Model.hh
===================================================================
--- code/gazebo/trunk/server/Model.hh   2008-09-02 01:21:56 UTC (rev 7002)
+++ code/gazebo/trunk/server/Model.hh   2008-09-02 11:56:30 UTC (rev 7003)
@@ -126,6 +126,9 @@
     /// \brief Get a body by name
     /// \return Pointer to the body
     public: Body *GetBody(const std::string &name);
+
+    /// \brief Get a map of all the bodies
+    public: const std::map<std::string, Body*> *GetBodies() const;
   
     /// \brief Attach this model to its parent
     public: void Attach(XMLConfigNode *node);
@@ -185,6 +188,7 @@
     private: ParamT<std::string> *parentBodyNameP;
     private: ParamT<std::string> *myBodyNameP;
 
+
     // Name of a light (if the model is renderable:light)
     private: std::string lightName;
 

Modified: code/gazebo/trunk/server/gui/Gui.cc
===================================================================
--- code/gazebo/trunk/server/gui/Gui.cc 2008-09-02 01:21:56 UTC (rev 7002)
+++ code/gazebo/trunk/server/gui/Gui.cc 2008-09-02 11:56:30 UTC (rev 7003)
@@ -59,7 +59,7 @@
   // The order of creation matters! Menubar first, followed by FrameManager,
   // then statusbar
   {
-    int toolbarWidth = 200;
+    int toolbarWidth = 250;
 
     // Create a main menu
     new MainMenu(0,0,w(),30,(char *)"MainMenu");

Modified: code/gazebo/trunk/server/gui/Toolbar.cc
===================================================================
--- code/gazebo/trunk/server/gui/Toolbar.cc     2008-09-02 01:21:56 UTC (rev 
7002)
+++ code/gazebo/trunk/server/gui/Toolbar.cc     2008-09-02 11:56:30 UTC (rev 
7003)
@@ -27,8 +27,11 @@
 #include <stdio.h>
 #include <FL/Fl_Value_Output.H>
 #include <FL/Fl_Output.H>
+#include <FL/Fl_Input.H>
 #include <FL/Fl_Button.H>
 
+#include "Body.hh"
+#include "Geom.hh"
 #include "Entity.hh"
 #include "Model.hh"
 #include "Simulator.hh"
@@ -48,7 +51,7 @@
   this->columnWidths[1] = 120;
   this->columnWidths[2] = 0;
 
-  this->entityBrowser = new Fl_Hold_Browser(x+10, y+20, w-20, 25*5, 
"Attributes");
+  this->entityBrowser = new Fl_Hold_Browser(x+10, y+20, w-20, 25*10, 
"Attributes");
   this->entityBrowser->align(FL_ALIGN_TOP);
   this->entityBrowser->column_char('~');
   this->entityBrowser->column_widths( columnWidths );
@@ -68,74 +71,44 @@
 void Toolbar::Update()
 {
   Entity *entity = Simulator::Instance()->GetSelectedEntity();
-  std::vector<Param*> *parameters;
-  std::vector<Param*>::iterator iter;
 
+  this->attrCount = 0;
   if (entity)
   {
-    //Model *model = dynamic_cast<Model *>(entity);
+    std::string value = "@[EMAIL PROTECTED]@[EMAIL PROTECTED] ";
+    this->AddToBrowser(value);
+    this->AddEntityToAttributeBrowser(entity, "");
 
-    parameters = entity->GetParameters();
-
-    int i=0;
-    for (iter = parameters->begin(); iter != parameters->end(); iter++, i++)
+    Model *model = dynamic_cast<Model *>(entity);
+    if (model)
     {
+      const std::map<std::string, Body *> *bodies = model->GetBodies();
+      const std::vector< Geom *> *geoms;;
+      std::map<std::string, Body *>::const_iterator iter;
+      std::vector<Geom*>::const_iterator giter;
       std::string value;
-      //boost::any anyValue = (*iter)->Get();
-      //std::string typeName = (*iter)->GetTypename();
-      std::string colorStr = "";
 
-      /*if ( i%2 == 0)
-        colorStr = "@B50";
-        */
+      for (iter = bodies->begin(); iter != bodies->end(); iter++)
+      {
+        value = "@[EMAIL PROTECTED]@s-Body:";
+        this->AddToBrowser(value);
+        this->AddEntityToAttributeBrowser( iter->second, "  " );
 
-      value = colorStr + "@[EMAIL PROTECTED]" + (*iter)->GetKey() + ":~" + 
colorStr + "@s";
-      value += (*iter)->GetAsString();
+        geoms = iter->second->GetGeoms();
 
-
-      // Convert the variable value to a string
-      /*if (typeName == typeid(float).name())
-        value += boost::lexical_cast<std::string>(
-            boost::any_cast<float>( anyValue ));
-      else if (typeName == typeid(double).name())
-        value += boost::lexical_cast<std::string>(
-            boost::any_cast<double>( anyValue )); 
-      else if (typeName == typeid(int).name())
-        value += boost::lexical_cast<std::string>(
-            boost::any_cast<int>( anyValue ));
-      else if (typeName == typeid(bool).name())
-        value += boost::lexical_cast<std::string>( 
-            boost::any_cast<bool>(anyValue) );
-      else if (typeName == typeid(long).name())
-        value += boost::lexical_cast<std::string>( 
-            boost::any_cast<long>(anyValue) );
-      else if (typeName == typeid(Quatern).name())
-        value += boost::lexical_cast<std::string>(
-            boost::any_cast<Quatern>( anyValue ));
-      else if (typeName == typeid(Vector3).name())
-        value += boost::lexical_cast<std::string>(
-            boost::any_cast<Vector3>( anyValue ));
-      else if (typeName == typeid(std::string).name())
-        value += boost::any_cast<std::string>( anyValue );
-      else
-        gzerr(0) << "Unknown typename[" << typeName << "]\n";
-        */
-
-      if (!this->entityBrowser->text(i+1))
-      {
-        this->entityBrowser->add( value.c_str() );
+        for (giter = geoms->begin(); giter != geoms->end(); giter++)
+        {
+          value = "@[EMAIL PROTECTED]@s  -Geom:";
+          this->AddToBrowser(value);
+          this->AddEntityToAttributeBrowser( (*giter), "    " );
+        }
       }
-      else if (strcmp(this->entityBrowser->text(i+1), value.c_str()) != 0)
-      {
-        this->entityBrowser->text( i+1, value.c_str() );
-      }
     }
 
     // Clear the remaining lines
-    while ( this->entityBrowser->text(i+1) != NULL )
+    while ( this->entityBrowser->text(this->attrCount+1) != NULL )
     {
-      this->entityBrowser->text( i+1, "" );
-      i++;
+      this->AddToBrowser("");
     }
 
   }
@@ -148,3 +121,45 @@
 {
   printf("Callback\n");
 }
+
+////////////////////////////////////////////////////////////////////////////////
+// Add entity to browser
+void Toolbar::AddEntityToAttributeBrowser(Entity *entity, std::string prefix)
+{
+  std::vector<Param*> *parameters;
+  std::vector<Param*>::iterator iter;
+  std::string value;
+  std::string colorStr = "";
+
+  parameters = entity->GetParameters();
+
+  // Process all the parameters in the entity
+  for (iter = parameters->begin(); iter != parameters->end(); iter++)
+  {
+
+    /*if ( i%2 == 0)
+      colorStr = "@B50";
+      */
+
+    value = colorStr + "@[EMAIL PROTECTED]" + prefix + (*iter)->GetKey() + 
":~" + 
+      colorStr + "@s" + (*iter)->GetAsString();
+
+    this->AddToBrowser( value );
+  }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Add a line to the attribute browser
+void Toolbar::AddToBrowser(const std::string &line)
+{
+  if (!this->entityBrowser->text(this->attrCount+1))
+  {
+    this->entityBrowser->add( line.c_str() );
+  }
+  else if (strcmp(this->entityBrowser->text(this->attrCount+1), line.c_str()) 
!= 0)
+  {
+    this->entityBrowser->text( this->attrCount+1, line.c_str() );
+  }
+
+  this->attrCount++;
+}

Modified: code/gazebo/trunk/server/gui/Toolbar.hh
===================================================================
--- code/gazebo/trunk/server/gui/Toolbar.hh     2008-09-02 01:21:56 UTC (rev 
7002)
+++ code/gazebo/trunk/server/gui/Toolbar.hh     2008-09-02 11:56:30 UTC (rev 
7003)
@@ -32,10 +32,12 @@
 
 class Fl_Value_Output;
 class Fl_Output;
+class Fl_Input;
 class Fl_Button;
 
 namespace gazebo
 {
+  class Entity;
 
   /// \brief Toolbar
   class Toolbar : public Fl_Group
@@ -51,9 +53,13 @@
 
     public: static void AttributeBrowserCB( Fl_Widget * w, void *data);
 
+    private: void AddEntityToAttributeBrowser(Entity *ent, std::string prefix);
+    private: void AddToBrowser(const std::string &line);
+
     private: Fl_Hold_Browser *entityBrowser;
 
     private: int columnWidths[3];
+    private: int attrCount;
   };
   
 }

Modified: code/gazebo/trunk/server/physics/Body.cc
===================================================================
--- code/gazebo/trunk/server/physics/Body.cc    2008-09-02 01:21:56 UTC (rev 
7002)
+++ code/gazebo/trunk/server/physics/Body.cc    2008-09-02 11:56:30 UTC (rev 
7003)
@@ -679,3 +679,10 @@
 
   return torque;
 }
+
+////////////////////////////////////////////////////////////////////////////////
+/// Get the vector of all geoms
+const std::vector<Geom*> *Body::GetGeoms() const
+{
+  return &(this->geoms);
+}

Modified: code/gazebo/trunk/server/physics/Body.hh
===================================================================
--- code/gazebo/trunk/server/physics/Body.hh    2008-09-02 01:21:56 UTC (rev 
7002)
+++ code/gazebo/trunk/server/physics/Body.hh    2008-09-02 11:56:30 UTC (rev 
7003)
@@ -139,6 +139,9 @@
   
     /// \brief Get the torque applied to the body
     public: Vector3 GetTorque() const;
+
+    /// \brief Get the vector of all geoms
+    public: const std::vector<Geom*> *GetGeoms() const;
   
     /// Load a new geom helper function
     /// \param node XMLConfigNode used to load the geom


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Playerstage-commit mailing list
Playerstage-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to