Revision: 8416
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8416&view=rev
Author:   natepak
Date:     2009-11-17 21:50:42 +0000 (Tue, 17 Nov 2009)

Log Message:
-----------
Fixed up gui

Modified Paths:
--------------
    code/gazebo/trunk/server/Entity.cc
    code/gazebo/trunk/server/physics/Body.cc
    code/gazebo/trunk/server/physics/Body.hh
    code/gazebo/trunk/server/physics/bullet/BulletBody.cc

Added Paths:
-----------
    code/gazebo/trunk/server/gui/Toolbar.cc
    code/gazebo/trunk/server/gui/Toolbar.hh

Modified: code/gazebo/trunk/server/Entity.cc
===================================================================
--- code/gazebo/trunk/server/Entity.cc  2009-11-17 19:15:17 UTC (rev 8415)
+++ code/gazebo/trunk/server/Entity.cc  2009-11-17 21:50:42 UTC (rev 8416)
@@ -174,17 +174,11 @@
   Body *body = NULL;
 
   this->selected = s;
-  //std::cout << " SetSelected Entity : " << this->GetName() << " selected(" 
<< s << ")" << std::endl;
 
   for (iter = this->children.begin(); iter != this->children.end(); iter++)
   {
-    //std::cout << " SetSelected Entity Children: " << (*iter)->GetName() << 
std::endl;
     (*iter)->SetSelected(s);
     body = dynamic_cast<Body*>(*iter);
-
-    //enabling SetEnabled(!s) makes body unstabel upon unselection
-    //if (body)
-      //body->SetEnabled(!s);
   }
 
   return true;

