Revision: 8531
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8531&view=rev
Author:   natepak
Date:     2010-01-27 01:47:07 +0000 (Wed, 27 Jan 2010)

Log Message:
-----------
Updated to use signals for viewing options

Modified Paths:
--------------
    code/gazebo/trunk/server/World.cc
    code/gazebo/trunk/server/World.hh
    code/gazebo/trunk/server/gui/MainMenu.cc
    code/gazebo/trunk/server/gui/MainMenu.hh
    code/gazebo/trunk/server/physics/Geom.cc
    code/gazebo/trunk/server/physics/PhysicsEngine.cc
    code/gazebo/trunk/server/physics/PhysicsEngine.hh
    code/gazebo/trunk/server/rendering/OgreCamera.cc
    code/gazebo/trunk/server/rendering/OgreCamera.hh
    code/gazebo/trunk/server/rendering/UserCamera.cc
    code/gazebo/trunk/server/rendering/UserCamera.hh
    code/gazebo/trunk/worlds/CMakeLists.txt

Modified: code/gazebo/trunk/server/World.cc
===================================================================
--- code/gazebo/trunk/server/World.cc   2010-01-26 23:24:14 UTC (rev 8530)
+++ code/gazebo/trunk/server/World.cc   2010-01-27 01:47:07 UTC (rev 8531)
@@ -61,6 +61,7 @@
   this->showJoints = false;
   this->showContacts = false;
   this->showLights = false;
+  this->showCameras = false;
   this->wireframe = false;
   this->showPhysics = false;
   this->physicsEngine = NULL;
@@ -720,6 +721,7 @@
 void World::SetShowContacts(bool show)
 {
   this->showContacts = show;
+  this->showContactsSignal(this->showContacts);
 }
 
 
////////////////////////////////////////////////////////////////////////////////
@@ -745,10 +747,26 @@
 }
 
 
////////////////////////////////////////////////////////////////////////////////
+/// Set whether to show the camera visuals
+void World::SetShowCameras(bool show)
+{
+  this->showCameras = show;
+  this->showCamerasSignal(this->showCameras);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Get whether to show the camera visuals
+bool World::GetShowCameras() const
+{
+  return this->showCameras;
+}
+
+////////////////////////////////////////////////////////////////////////////////
 /// Set to view as wireframe
 void World::SetWireframe( bool wire )
 {
   this->wireframe = wire;
+  this->wireframeSignal(this->wireframe);
 }
 
 
////////////////////////////////////////////////////////////////////////////////
@@ -772,18 +790,17 @@
 void World::SetShowPhysics(bool show)
 {
   this->showPhysics = show;
+  this->showPhysicsSignal(this->showPhysics);
 
-  std::vector< Geom*>::iterator iter;
+  /*std::vector< Geom*>::iterator iter;
 
   for (iter = this->geometries.begin(); iter != this->geometries.end(); iter++)
   {
     (*iter)->ShowPhysics(this->showPhysics);
-  }
-
+  }*/
 }
 
 
-
 
////////////////////////////////////////////////////////////////////////////////
 // Update the simulation interface
 void World::UpdateSimulationIface()

Modified: code/gazebo/trunk/server/World.hh
===================================================================
--- code/gazebo/trunk/server/World.hh   2010-01-26 23:24:14 UTC (rev 8530)
+++ code/gazebo/trunk/server/World.hh   2010-01-27 01:47:07 UTC (rev 8531)
@@ -200,6 +200,12 @@
   /// \brief Get whether to show the light source visuals
   public: bool GetShowLights() const;
 
+  /// \brief Set whether to show the camera visuals
+  public: void SetShowCameras(bool show);
+
+  /// \brief Get whether to show the camera visuals
+  public: bool GetShowCameras() const;
+
   /// \brief Set to view as wireframe
   public: void SetWireframe( bool wire );
 
@@ -234,6 +240,8 @@
 
   private: bool showLights;
 
+  private: bool showCameras;
+
   private: bool showPhysics;
 
   private: bool wireframe;
@@ -268,7 +276,36 @@
             showLightsSignal.connect(subscriber);
           }
 
