Revision: 7338 http://playerstage.svn.sourceforge.net/playerstage/?rev=7338&view=rev Author: rtv Date: 2009-02-17 06:13:41 +0000 (Tue, 17 Feb 2009)
Log Message: ----------- cleaned up vis options and dialog Modified Paths: -------------- code/stage/trunk/libstage/model.cc code/stage/trunk/libstage/model_blinkenlight.cc code/stage/trunk/libstage/model_blobfinder.cc code/stage/trunk/libstage/model_camera.cc code/stage/trunk/libstage/model_draw.cc code/stage/trunk/libstage/model_fiducial.cc code/stage/trunk/libstage/model_gripper.cc code/stage/trunk/libstage/model_position.cc code/stage/trunk/libstage/model_ranger.cc code/stage/trunk/libstage/options_dlg.cc code/stage/trunk/libstage/options_dlg.hh code/stage/trunk/libstage/stage.hh code/stage/trunk/libstage/worldgui.cc Modified: code/stage/trunk/libstage/model.cc =================================================================== --- code/stage/trunk/libstage/model.cc 2009-02-17 00:56:38 UTC (rev 7337) +++ code/stage/trunk/libstage/model.cc 2009-02-17 06:13:41 UTC (rev 7338) @@ -1022,8 +1022,8 @@ void Model::RegisterOption( Option* opt ) { - drawOptions.push_back( opt ); + //drawOptions.push_back( opt ); - if( world->IsGUI() ) - world->RegisterOption( opt ); + //if( world->IsGUI() ) + world->RegisterOption( opt ); } Modified: code/stage/trunk/libstage/model_blinkenlight.cc =================================================================== --- code/stage/trunk/libstage/model_blinkenlight.cc 2009-02-17 00:56:38 UTC (rev 7337) +++ code/stage/trunk/libstage/model_blinkenlight.cc 2009-02-17 06:13:41 UTC (rev 7338) @@ -83,7 +83,7 @@ this->Startup(); - registerOption( &showBlinkenData ); + RegisterOption( &showBlinkenData ); } ModelBlinkenlight::~ModelBlinkenlight() Modified: code/stage/trunk/libstage/model_blobfinder.cc =================================================================== --- code/stage/trunk/libstage/model_blobfinder.cc 2009-02-17 00:56:38 UTC (rev 7337) +++ code/stage/trunk/libstage/model_blobfinder.cc 2009-02-17 06:13:41 UTC (rev 7338) @@ -100,7 +100,7 @@ // leave the color filter array empty initally - this tracks all colors colors = g_array_new( false, true, sizeof(stg_color_t) ); - registerOption( &showBlobData ); + RegisterOption( &showBlobData ); } Modified: code/stage/trunk/libstage/model_camera.cc =================================================================== --- code/stage/trunk/libstage/model_camera.cc 2009-02-17 00:56:38 UTC (rev 7337) +++ code/stage/trunk/libstage/model_camera.cc 2009-02-17 06:13:41 UTC (rev 7338) @@ -122,7 +122,7 @@ // set default color SetColor( stg_lookup_color(DEFAULT_GEOM_COLOR)); - registerOption( &showCameraData ); + RegisterOption( &showCameraData ); Startup(); } Modified: code/stage/trunk/libstage/model_draw.cc =================================================================== --- code/stage/trunk/libstage/model_draw.cc 2009-02-17 00:56:38 UTC (rev 7337) +++ code/stage/trunk/libstage/model_draw.cc 2009-02-17 06:13:41 UTC (rev 7338) @@ -269,7 +269,7 @@ true, world_gui ); canvas->_custom_options[ custom_visual->name() ] = op; - registerOption( op ); + RegisterOption( op ); } } Modified: code/stage/trunk/libstage/model_fiducial.cc =================================================================== --- code/stage/trunk/libstage/model_fiducial.cc 2009-02-17 00:56:38 UTC (rev 7337) +++ code/stage/trunk/libstage/model_fiducial.cc 2009-02-17 06:13:41 UTC (rev 7338) @@ -99,7 +99,7 @@ data = g_array_new( false, true, sizeof(stg_fiducial_t) ); - registerOption( &showFiducialData ); + RegisterOption( &showFiducialData ); } ModelFiducial::~ModelFiducial( void ) Modified: code/stage/trunk/libstage/model_gripper.cc =================================================================== --- code/stage/trunk/libstage/model_gripper.cc 2009-02-17 00:56:38 UTC (rev 7337) +++ code/stage/trunk/libstage/model_gripper.cc 2009-02-17 06:13:41 UTC (rev 7338) @@ -78,6 +78,10 @@ cfg.paddles_stalled = false; cfg.autosnatch = false; cfg.gripped = NULL; + cfg.beam[0] = 0; + cfg.beam[1] = 0; + cfg.contact[0] = 0; + cfg.contact[1] = 0; // place the break beam sensors at 1/4 and 3/4 the length of the paddle cfg.break_beam_inset[0] = 3.0/4.0 * cfg.paddle_size.x; @@ -101,7 +105,7 @@ PositionPaddles(); - registerOption( &showData ); + RegisterOption( &showData ); } ModelGripper::~ModelGripper() @@ -480,8 +484,8 @@ if( subs < 1 ) return; - if( ! showData ) - return; + //if( ! showData ) + //return; // outline the sensor lights in black PushColor( 0,0,0,1.0 ); // black Modified: code/stage/trunk/libstage/model_position.cc =================================================================== --- code/stage/trunk/libstage/model_position.cc 2009-02-17 00:56:38 UTC (rev 7337) +++ code/stage/trunk/libstage/model_position.cc 2009-02-17 06:13:41 UTC (rev 7338) @@ -135,8 +135,8 @@ drand48() * STG_POSITION_INTEGRATION_ERROR_MAX_A - STG_POSITION_INTEGRATION_ERROR_MAX_A/2.0; - registerOption( &showCoords ); - registerOption( &showWaypoints ); + RegisterOption( &showCoords ); + RegisterOption( &showWaypoints ); } Modified: code/stage/trunk/libstage/model_ranger.cc =================================================================== --- code/stage/trunk/libstage/model_ranger.cc 2009-02-17 00:56:38 UTC (rev 7337) +++ code/stage/trunk/libstage/model_ranger.cc 2009-02-17 06:13:41 UTC (rev 7338) @@ -100,7 +100,6 @@ static const char RANGER_CONFIG_COLOR[] = "gray90"; static const char RANGER_GEOM_COLOR[] = "orange"; -//TODO make instance attempt to register an option (as customvisualizations do) Option ModelRanger::showRangerData( "Ranger ranges", "show_ranger", "", true, NULL ); Option ModelRanger::showRangerTransducers( "Ranger transducers", "show_ranger_transducers", "", false, NULL ); @@ -155,12 +154,14 @@ sensors[c].ray_count = RANGER_RAYCOUNT; } - registerOption( &showRangerData ); - registerOption( &showRangerTransducers ); + RegisterOption( &showRangerData ); + RegisterOption( &showRangerTransducers ); } ModelRanger::~ModelRanger() { + if( sensors ) + delete[] sensors; } void ModelRanger::Startup( void ) Modified: code/stage/trunk/libstage/options_dlg.cc =================================================================== --- code/stage/trunk/libstage/options_dlg.cc 2009-02-17 00:56:38 UTC (rev 7337) +++ code/stage/trunk/libstage/options_dlg.cc 2009-02-17 06:13:41 UTC (rev 7338) @@ -14,19 +14,19 @@ showAllCheck = new Fl_Check_Button( 0,0, w,boxH ); showAllCheck->callback( checkChanged, this ); - - scroll = new Fl_Scroll( 0,boxH+vm, w,h-boxH-btnH-3*vm ); - scroll->type( Fl_Scroll::VERTICAL ); + showAllCheck->box( FL_UP_FRAME ); + + //scroll = new Fl_Scroll( 0,boxH+vm, w,h-boxH-btnH-3*vm ); + scroll = new Fl_Scroll( 0,boxH+vm, w,h-boxH-3*vm ); + //scroll->box( FL_ENGRAVED_BOX ); + resizable( scroll ); + scroll->type( Fl_Scroll::VERTICAL ); scroll->end(); - - button = new Fl_Button( hm, h-btnH-vm, w-2*hm, btnH, "&Close" ); - button->callback( closePress, this ); this->end(); } OptionsDlg::~OptionsDlg() { - delete button; delete scroll; // deletes members delete showAllCheck; } @@ -55,19 +55,6 @@ } } - void OptionsDlg::closePress( Fl_Widget* w, void* p ) { - OptionsDlg* oDlg = static_cast<OptionsDlg*>( p ); - - oDlg->status = CLOSE; - oDlg->do_callback(); - oDlg->status = NO_EVENT; - } - -// int OptionsDlg::handle( int event ) { -// return Fl_Window::handle( event ); -// } - - void OptionsDlg::updateChecks() { if (scroll->children()) scroll->clear(); @@ -84,15 +71,11 @@ } void OptionsDlg::setOptions( const std::vector<Option*>& opts ) { + options.clear(); options.assign( opts.begin(), opts.end() ); updateChecks(); } - void OptionsDlg::setOptions( const std::set<Option*, Option::optComp>& opts ) { - options.clear(); - options.insert( options.begin(), opts.begin(), opts.end() ); - updateChecks(); - } void OptionsDlg::showAllOpt( Option* opt ) { showAll = opt; Modified: code/stage/trunk/libstage/options_dlg.hh =================================================================== --- code/stage/trunk/libstage/options_dlg.hh 2009-02-17 00:56:38 UTC (rev 7337) +++ code/stage/trunk/libstage/options_dlg.hh 2009-02-17 06:13:41 UTC (rev 7338) @@ -27,18 +27,14 @@ Option* showAll; event_t status; Fl_Scroll* scroll; - Fl_Button* button; Fl_Check_Button* showAllCheck; void updateChecks(); - //virtual int handle( int event ); static void checkChanged( Fl_Widget* w, void* p ); - static void closePress( Fl_Widget* w, void* p ); - + // constants static const int vm = 4; const int hm; - static const int btnH = 25; static const int boxH = 30; public: @@ -46,7 +42,6 @@ virtual ~OptionsDlg(); void setOptions( const std::vector<Option*>& opts ); - void setOptions( const std::set<Option*, Option::optComp>& 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-02-17 00:56:38 UTC (rev 7337) +++ code/stage/trunk/libstage/stage.hh 2009-02-17 06:13:41 UTC (rev 7338) @@ -1387,8 +1387,8 @@ static void fileSaveCb( Fl_Widget* w, void* p ); static void fileSaveAsCb( Fl_Widget* w, void* p ); static void fileExitCb( Fl_Widget* w, void* p ); - static void viewOptionsCb( Fl_Widget* w, void* p ); - static void optionsDlgCb( Fl_Widget* w, void* p ); + static void viewOptionsCb( OptionsDlg* oDlg, WorldGui* worldGui ); + static void optionsDlgCb( OptionsDlg* oDlg, WorldGui* worldGui ); static void helpAboutCb( Fl_Widget* w, void* p ); // GUI functions @@ -1684,7 +1684,6 @@ /// Register an Option for pickup by the GUI void RegisterOption( Option* opt ); - void registerOption( Option* opt ) { RegisterOption( opt) ; }; GList* AppendTouchingModels( GList* list ); //void AddTouchingModelsToList( GList* list ); Modified: code/stage/trunk/libstage/worldgui.cc =================================================================== --- code/stage/trunk/libstage/worldgui.cc 2009-02-17 00:56:38 UTC (rev 7337) +++ code/stage/trunk/libstage/worldgui.cc 2009-02-17 06:13:41 UTC (rev 7338) @@ -192,7 +192,7 @@ mbar->add( "File/E&xit", FL_CTRL+'q', WorldGui::fileExitCb, this ); mbar->add( "&View", 0, 0, 0, FL_SUBMENU ); - mbar->add( "View/Filter data...", FL_SHIFT + 'd', WorldGui::viewOptionsCb, this ); + mbar->add( "View/Filter data...", FL_SHIFT + 'd', (Fl_Callback*)WorldGui::viewOptionsCb, this ); canvas->createMenuItems( mbar, "View" ); mbar->add( "&Help", 0, 0, 0, FL_SUBMENU ); @@ -258,7 +258,7 @@ } label( title.c_str() ); - UpdateOptions(); + //UpdateOptions(); show(); } @@ -518,40 +518,54 @@ } } +static void append_option( char* name, Option* opt, std::vector<Option*>* optv ) +{ + //printf( "adding option %s @ %p\n", name, opt ); + optv->push_back( opt ); +} -void list_option( char* name, Option* opt, void* dummy ) +static bool sort_option_pointer( Option* a, Option* b ) { - printf( "option %s @ %p\n", name, opt ); - + // Option class overloads operator<. Nasty nasty C++ makes code less + // readable IMHO. + return (*a) < (*b); } -void WorldGui::viewOptionsCb( Fl_Widget* w, void* p ) +void WorldGui::viewOptionsCb( OptionsDlg* oDlg, WorldGui* worldGui ) { - WorldGui* worldGui = static_cast<WorldGui*>( p ); + // the options dialog expects a std::vector of options (annoyingly) + std::vector<Option*> optvec; + // adds each option to the vector + 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 ); + if ( !worldGui->oDlg ) { int x = worldGui->w()+worldGui->x() + 10; int y = worldGui->y(); OptionsDlg* oDlg = new OptionsDlg( x,y, 180,250 ); - oDlg->callback( optionsDlgCb, worldGui ); - oDlg->setOptions( worldGui->drawOptions ); + oDlg->callback( (Fl_Callback*)optionsDlgCb, worldGui ); + + oDlg->setOptions( optvec ); oDlg->showAllOpt( &worldGui->canvas->visualizeAll ); worldGui->oDlg = oDlg; oDlg->show(); } else { - worldGui->oDlg->show(); // bring it to front + worldGui->oDlg->hide(); + delete worldGui->oDlg; + worldGui->oDlg = NULL; } - - //g_hash_table_foreach( worldGui->option_table, (GHFunc)list_option, NULL ); + } -void WorldGui::optionsDlgCb( Fl_Widget* w, void* p ) { - OptionsDlg* oDlg = static_cast<OptionsDlg*>( w ); - WorldGui* worldGui = static_cast<WorldGui*>( p ); - +void WorldGui::optionsDlgCb( OptionsDlg* oDlg, WorldGui* worldGui ) +{ // get event from dialog OptionsDlg::event_t event; event = oDlg->event(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ Playerstage-commit mailing list Playerstage-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/playerstage-commit