Revision: 8242
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8242&view=rev
Author:   rtv
Date:     2009-09-04 23:58:07 +0000 (Fri, 04 Sep 2009)

Log Message:
-----------
cleaning up namespace - may break some client code, but easy to fix

Modified Paths:
--------------
    code/stage/trunk/examples/ctrl/source.cc
    code/stage/trunk/libstage/CMakeLists.txt
    code/stage/trunk/libstage/model.cc
    code/stage/trunk/libstage/model_position.cc
    code/stage/trunk/libstage/stage.hh

Removed Paths:
-------------
    code/stage/trunk/libstage/resource.cc
    code/stage/trunk/libstage/waypoint.cc

Modified: code/stage/trunk/examples/ctrl/source.cc
===================================================================
--- code/stage/trunk/examples/ctrl/source.cc    2009-09-02 01:48:27 UTC (rev 
8241)
+++ code/stage/trunk/examples/ctrl/source.cc    2009-09-04 23:58:07 UTC (rev 
8242)
@@ -19,7 +19,7 @@
 int Update( Model* mod, void* dummy )
 {
   if( mod->GetWorld()->GetUpdateCount() % INTERVAL  == 0 )
-               mod->PushFlag( new Flag( Color( 1,1,0 ), FLAGSZ ) );
+        mod->PushFlag( new Model::Flag( Color( 1,1,0 ), FLAGSZ ) );
 
   return 0; // run again
 }

Modified: code/stage/trunk/libstage/CMakeLists.txt
===================================================================
--- code/stage/trunk/libstage/CMakeLists.txt    2009-09-02 01:48:27 UTC (rev 
8241)
+++ code/stage/trunk/libstage/CMakeLists.txt    2009-09-04 23:58:07 UTC (rev 
8242)
@@ -32,19 +32,17 @@
        option.cc
        powerpack.cc
        region.cc
-       resource.cc
        stage.cc
        stage.hh
        texture_manager.cc
        typetable.cc            
-  vis_strip.cc                 
-       waypoint.cc                     
+   vis_strip.cc                        
        world.cc                        
        worldfile.cc            
-  worldgui.cc 
-  canvas.cc 
-  options_dlg.cc
-  options_dlg.hh
+   worldgui.cc 
+   canvas.cc 
+   options_dlg.cc
+   options_dlg.hh
 )
 
 set_source_files_properties( ${stageSrcs} PROPERTIES COMPILE_FLAGS 
"${FLTK_CFLAGS}" )

Modified: code/stage/trunk/libstage/model.cc
===================================================================
--- code/stage/trunk/libstage/model.cc  2009-09-02 01:48:27 UTC (rev 8241)
+++ code/stage/trunk/libstage/model.cc  2009-09-04 23:58:07 UTC (rev 8242)
@@ -142,7 +142,7 @@
   wf->WriteTupleAngle(  section, keyword, 3, a );
 }
 
-Visibility::Visibility() : 
+Model::Visibility::Visibility() : 
   blob_return( true ),
   fiducial_key( 0 ),
   fiducial_return( 0 ),
@@ -155,7 +155,7 @@
 //static const members
 static const double DEFAULT_FRICTION = 0.0;
 
-void Visibility::Load( Worldfile* wf, int wf_entity )
+void Model::Visibility::Load( Worldfile* wf, int wf_entity )
 {
   blob_return = wf->ReadInt( wf_entity, "blob_return", blob_return);    
   fiducial_key = wf->ReadInt( wf_entity, "fiducial_key", fiducial_key);
@@ -168,14 +168,14 @@
   sticky_return = wf->ReadInt( wf_entity, "sticky_return", sticky_return);
 }    
 
-GuiState:: GuiState() :
+Model::GuiState::GuiState() :
   grid( false ),
   move( false ),  
   nose( false ),
   outline( false )
 { /* nothing to do */}
 
-void GuiState::Load( Worldfile* wf, int wf_entity )
+void Model::GuiState::Load( Worldfile* wf, int wf_entity )
 {
   nose = wf->ReadInt( wf_entity, "gui_nose", nose);    
   grid = wf->ReadInt( wf_entity, "gui_grid", grid);    
@@ -342,7 +342,7 @@
         }
 }
 
