[Avida-SVN] r2871 - branches/vo/source/targets/viewer-fltk

michaelvo at myxo.css.msu.edu michaelvo at myxo.css.msu.edu
Fri Oct 24 08:00:49 PDT 2008


Author: michaelvo
Date: 2008-10-24 11:00:49 -0400 (Fri, 24 Oct 2008)
New Revision: 2871

Added:
   branches/vo/source/targets/viewer-fltk/cFLTKChart.h
   branches/vo/source/targets/viewer-fltk/cFLTKGroup.h
   branches/vo/source/targets/viewer-fltk/cFLTKMapScreen.h
   branches/vo/source/targets/viewer-fltk/cFLTKScreen.h
   branches/vo/source/targets/viewer-fltk/cFLTKStats.h
   branches/vo/source/targets/viewer-fltk/cFLTKTable.cpp
   branches/vo/source/targets/viewer-fltk/cFLTKTable.h
   branches/vo/source/targets/viewer-fltk/cFLTKTabs.h
   branches/vo/source/targets/viewer-fltk/cFLTKZoom.h
   branches/vo/source/targets/viewer-fltk/oldstats.h
Modified:
   branches/vo/source/targets/viewer-fltk/cDriver_FLTKViewer.cc
   branches/vo/source/targets/viewer-fltk/cDriver_FLTKViewer.h
Log:
Added a bunch of files.  Not all of these are necessary, and I'll be deleting some shortly.



Modified: branches/vo/source/targets/viewer-fltk/cDriver_FLTKViewer.cc
===================================================================
--- branches/vo/source/targets/viewer-fltk/cDriver_FLTKViewer.cc	2008-10-24 04:14:18 UTC (rev 2870)
+++ branches/vo/source/targets/viewer-fltk/cDriver_FLTKViewer.cc	2008-10-24 15:00:49 UTC (rev 2871)
@@ -45,6 +45,10 @@
 #include "tFLTKButton.h"
 #include "avidalogo.xpm"
 #include "cFLTKStats.h"
+#include "cFLTKMapScreen.h"
+#include "cFLTKChart.h"
+#include "cFLTKTabs.h"
+#include "cFLTKGroup.h"
 #include <cstdlib>
 
 #include <FL/Fl.H>
@@ -79,43 +83,48 @@
 {
   // Setup the initial view mode (loaded from avida.cfg)
   m_info.SetViewMode(world->GetConfig().VIEW_MODE.Get());
+  m_body_box = new cFLTKBox(m_main_window, 0, 0, FLTK_MAINWIN_WIDTH, FLTK_BODY_HEIGHT);
+  m_title_box = new cFLTKBox(m_main_window,    0, FLTK_MENU2_Y,  80, FLTK_MENUBAR_HEIGHT);
+  m_tabs = new cFLTKTabs(10, 10, FLTK_MAINWIN_WIDTH-20, FLTK_MENU2_Y-15);
 
-  
-  Fl_Tabs* tabs = new Fl_Tabs(10, 10, FLTK_MAINWIN_WIDTH-20, FLTK_MENU2_Y-15);
-  
   Fl_Group* a = new Fl_Group(10, 35, FLTK_MAINWIN_WIDTH-20, FLTK_MENU2_Y-15, "&Map");
-  //fl_color(0xDD, 0xDD, 0xFF);
-  //a->color(fl_color());
-  //m_main_window = new cFLTKWindow(FLTK_MAINWIN_WIDTH, FLTK_MAINWIN_HEIGHT, "Avida");
-  m_body_box = new cFLTKBox(m_main_window, 0, 0, FLTK_MAINWIN_WIDTH, FLTK_BODY_HEIGHT);
-  m_title_box = new cFLTKBox(m_main_window,    0, FLTK_MENU2_Y,  80, FLTK_MENUBAR_HEIGHT);
-  m_grid_view = new cFLTKGridView(m_info, m_main_window, FLTK_SPACING+20, FLTK_SPACING+50, FLTK_GRID_SIDE, FLTK_GRID_SIDE);
-  
-  m_legend = new cFLTKLegend(*m_grid_view, m_main_window, FLTK_GRID_SIDE + 2*FLTK_SPACING+20, FLTK_SPACING+50, FLTK_SIDEBAR_WIDTH, FLTK_SIDEBAR_HEIGHT);
-  m_grid_view_menu = new tFLTKMenu<cDriver_FLTKViewer>(m_main_window,   140, FLTK_MENU1_Y, 80, 30, "View:");
-  m_grid_tags_menu = new tFLTKMenu<cDriver_FLTKViewer>(m_main_window,   270, FLTK_MENU1_Y, 80, 30, "Tags:");
-  m_grid_symbol_menu = new tFLTKMenu<cDriver_FLTKViewer>(m_main_window, 400, FLTK_MENU1_Y, 80, 30, "Mark:");
-  
+  {
+    cFLTKScreen* s = new cFLTKMapScreen(m_world, &m_main_window);
+    m_screen.Add(s);
+  }
   a->end();
   
   Fl_Group* b = new Fl_Group(10, 35, FLTK_MAINWIN_WIDTH-20, FLTK_MENU2_Y-15, "&Zoom");
   {
-		m_zoom_screen=new cFLTKZoom(world);
+    cFLTKScreen* s = new cFLTKZoom(m_world);
+    m_screen.Add(s);
 	}
   
   b->end();
 
   Fl_Group* c = new Fl_Group(10, 35, FLTK_MAINWIN_WIDTH-20, FLTK_MENU2_Y-15, "&Stats");
 	{
-    m_stats_screen= new cFLTKStats(m_world);
+    cFLTKScreen* s = new cFLTKStats(m_world);
+    m_screen.Add(s);
 	}
+  
 	c->end();
-  tabs->end();
-
+  
+  Fl_Group* d = new Fl_Group(10, 35, FLTK_MAINWIN_WIDTH-20, FLTK_MENU2_Y-15, "&Chart");
+	{
+    cFLTKScreen* s = new cFLTKChart(m_world);
+    m_screen.Add(s);
+	}
+  
+	d->end();
+  
+  m_tabs->Finalize();
+    
   m_update_box = new cFLTKBox(m_main_window, 100, FLTK_MENU2_Y, 200, FLTK_MENUBAR_HEIGHT, "Update: 0");
   m_pause_button = new tFLTKButton<cDriver_FLTKViewer>(m_main_window,     400, FLTK_MENU2_Y, 30, 30, "@||");
   m_quit_button = new tFLTKButton<cDriver_FLTKViewer>(m_main_window,      440, FLTK_MENU2_Y, 30, 30, "@square");
-  //m_org_inst_buffer->text("N/A");
+  m_pop_button = new tFLTKButton<cDriver_FLTKViewer>(m_main_window,       685, 560, 90, 30, "Pop Out");
+  
   cDriverManager::Register(static_cast<cAvidaDriver*>(this));
   world->SetDriver(this);
 	
@@ -137,35 +146,15 @@
   m_title_box->SetTooltip(title_tooltip);
   //m_title_box->SetImage_XPM(avidalogo);
   m_title_box->Refresh();
-
-  cCoreView_Map & map_info = m_grid_view->GetMapInfo();
-  int num_modes = map_info.GetNumModes();
   
-  for (int i = 0; i < num_modes; i++) {
-    const cString & cur_name = map_info.GetModeName(i);
-    const int cur_type = map_info.GetModeType(i);	
-    if (cur_type == cCoreView_Map::VIEW_COLOR) {
-      m_grid_view_menu->AddOption(cur_name, this, &cDriver_FLTKViewer::MenuCallback_View, i);
-    } else if (cur_type == cCoreView_Map::VIEW_TAGS) {
-      m_grid_tags_menu->AddOption(cur_name, this, &cDriver_FLTKViewer::MenuCallback_View, i);
-    } else if (cur_type == cCoreView_Map::VIEW_SYMBOLS) {
-      m_grid_symbol_menu->AddOption(cur_name, this, &cDriver_FLTKViewer::MenuCallback_View, i);
-    }
-	
-  }
 
-  m_grid_view_menu->SetActive(0);
-  m_grid_tags_menu->SetActive(0);
-  m_grid_symbol_menu->SetActive(0);
-
-
   m_pause_button->SetCallback(this, &cDriver_FLTKViewer::ButtonCallback_Pause);
   m_pause_button->SetTooltip("Pause");
   m_quit_button->SetCallback(this, &cDriver_FLTKViewer::ButtonCallback_Quit);
   m_quit_button->SetFontColor(cColor::DARK_RED);
   m_quit_button->SetFontSize(12);
   m_quit_button->SetTooltip("Quit");
-
+  m_pop_button->SetCallback(this, &cDriver_FLTKViewer::ButtonCallback_Pop);
   m_main_window.Finalize();
 }
 