-  /// \brif Get the names of interfaces defined in the tree of a model
+  /// \brief Connect a boost::slot the the show camera source signal
+  public: template<typename T>
+          void ConnectShowCamerasSignal( T subscriber )
+          {
+            showCamerasSignal.connect(subscriber);
+          }
+
+  /// \brief Connect a boost::slot the the show contacts signal
+  public: template<typename T>
+          void ConnectShowContactsSignal( T subscriber )
+          {
+            showContactsSignal.connect(subscriber);
+          }
+
+  /// \brief Connect a boost::slot the the show wireframe signal
+  public: template<typename T>
+          void ConnectShowWireframeSignal( T subscriber )
+          {
+            wireframeSignal.connect(subscriber);
+          }
+
+  /// \brief Connect a boost::slot the the show physics signal
+  public: template<typename T>
+          void ConnectShowPhysicsSignal( T subscriber )
+          {
+            showPhysicsSignal.connect(subscriber);
+          }
+
+
+  /// \brief Get the names of interfaces defined in the tree of a model
   private: void GetInterfaceNames(Entity* m, std::vector<std::string>& list);
 
   /// Pointer the physics engine
@@ -317,6 +354,10 @@
 
   private: boost::signal<void (Entity*)> addEntitySignal;
   private: boost::signal<void (bool)> showLightsSignal;
+  private: boost::signal<void (bool)> showCamerasSignal;
+  private: boost::signal<void (bool)> showContactsSignal;
+  private: boost::signal<void (bool)> wireframeSignal;
+  private: boost::signal<void (bool)> showPhysicsSignal;
 
   private: std::deque<WorldState> worldStates;
   private: std::deque<WorldState>::iterator worldStatesInsertIter;

Modified: code/gazebo/trunk/server/gui/MainMenu.cc
===================================================================
--- code/gazebo/trunk/server/gui/MainMenu.cc    2010-01-26 23:24:14 UTC (rev 
8530)
+++ code/gazebo/trunk/server/gui/MainMenu.cc    2010-01-27 01:47:07 UTC (rev 
8531)
@@ -64,6 +64,7 @@
     { "Show Joints", 0, &gazebo::MainMenu::ShowJointsCB,0, FL_MENU_TOGGLE, 
FL_NORMAL_LABEL, 0, 14, 0},
     { "Show Contacts", 0, &gazebo::MainMenu::ShowContactsCB,0, FL_MENU_TOGGLE, 
FL_NORMAL_LABEL, 0, 14, 0},
     { "Show Lights", 0, &gazebo::MainMenu::ShowLightsCB,0, FL_MENU_TOGGLE, 
FL_NORMAL_LABEL, 0, 14, 0},
+    { "Show Cameras", 0, &gazebo::MainMenu::ShowCamerasCB,0, FL_MENU_TOGGLE, 
FL_NORMAL_LABEL, 0, 14, 0},
     { 0 },
 
     { 0 }
@@ -167,3 +168,10 @@
 {
   World::Instance()->SetShowLights( !World::Instance()->GetShowLights() );
 }
+
+////////////////////////////////////////////////////////////////////////////////
+// View the light source visuals
+void MainMenu::ShowCamerasCB(Fl_Widget * /*w*/, void * /*data*/)
+{
+  World::Instance()->SetShowCameras( !World::Instance()->GetShowCameras() );
+}

Modified: code/gazebo/trunk/server/gui/MainMenu.hh
===================================================================
--- code/gazebo/trunk/server/gui/MainMenu.hh    2010-01-26 23:24:14 UTC (rev 
8530)
+++ code/gazebo/trunk/server/gui/MainMenu.hh    2010-01-27 01:47:07 UTC (rev 
8531)
@@ -59,6 +59,8 @@
 
     public: static void ShowLightsCB(Fl_Widget * /*w*/, void * /*data*/);
 
+    public: static void ShowCamerasCB(Fl_Widget * /*w*/, void * /*data*/);
+
   };
 }
 