-Flag* Model::PopFlag()
+Model::Flag* Model::PopFlag()
 {
   if( flag_list.size() == 0 )
     return NULL;
@@ -1119,3 +1119,42 @@
 {
   pts.clear();
 }
+
+
+Model::Flag::Flag( Color color, double size )
+{ 
+       this->color = color;
+       this->size = size;
+}
+
+Model::Flag* Model::Flag::Nibble( double chunk )
+{
+       Flag* piece = NULL;
+
+       if( size > 0 )
+       {
+               chunk = std::min( chunk, this->size );
+               piece = new Flag( this->color, chunk );
+               this->size -= chunk;
+       }
+
+       return piece;
+}
+
+
+void Model::Flag::Draw(  GLUquadric* quadric )
+{
+  glColor4f( color.r, color.g, color.b, color.a );
+    
+  glEnable(GL_POLYGON_OFFSET_FILL);
+  glPolygonOffset(1.0, 1.0);
+  gluQuadricDrawStyle( quadric, GLU_FILL );
+  gluSphere( quadric, size/2.0, 4,2  );
+  glDisable(GL_POLYGON_OFFSET_FILL);
+  
+  // draw the edges darker version of the same color
+  glColor4f( color.r/2.0, color.g/2.0, color.b/2.0, color.a/2.0 );
+    
+  gluQuadricDrawStyle( quadric, GLU_LINE );
+  gluSphere( quadric, size/2.0, 4,2 );
+}

Modified: code/stage/trunk/libstage/model_position.cc
===================================================================
--- code/stage/trunk/libstage/model_position.cc 2009-09-02 01:48:27 UTC (rev 
8241)
+++ code/stage/trunk/libstage/model_position.cc 2009-09-04 23:58:07 UTC (rev 
8242)
@@ -90,8 +90,7 @@
                                                        drand48() * 
INTEGRATION_ERROR_MAX_Y - INTEGRATION_ERROR_MAX_Y/2.0,
                                                        drand48() * 
INTEGRATION_ERROR_MAX_Z - INTEGRATION_ERROR_MAX_Z/2.0,
                                                        drand48() * 
INTEGRATION_ERROR_MAX_A - INTEGRATION_ERROR_MAX_A/2.0 ),
-  waypoints( NULL ),
-  waypoint_count( 0 ),
+  waypoints(),
   wpvis(),
   posevis()
 {
@@ -530,17 +529,6 @@
   est_origin.a = da;
 } 
 
-/** Set the waypoint array pointer. Returns the old pointer, in case you need 
to free/delete[] it */
-Waypoint* ModelPosition::SetWaypoints( Waypoint* wps, uint32_t count )
-{
-  Waypoint* replaced = waypoints;
-  
-  waypoints = wps;
-  waypoint_count = count;
-  
-  return replaced;
-}
-
 ModelPosition::PoseVis::PoseVis()
   : Visualizer( "Position coordinates", "show_position_coords" )
 {}
