StatisticsWindow Class Reference

#include <StatisticsWindow.h>


Public Types

enum  stat_types { STAT_TYPE_TOTAL, STAT_TYPE_SEQUENCE, STAT_TYPE_GAME, STAT_TYPE_ROBOT }

Public Member Functions

 StatisticsWindow (const int default_width=-1, const int default_height=-1, const int default_x_pos=-1, const int default_y_pos=-1)
 ~StatisticsWindow ()
void make_title_button ()
void add_new_row (Robot *robot_p, stat_t average_stat, int games_played)
GtkWidgetget_window_p ()
GtkWidgetget_clist ()
enum stat_types get_type ()
int get_looking_at_nr ()
void set_looking_at_nr (const int number)
void set_type (stat_types t)

Static Public Member Functions

void delete_event_occured (GtkWidget *widget, GdkEvent *event, class StatisticsWindow *sw_p)
void exit (GtkWidget *widget, class StatisticsWindow *sw_p)
void save (GtkWidget *widget, class StatisticsWindow *sw_p)
void save_stats (GtkWidget *widget, class StatisticsWindow *sw_p)
void destroy_filesel (GtkWidget *widget, class StatisticsWindow *sw_p)
void change_table_type (GtkWidget *widget, struct change_type_data_t *info_p)
void change_stats_viewed (GtkWidget *widget, struct change_stat_data_t *info_p)
void add_the_statistics_to_clist (GtkWidget *widget, class StatisticsWindow *sw_p)
void change_sorting_in_clist (GtkCList *clist, gint column, class StatisticsWindow *sw_p)
void row_selected (GtkWidget *clist, gint row, gint column, GdkEventButton *event, class StatisticsWindow *sw_p)

Private Member Functions

GtkWidgetget_filesel ()
void set_filesel (GtkWidget *fs)

Private Attributes

GtkWidgetwindow_p
GtkWidgetclist
GtkWidgettitle_button
GtkWidgettitle_button_hbox
GtkWidgetfilesel
stat_types type
int looking_at_nr


Member Enumeration Documentation

enum StatisticsWindow::stat_types
 

Enumeration values:
STAT_TYPE_TOTAL 
STAT_TYPE_SEQUENCE 
STAT_TYPE_GAME 
STAT_TYPE_ROBOT 

Definition at line 41 of file StatisticsWindow.h.

Referenced by add_the_statistics_to_clist(), change_sorting_in_clist(), change_stats_viewed(), change_table_type(), and row_selected().

00042   {
00043     STAT_TYPE_TOTAL,
00044     STAT_TYPE_SEQUENCE,
00045     STAT_TYPE_GAME,
00046     STAT_TYPE_ROBOT
00047   };


Constructor & Destructor Documentation

StatisticsWindow::StatisticsWindow const int  default_width = -1,
const int  default_height = -1,
const int  default_x_pos = -1,
const int  default_y_pos = -1
 

Definition at line 32 of file StatisticsWindow.cc.

References _, add_the_statistics_to_clist(), change_sorting_in_clist(), clist, delete_event_occured(), filesel, float_compare(), Gui::get_bg_gdk_colour_p(), Gui::get_fg_gdk_colour_p(), gpointer, GtkWidget, looking_at_nr, make_gdk_colour(), row_selected(), STAT_TYPE_GAME, STAT_TYPE_ROBOT, STAT_TYPE_SEQUENCE, STAT_TYPE_TOTAL, the_gui, title_button, title_button_hbox, type, and window_p.