Added: code/gazebo/trunk/server/gui/Toolbar.cc
===================================================================
--- code/gazebo/trunk/server/gui/Toolbar.cc                             (rev 0)
+++ code/gazebo/trunk/server/gui/Toolbar.cc     2009-11-17 21:50:42 UTC (rev 
8416)
@@ -0,0 +1,212 @@
+/*
+ *  Gazebo - Outdoor Multi-Robot Simulator
+ *  Copyright (C) 2003
+ *     Nate Koenig & Andrew Howard
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+/* Desc: Toolbar
+ * Author: Nate Koenig
+ * Date: 13 Feb 2006
+ * SVN: $Id$
+ */
+
+#include <stdio.h>
+
+#include <FL/Fl_Button.H>
+#include <FL/Fl_Box.H>
+#include <FL/Fl_Bitmap.H>
+#include <FL/Fl_RGB_Image.H>
+
+#include "Image.hh"
+#include "Gui.hh"
+#include "Global.hh"
+#include "Simulator.hh"
+#include "Toolbar.hh"
+
+using namespace gazebo;
+
+////////////////////////////////////////////////////////////////////////////////
+// Constructor
+Toolbar::Toolbar(int x, int y, int w, int h, const char *l)
+    : Fl_Group(x,y,w,h,l)
+{
+  this->box(FL_THIN_DOWN_BOX);
+
+  this->color(BG_COLOR);
+
+  unsigned char *data = NULL;
+  unsigned int dataCount;
+
+  Image image;
+  image.Load("blue_play_button.png");
+  image.Rescale(20,20);
+  image.GetData(&data, dataCount);
+
+  this->playImage[0] = new Fl_RGB_Image(data, image.GetWidth(), 
+                                        image.GetHeight(), 4);
+
+  data = NULL;
+  image.Load("grey_play_button.png");
+  image.Rescale(20,20);
+  image.GetData(&data, dataCount);
+  this->playImage[1] = new Fl_RGB_Image(data, image.GetWidth(), 
+                                        image.GetHeight(), 4);
+
+  data = NULL;
+  image.Load("blue_pause_button.png");
+  image.Rescale(20,20);
+  image.GetData(&data, dataCount);
+  this->pauseImage[0] = new Fl_RGB_Image(data, image.GetWidth(), 
+                                         image.GetHeight(), 4);
+
+  data = NULL;
+  image.Load("grey_pause_button.png");
+  image.Rescale(20,20);
+  image.GetData(&data, dataCount);
+  this->pauseImage[1] = new Fl_RGB_Image(data, image.GetWidth(), 
+                                         image.GetHeight(), 4);
+
+  data = NULL;
+  image.Load("blue_step_button.png");
+  image.Rescale(20,20);
+  image.GetData(&data, dataCount);
+  this->stepImage[0] = new Fl_RGB_Image(data, image.GetWidth(), 
+                                        image.GetHeight(), 4);
+
+  data = NULL;
+  image.Load("grey_step_button.png");
+  image.Rescale(20,20);
+  image.GetData(&data, dataCount);
+  this->stepImage[1] = new Fl_RGB_Image(data, image.GetWidth(), 
+                                        image.GetHeight(), 4);
+
+
+  x += 5;
+  y += 5;
+  this->playButton = new Fl_Button(x, y, 30, 20);
+  this->playButton->callback( &gazebo::Toolbar::PlayButtonCB, this );
+  this->playButton->color(BG_COLOR, BG_COLOR);
+  this->playButton->image(this->playImage[1]);
+  this->playButton->box(FL_NO_BOX);
+  this->playButton->deactivate();
+
+  x = this->playButton->x() + this->playButton->w() + 10;
+  this->pauseButton = new Fl_Button(x, y, 30, 20);
+  this->pauseButton->callback( &gazebo::Toolbar::PauseButtonCB, this );
+  this->pauseButton->color(BG_COLOR, BG_COLOR);
+  this->pauseButton->image(this->pauseImage[0]);
+  this->pauseButton->box(FL_NO_BOX);
+
+  x = this->pauseButton->x() + this->pauseButton->w() + 10;
+  this->stepButton = new Fl_Button(x, y, 30, 20);
+  this->stepButton->callback( &gazebo::Toolbar::StepButtonCB, this );
+  this->stepButton->color(BG_COLOR, BG_COLOR);
+  this->stepButton->image(this->stepImage[1]);
+  this->stepButton->box(FL_NO_BOX);
+  this->stepButton->deactivate();
+
+  this->end();
+  this->resizable(NULL);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Destructor
+Toolbar::~Toolbar()
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Update the toolbar data
+void Toolbar::Update()
+{
+  if (Simulator::Instance()->IsPaused())
+  {
+    //this->playButton->label("@>");
+    //this->stepButton->activate();
+  }
+  else
+  {
+    //this->playButton->label("@||");
+    //this->stepButton->deactivate();
+  }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Play pause button callback
+void Toolbar::PlayButtonCB( Fl_Widget *w, void *data )
+{
+  Toolbar *tb = (Toolbar*)(data);
+/*
+  if (strcmp(w->label(), "@||") == 0)
+  {
+    Simulator::Instance()->SetPaused(true);
+
+    tb->stepButton->activate();
+    w->label("@>");
+  }
+  else
+  {
+    w->label("@||");
+  }*/
+
+  if (Simulator::Instance()->IsPaused())
+  {
+    Simulator::Instance()->SetPaused(false);
+
+    tb->stepButton->deactivate();
+    tb->stepButton->image(tb->stepImage[1]);
+
+    tb->pauseButton->activate();
+    tb->pauseButton->image(tb->pauseImage[0]);
+
+    tb->playButton->image( tb->playImage[1] );
+    tb->playButton->deactivate();
+  }
+
+  w->clear_visible_focus();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Play pause button callback
+void Toolbar::PauseButtonCB( Fl_Widget *w, void *data )
+{
+  Toolbar *tb = (Toolbar*)(data);
+
+  if (!Simulator::Instance()->IsPaused())
+  {
+    Simulator::Instance()->SetPaused(true);
+
+    tb->stepButton->image( tb->stepImage[0] );
+    tb->stepButton->activate();
+
+    tb->playButton->image( tb->playImage[0] );
+    tb->playButton->activate();
+
+    tb->pauseButton->image( tb->pauseImage[1] );
+    tb->pauseButton->deactivate();
+  }
+
+  w->clear_visible_focus();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Set button callback
+void Toolbar::StepButtonCB( Fl_Widget *w, void * /*data*/ )
+{
+  Simulator::Instance()->SetStepInc( true );
+  w->clear_visible_focus();
+}

Added: code/gazebo/trunk/server/gui/Toolbar.hh
===================================================================
--- code/gazebo/trunk/server/gui/Toolbar.hh                             (rev 0)
+++ code/gazebo/trunk/server/gui/Toolbar.hh     2009-11-17 21:50:42 UTC (rev 
8416)
@@ -0,0 +1,71 @@
+/*
+ *  Gazebo - Outdoor Multi-Robot Simulator
+ *  Copyright (C) 2003  
+ *     Nate Koenig & Andrew Howard
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+/* Desc: Toolbar
+ * Author: Nate Koenig
+ * Date: 13 Feb 2006
+ * SVN: $Id: Toolbar.hh 8381 2009-11-10 17:10:09Z natepak $
+ */
+
+#ifndef TOOLBAR_HH
+#define TOOLBAR_HH
+
+#include <FL/Fl_Group.H>
+
+class Fl_Button;
+class Fl_Box;
+
+namespace gazebo
+{
+  class Common;
+
+  /// \brief Toolbar
+  class Toolbar : public Fl_Group
+  {
+    /// \brief Constructor
+    public: Toolbar (int x, int y, int w, int h, const char *l=0);
+  
+    /// \brief Destructor
+    public: virtual ~Toolbar();
+
+    /// \brief Update the toolbar data
+    public: void Update();
+
+    /// \brief Play pause button callback
+    public: static void PlayButtonCB( Fl_Widget *w, void *data );
+
+    /// \brief Pause pause button callback
+    public: static void PauseButtonCB( Fl_Widget *w, void *data );
+
+    /// \brief Set button callback
+    public: static void StepButtonCB( Fl_Widget * /*w*/, void * /*data*/ );
+
+    private: Fl_Button *playButton;
+    private: Fl_Button *pauseButton;
+    private: Fl_Button *stepButton;
+
+    private: Fl_RGB_Image *playImage[2];
+    private: Fl_RGB_Image *pauseImage[2];
+    private: Fl_RGB_Image *stepImage[2];
+  };
+  
+}
+
+#endif

Modified: code/gazebo/trunk/server/physics/Body.cc
===================================================================
--- code/gazebo/trunk/server/physics/Body.cc    2009-11-17 19:15:17 UTC (rev 
8415)
+++ code/gazebo/trunk/server/physics/Body.cc    2009-11-17 21:50:42 UTC (rev 
8416)
@@ -687,4 +687,12 @@
     this->cgVisual->SetVisible(show);
 }
 
+////////////////////////////////////////////////////////////////////////////////
+/// Set whether this entity has been selected by the user through the gui
+bool Body::SetSelected( bool s )
+{
+  Entity::SetSelected(s);
 
+  if (s == false)
+    this->SetEnabled(true);
+}

Modified: code/gazebo/trunk/server/physics/Body.hh
===================================================================
--- code/gazebo/trunk/server/physics/Body.hh    2009-11-17 19:15:17 UTC (rev 
8415)
+++ code/gazebo/trunk/server/physics/Body.hh    2009-11-17 21:50:42 UTC (rev 
8416)
@@ -91,6 +91,10 @@
     /// \brief Set whether this body is enabled
     public: virtual void SetEnabled(bool enable) const = 0;
 
+    /// \brief Set whether this entity has been selected by the user 
+    ///        through the gui
+    public: virtual bool SetSelected( bool s );
+
     /// \brief Update the center of mass
     public: virtual void UpdateCoM();
 

Modified: code/gazebo/trunk/server/physics/bullet/BulletBody.cc
===================================================================
--- code/gazebo/trunk/server/physics/bullet/BulletBody.cc       2009-11-17 
19:15:17 UTC (rev 8415)
+++ code/gazebo/trunk/server/physics/bullet/BulletBody.cc       2009-11-17 
21:50:42 UTC (rev 8416)
@@ -290,7 +290,10 @@
   if (!this->rigidBody)
     return;
 
-  this->rigidBody->setActivationState(WANTS_DEACTIVATION);
+  if (enable)
+    this->rigidBody->activate(true);
+  else
+    this->rigidBody->setActivationState(WANTS_DEACTIVATION);
 }
 
 /////////////////////////////////////////////////////////////////////


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

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Playerstage-commit mailing list
Playerstage-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to