Revision: 8061
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8061&view=rev
Author:   rtv
Date:     2009-07-21 01:49:26 +0000 (Tue, 21 Jul 2009)

Log Message:
-----------
more STLing - option sorting broken temporarily

Modified Paths:
--------------
    code/stage/trunk/libstage/option.hh
    code/stage/trunk/libstage/options_dlg.cc
    code/stage/trunk/libstage/options_dlg.hh
    code/stage/trunk/libstage/stage.hh
    code/stage/trunk/libstage/world.cc
    code/stage/trunk/libstage/worldgui.cc

Modified: code/stage/trunk/libstage/option.hh
===================================================================
--- code/stage/trunk/libstage/option.hh 2009-07-21 01:21:39 UTC (rev 8060)
+++ code/stage/trunk/libstage/option.hh 2009-07-21 01:49:26 UTC (rev 8061)
@@ -39,15 +39,19 @@
                inline bool val() const { return value; }
                inline operator bool() { return val(); }
                inline bool operator<( const Option& rhs ) const
-                       { return optName<rhs.optName; } 
+                       {
+                         puts( "comparing" );
+                         return optName<rhs.optName; 
+                       } 
                void set( bool val );
                void invert() { set( !value ); }
 
-               // Comparator to dereference Option pointers and compare their 
strings
-               struct optComp {
-                       inline bool operator()( const Option* lhs, const 
Option* rhs ) const
-                               { return lhs->operator<(*rhs); } 
-               };
+//             // Comparator to dereference Option pointers and compare their 
strings
+//             struct optComp {
+//                     inline bool operator()( const Option* a, const Option* 
b ) const
+//                     //{ return lhs->operator<(*rhs); } 
+//                             { return a->optName < b->optName; } 
+//             };
 
 
                void createMenuItem( Fl_Menu_Bar* menu, std::string path );

Modified: code/stage/trunk/libstage/options_dlg.cc
===================================================================
--- code/stage/trunk/libstage/options_dlg.cc    2009-07-21 01:21:39 UTC (rev 
8060)
+++ code/stage/trunk/libstage/options_dlg.cc    2009-07-21 01:49:26 UTC (rev 
8061)
@@ -68,7 +68,7 @@
                this->redraw();
        }
 
-       void OptionsDlg::setOptions( const std::vector<Option*>& opts ) {
+       void OptionsDlg::setOptions( const std::set<Option*>& opts ) {
          options.clear();
                options.assign( opts.begin(), opts.end() );
                updateChecks();

Modified: code/stage/trunk/libstage/options_dlg.hh
===================================================================
--- code/stage/trunk/libstage/options_dlg.hh    2009-07-21 01:21:39 UTC (rev 
8060)
+++ code/stage/trunk/libstage/options_dlg.hh    2009-07-21 01:49:26 UTC (rev 
8061)
@@ -41,7 +41,7 @@
                OptionsDlg( int x, int y, int w, int h );
                virtual ~OptionsDlg();
                
-               void setOptions( const std::vector<Option*>& opts );
+               void setOptions( const std::set<Option*>& opts );
                void clearOptions() { options.clear(); }
                void showAllOpt( Option* opt );
                const event_t event() const { return status; }

Modified: code/stage/trunk/libstage/stage.hh
===================================================================
--- code/stage/trunk/libstage/stage.hh  2009-07-21 01:21:39 UTC (rev 8060)
+++ code/stage/trunk/libstage/stage.hh  2009-07-21 01:49:26 UTC (rev 8061)
@@ -884,7 +884,8 @@
     stg_bounds3d_t extent; ///< Describes the 3D volume of the world
     bool graphics;///< true iff we have a GUI
     stg_usec_t interval_sim; ///< temporal resolution: microseconds that 
elapse between simulated time steps 
-        GHashTable* option_table; ///< GUI options (toggles) registered by 
models
+        //GHashTable* option_table; ///< GUI options (toggles) registered by 
models     
+        std::set<Option*> option_table; ///< GUI options (toggles) registered 
by models
         std::list<PowerPack*> powerpack_list; ///< List of all the powerpacks 
attached to models in the world
         std::list<float*> ray_list;///< List of rays traced for debug 
visualization
     stg_usec_t sim_time; ///< the current sim time in this world in 
microseconds
@@ -1444,8 +1445,6 @@
     bool pause_time;
     stg_usec_t real_time_of_last_update;
        
-    void UpdateOptions();
-       
     // static callback functions
     static void windowCb( Fl_Widget* w, void* p );     
     static void fileLoadCb( Fl_Widget* w, void* p );

Modified: code/stage/trunk/libstage/world.cc
===================================================================
--- code/stage/trunk/libstage/world.cc  2009-07-21 01:21:39 UTC (rev 8060)
+++ code/stage/trunk/libstage/world.cc  2009-07-21 01:49:26 UTC (rev 8061)
@@ -103,7 +103,8 @@
   extent(),
   graphics( false ), 
   interval_sim( (stg_usec_t)thousand * interval_sim ),
-  option_table( g_hash_table_new( g_str_hash, g_str_equal ) ), 
+  //option_table( g_hash_table_new( g_str_hash, g_str_equal ) ), 
+  option_table(),
   powerpack_list(),
   ray_list(),  
   sim_time( 0 ),
@@ -1072,7 +1073,8 @@
 /// Register an Option for pickup by the GUI
 void World:: RegisterOption( Option* opt )
 {
-  g_hash_table_insert( option_table, (void*)opt->htname, opt );
+  //g_hash_table_insert( option_table, (void*)opt->htname, opt );
+  option_table.insert( opt );
 }
 
 int World::UpdateListAdd( Model* mod )

Modified: code/stage/trunk/libstage/worldgui.cc
===================================================================
--- code/stage/trunk/libstage/worldgui.cc       2009-07-21 01:21:39 UTC (rev 
8060)
+++ code/stage/trunk/libstage/worldgui.cc       2009-07-21 01:49:26 UTC (rev 
8061)
@@ -545,18 +545,19 @@
   }
 }
 