00036 {
00037   type = STAT_TYPE_TOTAL;
00038   looking_at_nr = 1;
00039   filesel = NULL;
00040 
00041   // The window widget
00042 
00043   window_p = gtk_window_new( GTK_WINDOW_TOPLEVEL );
00044   gtk_widget_set_name( window_p, "RTB Statistics" );
00045 
00046   gtk_window_set_title( GTK_WINDOW( window_p ), _("Statistics") );
00047 
00048   gtk_container_border_width( GTK_CONTAINER( window_p ), 12 );
00049 
00050   if( default_width != -1 && default_height != -1 )
00051     {
00052       gtk_window_set_default_size( GTK_WINDOW( window_p ),
00053                                    default_width, default_height );
00054       gtk_widget_set_usize( window_p , 364, 130 );
00055     }
00056   if( default_x_pos != -1 && default_y_pos != -1 )
00057     gtk_widget_set_uposition( window_p, default_x_pos, default_y_pos );
00058 
00059   gtk_signal_connect( GTK_OBJECT( window_p ), "delete_event",
00060                       (GtkSignalFunc) StatisticsWindow::delete_event_occured,
00061                       (gpointer) this );
00062 
00063   // Main box
00064 
00065   GtkWidget* vbox = gtk_vbox_new( FALSE, 10 );
00066   gtk_container_add( GTK_CONTAINER( window_p ) ,vbox );
00067   gtk_widget_show( vbox );
00068 
00069   // Buttons for displaying different types of statistics
00070 
00071   GtkWidget* hbox = gtk_hbox_new( FALSE, 10 );
00072   gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
00073   gtk_widget_show( hbox );
00074 
00075   {
00076     struct button_t { String label; GtkSignalFunc func; gpointer data; };
00077 
00078     struct button_t buttons[] = {
00079       { (String)_(" Close "), (GtkSignalFunc) StatisticsWindow::exit,
00080         (gpointer) this },
00081       { (String)_(" Save Statistics "), (GtkSignalFunc) StatisticsWindow::save,
00082         (gpointer) this },
00083       { (String)_(" Total "), (GtkSignalFunc) StatisticsWindow::change_table_type,
00084         (gpointer) new change_type_data_t( STAT_TYPE_TOTAL, this ) },
00085       { (String)_(" Sequence Total "), (GtkSignalFunc) StatisticsWindow::change_table_type,
00086         (gpointer) new change_type_data_t( STAT_TYPE_SEQUENCE, this ) },
00087       { (String)" " + (String)_("Game") + (String)" ",
00088         (GtkSignalFunc) StatisticsWindow::change_table_type,
00089         (gpointer) new change_type_data_t( STAT_TYPE_GAME, this ) },
00090       { (String)_(" Robot "), (GtkSignalFunc) StatisticsWindow::change_table_type,
00091         (gpointer) new change_type_data_t( STAT_TYPE_ROBOT, this ) } };
00092 
00093     GtkWidget* button_w;
00094     for( int i=0; i<6; i++ )
00095       {
00096         button_w = gtk_button_new_with_label( buttons[i].label.chars() );
00097         gtk_signal_connect( GTK_OBJECT( button_w ), "clicked",
00098                             buttons[i].func, buttons[i].data );
00099         gtk_box_pack_start( GTK_BOX( hbox ), button_w, TRUE, TRUE, 0 );
00100         gtk_widget_show( button_w );
00101       } 
00102   }
00103 
00104   gtk_widget_show( window_p );
00105 
00106   hbox = gtk_hbox_new( FALSE, 10 );
00107   gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
00108   gtk_widget_show( hbox );
00109 
00110   {
00111     char* first_xpm[13] =
00112     { "13 10 2 1",
00113       "       c None",
00114       "x      c #000000000000",
00115       "xx         xx",
00116       "xx       xxxx",  
00117       "xx     xxxxxx",
00118       "xx   xxxxxxxx",
00119       "xx  xxxxxxxxx",
00120       "xx  xxxxxxxxx",
00121       "xx   xxxxxxxx",
00122       "xx     xxxxxx",
00123       "xx       xxxx",
00124       "xx         xx" };
00125     char* prev_xpm[13] =
00126     { "9 10 2 1",
00127       "       c None",
00128       "x      c #000000000000",
00129       "       xx",
00130       "     xxxx",  
00131       "   xxxxxx",
00132       " xxxxxxxx",
00133       "xxxxxxxxx",
00134       "xxxxxxxxx",
00135       " xxxxxxxx",
00136       "   xxxxxx",
00137       "     xxxx",
00138       "       xx" };
00139     char* next_xpm[13] =
00140     { "9 10 2 1",
00141       "       c None",
00142       "x      c #000000000000",
00143       "xx       ",
00144       "xxxx     ",  
00145       "xxxxxx   ",
00146       "xxxxxxxx ",
00147       "xxxxxxxxx",
00148       "xxxxxxxxx",
00149       "xxxxxxxx ",
00150       "xxxxxx   ",
00151       "xxxx     ",
00152       "xx       " };
00153     char* last_xpm[13] =
00154     { "13 10 2 1",
00155       "       c None",
00156       "x      c #000000000000",
00157       "xx         xx",
00158       "xxxx       xx",  
00159       "xxxxxx     xx",
00160       "xxxxxxxx   xx",
00161       "xxxxxxxxx  xx",
00162       "xxxxxxxxx  xx",
00163       "xxxxxxxx   xx",
00164       "xxxxxx     xx",
00165       "xxxx       xx",
00166       "xx         xx" };
00167 
00168     struct button_t
00169     { char** xpm; GtkSignalFunc func; gpointer data; int pack; };
00170 
00171     struct button_t buttons[] = {
00172       { first_xpm, (GtkSignalFunc) StatisticsWindow::change_stats_viewed,
00173         (gpointer) new change_stat_data_t( -1, true, this ), FALSE },
00174       { prev_xpm, (GtkSignalFunc) StatisticsWindow::change_stats_viewed,
00175         (gpointer) new change_stat_data_t( -1, false, this ), FALSE },
00176       { NULL, (GtkSignalFunc) StatisticsWindow::add_the_statistics_to_clist,
00177         (gpointer) this, TRUE },
00178       { next_xpm, (GtkSignalFunc) StatisticsWindow::change_stats_viewed,
00179         (gpointer) new change_stat_data_t( 1, false, this ), FALSE },
00180       { last_xpm, (GtkSignalFunc) StatisticsWindow::change_stats_viewed,
00181         (gpointer) new change_stat_data_t( 1, true, this ), FALSE } };
00182 
00183     for( int i=0; i<5; i++ )
00184       {
00185         GtkWidget* button_w = gtk_button_new();
00186         if( buttons[i].xpm != NULL )
00187           {
00188             GdkPixmap* pixmap;
00189             GdkBitmap* bitmap_mask;
00190 
00191             pixmap = gdk_pixmap_create_from_xpm_d( window_p->window,
00192                                                    &bitmap_mask,
00193                                                    &(window_p->style->black),
00194                                                    buttons[i].xpm );
00195             GtkWidget* pixmap_widget = gtk_pixmap_new( pixmap, bitmap_mask );
00196             gtk_widget_show( pixmap_widget );
00197             gtk_container_add( GTK_CONTAINER( button_w ), pixmap_widget );
00198             gtk_widget_set_usize( button_w, 24, 20 );
00199           }
00200         else
00201           {
00202             title_button = button_w;
00203             title_button_hbox = NULL;
00204           }
00205         gtk_signal_connect( GTK_OBJECT( button_w ), "clicked",
00206                             buttons[i].func, buttons[i].data );
00207         gtk_box_pack_start( GTK_BOX( hbox ), button_w,
00208                             buttons[i].pack, buttons[i].pack, 0 );
00209         gtk_widget_show( button_w );
00210       }
00211   }
00212 
00213   GtkObject* hadj = gtk_adjustment_new( 0.0, 0.0, 100.0, 1.0, 1.0, 1.0 );
00214   GtkObject* vadj = gtk_adjustment_new( 0.0, 0.0, 100.0, 1.0, 1.0, 1.0 );
00215   GtkWidget* scrolled_win = gtk_scrolled_window_new( GTK_ADJUSTMENT( hadj ),
00216                                                      GTK_ADJUSTMENT( vadj ) );
00217   gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolled_win ),
00218                                   GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
00219   gtk_box_pack_start( GTK_BOX( vbox ), scrolled_win, TRUE, TRUE, 0);
00220   gtk_widget_show( scrolled_win );
00221 
00222   char * titles[7] = { "",_("Name"), _("Position"), _("Points"),
00223                        _("Games"), _("Survival Time"), _("Total Points") };
00224   clist = gtk_clist_new_with_titles(7, titles );
00225   gtk_clist_set_selection_mode( GTK_CLIST( clist ), GTK_SELECTION_BROWSE );
00226   gtk_clist_set_column_width( GTK_CLIST( clist ), 0, 5 );
00227   gtk_clist_set_column_width( GTK_CLIST( clist ), 1, 120 );
00228   gtk_clist_set_column_width( GTK_CLIST( clist ), 2, 45 );
00229   gtk_clist_set_column_width( GTK_CLIST( clist ), 3, 35 );
00230   gtk_clist_set_column_width( GTK_CLIST( clist ), 4, 45 );
00231   gtk_clist_set_column_width( GTK_CLIST( clist ), 5, 75 );
00232   gtk_clist_set_column_width( GTK_CLIST( clist ), 6, 60 );
00233   gtk_clist_set_column_justification( GTK_CLIST( clist ), 0,
00234                                       GTK_JUSTIFY_CENTER );
00235   gtk_clist_set_column_justification( GTK_CLIST( clist ), 1,
00236                                       GTK_JUSTIFY_LEFT );
00237   gtk_clist_set_column_justification( GTK_CLIST( clist ), 2,
00238                                       GTK_JUSTIFY_RIGHT );
00239   gtk_clist_set_column_justification( GTK_CLIST( clist ), 3,
00240                                       GTK_JUSTIFY_RIGHT );
00241   gtk_clist_set_column_justification( GTK_CLIST( clist ), 4,
00242                                       GTK_JUSTIFY_RIGHT );
00243   gtk_clist_set_column_justification( GTK_CLIST( clist ), 5,
00244                                       GTK_JUSTIFY_RIGHT );
00245   gtk_clist_set_column_justification( GTK_CLIST( clist ), 6,
00246                                       GTK_JUSTIFY_RIGHT );
00247   gtk_clist_column_title_passive( GTK_CLIST( clist ), 0 );
00248   gtk_signal_connect( GTK_OBJECT( clist ), "select_row",
00249                       (GtkSignalFunc) row_selected, this );
00250 
00251   gtk_clist_set_column_resizeable( GTK_CLIST( clist ), 0, FALSE );
00252   gtk_clist_set_column_max_width( GTK_CLIST( clist ), 0, 5 );
00253 
00254   gtk_clist_set_shadow_type( GTK_CLIST( clist ), GTK_SHADOW_IN );
00255   gtk_clist_set_compare_func( GTK_CLIST( clist ), float_compare );
00256   gtk_clist_set_sort_column( GTK_CLIST( clist ), 6 );
00257   gtk_clist_set_sort_type( GTK_CLIST( clist ), GTK_SORT_DESCENDING );
00258 
00259   for( int i=2; i <=6; i++ )
00260     gtk_clist_set_column_auto_resize( GTK_CLIST( clist ), i, TRUE );
00261 
00262   gtk_signal_connect( GTK_OBJECT( clist ), "click_column",
00263                       (GtkSignalFunc) change_sorting_in_clist,
00264                       (gpointer) this );
00265   gtk_container_add( GTK_CONTAINER( scrolled_win ), clist );
00266 
00267   GtkStyle* clist_style = gtk_rc_get_style(window_p);
00268   if( clist_style == NULL )
00269     clist_style = gtk_style_new();
00270   else
00271     clist_style = gtk_style_copy(clist_style);
00272   clist_style->base[GTK_STATE_NORMAL] = *(the_gui.get_bg_gdk_colour_p());
00273   clist_style->base[GTK_STATE_ACTIVE] = make_gdk_colour( 0xffffff );
00274   clist_style->bg[GTK_STATE_SELECTED] = make_gdk_colour( 0xf0d2b4 );
00275   clist_style->fg[GTK_STATE_SELECTED] = *(the_gui.get_fg_gdk_colour_p());
00276   gtk_widget_set_style( clist, clist_style );
00277   gtk_widget_show( clist );
00278 
00279   add_the_statistics_to_clist( clist, this );
00280 }