@@ -609,11 +597,9 @@
 void ModelPosition::WaypointVis::Visualize( Model* mod, Camera* cam )
 {
   ModelPosition* pos = dynamic_cast<ModelPosition*>(mod);
+  const std::vector<Waypoint>& waypoints = pos->waypoints;
 
-  Waypoint* waypoints = pos->waypoints;
-  unsigned int waypoint_count = pos->waypoint_count;
-
-  if( (waypoints == NULL) || (waypoint_count < 1) )
+  if( waypoints.empty() )
         return;
 
   glPointSize( 5 );
@@ -627,20 +613,24 @@
   
   // draw waypoints
   glLineWidth( 3 );
-  for( unsigned int i=0; i < waypoint_count; i++ )
-        waypoints[i].Draw();
+  FOR_EACH( it, waypoints )
+        it->Draw();
   glLineWidth( 1 );
-
+  
   // draw lines connecting the waypoints
-  if( waypoint_count > 1 )
+  const unsigned int num = waypoints.size();  
+  if( num > 1 )
     {
                pos->PushColor( 1,0,0,0.3 );
                glBegin( GL_LINES );
       
-      for( unsigned int i=1; i < waypoint_count; i++ )
+      for( unsigned int i=1; i<num ; i++ )
                  {
-                        glVertex2f( waypoints[i].pose.x,  waypoints[i].pose.y 
);
-                        glVertex2f( waypoints[i-1].pose.x,  
waypoints[i-1].pose.y );
+                        Pose p = waypoints[i].pose;
+                        Pose o = waypoints[i-1].pose;
+
+                        glVertex2f( p.x, p.y );
+                        glVertex2f( o.x, o.y );
                  }
                
       glEnd();
@@ -651,3 +641,47 @@
   pos->PopColor();
   glPopMatrix();
 }
+
+ModelPosition::Waypoint::Waypoint( const Pose& pose, Color color ) 
+  : pose(pose), color(color)
+{ 
+}
+
+ModelPosition::Waypoint::Waypoint( stg_meters_t x, stg_meters_t y, 
stg_meters_t z, stg_radians_t a, Color color ) 
+  : pose(x,y,z,a), color(color)
+{ 
+}
+
+
+ModelPosition::Waypoint::Waypoint()
+{ 
+  pose = Pose( 0,0,0,0 ); 
+  color = 0; 
+};
+
+
+void ModelPosition::Waypoint::Draw() const
+{
+  GLdouble d[4];
+  
+  d[0] = color.r;
+  d[1] = color.g;
+  d[2] = color.b;
+  d[3] = color.a;
+  
+  glColor4dv( d );
+  
+  glBegin(GL_POINTS);
+  glVertex3f( pose.x, pose.y, pose.z );
+  glEnd();
+
+  stg_meters_t quiver_length = 0.15;
+
+  double dx = cos(pose.a) * quiver_length;
+  double dy = sin(pose.a) * quiver_length;
+
+  glBegin(GL_LINES);
+  glVertex3f( pose.x, pose.y, pose.z );
+  glVertex3f( pose.x+dx, pose.y+dy, pose.z );
+  glEnd();      
+}

Deleted: code/stage/trunk/libstage/resource.cc
===================================================================
--- code/stage/trunk/libstage/resource.cc       2009-09-02 01:48:27 UTC (rev 
8241)
+++ code/stage/trunk/libstage/resource.cc       2009-09-04 23:58:07 UTC (rev 
8242)
@@ -1,40 +0,0 @@
-#include "stage.hh"
-using namespace Stg;
-
-Flag::Flag( Color color, double size )
-{ 
-       this->color = color;
-       this->size = size;
-}
-
-Flag* Flag::Nibble( double chunk )
-{
-       Flag* piece = NULL;
-
-       if( size > 0 )
-       {
-               chunk = std::min( chunk, this->size );
-               piece = new Flag( this->color, chunk );
-               this->size -= chunk;
-       }
-
-       return piece;
-}
-
-
-void Flag::Draw(  GLUquadric* quadric )
-{
-  glColor4f( color.r, color.g, color.b, color.a );
-    
-  glEnable(GL_POLYGON_OFFSET_FILL);
-  glPolygonOffset(1.0, 1.0);
-  gluQuadricDrawStyle( quadric, GLU_FILL );
-  gluSphere( quadric, size/2.0, 4,2  );
-  glDisable(GL_POLYGON_OFFSET_FILL);
-  
-  // draw the edges darker version of the same color
-  glColor4f( color.r/2.0, color.g/2.0, color.b/2.0, color.a/2.0 );
-    
-  gluQuadricDrawStyle( quadric, GLU_LINE );
-  gluSphere( quadric, size/2.0, 4,2 );
-}

Modified: code/stage/trunk/libstage/stage.hh
===================================================================
--- code/stage/trunk/libstage/stage.hh  2009-09-02 01:48:27 UTC (rev 8241)
+++ code/stage/trunk/libstage/stage.hh  2009-09-04 23:58:07 UTC (rev 8242)
@@ -380,20 +380,6 @@
         }
   };
   
