Permalink
Browse files

added support for load/save of visualization options

  • Loading branch information...
rtv committed Dec 2, 2011
1 parent 4de1b77 commit 379cfd6a8966e4ce397086caa59dbcb4ea4fc817
Showing with 28 additions and 22 deletions.
  1. +1 −1 libstage/option.cc
  2. +1 −0 libstage/world.cc
  3. +1 −1 libstage/worldfile.cc
  4. +25 −20 libstage/worldgui.cc
View
@@ -33,7 +33,7 @@ Fl_Menu_Item* getMenuItem( Fl_Menu_* menu, int i )
void Option::Load( Worldfile* wf, int section )
{
//printf( "loading wf key %s\n", wf_token.c_str() );
- set( (bool)wf->ReadInt( section, wf_token.c_str(), value ));
+ set( (bool)wf->ReadInt( section, wf_token.c_str(), value ));
}
void Option::Save( Worldfile* wf, int section )
View
@@ -1159,6 +1159,7 @@ void World::RemovePowerPack( PowerPack* pp )
/// Register an Option for pickup by the GUI
void World:: RegisterOption( Option* opt )
{
+ assert(opt);
option_table.insert( opt );
}
View
@@ -1632,7 +1632,7 @@ void Worldfile::WriteTuple( const int entity, const char *name,
exit(-1);
}
- printf( "writing %s %d %s\n", name, first+i, buf );
+ //printf( "writing %s %d %s\n", name, first+i, buf );
SetPropertyValue(property, first+i, buf );
}
View
@@ -286,8 +286,6 @@ void WorldGui::Load( const std::string& filename )
// configure the canvas
canvas->Load( wf, window_section );
- // warn about unused WF lines
- wf->WarnUnused();
std::string title = PROJECT;
if ( wf->filename.size() ) {
@@ -296,6 +294,12 @@ void WorldGui::Load( const std::string& filename )
title += wf->filename;
}
label( title.c_str() );
+
+ FOR_EACH( it, option_table )
+ (*it)->Load( wf, window_section );
+
+ // warn about unused WF lines
+ wf->WarnUnused();
}
const usec_t load_end_time = RealTimeNow();
@@ -332,7 +336,8 @@ bool WorldGui::Save( const char* filename )
canvas->Save( wf, window_section );
- // TODO - per model visualizations save
+ FOR_EACH( it, option_table )
+ (*it)->Save( wf, window_section );
}
World::Save( filename );
@@ -645,24 +650,24 @@ void WorldGui::viewOptionsCb( OptionsDlg* oDlg, WorldGui* wg )
//std::sort();// wg->option_table.begin(), wg->option_table.end() );//, sort_option_pointer );
if ( !wg->oDlg )
- {
- int x = wg->w()+wg->x() + 10;
- int y = wg->y();
- OptionsDlg* oDlg = new OptionsDlg( x,y, 180,250 );
- oDlg->callback( (Fl_Callback*)optionsDlgCb, wg );
-
- oDlg->setOptions( wg->option_table );
- oDlg->showAllOpt( &wg->canvas->visualizeAll );
- wg->oDlg = oDlg;
- oDlg->show();
- }
+ {
+ int x = wg->w()+wg->x() + 10;
+ int y = wg->y();
+ OptionsDlg* oDlg = new OptionsDlg( x,y, 180,250 );
+ oDlg->callback( (Fl_Callback*)optionsDlgCb, wg );
+
+ oDlg->setOptions( wg->option_table );
+ oDlg->showAllOpt( &wg->canvas->visualizeAll );
+ wg->oDlg = oDlg;
+ oDlg->show();
+ }
else
- {
- wg->oDlg->hide();
- delete wg->oDlg;
- wg->oDlg = NULL;
- }
-
+ {
+ wg->oDlg->hide();
+ delete wg->oDlg;
+ wg->oDlg = NULL;
+ }
+
}
void WorldGui::optionsDlgCb( OptionsDlg* oDlg, WorldGui* wg )

0 comments on commit 379cfd6

Please sign in to comment.