Here is the call graph for this function:

StatisticsWindow::~StatisticsWindow  ) 
 

Definition at line 282 of file StatisticsWindow.cc.

References window_p.

00283 {
00284   gtk_widget_destroy( window_p );
00285 }


Member Function Documentation

void StatisticsWindow::add_new_row Robot robot_p,
stat_t  average_stat,
int  games_played
 

Definition at line 533 of file StatisticsWindow.cc.

References clist, stat_t::game_nr, Gui::get_bg_gdk_colour_p(), Gui::get_fg_gdk_colour_p(), Robot::get_robot_name(), Robot::get_stat_pixmap(), String::non_const_chars(), stat_t::points, stat_t::position, stat_t::sequence_nr, STAT_TYPE_GAME, STAT_TYPE_SEQUENCE, STAT_TYPE_TOTAL, STRING_FIXED_FORM, the_gui, stat_t::time_survived, stat_t::total_points, type, and window_p.

00535 {
00536   char* empty_list[] = { "", "", "", "", "", "", "", "" };
00537   int row = gtk_clist_append( GTK_CLIST( clist ), empty_list );
00538   gtk_clist_set_foreground( GTK_CLIST( clist ), row,
00539                             the_gui.get_fg_gdk_colour_p() );
00540   gtk_clist_set_background( GTK_CLIST( clist ), row,
00541                             the_gui.get_bg_gdk_colour_p() );
00542 
00543   if( type == STAT_TYPE_GAME ||
00544       type == STAT_TYPE_SEQUENCE ||
00545       type == STAT_TYPE_TOTAL)
00546     {
00547       GdkPixmap * colour_pixmap;
00548       GdkBitmap * bitmap_mask;
00549 
00550       robot_p->get_stat_pixmap( window_p->window,
00551                                 colour_pixmap, bitmap_mask );
00552 
00553       gtk_clist_set_pixmap( GTK_CLIST( clist ), row, 0,
00554                             colour_pixmap, bitmap_mask );
00555       gtk_clist_set_text( GTK_CLIST( clist ), row, 1,
00556                           robot_p->get_robot_name().non_const_chars() );
00557     }
00558 
00559   if( type == STAT_TYPE_ROBOT)
00560     {
00561       gtk_clist_set_text( GTK_CLIST( clist ), row, 0,
00562                           String( average_stat.sequence_nr ).non_const_chars() );
00563       gtk_clist_set_text( GTK_CLIST( clist ), row, 1,
00564                           String( average_stat.game_nr ).non_const_chars() );
00565     }
00566 
00567   gtk_clist_set_text( GTK_CLIST( clist ), row, 2,
00568                       String( average_stat.position ).non_const_chars() );
00569 
00570   String str;
00571   if( type == STAT_TYPE_SEQUENCE ||
00572       type == STAT_TYPE_TOTAL)
00573     str = String(average_stat.points, 2, STRING_FIXED_FORM );
00574   else
00575     str = String(average_stat.points );
00576 
00577   gtk_clist_set_text( GTK_CLIST( clist ), row, 3, str.non_const_chars() );
00578 
00579   if( type == STAT_TYPE_TOTAL ||
00580       type == STAT_TYPE_SEQUENCE )
00581       gtk_clist_set_text( GTK_CLIST( clist ), row, 4,
00582                           String( games_played ).non_const_chars() );
00583   else
00584       gtk_clist_set_text( GTK_CLIST( clist ), row, 4,
00585                           String( "" ).non_const_chars() );
00586 
00587   gtk_clist_set_text( GTK_CLIST( clist ), row, 5,
00588                       String( average_stat.time_survived, 2,
00589                               STRING_FIXED_FORM).non_const_chars() );
00590   gtk_clist_set_text( GTK_CLIST( clist ), row, 6,
00591                       String( average_stat.total_points ).non_const_chars() );
00592 }