-  /** Specify a point in space. Arrays of Waypoints can be attached to
-               Models and visualized. */
-  class Waypoint
-  {
-  public:
-    Waypoint( stg_meters_t x, stg_meters_t y, stg_meters_t z, stg_radians_t a, 
Color color ) ;
-    Waypoint( const Pose& pose, Color color ) ;
-    Waypoint();
-    void Draw();
-    
-    Pose pose;
-    Color color;
-  };
-  
   /** Bound a range of values, from min to max. min and max are initialized to 
zero. */
   class Bounds
   {
@@ -524,19 +510,6 @@
   
   void RegisterModels();
   
-  class Flag
-  {
-  public:
-    Color color;
-    double size;
-
-    Flag( Color color, double size );
-    Flag* Nibble( double portion );
-
-        /** Draw the flag in OpenGl. Takes a quadric parameter to save
-                 creating the quadric for each flag */
-        void Draw(  GLUquadric* quadric );
-  };
   
   /** Abstract class for adding visualizations to models. DataVisualize must 
be overloaded, and is then called in the models local coord system */
   class Visualizer {
@@ -575,16 +548,6 @@
     double duty_cycle; ///< mark/space ratio
   } stg_blinkenlight_t;
 
-  class TrailItem 
-  {                                                                            
                                                                                
                        
-  public:
-    stg_usec_t time;
-    Pose pose;
-    Color color;
-
-        TrailItem( stg_usec_t time, Pose pose, Color color ) 
-               : time(time), pose(pose), color(color){}
-  };
   
   /** Defines a rectangle of [size] located at [pose] */
   typedef struct
@@ -1191,9 +1154,6 @@
                  (m) */
         stg_point_t BlockPointToModelMeters( const stg_point_t& bpt );
        
-        /** Update the cache of block points converted to model coordinates */
-        //stg_point_t* GetPointsInModelCoords();
-               
         /** invalidate the cache of points in model coordinates */
         void InvalidateModelPointCache();
   };
@@ -1618,52 +1578,7 @@
         void Dissipate( stg_joules_t j, const Pose& p );
   };
 
-  class Visibility
-  {
-  public:
-        bool blob_return;
-        int fiducial_key;
-        int fiducial_return;
-        bool gripper_return;
-        stg_laser_return_t laser_return;
-        bool obstacle_return;
-        bool ranger_return;
-        bool gravity_return;
-        bool sticky_return;
-       
-        Visibility();
-        void Load( Worldfile* wf, int wf_entity );
-  };
-
-  /* Hooks for attaching special callback functions (not used as
-         variables - we just need unique addresses for them.) */  
-  class CallbackHooks
-  {
-  public:
-        int flag_incr;
-        int flag_decr;
-        int init;
-        int load;
-        int save;
-        int shutdown;
-        int startup;
-        int update;
-        int update_done;
-  };
-  
-  /** Records model state and functionality in the GUI, if used */
-  class GuiState
-  {
-  public:
-        bool grid;
-        bool move;
-        bool nose;
-        bool outline;
-               
-        GuiState();
-        void Load( Worldfile* wf, int wf_entity );
-  };
-  
+   
   /// %Model class
   class Model : public Ancestor
   {
@@ -1727,6 +1642,20 @@
                { return( callback == other.callback);  }                       
         };
                
+        class Flag
+        {
+        public:
+               Color color;
+               double size;
+               
+               Flag( Color color, double size );
+               Flag* Nibble( double portion );
+               
+               /** Draw the flag in OpenGl. Takes a quadric parameter to save
+                        creating the quadric for each flag */
+               void Draw(  GLUquadric* quadric );
+        };
+
   protected:
         /** A list of callback functions can be attached to any
                  address. When Model::CallCallbacks( void*) is called, the
@@ -1748,13 +1677,39 @@
         Pose global_pose;
         bool gpose_dirty; ///< set this to indicate that global pose may have 
changed  
         /** Controls our appearance and functionality in the GUI, if used */
-        GuiState gui;
-  
+        
+        /** Records model state and functionality in the GUI, if used */
+        class GuiState
+        {
+        public:
+               bool grid;
+               bool move;
+               bool nose;
+               bool outline;
+               
+               GuiState();
+               void Load( Worldfile* wf, int wf_entity );
+        } gui;
+        
         bool has_default_block;
   
         /* hooks for attaching special callback functions (not used as
                 variables - we just need unique addresses for them.) */  
-        CallbackHooks hooks;
+        /* Hooks for attaching special callback functions (not used as
+                variables - we just need unique addresses for them.) */  
+        class CallbackHooks
+        {
+        public:
+               int flag_incr;
+               int flag_decr;
+               int init;
+               int load;
+               int save;
+               int shutdown;
+               int startup;
+               int update;
+               int update_done;
+        } hooks;
   
         /** unique process-wide identifier for this model */
         uint32_t id;   