Modified: code/gazebo/trunk/server/physics/Geom.cc
===================================================================
--- code/gazebo/trunk/server/physics/Geom.cc    2010-01-26 23:24:14 UTC (rev 
8530)
+++ code/gazebo/trunk/server/physics/Geom.cc    2010-01-27 01:47:07 UTC (rev 
8531)
@@ -76,6 +76,8 @@
   this->laserFiducialIdP = new ParamT<int>("laserFiducialId",-1,0);
   this->laserRetroP = new ParamT<float>("laserRetro",-1,0);
   Param::End();
+
+  World::Instance()->ConnectShowPhysicsSignal( boost::bind(&Geom::ShowPhysics, 
this, _1) );
 }
 
 
////////////////////////////////////////////////////////////////////////////////

Modified: code/gazebo/trunk/server/physics/PhysicsEngine.cc
===================================================================
--- code/gazebo/trunk/server/physics/PhysicsEngine.cc   2010-01-26 23:24:14 UTC 
(rev 8530)
+++ code/gazebo/trunk/server/physics/PhysicsEngine.cc   2010-01-27 01:47:07 UTC 
(rev 8531)
@@ -72,6 +72,8 @@
     this->visual->AttachObject(*this->contactLinesIter);
   }
 
+  World::Instance()->ConnectShowContactsSignal( 
boost::bind(&PhysicsEngine::ShowVisual, this, _1) );
+
   this->contactLinesIter = this->contactLines.begin();
   delete mat;
 }
@@ -98,17 +100,10 @@
 /// Update the physics engine
 void PhysicsEngine::UpdatePhysics()
 {
-  if (World::Instance()->GetShowContacts())
-  {
-    this->visual->SetVisible(true);
-    this->contactLinesIter = this->contactLines.begin();
-  }
-  else
-  {
-    this->visual->SetVisible(false);
-  }
 }
- 
+
+
+
 
////////////////////////////////////////////////////////////////////////////////
 /// Return the gavity vector
 Vector3 PhysicsEngine::GetGravity() const
@@ -170,3 +165,12 @@
   if (this->contactLinesIter == this->contactLines.end())
     this->contactLinesIter = this->contactLines.begin();
 }
+
+////////////////////////////////////////////////////////////////////////////////
+// Set whether to show contacts
+void PhysicsEngine::ShowVisual(bool show)
+{
+  this->visual->SetVisible(show);
+  if (show)
+    this->contactLinesIter = this->contactLines.begin();
+}

Modified: code/gazebo/trunk/server/physics/PhysicsEngine.hh
===================================================================
--- code/gazebo/trunk/server/physics/PhysicsEngine.hh   2010-01-26 23:24:14 UTC 
(rev 8530)
+++ code/gazebo/trunk/server/physics/PhysicsEngine.hh   2010-01-27 01:47:07 UTC 
(rev 8531)
@@ -150,6 +150,9 @@
     /// \brief Convert a Gazebo mass to an engine specific mass
     public: virtual void ConvertMass(void *engineMass, const Mass &mass) = 0;
 
+    /// \brief Set whether to show contacts
+    public: void ShowVisual(bool show);
+
     /// \brief Add a contact visual
     protected: void AddContactVisual(Vector3 pos, Vector3 norm);
 

Modified: code/gazebo/trunk/server/rendering/OgreCamera.cc
===================================================================
--- code/gazebo/trunk/server/rendering/OgreCamera.cc    2010-01-26 23:24:14 UTC 
(rev 8530)
+++ code/gazebo/trunk/server/rendering/OgreCamera.cc    2010-01-27 01:47:07 UTC 
(rev 8531)
@@ -86,6 +86,8 @@
 
   this->renderPeriod = Time(1.0/(**this->updateRateP));
   this->renderingEnabled = true;
+
+  World::Instance()->ConnectShowWireframeSignal( 
boost::bind(&OgreCamera::ShowWireframe, this, _1) );
 }
 
 
@@ -221,18 +223,6 @@
   if (!Simulator::Instance()->GetRenderEngineEnabled())
     return;
 
-  if (this->camera)
-  {
-    if (World::Instance()->GetWireframe())
-    {
-      this->camera->setPolygonMode(Ogre::PM_WIREFRAME);
-    }
-    else
-    {
-      this->camera->setPolygonMode(Ogre::PM_SOLID);
-    }
-  }
-
   if (this->sceneNode)
   {
     Ogre::Vector3 v = this->sceneNode->_getDerivedPosition();
@@ -714,3 +704,20 @@
     this->origParentNode->addChild(this->sceneNode);
   }
 }