Here is the call graph for this function:

void StatisticsWindow::add_the_statistics_to_clist GtkWidget widget,
class StatisticsWindow sw_p
[static]
 

Definition at line 595 of file StatisticsWindow.cc.

References clist, List< T >::first(), stat_t::game_nr, Robot::get_statistics(), GtkWidget, ListIterator< T >::ok(), stat_t::points, stat_t::position, stat_t::sequence_nr, STAT_TYPE_GAME, STAT_TYPE_ROBOT, STAT_TYPE_SEQUENCE, STAT_TYPE_TOTAL, stat_types, the_arena, stat_t::time_survived, and stat_t::total_points.

Referenced by change_sorting_in_clist(), change_stats_viewed(), change_table_type(), and StatisticsWindow().

00597 {
00598   Robot* robot_p = NULL;
00599   stat_t* stat_p = NULL;
00600   ListIterator<Robot> li;
00601   ListIterator<stat_t> stat_li;
00602 
00603   GtkWidget* clist = sw_p->get_clist();
00604   stat_types sw_type = sw_p->get_type();
00605   int number = sw_p->get_looking_at_nr();
00606 
00607   sw_p->make_title_button();
00608 
00609   gtk_clist_freeze( GTK_CLIST( clist ) );
00610   gtk_clist_clear( GTK_CLIST( clist ) );
00611 
00612   switch( sw_type )
00613     {
00614     case STAT_TYPE_TOTAL:
00615     case STAT_TYPE_SEQUENCE:
00616       {
00617         int number_of_robots = the_arena.get_number_of_robots();
00618 
00619         double points[number_of_robots];
00620         int position[number_of_robots];
00621 
00622         int robot_nr = -1;
00623 
00624         for( the_arena.get_all_robots_in_tournament()->first(li);
00625              li.ok(); li++ )
00626           {
00627             robot_nr++;
00628             robot_p = li();
00629             points[robot_nr] = 0;
00630             for(robot_p->get_statistics()->first(stat_li);
00631                 stat_li.ok(); stat_li++)
00632               {
00633                 stat_p = stat_li();
00634                 if( ( sw_type == STAT_TYPE_SEQUENCE &&
00635                       stat_p->sequence_nr == number ) ||
00636                     sw_type == STAT_TYPE_TOTAL )
00637                   points[robot_nr] += stat_li()->points;
00638               }
00639           }
00640 
00641         for(int i = 0;i<number_of_robots;i++)
00642           {
00643             int temp_pos = 1;
00644             for(int j = 0;j<number_of_robots;j++)
00645               if(points[j] > points[i])
00646                 temp_pos++;
00647             position[i] = temp_pos;
00648           }
00649 
00650         robot_nr = -1;
00651         for( the_arena.get_all_robots_in_tournament()->first(li);
00652              li.ok(); li++ )
00653           {
00654             robot_nr++;
00655             robot_p = li();
00656             stat_t average_stat(0,0,0,0.0,0.0,0.0);
00657             int number_of_stat_found = 0;
00658             for(robot_p->get_statistics()->first(stat_li);
00659                 stat_li.ok(); stat_li++)
00660               {
00661                 stat_p = stat_li();
00662                 if( ( sw_type == STAT_TYPE_SEQUENCE &&
00663                       stat_p->sequence_nr == number ) ||
00664                     sw_type == STAT_TYPE_TOTAL )
00665                   {
00666                     number_of_stat_found++;
00667                     average_stat.points += stat_p->points;
00668                     average_stat.time_survived += stat_p->time_survived;
00669                     average_stat.total_points += stat_p->points;
00670                   }
00671               }
00672 
00673             if( number_of_stat_found > 0 )
00674               {
00675                 average_stat.position = position[robot_nr];
00676                 average_stat.points /= number_of_stat_found;
00677                 average_stat.time_survived /= number_of_stat_found;
00678                 sw_p->add_new_row( robot_p, average_stat, number_of_stat_found );
00679               }
00680           }
00681       }
00682       break;
00683     case STAT_TYPE_GAME:
00684       {
00685         int gps = the_arena.get_games_per_sequence();
00686         int game = number % gps;
00687         int sequence = ( number / gps ) + 1;
00688         if( game == 0 )
00689           {
00690             game = gps;
00691             sequence--;
00692           }
00693 
00694         for( the_arena.get_all_robots_in_tournament()->first(li); li.ok(); li++ )
00695           {
00696             robot_p = li();
00697 
00698             for(robot_p->get_statistics()->first(stat_li); stat_li.ok(); stat_li++)
00699               {
00700                 stat_p = stat_li();
00701                 if(stat_p->sequence_nr == sequence &&
00702                    stat_p->game_nr == game)
00703                   sw_p->add_new_row( robot_p, *stat_p, -1 );
00704               }
00705           }
00706       }
00707       break;
00708     case STAT_TYPE_ROBOT:
00709       {
00710         int i=0;
00711 
00712         for( the_arena.get_all_robots_in_tournament()->first(li); li.ok(); li++ )
00713           {
00714             i++;
00715             robot_p = li();
00716             if( i == number )
00717               for(robot_p->get_statistics()->first(stat_li); stat_li.ok(); stat_li++)
00718                 {
00719                   stat_p = stat_li();
00720                   sw_p->add_new_row( robot_p, *stat_p, -1 );
00721                 }
00722           }
00723       }
00724       break;
00725     }
00726 
00727   gtk_clist_sort( GTK_CLIST( clist ) );
00728   gtk_clist_thaw( GTK_CLIST( clist ) );
00729 }

