Revision: 8936
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8936&view=rev
Author:   hsujohnhsu
Date:     2010-10-06 22:52:26 +0000 (Wed, 06 Oct 2010)

Log Message:
-----------
read updateRate from rendering:gui XML block for gui.

Modified Paths:
--------------
    code/gazebo/branches/wg/server/Simulator.cc
    code/gazebo/branches/wg/server/gui/Gui.cc
    code/gazebo/branches/wg/server/gui/Gui.hh

Modified: code/gazebo/branches/wg/server/Simulator.cc
===================================================================
--- code/gazebo/branches/wg/server/Simulator.cc 2010-10-04 16:53:48 UTC (rev 
8935)
+++ code/gazebo/branches/wg/server/Simulator.cc 2010-10-06 22:52:26 UTC (rev 
8936)
@@ -408,8 +408,9 @@
   //DIAGNOSTICTIMER(timer("--------------------------- START 
Simulator::MainLoop() --------------------------",6));
   Time currTime = 0;
   Time lastTime = 0;
+  Time lastGuiTime = 0;
   struct timespec timeSpec;
-  double freq = 80.0; //FIXME: HARDCODED
+  double freq = 80.0; //FIXME: HARDCODED Rendering Loop Rate
 
   this->physicsThread = new boost::thread( 
                          boost::bind(&Simulator::PhysicsLoop, this));
@@ -424,8 +425,9 @@
     {
       lastTime = this->GetWallTime();
 
-      if (this->gui)
+      if (this->gui && (currTime - lastGuiTime > 
1.0/this->gui->GetUpdateRate()))
       {
+        lastGuiTime = this->GetWallTime();
         DIAGNOSTICTIMER(timer1("GUI update",6));
         this->gui->Update();
       }
@@ -461,6 +463,7 @@
 
         nanosleep(&timeSpec, NULL);
       }
+
     }
     else
     {

Modified: code/gazebo/branches/wg/server/gui/Gui.cc
===================================================================
--- code/gazebo/branches/wg/server/gui/Gui.cc   2010-10-04 16:53:48 UTC (rev 
8935)
+++ code/gazebo/branches/wg/server/gui/Gui.cc   2010-10-06 22:52:26 UTC (rev 
8936)
@@ -64,6 +64,7 @@
   Param::Begin(&this->parameters);
   this->sizeP = new ParamT<Vector2<int> >("size", Vector2<int>(800, 600), 0);
   this->posP = new ParamT<Vector2<int> >("pos",Vector2<int>(0,0),0);
+  this->updateRateP = new ParamT<double>("updateRate",15,0);
   Param::End();
 
   width = std::max(800, this->w());
@@ -125,6 +126,7 @@
 
   delete this->sizeP;
   delete this->posP;
+  delete this->updateRateP;
 
   //delete this->statusbar;
 }
@@ -135,6 +137,8 @@
 {
   this->sizeP->Load(node);
   this->posP->Load(node);
+  this->updateRateP->Load(node);
+  this->updateRate = this->updateRateP->GetValue();
 
   if (node)
     this->frameMgr->Load( node->GetChild("frames") );
@@ -150,10 +154,12 @@
 
   this->sizeP->SetValue(Vector2<int>(this->GetWidth(), this->GetHeight()));
   this->posP->SetValue(Vector2<int>(this->x(), this->y()));
+  this->updateRateP->SetValue(this->updateRate);
 
   stream << prefix <<  "<rendering:gui>\n";
   stream << prefix <<  "  " << *(this->sizeP) << "\n";
   stream << prefix <<  "  " << *(this->posP) << "\n";
+  stream << prefix <<  "  " << *(this->updateRateP) << "\n";
   this->frameMgr->Save(p, stream);
   stream << prefix << "</rendering:gui>\n";
 }

Modified: code/gazebo/branches/wg/server/gui/Gui.hh
===================================================================
--- code/gazebo/branches/wg/server/gui/Gui.hh   2010-10-04 16:53:48 UTC (rev 
8935)
+++ code/gazebo/branches/wg/server/gui/Gui.hh   2010-10-06 22:52:26 UTC (rev 
8936)
@@ -85,6 +85,7 @@
 
     /// \brief Get the average FPS
     public: float GetAvgFPS() const;
+    public: double GetUpdateRate() {return this->updateRate;};
 
     /// \brief Time slider cb
     private: static void TimeSliderCB( Fl_Widget * w, void *data);
@@ -98,6 +99,8 @@
 
     private: ParamT<Vector2<int> > *sizeP;
     private: ParamT<Vector2<int> > *posP;
+    private: ParamT<double> *updateRateP;
+    private: double updateRate;
     private: std::vector<Param*> parameters;
 
     private: Fl_Slider *timeSlider;


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

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to