-static void append_option( char* name, Option* opt, std::vector<Option*>* optv 
)
-{
-  //printf( "adding option %s @ %p\n", name, opt );
-  optv->push_back( opt );
-}
+// static void append_option( char* name, Option* opt, std::vector<Option*>* 
optv )
+// {
+//   //printf( "adding option %s @ %p\n", name, opt );
+//   optv->push_back( opt );
+// }
 
-static bool sort_option_pointer( Option* a, Option* b )
-{
-  // Option class overloads operator<. Nasty nasty C++ makes code less
-  // readable IMHO.
-  return (*a) < (*b);
-}
+// static bool sort_option_pointer( const Option* a, 
+//                                                                             
        const Option* b ) const
+// {
+//   // Option class overloads operator<. Nasty nasty C++ makes code less
+//   // readable IMHO.
+//   return (*a) < (*b);
+// }
 
 void WorldGui::resetViewCb( Fl_Widget* w, WorldGui* worldGui )
 {
@@ -636,14 +637,15 @@
 void WorldGui::viewOptionsCb( OptionsDlg* oDlg, WorldGui* worldGui ) 
 {
   // the options dialog expects a std::vector of options (annoyingly)
-  std::vector<Option*> optvec;
+  // std::vector<Option*> optvec;
   // adds each option to the vector
-  g_hash_table_foreach( worldGui->option_table, 
-                                                               
(GHFunc)append_option, 
-                                                               (void*)&optvec 
);  
+  //g_hash_table_foreach( worldGui->option_table, 
+  //                                           (GHFunc)append_option, 
+  //                                           (void*)&optvec );  
   
   // sort the vector by option label alphabetically
-  std::sort( optvec.begin(), optvec.end(), sort_option_pointer );
+  //std::sort();// worldGui->option_table.begin(), 
worldGui->option_table.end() );//, sort_option_pointer );
+  //std::sort();// worldGui->option_table.begin(), 
worldGui->option_table.end() );//, sort_option_pointer );
 
   if ( !worldGui->oDlg ) 
         {
@@ -652,7 +654,7 @@
                OptionsDlg* oDlg = new OptionsDlg( x,y, 180,250 );
                oDlg->callback( (Fl_Callback*)optionsDlgCb, worldGui );
                
-               oDlg->setOptions( optvec );
+               oDlg->setOptions( worldGui->option_table );
                oDlg->showAllOpt( &worldGui->canvas->visualizeAll );
                worldGui->oDlg = oDlg;
                oDlg->show();
@@ -853,25 +855,6 @@
   }
 }
 
-void WorldGui::UpdateOptions() 
-{
-  std::set<Option*, Option::optComp> options;
-  std::vector<Option*> modOpts;
-  
-  FOR_EACH( it1, update_lists )
-       FOR_EACH( it2, (*it1) )
-       {
-         modOpts = (*it2)->getOptions();
-         options.insert( modOpts.begin(), modOpts.end() );     
-       }
-  
-  
-  drawOptions.assign( options.begin(), options.end() );
-  
-  if ( oDlg ) 
-        oDlg->setOptions( drawOptions );
-}
-
 void WorldGui::DrawBoundingBoxTree()
 {
   FOR_EACH( it, World::children )


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

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to