Here is the call graph for this function:

void StatisticsWindow::change_sorting_in_clist GtkCList *  clist,
gint  column,
class StatisticsWindow sw_p
[static]
 

Definition at line 732 of file StatisticsWindow.cc.

References add_the_statistics_to_clist(), float_compare(), STAT_TYPE_TOTAL, stat_types, and string_case_insensitive_compare().

Referenced by change_table_type(), and StatisticsWindow().

00734 {
00735   stat_types sw_type = sw_p->get_type();
00736   
00737   gtk_clist_freeze( clist );
00738   switch(column)
00739     {
00740     case 0:
00741       if( sw_type == STAT_TYPE_ROBOT )
00742         {
00743           gtk_clist_set_compare_func( clist, float_compare );
00744           gtk_clist_set_sort_column( clist, column );
00745           gtk_clist_set_sort_type( clist, GTK_SORT_ASCENDING );
00746           gtk_clist_sort( clist );
00747         }
00748       break;
00749     case 1:
00750       if( sw_type != STAT_TYPE_ROBOT )
00751         {
00752           gtk_clist_set_compare_func( clist, string_case_insensitive_compare );
00753           gtk_clist_set_sort_column( clist, column );
00754           gtk_clist_set_sort_type( clist, GTK_SORT_ASCENDING );
00755           gtk_clist_sort( clist );
00756         }
00757       else
00758         {
00759           gtk_clist_set_compare_func( clist, float_compare );
00760           gtk_clist_set_sort_column( clist, column );
00761           gtk_clist_set_sort_type( clist, GTK_SORT_ASCENDING );
00762           gtk_clist_sort( clist );
00763         }
00764       break;
00765     case 2:
00766       gtk_clist_set_compare_func( clist, float_compare );
00767       gtk_clist_set_sort_column( clist, column );
00768       gtk_clist_set_sort_type( clist, GTK_SORT_ASCENDING );
00769       gtk_clist_sort( clist );
00770       break;
00771     case 3:
00772     case 5:
00773     case 6:
00774       gtk_clist_set_compare_func( clist, float_compare );
00775       gtk_clist_set_sort_column( clist, column );
00776       gtk_clist_set_sort_type( clist, GTK_SORT_DESCENDING );
00777       gtk_clist_sort( clist );
00778       break;
00779     case 4:
00780       if( sw_type == STAT_TYPE_TOTAL || sw_type == STAT_TYPE_SEQUENCE )
00781         {
00782           gtk_clist_set_compare_func( clist, float_compare );
00783           gtk_clist_set_sort_column( clist, column );
00784           gtk_clist_set_sort_type( clist, GTK_SORT_ASCENDING );
00785           gtk_clist_sort( clist );
00786         }
00787       break;
00788     }
00789   add_the_statistics_to_clist( GTK_WIDGET( clist ), sw_p );
00790   gtk_clist_thaw( clist );
00791 }

Here is the call graph for this function:

void StatisticsWindow::change_stats_viewed GtkWidget widget,
struct change_stat_data_t info_p
[static]
 

Definition at line 424 of file StatisticsWindow.cc.

References abs, add_the_statistics_to_clist(), StatisticsWindow::change_stat_data_t::change, clist, StatisticsWindow::change_stat_data_t::extreme_change, get_clist(), get_looking_at_nr(), get_type(), GtkWidget, max, min, set_looking_at_nr(), STAT_TYPE_GAME, STAT_TYPE_ROBOT, STAT_TYPE_SEQUENCE, STAT_TYPE_TOTAL, stat_types, StatisticsWindow::change_stat_data_t::sw_p, and the_arena.

Referenced by row_selected().