@@ -316,11 +305,9 @@
   m_info.SetupUpdate();
   m_update_box->SetLabel(curr_update);
   
-  m_grid_view->Redraw();
-  m_legend->Redraw();
+  for(int n=0; n<m_screen.Size(); n++)
+    m_screen[n]->Redraw();
   
-	m_zoom_screen->Redraw();
-	m_stats_screen->Redraw();
   const int pause_level = m_info.GetPauseLevel();
 
   // If we are stepping in some way, we've come to a stop, so revert to a normal pause.
@@ -338,6 +325,7 @@
   while (m_info.GetPauseLevel() == cCoreView_Info::PAUSE_ON) {
     error = Fl::check();
   }
+  
 }
 
 void cDriver_FLTKViewer::NotifyComment(const cString& in_string)
@@ -399,14 +387,28 @@
   }
 }
 
+void cDriver_FLTKViewer::ButtonCallback_Pop(double ignore)
+{
+  cString curr_tab = m_tabs->GetCurrentTabName();
+  cFLTKScreen* s;
 
-void cDriver_FLTKViewer::MenuCallback_View(int new_mode)
-{
-  m_grid_view->GetMapInfo().SetMode(new_mode);
+  cFLTKWindow* win = new cFLTKWindow(800, 600, curr_tab);
+  if(curr_tab=="&Stats")
+    s = new cFLTKStats(m_world);
+  else if(curr_tab=="&Map")
+    s = new cFLTKMapScreen(m_world, &m_main_window);
+  else
+    s = new cFLTKZoom(m_world);
+  
+  win->Finalize();
+  m_screen.Add(s);
 }
 
 
 
+
+
+
 void ExitFLTKViewer(int exit_code)
 {
   signal(SIGINT, SIG_IGN);           // Ignore all future interupts.

Modified: branches/vo/source/targets/viewer-fltk/cDriver_FLTKViewer.h
===================================================================
--- branches/vo/source/targets/viewer-fltk/cDriver_FLTKViewer.h	2008-10-24 04:14:18 UTC (rev 2870)
+++ branches/vo/source/targets/viewer-fltk/cDriver_FLTKViewer.h	2008-10-24 15:00:49 UTC (rev 2871)
@@ -26,7 +26,7 @@
 #define cDriver_FLTKViewer_h
 
 #ifndef cAvidaDriver_h
-#include "cAvidaDriver.h"Ä
+#include "cAvidaDriver.h"
 #endif
 
 #ifndef cCoreView_Info_h
@@ -46,8 +46,11 @@
 #include "tFLTKMenu.h"
 #include <FL/Fl_Text_Display.H>
 #include <FL/Fl_Multiline_Output.H>
+#include <FL/Fl_Tabs.h>
 #include "cFLTKZoom.h"
+#include "cFLTKScreen.h"
 #include "cFLTKStats.h"
+#include "cFLTKTabs.h"
 #include <sstream>
 #include <iostream>
 #include <fstream>
@@ -73,23 +76,15 @@
 
   cFLTKBox* m_update_box;
   cFLTKBox* m_title_box;
-
-  cFLTKGridView* m_grid_view;
-  cFLTKLegend* m_legend;
-  cFLTKZoom* m_zoom_screen;
-  cFLTKStats* m_stats_screen;
-  tFLTKMenu<cDriver_FLTKViewer>* m_grid_view_menu;
-  tFLTKMenu<cDriver_FLTKViewer>* m_grid_tags_menu;
-  tFLTKMenu<cDriver_FLTKViewer>* m_grid_symbol_menu;
+  
+  tVector<cFLTKScreen*> m_screen;
   tFLTKButton<cDriver_FLTKViewer>* m_pause_button;
   tFLTKButton<cDriver_FLTKViewer>* m_quit_button;
-  
+  tFLTKButton<cDriver_FLTKViewer>* m_pop_button;
 
-  Fl_Multiline_Output* m_pop_stats_label;
-  Fl_Multiline_Output* m_pop_dominant_label;
-  Fl_Multiline_Output* m_pop_average_label;
-  Fl_Multiline_Output* m_task_label;
 
+  cFLTKTabs* m_tabs;
+
 public:
   cDriver_FLTKViewer(cWorld* world);
   ~cDriver_FLTKViewer();
@@ -128,9 +123,8 @@
   // Button Callbacks...
   void ButtonCallback_Quit(double ignore);
   void ButtonCallback_Pause(double ignore);
+  void ButtonCallback_Pop(double ignore);
 
-  // Menu Callbacks
-  void MenuCallback_View(int new_mode);
 
 };
 

Added: branches/vo/source/targets/viewer-fltk/cFLTKChart.h
===================================================================
--- branches/vo/source/targets/viewer-fltk/cFLTKChart.h	                        (rev 0)
+++ branches/vo/source/targets/viewer-fltk/cFLTKChart.h	2008-10-24 15:00:49 UTC (rev 2871)
@@ -0,0 +1,52 @@
+/*
+ *  cFLTKChart.h
+ *  
+ *
+ *  Created by Michael Vo on 10/24/08.
+ *  Copyright 2008 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+/*
+ *  cFLTKStats.h
+ *  
+ *
+ *  Created by Michael Vo on 8/3/08.
+ *  Copyright 2008 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#ifndef cFLTKChart_h
+#define cFLTKChart_h
+
+#include "cCoreView_Text.h"
+#include <FL/Fl_Text_Display.H>
+#include <FL/Fl_Multiline_Output.H>
+#include <FL/Fl_Box.H>
+#include <Fl/Fl_Chart.H>
+#include "cWorld.h"
+#include "cFLTKScreen.h"
+
+class cFLTKChart : public cFLTKScreen {
+private:
+	cWorld* m_world;
+  Fl_Chart* chart;
+public:
+
+  cFLTKChart(cWorld* world) : m_world(world)
+  {
+	  chart = new Fl_Chart( 100, 100, 300, 115);
+    chart->type(FL_LINE_CHART);
+  }
+	
+	void Redraw()
+	{
+    chart->add(m_world->GetStats().GetAveFitness());
+    //m_world->GetStats().GetAveFitness();
+    chart->bounds(0, m_world->GetStats().GetAveFitness());
+  }
+
+};
+
+
+#endif

Added: branches/vo/source/targets/viewer-fltk/cFLTKGroup.h
===================================================================
--- branches/vo/source/targets/viewer-fltk/cFLTKGroup.h	                        (rev 0)
+++ branches/vo/source/targets/viewer-fltk/cFLTKGroup.h	2008-10-24 15:00:49 UTC (rev 2871)
@@ -0,0 +1,39 @@
+/*
+ *  cFLTKGroup.h
+ *  
+ *
+ *  Created by Michael Vo on 10/24/08.
+ *  Copyright 2008 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+
+#ifndef cFLTKGroup_h
+#define cFLTKGroup_h
+
+#include "cFLTKWidget.h"
+
+#include <FL/Fl_Group.h>
+
+class cFLTKGroup : public cGUIContainer, cFLTKWidget {
+protected:
+  Fl_Group * m_group;
+
+public:
+  cFLTKGroup(int x, int y, int width, int height, const cString & name="")
+    : cFLTKWidget(this)
+  {
+    m_group = new Fl_Group(x, y, width, height, name);
+    SetWidget(m_group);
+  }
+  
+  void Finalize() { 
+    m_group->end();
+  }
+    
+  ~cFLTKGroup() { delete m_group; }
+
+  Fl_Group * GetFLTKPtr() { return m_group; }
+};
+
+#endif
\ No newline at end of file

Added: branches/vo/source/targets/viewer-fltk/cFLTKMapScreen.h
===================================================================
--- branches/vo/source/targets/viewer-fltk/cFLTKMapScreen.h	                        (rev 0)
+++ branches/vo/source/targets/viewer-fltk/cFLTKMapScreen.h	2008-10-24 15:00:49 UTC (rev 2871)
@@ -0,0 +1,90 @@
+
+
+#ifndef cFLTKMap_h
+#define cFLTKMap_h
+
+#include "cCoreView_Text.h"
+#include <FL/Fl_Text_Display.H>
+#include <FL/Fl_Multiline_Output.H>
+#include <FL/Fl_Box.H>
+#include "cWorld.h"
+#include "tFLTKButton.h"
+#include <FL/Fl_Return_Button.H>
+#include "cFLTKGridView.h"
+#include "cFLTKScreen.h"
+#include "cFLTKWindow.h"
+#include "tFLTKMenu.h"
+
+#define FLTK_MAINWIN_WIDTH  800
+#define FLTK_MAINWIN_HEIGHT 600
+#define FLTK_MENUBAR_HEIGHT 35
+#define FLTK_SPACING 5
+#define FLTK_GRID_SIDE 450
+
+#define FLTK_SIDEBAR_WIDTH (FLTK_MAINWIN_WIDTH - FLTK_GRID_SIDE - 3*FLTK_SPACING-20)
+#define FLTK_SIDEBAR_HEIGHT (FLTK_MAINWIN_HEIGHT - 2*FLTK_SPACING-20)
+#define FLTK_BODY_HEIGHT (FLTK_MAINWIN_HEIGHT - 2 * FLTK_MENUBAR_HEIGHT - 2 * FLTK_SPACING)
+#define FLTK_MENU1_Y FLTK_BODY_HEIGHT
+#define FLTK_MENU2_Y (FLTK_MENU1_Y + FLTK_MENUBAR_HEIGHT + FLTK_SPACING)
+
+#define FLTK_MENU_FONT_SIZE 20
+
+
+class cFLTKMapScreen : public cFLTKScreen{
+private:
+  cFLTKGridView* m_grid_view;
+  cFLTKLegend* m_legend;
+  tFLTKMenu<cFLTKMapScreen>* m_grid_view_menu;
+  tFLTKMenu<cFLTKMapScreen>* m_grid_tags_menu;
+  tFLTKMenu<cFLTKMapScreen>* m_grid_symbol_menu;
+
+  cCoreView_Info m_info;
+  cFLTKWindow* m_main_window;
+public:
+
+  cFLTKMapScreen(cWorld* world, cFLTKWindow* window) : m_info(world, 18)
+  {
+    //m_world = world;
+    m_main_window = window;
+    m_grid_view = new cFLTKGridView(m_info, *m_main_window, FLTK_SPACING+20, FLTK_SPACING+50, FLTK_GRID_SIDE, FLTK_GRID_SIDE);
+  
+    m_legend = new cFLTKLegend(*m_grid_view, *m_main_window, FLTK_GRID_SIDE + 2*FLTK_SPACING+20, FLTK_SPACING+50, FLTK_SIDEBAR_WIDTH, FLTK_SIDEBAR_HEIGHT);
+    m_grid_view_menu = new tFLTKMenu<cFLTKMapScreen>(*m_main_window,   140, FLTK_MENU1_Y, 80, 30, "View:");
+    m_grid_tags_menu = new tFLTKMenu<cFLTKMapScreen>(*m_main_window,   270, FLTK_MENU1_Y, 80, 30, "Tags:");
+    m_grid_symbol_menu = new tFLTKMenu<cFLTKMapScreen>(*m_main_window, 400, FLTK_MENU1_Y, 80, 30, "Mark:");
+    cCoreView_Map & map_info = m_grid_view->GetMapInfo();
+    int num_modes = map_info.GetNumModes();
+    
+    for (int i = 0; i < num_modes; i++) {
+      const cString & cur_name = map_info.GetModeName(i);
+      const int cur_type = map_info.GetModeType(i);	
+      if (cur_type == cCoreView_Map::VIEW_COLOR) {
+        m_grid_view_menu->AddOption(cur_name, this, &cFLTKMapScreen::MenuCallback_View, i);
+      } else if (cur_type == cCoreView_Map::VIEW_TAGS) {
+        m_grid_tags_menu->AddOption(cur_name, this, &cFLTKMapScreen::MenuCallback_View, i);
+      } else if (cur_type == cCoreView_Map::VIEW_SYMBOLS) {
+        m_grid_symbol_menu->AddOption(cur_name, this, &cFLTKMapScreen::MenuCallback_View, i);
+      }
+    
+    }
+
+    m_grid_view_menu->SetActive(0);
+    m_grid_tags_menu->SetActive(0);
+    m_grid_symbol_menu->SetActive(0);
+  }
+	
+	void Redraw()
+	{
+    m_grid_view->Redraw();
+    m_legend->Redraw();
+	}
+
+  void MenuCallback_View(int new_mode)
+  {
+    m_grid_view->GetMapInfo().SetMode(new_mode);
+  }
+
+
+};
+
+#endif
\ No newline at end of file

Added: branches/vo/source/targets/viewer-fltk/cFLTKScreen.h
===================================================================
--- branches/vo/source/targets/viewer-fltk/cFLTKScreen.h	                        (rev 0)
+++ branches/vo/source/targets/viewer-fltk/cFLTKScreen.h	2008-10-24 15:00:49 UTC (rev 2871)
@@ -0,0 +1,11 @@
+#ifndef cFLTKScreen_h
+#define cFLTKScreen_h
+
+
+class cFLTKScreen {
+  public:
+    virtual void Redraw()=0;
+};
+
+#endif
+

Added: branches/vo/source/targets/viewer-fltk/cFLTKStats.h
===================================================================
--- branches/vo/source/targets/viewer-fltk/cFLTKStats.h	                        (rev 0)
+++ branches/vo/source/targets/viewer-fltk/cFLTKStats.h	2008-10-24 15:00:49 UTC (rev 2871)
@@ -0,0 +1,94 @@
+/*
+ *  cFLTKStats.h
+ *  
+ *
+ *  Created by Michael Vo on 8/3/08.
+ *  Copyright 2008 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#ifndef cFLTKStats_h
+#define cFLTKStats_h
+
+#include "cCoreView_Text.h"
+#include <FL/Fl_Text_Display.H>
+#include <FL/Fl_Multiline_Output.H>
+#include <FL/Fl_Box.H>
+#include "cWorld.h"
+#include "cFLTKScreen.h"
+#include "cFLTKTable.h"
+
+class cFLTKStats : public cFLTKScreen {
+private:
+  cFLTKTable* m_stats_table;
+  cFLTKTable* m_task_table;
+  cFLTKTable* m_general_table;
+	cWorld* m_world;
+public:
+
+
+  cFLTKStats(cWorld* world) : m_world(world)
+  {
+    tVector<int> widths;
+    for(int n=0; n<3; n++)
+      widths.Add(100);
+    m_stats_table = new cFLTKTable(75, 75, widths, 180);
+    m_stats_table->ChangeHeader(1, "Dominant");
+    m_stats_table->ChangeHeader(2, "Average");
+    m_stats_table->ChangeColumn(0, "Fitness:\nMerit:\nGestation:\nLength:\nCopy Length:\nExec Length:\nAbundance:\nBirths:\nBirthrate:\nTree Depth:\nGen. Ave:");
+    
+    widths.Clear();
+    for(int n=0; n<2; n++)
+      widths.Add(100);
+    m_task_table = new cFLTKTable(400, 75, widths, 180);
+    m_task_table->ChangeHeader(0, "Task Name");
+    m_task_table->ChangeHeader(1, "Performance");
+    
+    cString task_string="";
+    for(int n=0; n<m_world->GetEnvironment().GetNumTasks(); n++){
+      task_string+=m_world->GetEnvironment().GetTask(n).GetName();
+      task_string+="\n";
+    }
+    m_task_table->ChangeColumn(0, task_string);
+    
+    widths.Clear();
+    for(int n=0; n<2; n++)
+      widths.Add(150);
+    m_general_table = new cFLTKTable(75, 290, widths, 100);
+    m_general_table->ChangeColumn(0, "Total Births:\nBreedTrue:\nParasites:\nEnergy:\nMax Fitness:\nMax Merit:");
+  }
+	
+	void Redraw()
+	{
+  
+		cString stats_string;
+		stats_string.Set("%d\n%d\n%d\n%f\n%f\n%f", m_world->GetStats().GetNumBirths(), m_world->GetStats().GetBreedTrue(),
+			m_world->GetStats().GetNumParasites(), m_world->GetStats().GetEnergy(), m_world->GetStats().GetMaxFitness(), m_world->GetStats().GetMaxMerit());
+    m_general_table->ChangeColumn(1, stats_string);
+		
+		stats_string.Set("%f \n%f \n%f \n%d \n%f \n%f \n%d \n%d \n%f \n%d", m_world->GetStats().GetDomFitness(), m_world->GetStats().GetDomMerit(),
+			m_world->GetStats().GetDomGestation(), m_world->GetStats().GetDomSize(), m_world->GetStats().GetDomCopySize(), m_world->GetStats().GetDomExeSize(),
+			m_world->GetStats().GetDomAbundance(), m_world->GetStats().GetDomBirths(), m_world->GetStats().GetDomReproRate(), m_world->GetStats().GetDomGeneDepth());
+    m_stats_table->ChangeColumn(1, stats_string);
+		
+		stats_string.Set("%f \n%f \n%f \n%f \n%f \n%f \n%f \n%f \n%f \n%f \n%f", m_world->GetStats().GetAveFitness(), m_world->GetStats().GetAveMerit(),
+			m_world->GetStats().GetAveGestation(), m_world->GetStats().GetAveSize(), m_world->GetStats().GetAveCopySize(), m_world->GetStats().GetAveExeSize(),
+			double(m_world->GetStats().GetNumCreatures())/m_world->GetStats().GetNumGenotypes(),
+			0,
+			m_world->GetStats().GetAveReproRate(), 0,0);
+
+    m_stats_table->ChangeColumn(2, stats_string);
+		
+		cString format_string="";
+		for(int n=0; n<m_world->GetEnvironment().GetNumTasks(); n++){
+			stats_string.Set("%d\n", m_world->GetStats().GetTaskLastCount(n));
+			format_string+=stats_string;
+		}
+    m_task_table->ChangeColumn(1, format_string);
+    
+	}
+
+};
+
+
+#endif

Added: branches/vo/source/targets/viewer-fltk/cFLTKTable.cpp
===================================================================
--- branches/vo/source/targets/viewer-fltk/cFLTKTable.cpp	                        (rev 0)
+++ branches/vo/source/targets/viewer-fltk/cFLTKTable.cpp	2008-10-24 15:00:49 UTC (rev 2871)
@@ -0,0 +1,11 @@
+/*
+ *  cFLTKTable.cpp
+ *  
+ *
+ *  Created by Michael Vo on 9/1/08.
+ *  Copyright 2008 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#include "cFLTKTable.h"
+

Added: branches/vo/source/targets/viewer-fltk/cFLTKTable.h
===================================================================
--- branches/vo/source/targets/viewer-fltk/cFLTKTable.h	                        (rev 0)
+++ branches/vo/source/targets/viewer-fltk/cFLTKTable.h	2008-10-24 15:00:49 UTC (rev 2871)
@@ -0,0 +1,79 @@
+/*
+ *  cFLTKTable.h
+ *  
+ *
+ *  Created by Michael Vo on 9/1/08.
+ *  Copyright 2008 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+
+#ifndef cFLTKTable_h
+#define cFLTKTable_h
+
+#include <FL/Fl_Multiline_Output.H>
+#include "tVector.h"
+
+class cFLTKTable {
+private:
+  tVector<Fl_Multiline_Output*> m_column;
+  tVector<Fl_Multiline_Output*> m_header;
+public:
+  
+  void ChangeHeader(int n, cString text)
+  {
+    m_header[n]->value(text);
+  }
+  
+  void ChangeColumn(int n, cString text)
+  {
+    m_column[n]->value(text);
+  }
+  
+  void ChangeAllHeaders(tVector<cString> header_text)
+  {
+    for(int n=0; n<header_text.Size(); n++)
+      m_header[n]->value(header_text[n]);
+  }
+  
+  void ChangeAllColumns(tVector<cString> column_text)
+  {
+    for(int n=0; n<column_text.Size(); n++)
+      m_column[n]->value(column_text[n]);
+  }
+
+  cFLTKTable(int x, int y, tVector<int> width, int height)
+  {
+    int currX = x;
+    int header_height = 20;
+    for(int n=0; n<width.Size(); n++)
+    {
+      Fl_Multiline_Output* newColumn = new Fl_Multiline_Output(currX, y + header_height, width[n], height, "");
+      Fl_Multiline_Output* newHeader = new Fl_Multiline_Output(currX, y, width[n], header_height, "");
+      m_column.Add(newColumn);
+      m_header.Add(newHeader);
+      currX+=width[n];
+    }
+  }
+  
+  cFLTKTable(int x, int y, tVector<int> width, int height, tVector<cString> header_text)
+  {
+    cFLTKTable(x, y, width, height);
+    ChangeAllHeaders(header_text);
+  }
+  
+  
+  cFLTKTable(int x, int y, tVector<int> width, int height, tVector<cString> header_text, tVector<cString> column_text)
+  {
+    cFLTKTable(x, y, width, height);
+    ChangeAllHeaders(header_text);
+    ChangeAllColumns(column_text);
+  }
+  
+
+  
+};
+
+#endif
+
+      
\ No newline at end of file

Added: branches/vo/source/targets/viewer-fltk/cFLTKTabs.h
===================================================================
--- branches/vo/source/targets/viewer-fltk/cFLTKTabs.h	                        (rev 0)
+++ branches/vo/source/targets/viewer-fltk/cFLTKTabs.h	2008-10-24 15:00:49 UTC (rev 2871)
@@ -0,0 +1,44 @@
+/*
+ *  cFLTKTabs.h
+ *  
+ *
+ *  Created by Michael Vo on 10/24/08.
+ *  Copyright 2008 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#ifndef cFLTKTabs_h
+#define cFLTKTabs_h
+
+#include "cFLTKWidget.h"
+
+#include <FL/Fl_Tabs.h>
+
+class cFLTKTabs : public cGUIContainer, cFLTKWidget {
+protected:
+  Fl_Tabs * m_tabs;
+  
+public:
+  cFLTKTabs(int x, int y, int width, int height, const cString & name="")
+    : cFLTKWidget(this)
+  {
+    m_tabs = new Fl_Tabs(x, y, width, height, name);
+    SetWidget(m_tabs);
+  }
+  
+  void Finalize() { 
+    m_tabs->end();
+  }
+  
+  cString GetCurrentTabName()
+  {
+    cString retVal = m_tabs->value()->label();
+    return retVal;
+  }
+  
+  ~cFLTKTabs() { delete m_tabs; }
+
+  Fl_Tabs * GetFLTKPtr() { return m_tabs; }
+};
+
+#endif
\ No newline at end of file

Added: branches/vo/source/targets/viewer-fltk/cFLTKZoom.h
===================================================================
--- branches/vo/source/targets/viewer-fltk/cFLTKZoom.h	                        (rev 0)
+++ branches/vo/source/targets/viewer-fltk/cFLTKZoom.h	2008-10-24 15:00:49 UTC (rev 2871)
@@ -0,0 +1,171 @@
+/*
+ *  cFLTKZoom.h
+ *  
+ *
+ *  Created by Michael Vo on 7/1/08.
+ *  Copyright 2008 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#ifndef cFLTKZoom_h
+#define cFLTKZoom_h
+
+#include "cCoreView_Text.h"
+#include <FL/Fl_Text_Display.H>
+#include <FL/Fl_Multiline_Output.H>
+#include <FL/Fl_Box.H>
+#include "cWorld.h"
+#include "tFLTKButton.h"
+#include <FL/Fl_Return_Button.H>
+#include "cFLTKScreen.h"
+#include "cFLTKTable.h"
+
+class cFLTKZoom : public cFLTKScreen{
+private:
+  Fl_Input* m_cell_x_input;
+  Fl_Input* m_cell_y_input;
+  Fl_Text_Display* m_org_inst_display;
+  Fl_Text_Buffer* m_org_inst_buffer;
+  /*
+  Fl_Multiline_Output* m_org_info;
+  Fl_Multiline_Output* m_register;
+  Fl_Multiline_Output* m_stack;
+  Fl_Multiline_Output* m_inputs;
+  */
+  cFLTKTable* m_org_table;
+  cFLTKTable* m_memory_table;
+  
+  Fl_Box* m_genotype_id;
+  Fl_Box* m_genotype_name;
+  cWorld* m_world;
+  
+  cCoreView_Text m_text;
+public:
+
+	void PutInside(Fl_Widget* container, Fl_Widget* widget)
+	{
+		widget->position(container->x()+widget->x(), container->y()+widget->y());
+	}
+  
+  static void input_callback(Fl_Widget*, void* z)
+  {
+    cFLTKZoom* zoom = (cFLTKZoom*)z;
+    zoom->Redraw();
+  }
+  
+    
+    
+
+  cFLTKZoom(cWorld* world) : m_text(world)
+  {
+    m_world = world;
+    
+		m_org_inst_buffer = new Fl_Text_Buffer();
+		m_org_inst_display = new Fl_Text_Display(25, 200, 275, 345);
+    m_org_inst_display->scrollbar_align(FL_ALIGN_RIGHT);
+    m_org_inst_display->color(FL_BACKGROUND_COLOR);
+		m_org_inst_display->buffer(m_org_inst_buffer);
+	
+    Fl_Box* upper_left_box = new Fl_Box(25, 50, 275, 131);
+    upper_left_box->box(FL_THIN_UP_FRAME);
+    upper_left_box->labeltype(FL_NO_LABEL);
+    
+    { Fl_Box* o = new Fl_Box(40, 60, 0, 20, "Location");
+      o->align(FL_ALIGN_RIGHT);
+    } // Fl_Box* o
+    { Fl_Box* o = new Fl_Box(40, 85, 0, 20, "Genotype ID");
+      o->align(FL_ALIGN_RIGHT);
+    } // Fl_Box* o
+    { Fl_Box* o = new Fl_Box(40, 105, 0, 20, "Genotype Name");
+      o->align(FL_ALIGN_RIGHT);
+    }
+    
+    m_genotype_id = new Fl_Box(170, 85, 0, 20, "");
+    m_genotype_id->align(FL_ALIGN_RIGHT);
+
+    m_genotype_name = new Fl_Box(170, 105, 0, 20, "");
+    m_genotype_name->align(FL_ALIGN_RIGHT);
+    
+    m_cell_x_input = new Fl_Input(170, 60, 35, 20);
+		m_cell_x_input->value("0");
+    m_cell_x_input->when(FL_WHEN_CHANGED);
+    m_cell_x_input->callback(cFLTKZoom::input_callback, this);
+		m_cell_y_input = new Fl_Input(220, 60, 35, 20);
+		m_cell_y_input->value("0");
+    m_cell_y_input->when(FL_WHEN_CHANGED);
+    m_cell_y_input->callback(cFLTKZoom::input_callback, this);
+    
+    tVector<int> width;
+    for(int n=0; n<2; n++)
+      width.Add(150);
+    
+    m_org_table = new cFLTKTable(320, 200, width, 130);
+    m_org_table->ChangeHeader(0, "Organism Information");
+    m_org_table->ChangeColumn(0, "Genotype ID:\nGenotype Name:\nCurrent Energy:\nFaults:\nOffspring:\nThread:");
+    
+    width.Clear();
+    for(int n=0; n<3; n++)
+      width.Add(100);
+    m_memory_table = new cFLTKTable(320, 370, width, 80);
+    
+    m_memory_table->ChangeHeader(0, "Register");
+    m_memory_table->ChangeHeader(1, "Stack A");
+    m_memory_table->ChangeHeader(2, "Inputs");
+    m_memory_table->ChangeColumn(0, "AX:\nBX:\nCX:");
+  }
+	
+	void Redraw()
+	{
+		int org_id=0;
+		cString boxContents="";
+		cString number_converter;
+		int x, y;
+		number_converter=m_cell_x_input->value();
+		x=number_converter.AsInt();
+		
+		number_converter=m_cell_y_input->value();
+		y=number_converter.AsInt();	
+
+		tArray< cString > inst = m_text.GetOrganismInstructions(x, y);
+		if(inst.GetSize()>0)
+		{
+			for(int n=0; n<inst.GetSize(); n++)
+			{
+				cString box_line;
+				box_line.Set("%d: ", n);
+				boxContents+=box_line;
+				boxContents+=inst[n];
+				boxContents+="\n";
+			}
+		}
+		else
+		{
+			boxContents="N/A";
+		}
+		m_org_inst_buffer->text(boxContents);
+		m_org_inst_display->redraw();
+    cString info_string="";
+    
+    if(inst.GetSize()>0)
+    {
+      const char* geno_name = m_text.GetGenotypeName(x, y);
+      
+      m_genotype_name->label(geno_name);
+      info_string.Set("%d \n%s \n%f \n%d \n%d \n%d", m_text.GetGenotypeID(x, y)  , geno_name, m_text.GetEnergy(x, y), m_text.GetFaults(x, y), m_text.GetOffspring(x, y), 0);
+      m_org_table->ChangeColumn(1, info_string);
+      
+      info_string.Set("AX:  %d\nBX:  %d\nCX:  %d", m_text.GetRegister(x,y,0), m_text.GetRegister(x,y,1), m_text.GetRegister(x,y,2));
+      m_memory_table->ChangeColumn(0, info_string);
+      
+      info_string.Set("%d\n%d\n%d", m_text.GetStack(x,y,0), m_text.GetStack(x,y,1), m_text.GetStack(x,y,2));
+      m_memory_table->ChangeColumn(1, info_string);
+      
+      info_string.Set("%d\n%d\n%d", m_text.GetInputs(x,y,0), m_text.GetInputs(x,y,1), m_text.GetInputs(x,y,2));
+      m_memory_table->ChangeColumn(2, info_string);
+    }
+    
+	}
+
+};
+
+#endif
\ No newline at end of file