+
+//////////////////////////////////////////////////////////////////////////////
+// Set whether to view the world in wireframe
+void OgreCamera::ShowWireframe(bool s)
+{
+  if (this->camera)
+  {
+    if (s)
+    {
+      this->camera->setPolygonMode(Ogre::PM_WIREFRAME);
+    }
+    else
+    {
+      this->camera->setPolygonMode(Ogre::PM_SOLID);
+    }
+  }
+}

Modified: code/gazebo/trunk/server/rendering/OgreCamera.hh
===================================================================
--- code/gazebo/trunk/server/rendering/OgreCamera.hh    2010-01-26 23:24:14 UTC 
(rev 8530)
+++ code/gazebo/trunk/server/rendering/OgreCamera.hh    2010-01-27 01:47:07 UTC 
(rev 8531)
@@ -215,6 +215,9 @@
     /// \brief Set the camera to track an entity
     public: void TrackModel( Model *model );
 
+    /// \brief Set whether to view the world in wireframe
+    public: void ShowWireframe(bool s);
+
     // Save the camera frame
     protected: virtual void SaveFrame();
 

Modified: code/gazebo/trunk/server/rendering/UserCamera.cc
===================================================================
--- code/gazebo/trunk/server/rendering/UserCamera.cc    2010-01-26 23:24:14 UTC 
(rev 8530)
+++ code/gazebo/trunk/server/rendering/UserCamera.cc    2010-01-27 01:47:07 UTC 
(rev 8531)
@@ -35,6 +35,7 @@
 #include "OgreCreator.hh"
 #include "OgreVisual.hh"
 #include "OgreDynamicLines.hh"
+#include "World.hh"
 #include "UserCamera.hh"   
 
 using namespace gazebo;
@@ -55,6 +56,8 @@
   this->name = stream.str(); 
 
   this->viewport = NULL;
+
+  World::Instance()->ConnectShowCamerasSignal( 
boost::bind(&UserCamera::ShowVisual, this, _1) );
 }
 
 
////////////////////////////////////////////////////////////////////////////////
@@ -141,6 +144,7 @@
   line->setVisibilityFlags(GZ_LASER_CAMERA);
 
   this->visual->AttachObject(line);
+  this->visual->SetVisible(false);
 
   this->SetCamera(this);
   this->lastUpdate = Simulator::Instance()->GetRealTime();
@@ -250,3 +254,10 @@
 {
   return this->window;
 }
+
+////////////////////////////////////////////////////////////////////////////////
+// Set whether to show the visual
+void UserCamera::ShowVisual(bool s)
+{
+  this->visual->SetVisible(s);
+}

Modified: code/gazebo/trunk/server/rendering/UserCamera.hh
===================================================================
--- code/gazebo/trunk/server/rendering/UserCamera.hh    2010-01-26 23:24:14 UTC 
(rev 8530)
+++ code/gazebo/trunk/server/rendering/UserCamera.hh    2010-01-27 01:47:07 UTC 
(rev 8531)
@@ -81,6 +81,9 @@
     /// \brief Get the ogre window
     public: Ogre::RenderWindow *GetWindow();
 
+    /// \brief Set whether to show the visual
+    private: void ShowVisual(bool s);
+
     /// Pointer to the viewport
     protected: Ogre::Viewport *viewport;
 

Modified: code/gazebo/trunk/worlds/CMakeLists.txt
===================================================================
--- code/gazebo/trunk/worlds/CMakeLists.txt     2010-01-26 23:24:14 UTC (rev 
8530)
+++ code/gazebo/trunk/worlds/CMakeLists.txt     2010-01-27 01:47:07 UTC (rev 
8531)
@@ -1,7 +1,6 @@
 ADD_SUBDIRECTORY(models)
 
-SET (files audio.world 
-           bandit.world
+SET (files bandit.world
            bsp.world
            bumper.world
            epuck_single.world


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

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Playerstage-commit mailing list
Playerstage-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to