00426 {
00427   GtkWidget* clist = info_p->sw_p->get_clist();
00428   stat_types sw_type = info_p->sw_p->get_type();
00429   int number = info_p->sw_p->get_looking_at_nr();
00430 
00431   int game = the_arena.get_game_nr();
00432   int max_nr = -1;
00433 
00434   switch( sw_type )
00435     {
00436     case STAT_TYPE_TOTAL:
00437       max_nr = 1;
00438       break;
00439     case STAT_TYPE_SEQUENCE:
00440       max_nr = the_arena.get_sequence_nr();
00441       break;
00442     case STAT_TYPE_GAME:
00443       max_nr = ( the_arena.get_sequence_nr() - 1 ) *
00444         the_arena.get_games_per_sequence() + game;
00445       break;
00446     case STAT_TYPE_ROBOT:
00447       max_nr = the_arena.get_all_robots_in_tournament()->number_of_elements();
00448       break;
00449     }
00450 
00451   if( info_p->extreme_change && max_nr > 0 )
00452     {
00453       if( info_p->change < 0 )
00454         number = abs( info_p->change );
00455       else if( info_p->change > 0 )
00456         number = max( max_nr - info_p->change + 1, 1 );
00457     }
00458   else
00459     {
00460       number += info_p->change;
00461       number = min( number, max_nr );
00462       number = max( number, 1 );
00463     }
00464 
00465   info_p->sw_p->set_looking_at_nr( number );
00466   add_the_statistics_to_clist( clist, info_p->sw_p );
00467 }

Here is the call graph for this function:

void StatisticsWindow::change_table_type GtkWidget widget,
struct change_type_data_t info_p
[static]
 

Definition at line 342 of file StatisticsWindow.cc.

References _, add_the_statistics_to_clist(), change_sorting_in_clist(), clist, get_clist(), get_looking_at_nr(), get_type(), GtkWidget, set_looking_at_nr(), set_type(), STAT_TYPE_GAME, STAT_TYPE_ROBOT, STAT_TYPE_SEQUENCE, STAT_TYPE_TOTAL, stat_types, StatisticsWindow::change_type_data_t::sw_p, the_arena, and StatisticsWindow::change_type_data_t::type.

Referenced by row_selected().

00344 {
00345   GtkWidget* clist = info_p->sw_p->get_clist();
00346   stat_types sw_type = info_p->sw_p->get_type();
00347   int number = info_p->sw_p->get_looking_at_nr();
00348 
00349   gtk_clist_freeze( GTK_CLIST( clist ) );
00350 
00351   if( info_p->type != sw_type )
00352     {
00353       if( info_p->type == STAT_TYPE_TOTAL || info_p->type == STAT_TYPE_SEQUENCE )
00354         {
00355           gtk_clist_set_column_visibility( GTK_CLIST( clist ),4, TRUE );
00356         }
00357       else
00358         {
00359           gtk_clist_set_column_visibility ( GTK_CLIST( clist ),4,FALSE );
00360         }
00361       if(sw_type == STAT_TYPE_ROBOT && info_p->type != STAT_TYPE_ROBOT)
00362         {
00363           gtk_clist_set_column_resizeable( GTK_CLIST( clist ), 0, FALSE );
00364           gtk_clist_set_column_max_width( GTK_CLIST( clist ), 0, 5 );
00365 
00366           gtk_clist_set_column_auto_resize( GTK_CLIST( clist ), 0, FALSE );
00367           gtk_clist_set_column_auto_resize( GTK_CLIST( clist ), 1, FALSE );
00368           gtk_clist_set_column_title( GTK_CLIST( clist ), 0, "" );
00369           gtk_clist_set_column_title( GTK_CLIST( clist ), 1, _("Name") );
00370           gtk_clist_column_title_passive( GTK_CLIST( clist ), 0 );
00371           gtk_clist_set_column_width( GTK_CLIST( clist ), 0, 5 );
00372           gtk_clist_set_column_width( GTK_CLIST( clist ), 1, 120 );
00373           gtk_clist_set_column_justification( GTK_CLIST( clist ), 0,
00374                                               GTK_JUSTIFY_CENTER );
00375           gtk_clist_set_column_justification( GTK_CLIST( clist ), 1,
00376                                               GTK_JUSTIFY_LEFT );
00377         }
00378       if(sw_type != STAT_TYPE_ROBOT && info_p->type == STAT_TYPE_ROBOT)
00379         {
00380           gtk_clist_set_column_resizeable( GTK_CLIST( clist ), 0, TRUE );
00381           gtk_clist_set_column_max_width( GTK_CLIST( clist ), 0, 10000 );
00382 
00383           gtk_clist_set_column_auto_resize( GTK_CLIST( clist ), 0, TRUE );
00384           gtk_clist_set_column_auto_resize( GTK_CLIST( clist ), 1, TRUE );
00385           gtk_clist_set_column_title( GTK_CLIST( clist ), 0, _("Seq") );
00386           gtk_clist_set_column_title( GTK_CLIST( clist ), 1, _("Game") );
00387           gtk_clist_column_title_active( GTK_CLIST( clist ), 0 );
00388           gtk_clist_set_column_width( GTK_CLIST( clist ), 0, 40 );
00389           gtk_clist_set_column_width( GTK_CLIST( clist ), 1, 45 );
00390           gtk_clist_set_column_justification( GTK_CLIST( clist ), 0,
00391                                               GTK_JUSTIFY_RIGHT );
00392           gtk_clist_set_column_justification( GTK_CLIST( clist ), 1,
00393                                               GTK_JUSTIFY_RIGHT );
00394         }
00395       info_p->sw_p->set_type( info_p->type );
00396 
00397       switch( info_p->type )
00398         {
00399         case STAT_TYPE_TOTAL:
00400           change_sorting_in_clist( GTK_CLIST( clist ), 6, info_p->sw_p );
00401           break;
00402         case STAT_TYPE_SEQUENCE:
00403           change_sorting_in_clist( GTK_CLIST( clist ), 6, info_p->sw_p );
00404           number = the_arena.get_sequence_nr();
00405           break;
00406         case STAT_TYPE_GAME:
00407           change_sorting_in_clist( GTK_CLIST( clist ), 3, info_p->sw_p );
00408           number = ( the_arena.get_sequence_nr() - 1 ) *
00409             the_arena.get_games_per_sequence() + the_arena.get_game_nr();
00410           break;
00411         case STAT_TYPE_ROBOT:
00412           change_sorting_in_clist( GTK_CLIST( clist ), 0, info_p->sw_p );
00413           number = 1;
00414           break;
00415         }
00416       info_p->sw_p->set_looking_at_nr( number );
00417     }
00418 
00419   add_the_statistics_to_clist( clist, info_p->sw_p );
00420   gtk_clist_thaw( GTK_CLIST( clist ) );
00421 }