Added: branches/vo/source/targets/viewer-fltk/oldstats.h
===================================================================
--- branches/vo/source/targets/viewer-fltk/oldstats.h	                        (rev 0)
+++ branches/vo/source/targets/viewer-fltk/oldstats.h	2008-10-24 15:00:49 UTC (rev 2871)
@@ -0,0 +1,132 @@
+/*
+ *  cFLTKStats.h
+ *  
+ *
+ *  Created by Michael Vo on 8/3/08.
+ *  Copyright 2008 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#ifndef cFLTKStats_h
+#define cFLTKStats_h
+
+#include "cCoreView_Text.h"
+#include <FL/Fl_Text_Display.H>
+#include <FL/Fl_Multiline_Output.H>
+#include <FL/Fl_Box.H>
+#include "cWorld.h"
+#include "cFLTKScreen.h"
+#include "cFLTKTable.h"
+
+class cFLTKStats : public cFLTKScreen {
+private:
+  Fl_Multiline_Output* m_pop_stats_label;
+  Fl_Multiline_Output* m_pop_dominant_label;
+  Fl_Multiline_Output* m_pop_average_label;
+  Fl_Multiline_Output* m_task_label;
+  
+	cWorld* m_world;
+public:
+
+	void PutInside(Fl_Widget* container, Fl_Widget* widget)
+	{
+		widget->position(container->x()+widget->x(), container->y()+widget->y());
+	}
+  cFLTKStats(cWorld* world) : m_world(world)
+  {
+		Fl_Group* c = new Fl_Group(10, 35, 480, 580, "");
+		c->end();
+	  Fl_Box* framePopStats = new Fl_Box(FL_BORDER_FRAME, 20, 20, 300, 115, "");
+	  {
+
+			//framePopStats->align(FL_ALIGN_TOP|FL_ALIGN_INSIDE|FL_ALIGN_LEFT);
+			PutInside(c, framePopStats);
+			framePopStats->color(FL_BLACK);
+	  
+			Fl_Multiline_Output* popStatsLabel = new Fl_Multiline_Output(10, 10, 200, 100, "");
+			m_pop_stats_label = new Fl_Multiline_Output(150, 10, 100, 100, "");
+			//popStatsLabel->set_boxtype(FL_NO_BOX, 0, 0, 0, 0);
+	  
+			popStatsLabel->labelfont(FL_COURIER);
+			popStatsLabel->value("Total Births:\nBreedTrue:\nParasites:\nEnergy:\nMax Fitness:\nMax Merit:");
+	  
+			popStatsLabel->box(FL_NO_BOX);
+			m_pop_stats_label->box(FL_NO_BOX);
+			popStatsLabel->labelfont(FL_COURIER);
+	  
+			PutInside(framePopStats, popStatsLabel);
+			PutInside(framePopStats, m_pop_stats_label);
+	  }
+		
+	  Fl_Box* frameDomAveStats = new Fl_Box(FL_BORDER_FRAME, 20, 145, 400, 300, "");
+	  {
+			PutInside(c, frameDomAveStats);
+			frameDomAveStats->color(FL_BLACK);
+			Fl_Multiline_Output* domAveStatsLabel = new Fl_Multiline_Output(10, 25, 130, 270, "");
+			domAveStatsLabel->value("\nFitness:\nMerit:\nGestation:\nLength:\nCopy Length:\nExec Length:\nAbundance:\nBirths:\nBirthrate:\nTree Depth:\nGen. Ave:");
+			m_pop_dominant_label = new Fl_Multiline_Output(150, 25, 100, 270, "");
+			m_pop_average_label = new Fl_Multiline_Output(270, 25, 100, 270, "");
+			domAveStatsLabel->box(FL_NO_BOX);
+			m_pop_average_label->box(FL_NO_BOX);
+			m_pop_dominant_label->box(FL_NO_BOX);
+			PutInside(frameDomAveStats, domAveStatsLabel);
+			PutInside(frameDomAveStats, m_pop_average_label);
+			PutInside(frameDomAveStats, m_pop_dominant_label);
+	  }
+		
+		Fl_Box* frame_tasks = new Fl_Box(FL_BORDER_FRAME, 430, 145, 200, 300, "");
+		{
+			PutInside(c, frame_tasks);
+			frame_tasks->color(FL_BLACK);
+			Fl_Multiline_Output* task_label = new Fl_Multiline_Output(10, 25, 130, 270, "");
+			cString task_string="";
+			for(int n=0; n<m_world->GetEnvironment().GetNumTasks(); n++){
+				task_string+=m_world->GetEnvironment().GetTask(n).GetName();
+				task_string+="\n";
+			}
+			task_label->value(task_string);
+			m_task_label = new Fl_Multiline_Output(150, 25, 40, 270, ""); 
+			PutInside(frame_tasks, task_label);
+			PutInside(frame_tasks, m_task_label);
+			task_label->box(FL_NO_BOX);
+			m_task_label->box(FL_NO_BOX);
+		}
+  }
+	
+	void Redraw()
+	{
+		cString stats_string;
+		stats_string.Set("%d\n%d\n%d\n%f\n%f\n%f", m_world->GetStats().GetNumBirths(), m_world->GetStats().GetBreedTrue(),
+			m_world->GetStats().GetNumParasites(), m_world->GetStats().GetEnergy(), m_world->GetStats().GetMaxFitness(), m_world->GetStats().GetMaxMerit());
+		m_pop_stats_label->value(stats_string);
+		m_pop_stats_label->redraw_label();
+		
+		stats_string.Set("Dominant\n%f \n%f \n%f \n%d \n%f \n%f \n%d \n%d \n%f \n%d", m_world->GetStats().GetDomFitness(), m_world->GetStats().GetDomMerit(),
+			m_world->GetStats().GetDomGestation(), m_world->GetStats().GetDomSize(), m_world->GetStats().GetDomCopySize(), m_world->GetStats().GetDomExeSize(),
+			m_world->GetStats().GetDomAbundance(), m_world->GetStats().GetDomBirths(), m_world->GetStats().GetDomReproRate(), m_world->GetStats().GetDomGeneDepth());
+		m_pop_dominant_label->value(stats_string);
+		m_pop_dominant_label->redraw_label();
+		
+		stats_string.Set("Average\n%f \n%f \n%f \n%f \n%f \n%f \n%f \n%f \n%f \n%f \n%f", m_world->GetStats().GetAveFitness(), m_world->GetStats().GetAveMerit(),
+			m_world->GetStats().GetAveGestation(), m_world->GetStats().GetAveSize(), m_world->GetStats().GetAveCopySize(), m_world->GetStats().GetAveExeSize(),
+			double(m_world->GetStats().GetNumCreatures())/m_world->GetStats().GetNumGenotypes(),
+			0,
+			m_world->GetStats().GetAveReproRate(), 0,0);
+			//m_world->GetStats().SumGenotypeDepth().Average(), 
+			//m_world->GetStats().SumGeneration().Average());
+		m_pop_average_label->value(stats_string);
+		m_pop_average_label->redraw_label();
+		
+		cString format_string="";
+		for(int n=0; n<m_world->GetEnvironment().GetNumTasks(); n++){
+			stats_string.Set("%d\n", m_world->GetStats().GetTaskLastCount(n));
+			format_string+=stats_string;
+		}
+		m_task_label->value(format_string);
+		m_task_label->redraw_label();
+	}
+
+};
+
+
+#endif




More information about the Avida-cvs mailing list