@@ -1826,6 +1781,17 @@
         bool thread_safe;
         
         /** Cache of recent poses, used to draw the trail. */
+        class TrailItem 
+        {                                                                      
                                                                                
                                
+        public:
+               stg_usec_t time;
+               Pose pose;
+               Color color;
+               
+               TrailItem( stg_usec_t time, Pose pose, Color color ) 
+                 : time(time), pose(pose), color(color){}
+        };
+       
         std::list<TrailItem> trail;
         
         /** The maxiumum length of the trail drawn. Default is 20, but can
@@ -1862,8 +1828,24 @@
         
         const std::string& GetModelType() const {return type;}  
         std::string GetSayString(){return std::string(say_string);}
-        Visibility vis;
         
+        class Visibility
+        {
+        public:
+               bool blob_return;
+               int fiducial_key;
+               int fiducial_return;
+               bool gripper_return;
+               stg_laser_return_t laser_return;
+               bool obstacle_return;
+               bool ranger_return;
+               bool gravity_return;
+               bool sticky_return;
+               
+               Visibility();
+               void Load( Worldfile* wf, int wf_entity );
+        } vis;
+        
         stg_usec_t GetUpdateInterval(){ return interval; }
         stg_usec_t GetEnergyInterval(){ return interval_energy; }
         stg_usec_t GetPoseInterval(){ return interval_pose; }
@@ -2871,10 +2853,8 @@
         DriveMode drive_mode;
         LocalizationMode localization_mode; ///< global or local mode
         Velocity integration_error; ///< errors to apply in simple odometry 
model
-
-        Waypoint* waypoints;
-        uint32_t waypoint_count;        
-
+        
+        
   public:
         // constructor
         ModelPosition( World* world,
@@ -2887,10 +2867,23 @@
         virtual void Shutdown();
         virtual void Update();
         virtual void Load();
+               
+        /** Specify a point in space. Arrays of Waypoints can be attached to
+                 Models and visualized. */
+        class Waypoint
+        {
+        public:
+               Waypoint( stg_meters_t x, stg_meters_t y, stg_meters_t z, 
stg_radians_t a, Color color ) ;
+               Waypoint( const Pose& pose, Color color ) ;
+               Waypoint();
+               void Draw() const;
+               
+               Pose pose;
+               Color color;
+        };
         
-        /** Set the waypoint array pointer. Returns the old pointer, in case 
you need to free/delete[] it */
-        Waypoint* SetWaypoints( Waypoint* wps, uint32_t count );
-       
+        std::vector<Waypoint> waypoints;
+
         class WaypointVis : public Visualizer
         {
         public:

Deleted: code/stage/trunk/libstage/waypoint.cc
===================================================================
--- code/stage/trunk/libstage/waypoint.cc       2009-09-02 01:48:27 UTC (rev 
8241)
+++ code/stage/trunk/libstage/waypoint.cc       2009-09-04 23:58:07 UTC (rev 
8242)
@@ -1,47 +0,0 @@
-
-#include "stage.hh"
-using namespace Stg;
-
-Waypoint::Waypoint( const Pose& pose, Color color ) 
-  : pose(pose), color(color)
-{ 
-}
-
-Waypoint::Waypoint( stg_meters_t x, stg_meters_t y, stg_meters_t z, 
stg_radians_t a, Color color ) 
-  : pose(x,y,z,a), color(color)
-{ 
-}
-
-
-Waypoint::Waypoint()
-{ 
-  pose = Pose( 0,0,0,0 ); 
-  color = 0; 
-};
-
-
-void Waypoint::Draw()
-{
-  GLdouble d[4];
-  
-  d[0] = color.r;
-  d[1] = color.g;
-  d[2] = color.b;
-  d[3] = color.a;
-  
-  glColor4dv( d );
-  
-  glBegin(GL_POINTS);
-  glVertex3f( pose.x, pose.y, pose.z );
-  glEnd();
-
-  stg_meters_t quiver_length = 0.15;
-
-  double dx = cos(pose.a) * quiver_length;
-  double dy = sin(pose.a) * quiver_length;
-
-  glBegin(GL_LINES);
-  glVertex3f( pose.x, pose.y, pose.z );
-  glVertex3f( pose.x+dx, pose.y+dy, pose.z );
-  glEnd();      
-}


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
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to