Here is the call graph for this function:

void StatisticsWindow::delete_event_occured GtkWidget widget,
GdkEvent event,
class StatisticsWindow sw_p
[static]
 

Definition at line 288 of file StatisticsWindow.cc.

References Gui::close_statisticswindow(), and the_gui.

Referenced by StatisticsWindow().

00290 {
00291   the_gui.close_statisticswindow();
00292 }

Here is the call graph for this function:

void StatisticsWindow::destroy_filesel GtkWidget widget,
class StatisticsWindow sw_p
[static]
 

Definition at line 334 of file StatisticsWindow.cc.

Referenced by save(), and save_stats().

00336 {
00337   gtk_widget_destroy( sw_p->get_filesel() );
00338   sw_p->set_filesel( NULL );
00339 }

void StatisticsWindow::exit GtkWidget widget,
class StatisticsWindow sw_p
[static]
 

Definition at line 295 of file StatisticsWindow.cc.

References Gui::close_statisticswindow(), and the_gui.

00296 {
00297   the_gui.close_statisticswindow();
00298 }

Here is the call graph for this function:

GtkWidget* StatisticsWindow::get_clist  )  [inline]
 

Definition at line 102 of file StatisticsWindow.h.

References GtkWidget.

Referenced by change_stats_viewed(), and change_table_type().

00102 { return clist; }

GtkWidget* StatisticsWindow::get_filesel  )  [inline, private]
 

Definition at line 110 of file StatisticsWindow.h.

References GtkWidget.

00110 { return filesel; }

int StatisticsWindow::get_looking_at_nr  )  [inline]
 

Definition at line 104 of file StatisticsWindow.h.

Referenced by change_stats_viewed(), and change_table_type().

00104 { return looking_at_nr; }

enum stat_types StatisticsWindow::get_type  )  [inline]
 

Definition at line 103 of file StatisticsWindow.h.

Referenced by change_stats_viewed(), and change_table_type().

00103 { return type; }

GtkWidget* StatisticsWindow::get_window_p  )  [inline]
 

Definition at line 101 of file StatisticsWindow.h.

References GtkWidget.

Referenced by OptionsWindow::grab_windows().

00101 { return window_p; }

void StatisticsWindow::make_title_button  ) 
 

Definition at line 470 of file StatisticsWindow.cc.

References _, String::chars(), Robot::get_robot_name(), Robot::get_stat_pixmap(), GtkWidget, looking_at_nr, ListIterator< T >::ok(), STAT_TYPE_GAME, STAT_TYPE_ROBOT, STAT_TYPE_SEQUENCE, STAT_TYPE_TOTAL, the_arena, title_button, title_button_hbox, and window_p.

00471 {
00472   if( title_button_hbox != NULL )
00473     gtk_widget_destroy( title_button_hbox );
00474   title_button_hbox = gtk_hbox_new( FALSE, 10 );
00475   gtk_container_add( GTK_CONTAINER( title_button ), title_button_hbox );
00476   gtk_widget_show( title_button_hbox );
00477 
00478   String title;
00479   switch( type )
00480     {
00481     case STAT_TYPE_TOTAL:
00482       title = _(" Grand Total ");
00483       break;
00484     case STAT_TYPE_SEQUENCE:
00485       title = (String) _(" Sequence ") + String( looking_at_nr );
00486       break;
00487     case STAT_TYPE_GAME:
00488       {
00489         int gps = the_arena.get_games_per_sequence();
00490         int game = looking_at_nr % gps;
00491         int sequence = (looking_at_nr / gps ) + 1;
00492         if( game == 0 )
00493           {
00494             game = gps;
00495             sequence--;
00496           }
00497         title = (String) _(" Sequence: ") + String( sequence ) + "  " +
00498           _("Game") + ": " + String( game );
00499       }
00500       break;
00501     case STAT_TYPE_ROBOT:
00502       {
00503         Robot* robot_p;
00504 
00505         int i=0;
00506         ListIterator<Robot> li;
00507         for( the_arena.get_all_robots_in_tournament()->first(li); li.ok(); li++ )
00508           {
00509             i++;
00510             robot_p = li();
00511             if( looking_at_nr == i )
00512               {
00513                 GdkPixmap* col_pixmap;
00514                 GdkBitmap* bitmap_mask;
00515                 robot_p->get_stat_pixmap(window_p->window, col_pixmap, bitmap_mask);
00516                 GtkWidget* pixmap_w = gtk_pixmap_new( col_pixmap, bitmap_mask );
00517                 gtk_box_pack_start( GTK_BOX( title_button_hbox ),
00518                                     pixmap_w, FALSE, FALSE, 0 );
00519                 gtk_widget_show( pixmap_w );
00520                 title = robot_p->get_robot_name();
00521               }
00522           }
00523       }
00524       break;
00525     }
00526 
00527   GtkWidget* label = gtk_label_new( title.chars() );
00528   gtk_box_pack_start( GTK_BOX( title_button_hbox ), label, TRUE, TRUE, 0 );
00529   gtk_widget_show( label );
00530 }

Here is the call graph for this function:

void StatisticsWindow::row_selected GtkWidget clist,
gint  row,
gint  column,
GdkEventButton event,
class StatisticsWindow sw_p
[static]
 

Definition at line 794 of file StatisticsWindow.cc.

References change_stats_viewed(), change_table_type(), Robot::get_robot_name(), ListIterator< T >::ok(), STAT_TYPE_ROBOT, stat_types, and the_arena.

Referenced by StatisticsWindow().

00797 {
00798   stat_types sw_type = sw_p->get_type();
00799 
00800   if( column == 1 && sw_type != STAT_TYPE_ROBOT )
00801     {
00802       gtk_clist_freeze( GTK_CLIST( clist ) );
00803 
00804       gchar* clist_text;
00805 
00806       gtk_clist_get_text( GTK_CLIST( clist ), row, column, &clist_text );
00807       String robot_name;
00808       if( clist_text != NULL )
00809         robot_name = clist_text;
00810 
00811       ListIterator<Robot> li;
00812       Robot* robot_p = NULL;
00813       int counter = 0;
00814       bool found_robot = false;
00815       for( the_arena.get_all_robots_in_tournament()->first(li);
00816            li.ok() && !found_robot; li++ )
00817         {
00818           counter--;
00819           robot_p = li();
00820           if( robot_p->get_robot_name() == robot_name )
00821             {
00822               found_robot = true;
00823               change_type_data_t type_data( STAT_TYPE_ROBOT, sw_p );
00824               change_table_type( clist, &type_data );
00825 
00826               change_stat_data_t stat_data( counter, true, sw_p );
00827               change_stats_viewed( clist, &stat_data );
00828             }
00829         }
00830       gtk_clist_thaw( GTK_CLIST( clist ) );
00831     }
00832 }

Here is the call graph for this function:

void StatisticsWindow::save GtkWidget widget,
class StatisticsWindow sw_p
[static]
 

Definition at line 301 of file StatisticsWindow.cc.

References _, destroy_filesel(), gpointer, and GtkWidget.

00302 {
00303   if( sw_p->get_filesel() != NULL )
00304     return;
00305 
00306   GtkWidget* fs =
00307     gtk_file_selection_new( _("Choose a statistics file to save") );
00308   gtk_signal_connect( GTK_OBJECT( fs ), "destroy",
00309                       (GtkSignalFunc) StatisticsWindow::destroy_filesel,
00310                       (gpointer) sw_p );
00311   gtk_signal_connect
00312     ( GTK_OBJECT( GTK_FILE_SELECTION( fs )->cancel_button ), "clicked",
00313       (GtkSignalFunc) StatisticsWindow::destroy_filesel,
00314       (gpointer) sw_p );
00315   gtk_signal_connect
00316     ( GTK_OBJECT( GTK_FILE_SELECTION( fs )->ok_button ), "clicked",
00317       (GtkSignalFunc) StatisticsWindow::save_stats,
00318       (gpointer) sw_p );
00319   gtk_widget_show( fs );
00320   sw_p->set_filesel( fs );
00321 }

Here is the call graph for this function:

void StatisticsWindow::save_stats GtkWidget widget,
class StatisticsWindow sw_p
[static]
 

Definition at line 324 of file StatisticsWindow.cc.

References destroy_filesel(), and the_arena.

00326 {
00327   the_arena.save_statistics_to_file
00328     ( gtk_file_selection_get_filename
00329       ( GTK_FILE_SELECTION( sw_p->get_filesel() ) ) );
00330   destroy_filesel( sw_p->get_filesel(), sw_p );
00331 }

Here is the call graph for this function:

void StatisticsWindow::set_filesel GtkWidget fs  )  [inline, private]
 

Definition at line 111 of file StatisticsWindow.h.

00111 { filesel = fs; } 

void StatisticsWindow::set_looking_at_nr const int  number  )  [inline]
 

Definition at line 105 of file StatisticsWindow.h.

Referenced by change_stats_viewed(), and change_table_type().

00106     { looking_at_nr = number; }

void StatisticsWindow::set_type stat_types  t  )  [inline]
 

Definition at line 107 of file StatisticsWindow.h.

Referenced by change_table_type().

00107 { type = t; }


Field Documentation

GtkWidget* StatisticsWindow::clist [private]
 

Definition at line 114 of file StatisticsWindow.h.

Referenced by add_new_row(), add_the_statistics_to_clist(), change_stats_viewed(), change_table_type(), and StatisticsWindow().

GtkWidget* StatisticsWindow::filesel [private]
 

Definition at line 117 of file StatisticsWindow.h.

Referenced by StatisticsWindow().

int StatisticsWindow::looking_at_nr [private]
 

Definition at line 120 of file StatisticsWindow.h.

Referenced by make_title_button(), and StatisticsWindow().

GtkWidget* StatisticsWindow::title_button [private]
 

Definition at line 115 of file StatisticsWindow.h.

Referenced by make_title_button(), and StatisticsWindow().

GtkWidget* StatisticsWindow::title_button_hbox [private]
 

Definition at line 116 of file StatisticsWindow.h.

Referenced by make_title_button(), and StatisticsWindow().

stat_types StatisticsWindow::type [private]
 

Definition at line 119 of file StatisticsWindow.h.

Referenced by add_new_row(), and StatisticsWindow().

GtkWidget* StatisticsWindow::window_p [private]
 

Definition at line 113 of file StatisticsWindow.h.

Referenced by add_new_row(), make_title_button(), StatisticsWindow(), and ~StatisticsWindow().


The documentation for this class was generated from the following files:
Generated on Fri Oct 15 15:51:42 2004 for Real Time Battle by  doxygen 1.3.9.1