[Avida-SVN] r3211 - branches/developers/avida-edward/source/python/AvidaGui2

welsberr at myxo.css.msu.edu welsberr at myxo.css.msu.edu
Thu Apr 16 16:51:28 PDT 2009


Author: welsberr
Date: 2009-04-16 19:51:28 -0400 (Thu, 16 Apr 2009)
New Revision: 3211

Modified:
   branches/developers/avida-edward/source/python/AvidaGui2/pyEduSessionMenuBarHdlr.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyNavBarCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_GraphCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_StatsCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyWriteToFreezer.py
Log:
Run-up to plugin development for Avida-ED


Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyEduSessionMenuBarHdlr.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyEduSessionMenuBarHdlr.py	2009-04-16 19:59:43 UTC (rev 3210)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyEduSessionMenuBarHdlr.py	2009-04-16 23:51:28 UTC (rev 3211)
@@ -50,7 +50,7 @@
     main_window.m_new_workspace_fmi_id = main_window.m_file_menu.insertItem("New Workspace",
       self.m_session_mdl.m_session_mdtr, qt.PYSIGNAL("doNewWorkspaceSig"),
       qt.Qt.CTRL + qt.Qt.SHIFT + qt.Qt.Key_N)
-    main_window.m_open_workspace_fmi_id = main_window.m_file_menu.insertItem("Open Workspace...",
+    main_window.m_open_workspace_fmi_id = main_window.m_file_menu.insertItem("Open the Workspace...",
       self.m_session_mdl.m_session_mdtr, qt.PYSIGNAL("doOpenWorkspaceSig"),
       qt.Qt.CTRL + qt.Qt.Key_O)
     main_window.m_close_workspace_fmi_id = main_window.m_file_menu.insertItem("Close Workspace",
@@ -75,7 +75,7 @@
     main_window.m_menu_bar.insertItem("File", main_window.m_file_menu)
 
     main_window.m_edit_menu = qt.QPopupMenu()
-    main_window.m_undo_emi_id = main_window.m_edit_menu.insertItem("Undo",
+    main_window.m_undo_emi_id = main_window.m_edit_menu.insertItem("Undo Last Bad Thing",
       self.m_session_mdl.m_session_mdtr, qt.PYSIGNAL("doUndoSig"),
       qt.Qt.CTRL + qt.Qt.Key_Z)
     main_window.m_redo_emi_id = main_window.m_edit_menu.insertItem("Redo",

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py	2009-04-16 19:59:43 UTC (rev 3210)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py	2009-04-16 23:51:28 UTC (rev 3211)
@@ -17,23 +17,91 @@
 from pyDefaultFiles import pyDefaultFiles
 from pyReadFreezer import pyReadFreezer
 from pyWarnAboutTrashCtrl import pyWarnAboutTrashCtrl
-# from pyImportItemCtrl import pyImportItemCtrl
 from pyBeforeStartingCtrl import pyBeforeStartingCtrl
 from pyHelpScreenCtrl import pyHelpScreenCtrl
 from pyAboutScreenCtrl import pyAboutScreenCtrl
 from pyRenameDialogCtrl import pyRenameDialogCtrl
 import pyNewIconView
-import os.path, shutil
+
 from qt import *
 
+import os, os.path, shutil, sys, traceback
+
+
+# plugin_visitor
+# Inputs:
+#   arg : arguments that can be passed to all plugins
+#   dirname : a directory to look for the plugins in
+#   names : a list of plugin names to look for
+def plugin_visitor(arg, dirname, names):
+  print "in plugin_visitor(...)..."
+
+  # For readability: our single argument is a pyEduWorkspaceCtrl instance.
+  edu_workspace_ctrl = arg
+
+  # Find all the plugins, recognize by the extension using the following 
+  # filter function:
+  plugins = filter(lambda f: (os.path.splitext(f)[1] == '.ae_plugin'), names)
+
+  #print "plugin_visitor: arg:", arg
+  #print "plugin_visitor: dirname:", dirname
+  #print "plugin_visitor: names:", names
+  #print "plugin_visitor: plugins:", plugins
+
+  # Save the system path as is, so it can be restored later.
+  sys_path = sys.path
+  #print "plugin_visitor: sys.path:", sys.path
+
+  # Operate on the list of plugins that have been found
+  for plugin in plugins:
+    # Put together the path to this plugin
+    plugin_path = os.path.abspath(os.path.join(dirname, plugin))
+    #print "plugin_visitor: plugin_path:", plugin_path
+    
+    # Alter the system path temporarily
+    sys.path = [plugin_path] + sys_path
+    try:
+      # Load the plugin
+      import ae_plugin
+
+      # Reload, because all the plugins get called the same
+      # ae_plugin == Bruce
+      reload(ae_plugin)
+
+      # Call to plugin method to start things off
+      p = ae_plugin.AEPlugin(workspace_ctrl = edu_workspace_ctrl)
+
+      # Now pass in the session model to allow the plugin to hook itself
+      # into the Avida instance
+      p.construct(edu_workspace_ctrl.m_session_mdl)
+
+      #print "plugin_visitor: p:", p
+    except Exception, details:
+      # Handle exceptions so that all the plugins can be tried
+      print "Exception:", details
+      trace = traceback.format_exc()
+
+    # Restore the original system path
+    sys.path = sys_path
+    #print "plugin_visitor: sys.path:", sys.path
+
+
 class pyEduWorkspaceCtrl(pyEduWorkspaceView):
 
+  def load_plugins(self):
+    print "in pyEduWorkspaceCtrl.load_plugins ..."
+    plugins_dir = os.path.join(self.m_session_mdl.m_current_workspace, 'plugins')
+    plugins_dir = os.path.abspath(plugins_dir)
+    files = os.listdir(plugins_dir)
+    plugins = filter(lambda f: (os.path.splitext(f)[1] == '.ae_plugin'), files)
+    os.path.walk(plugins_dir, plugin_visitor, self)
+
+
   def construct(self, session_mdl):
     self.m_session_mdl = session_mdl
     self.m_avida = None
     self.startStatus = True
     self.m_nav_bar_ctrl.construct(session_mdl)
-    # self.m_nav_bar_list_view.construct(session_mdl)
     self.m_freezer_ctrl.construct(session_mdl)
     self.m_cli_to_ctrl_dict = {}
     self.m_ctrl_to_cli_dict = {}
@@ -56,7 +124,6 @@
     self.m_one_population_ctrl  = pyOnePopulationCtrl(self.m_widget_stack, "m_one_population_ctrl")
     self.m_one_organism_ctrl    = pyOneOrganismCtrl(self.m_widget_stack, "m_one_organism_ctrl")
     self.m_one_analyze_ctrl     = pyOneAnalyzeCtrl(self.m_widget_stack, "m_one_analyze_ctrl")
-
     # Mapping cli and ctrl elements
     #   Need to set up methods to do this kind of work 
     for (cli, ctrl) in (
@@ -67,17 +134,18 @@
       self.m_cli_to_ctrl_dict[cli] = ctrl
       self.m_ctrl_to_cli_dict[ctrl] = cli
 
-    #self.m_nav_bar_ctrl.m_one_population_cli.setState(QCheckListItem.On)
-    #self.m_nav_bar_ctrl.m_one_population_cli.setState(QCheckListItem.Off)
-    #self.m_nav_bar_ctrl.m_one_population_cli.setSelected(True)
-    #self.m_nav_bar_ctrl.m_one_population_cli.setSelected(False)
-
     #for ctrl in self.m_ctrl_to_cli_dict.keys():
-    #  ctrl.construct(self.m_session_mdl)
     self.m_one_population_ctrl.construct(self.m_session_mdl)
     self.m_one_organism_ctrl.construct(self.m_session_mdl, self)
     self.m_one_analyze_ctrl.construct(self.m_session_mdl)
         
+
+    # Load plug-ins!
+    print "calling self.load_plugins() ..."
+    self.load_plugins()
+    print "... done calling self.load_plugins()."
+
+
     self.connect(
       self, PYSIGNAL("quitAvidaPhaseISig"), self.startQuitProcessSlot)
     self.connect(self, PYSIGNAL("quitAvidaPhaseIISig"), qApp, SLOT("quit()"))
@@ -90,8 +158,8 @@
     self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("raiseOrgViewSig"), self.raiseOrgViewSlot)
     self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("raiseAnaViewSig"), self.raiseAnaViewSlot)
 
-    # self.connect(
-    #   self.fileOpenFreezerAction,SIGNAL("activated()"),self.freezerOpenSlot)
+    self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("raiseViewSig"), self.switchToViewSlot)
+
     self.connect(self.popview_controlNext_UpdateAction,SIGNAL("activated()"), self.next_UpdateActionSlot)
     self.connect(self.popview_controlStartAction,SIGNAL("activated()"),self.startActionSlot)
 
@@ -123,10 +191,6 @@
       self.m_session_mdl.m_session_mdtr,
       PYSIGNAL("doPauseSig"),
       self.doPauseAvidaSlot)
-    # self.connect(
-    #   self.m_session_mdl.m_session_mdtr,
-    #   PYSIGNAL("doNextUpdateSig"),
-    #   self.updatePBClickedSlot)
 
     self.connect(self.popview_controlRestart_ExpAction,SIGNAL("activated()"),
       self.Restart_ExpActionSlot)
@@ -154,13 +218,10 @@
 
     # set up the trash can to have one trash can icon that can not be selected
 
-    # self.TrashCanIconView.setItemTextPos(QIconView.Right)
-    # self.TrashCanIconView.setSpacing(1)
     self.TrashCanIconView.setVScrollBarMode(QIconView.AlwaysOff)
     self.TrashCanIconView.setHScrollBarMode(QIconView.AlwaysOff)
     self.TrashCanIconView.setSelectionMode(QIconView.NoSelection)
     self.TrashCanIconView.setAutoArrange(False)
-    # TCIcon = pyNewIconView.TrashIconViewItem(self.TrashCanIconView)
 
     self.show()
 
@@ -181,15 +242,23 @@
         if old_controller is not None:
           old_controller.aboutToBeLowered(self)
         controller.aboutToBeRaised(self)
+        print "navBarItemClickedSlot: about to call raiseWidget on controller:", controller
         self.m_widget_stack.raiseWidget(controller)
+        print "navBarItemClickedSlot: done with call raiseWidget on controller:", controller
 
   # @kgn : desperate hacks to get drag & drop working.
   def switchToView(self, cli):
-    self.m_nav_bar_ctrl.m_list_view.setSelected(self.m_nav_bar_ctrl.m_one_population_cli, False)
-    self.m_nav_bar_ctrl.m_list_view.setSelected(self.m_nav_bar_ctrl.m_one_organism_cli, False)
-    self.m_nav_bar_ctrl.m_list_view.setSelected(self.m_nav_bar_ctrl.m_one_analyze_cli, False)
+    for item in self.m_cli_to_ctrl_dict:
+      self.m_nav_bar_ctrl.m_list_view.setSelected(item, False)
     self.m_nav_bar_ctrl.m_list_view.setSelected(cli, True)
     self.navBarItemClickedSlot(cli)
+
+  def switchToViewSlot(self, ctrl):
+    print "in pyEduWorkspaceCtrl.switchToViewSlot(), called with ctrl:", ctrl
+    cli = self.m_ctrl_to_cli_dict[ctrl]
+    self.switchToView(cli)
+    print "pyEduWorkspaceCtrl.switchToViewSlot() done."
+
   def raisePopViewSlot(self):
     self.switchToView(self.m_nav_bar_ctrl.m_one_population_cli)
   def raiseOrgViewSlot(self):
@@ -314,6 +383,12 @@
                 shutil.copyfile(sourceName, destName)
               else:
                 pyDefaultFiles(fileName, destName)
+
+            # Now copy plugins directory verbatim.
+            plugins_dir = os.path.join(self.m_session_mdl.m_current_workspace, 'plugins')
+            new_plugins_dir = os.path.join(new_dir, 'plugins')
+            shutil.copytree(plugins_dir, new_plugins_dir)
+
             self.m_session_mdl.m_current_workspace = str(new_dir)
             self.m_session_mdl.m_current_freezer = os.path.join(new_dir, "freezer")
             self.m_session_mdl.directory_chosen = True
@@ -348,12 +423,11 @@
         initial_dir = ""
 
       workspace_dir = QFileDialog.getExistingDirectory(
-                    # self.m_session_mdl.m_current_workspace,
-                    initial_dir,
-                    None,
-                    "get existing workspace",
-                    tmpDialogCap,
-                    True);
+        initial_dir,
+        None,
+        "get existing workspace",
+        tmpDialogCap,
+        True);
       workspace_dir = str(workspace_dir)              
       workspace_dir = workspace_dir.strip()
 
@@ -422,7 +496,6 @@
             shutil.copytree(self.m_session_mdl.m_current_workspace, new_dir)
             self.m_session_mdl.m_current_workspace = str(new_dir)
             self.m_session_mdl.m_current_freezer = os.path.join(new_dir, "freezer")
-            #self.setCaption(self.m_session_mdl.m_current_workspace)
             self.setCaption('%s - %s' % ("Avida-ED", os.path.basename(os.path.splitext(self.m_session_mdl.m_current_workspace)[0])) )
             self.m_session_mdl.m_session_mdtr.emit(
               PYSIGNAL("doRefreshFreezerInventorySig"), ())
@@ -449,10 +522,6 @@
   def fileImportItem(self):
     "Import a freezer item that was previously exported"
 
-    # self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("importFreezerItemSig"), ())
-    # m_import_freeze_item = pyImportItemCtrl()
-    # item_to_import = m_import_freeze_item.showDialog(self.m_session_mdl)
-
     # If the user has not already chosen an active workspace for this session
     # make them do so now. If they chose not to pick a workspace, don't let
     # them import the file
@@ -679,31 +748,7 @@
   def helpIndex(self):
     self.help_dialog = pyHelpScreenCtrl()
     self.help_dialog.showDialog()
-  #  home = QDir("./documentation/index.html").absPath()
-  #  if self.help_screen is not None:
-  #    self.help_screen.setSource(home)
-  #  else:
-  #    self.help_screen = pyHelpScreenCtrl(home, ".", None)
-  #  #help_dialog.showDialog()
-  #  self.help_screen.show()
 
-  #def helpChanges(self):
-  #  home = QDir("./documentation/changes.html").absPath()
-  #  if self.help_screen is not None:
-  #    self.help_screen.setSource(home)
-  #  else:
-  #    self.help_screen = pyHelpScreenCtrl(home, ".", None)
-  #  self.help_screen.show()
-
-  #def helpKnownBugs(self):
-  #  home = QDir("./documentation/bugs.html").absPath()
-  #  if self.help_screen is not None:
-  #    descr("calling setSource")
-  #    self.help_screen.setSource(home)
-  #  else:
-  #    self.help_screen = pyHelpScreenCtrl(home, ".", None)
-  #  self.help_screen.show()
-
   # public slot
 
   def helpContents(self):
@@ -795,9 +840,6 @@
     if not(os.path.exists(file_name)):
       short_file_name = os.path.join("freezer", "@default.empty")
       pyDefaultFiles(short_file_name, file_name)
-      #warningNoMethodName(file_name + 
-      # " does not exist -- please start experiment by dragging dish")
-      #return
     thawed_item = pyReadFreezer(file_name)
     self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("startNewExperimentSig"),
       ())
@@ -874,4 +916,53 @@
         self.m_session_mdl.m_session_mdtr.emit(
           PYSIGNAL("DeleteFromAncestorViewSig"),
           (ancestor_item_name,) )
- 
+
+  #def AddViewerTonavBar(self, new_viewer):
+  #  """ AddViewerTonavBar
+  #  provides the mechanism to add another viewer to the NavBarView.
+  #  Abstraction of the process presently handled in "construct" method 
+  #  for built-in viewers.
+  #  """
+    # Using the population viewer as an example
+
+    # Add a control object for the new viewer
+    # self.m_one_population_ctrl  = pyOnePopulationCtrl(self.m_widget_stack, "m_one_population_ctrl")
+
+    # Mapping cli and ctrl elements
+    # self.m_cli_to_ctrl_dict[self.m_nav_bar_ctrl.m_one_population_cli] = self.m_one_population_ctrl
+    # self.m_ctrl_to_cli_dict[self.m_one_population_ctrl] = self.m_nav_bar_ctrl.m_one_population_cli
+
+    #for ctrl in self.m_ctrl_to_cli_dict.keys():
+    #self.m_one_population_ctrl.construct(self.m_session_mdl)
+        
+    # @kgn : desperate hacks to get drag & drop working.
+    # Kaben's comment: refactoring this should fairly straightforward.
+    # self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("raisePopViewSig"), self.raisePopViewSlot)
+
+    # Next connect is for where a user selects a veiwer from 
+    # the View menu
+    #self.connect( self.viewPopulationAction,SIGNAL("activated()"), 
+    #  self.viewPopulationActionSlot)
+   
+    # Kaben's best guess:
+    # This connect is for where a user restarts a petri dish by clicking on
+    # "Start New Experiment" in the "Control" menu, or when they double-click
+    # the default petri dish from the freezer.
+    # Kaben's comment: This is unique to the population viewer, or at least a
+    # single specific viewer that should be chosen to be the default (which
+    # might as well be the population viewer).
+    #self.connect(self.popview_controlRestart_ExpAction,SIGNAL("activated()"),
+    #  self.Restart_ExpActionSlot)
+
+    # Set viewer as active
+    # Wesley's comment: This is unique to the population viewer.
+    # self.navBarItemClickedSlot(self.m_nav_bar_ctrl.m_one_population_cli)
+    # Set selection in the NavBar
+    # self.m_nav_bar_ctrl.m_list_view.setSelected(self.m_nav_bar_ctrl.m_one_population_cli, True)
+    # Adjust splitter???
+    # Kaben's comment: This is a hard-wired dimension, and it will be wrong as
+    # soon as we add more viewers to the navigation bar.
+    #self.splitter1.setSizes([150,500,100])
+
+    #return
+

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyNavBarCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyNavBarCtrl.py	2009-04-16 19:59:43 UTC (rev 3210)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyNavBarCtrl.py	2009-04-16 23:51:28 UTC (rev 3211)
@@ -12,6 +12,8 @@
     apply(QListView.__init__,(self,) + args)
     self.viewport().setAcceptDrops( True )
 
+    self.m_viewer_dict = {}
+
   def construct(self, session_mdl):
     self.m_session_mdl = session_mdl
 
@@ -120,7 +122,14 @@
           self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("raiseAnaViewSig"),())
         else:
           info ("Only populated petri dishes can be dragged into the Analysis Viewer.")
+
+      else:
+        # Check whether <viewer_dropped_in> is in dictionary.
+        # Lookup <viewer_dropped_in> is in dictionary.
+        # Call HandleDropEvent method of object in dictionary, passing <dropped_item_name> as argument
+        pass
           
+          
 class pyNavBarCtrl(QWidget):
 
     def __init__(self,parent = None,name = None,fl = 0):

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphCtrl.py	2009-04-16 19:59:43 UTC (rev 3210)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphCtrl.py	2009-04-16 23:51:28 UTC (rev 3211)
@@ -262,7 +262,8 @@
           self.m_graph_ctrl.replot()
           return
         self.m_graph_ctrl.setAxisTitle(QwtPlot.yLeft, stat_1.name)
-        self.m_graph_ctrl.enableYLeftAxis(True)
+        # self.m_graph_ctrl.enableYLeftAxis(True)
+        self.m_graph_ctrl.enableAxis(QwtPlot.yLeft,True)
         self.m_graph_ctrl.setAxisAutoScale(QwtPlot.yLeft)
         self.m_curve_1_arrays = self.m_avida_stats_interface.load(
             str(row.m_petri_dish_dir_path), stat_1.file, 1, stat_1.index
@@ -281,7 +282,8 @@
           row.m_curve_1.setPen(QPen(self.m_Colors[row.layout.m_combo_box_1_color.currentItem()].qt_color))
         row.m_curve_1.setYAxis(QwtPlot.yLeft)
         if not self.m_combo_box_2.currentItem():
-          self.m_graph_ctrl.enableYRightAxis(False)
+          # self.m_graph_ctrl.enableYRightAxis(False)
+          self.m_graph_ctrl.enableAxis(QwtPlot.yRight,False)
           self.m_graph_ctrl.setTitle(stat_1.name + " vs. " + self.x_axis_title)
       else:
         self.m_graph_ctrl.enableYLeftAxis(False)
@@ -323,13 +325,17 @@
       if self.m_combo_box_1.currentItem() and self.m_combo_box_2.currentItem():
         self.m_graph_ctrl.setTitle(self.m_avida_stats_interface.m_entries[self.m_combo_box_1.currentItem()].name + ' (' + self.pen_styles[self.m_combo_box_1_style.currentItem()] \
         + ') and ' + self.m_avida_stats_interface.m_entries[self.m_combo_box_2.currentItem()].name + ' (' +  self.pen_styles[self.m_combo_box_2_style.currentItem()] +') vs. ' + self.x_axis_title)
-        bounding_rect_1 = self.m_graph_ctrl.curve(row.m_curve_1).boundingRect()
-        bounding_rect_2 = self.m_graph_ctrl.curve(row.m_curve_2).boundingRect()
+        # bounding_rect_1 = self.m_graph_ctrl.curve(row.m_curve_1).boundingRect()
+        bounding_rect_1 = row.m_curve_1.boundingRect()
+        # bounding_rect_2 = self.m_graph_ctrl.curve(row.m_curve_2).boundingRect()
+        bounding_rect_2 = row.m_curve_2.boundingRect()
         bounding_rect = bounding_rect_1.unite(bounding_rect_2)
       elif self.m_combo_box_1.currentItem():
-        bounding_rect = self.m_graph_ctrl.curve(row.m_curve_1).boundingRect()
+        # bounding_rect = self.m_graph_ctrl.curve(row.m_curve_1).boundingRect()
+        bounding_rect = row.m_curve_1.boundingRect()
       else:
-        bounding_rect = self.m_graph_ctrl.curve(row.m_curve_2).boundingRect()
+        # bounding_rect = self.m_graph_ctrl.curve(row.m_curve_2).boundingRect()
+        bounding_rect = row.m_curve_2.boundingRect()
 
       self.m_graph_ctrl.m_zoomer.setZoomBase(bounding_rect)
   

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_GraphCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_GraphCtrl.py	2009-04-16 19:59:43 UTC (rev 3210)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_GraphCtrl.py	2009-04-16 23:51:28 UTC (rev 3211)
@@ -68,7 +68,9 @@
       # self.m_graph_ctrl.setAxisAutoScale(QwtPlot.xBottom)
       # self.m_graph_ctrl.setAxisAutoScale(QwtPlot.yLeft)
 
+      # New QWT methods
       self.m_graph_ctrl.m_curve = QwtPlotCurve(self.m_avida_stats_interface.m_entries[index].name)
+      self.m_graph_ctrl.m_curve.attach(self.m_graph_ctrl)
       self.m_graph_ctrl.m_curve.setData(self.m_x_array, self.m_y_array)
       self.m_graph_ctrl.m_curve.setPen(QPen(Qt.red))
       self.m_graph_ctrl.m_zoomer.setZoomBase(self.m_graph_ctrl.m_curve.boundingRect())
@@ -91,6 +93,7 @@
         self.avidaUpdatedSlot)
 
   def avidaUpdatedSlot(self):
+    # print "... in avidaUpdatedSlot ..."
     if self.m_combo_box.currentItem():
       self.m_x_array = concatenate(
         (self.m_x_array, [self.m_avida.m_population.GetStats().GetUpdate()]),
@@ -106,8 +109,13 @@
         1
       )
       if hasattr(self.m_graph_ctrl, "m_curve"):
+        # print " m_graph_crtl has attribute m_curve\n"
         # self.m_graph_ctrl.setCurveData(self.m_graph_ctrl.m_curve, self.m_x_array, self.m_y_array)
         self.m_graph_ctrl.m_curve.setData(self.m_x_array, self.m_y_array)
+        # if self.m_graph_ctrl.m_curve.setData(self.m_x_array, self.m_y_array):
+        #  print " setData succeeded\n"
+        # else:
+        #  print " setData failed\n"
         # Quick hack: Cause the zoomer to limit zooming-out to the
         # boundaries of the displayed curve.
         self.m_graph_ctrl.m_zoomer.setZoomBase(self.m_graph_ctrl.m_curve.boundingRect())
@@ -116,6 +124,8 @@
         self.m_graph_ctrl.setAxisAutoScale(QwtPlot.xBottom)
         self.m_graph_ctrl.setAxisAutoScale(QwtPlot.yLeft)
         self.m_graph_ctrl.replot()
+      else:
+        print " m_graph_crtl DOES NOT have attribute m_curve\n"
 
   def printGraphSlot(self):
     printer = QPrinter()

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py	2009-04-16 19:59:43 UTC (rev 3210)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py	2009-04-16 23:51:28 UTC (rev 3211)
@@ -304,7 +304,8 @@
 
   def SetMapModeAndGraphModeToDefaultsSlot(self):
     descr()
-    self.m_mode_combobox.setCurrentItem(2)
+    # @WRE: reset main population viewer mode to "Fitness" (1) rather than "Gestation Time" (2)
+    self.m_mode_combobox.setCurrentItem(1)
     self.m_mode_index = self.m_mode_combobox.currentItem()
     self.modeActivatedSlot(self.m_mode_index)
     

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_StatsCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_StatsCtrl.py	2009-04-16 19:59:43 UTC (rev 3210)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_StatsCtrl.py	2009-04-16 23:51:28 UTC (rev 3211)
@@ -18,6 +18,7 @@
     self.m_session_mdl = session_mdl
     self.m_avida = None
     self.m_stat_task_button_states = [0,0,0,0,0,0,0,0,0]
+    self.m_stat_task_first_complete = [0,0,0,0,0,0,0,0,0]
     self.m_org_square_ctrl.construct()
     self.connect(
       self.m_session_mdl.m_session_mdtr, PYSIGNAL("setAvidaSig"),
@@ -77,6 +78,7 @@
         self.avidaUpdatedSlot)
 
   def avidaUpdatedSlot(self):
+    # print "pyOnePop_StatsCtrl.avidaUpdatedSlot() called.\n"
     stats = self.m_avida.m_population.GetStats()
              
     #STATISTICS WINDOW
@@ -122,33 +124,89 @@
 
 
     #TASK OUTLOOK 
+    # @WRE: get current update of run
+    age_now ="%d" %(stats.GetUpdate())
 
     num_not = str(stats.GetTaskLastCount(0))
-    self.m_num_not.setText(num_not)
+    # @WRE: adding first completion
+    if ((int(self.m_stat_task_first_complete[0]) <= 0) and (0 < int(num_not))):
+      self.m_stat_task_first_complete[0] = age_now
+    if ((int(self.m_stat_task_first_complete[0]) > 0) or (0 < int(num_not))):
+      self.m_num_not.setText("%s (1st@ %d)" %(num_not, int(self.m_stat_task_first_complete[0])))
+    else:
+      self.m_num_not.setText(num_not)
     
     num_nand = str(stats.GetTaskLastCount(1))
-    self.m_num_nand.setText(num_nand)
+    # @WRE: adding first completion
+    if ((int(self.m_stat_task_first_complete[1]) <= 0) and (0 < int(num_nand))):
+      self.m_stat_task_first_complete[1] = age_now
+    if ((int(self.m_stat_task_first_complete[1]) > 0) or (0 < int(num_nand))):
+      self.m_num_nand.setText("%s (1st@ %d)" %(num_nand, int(self.m_stat_task_first_complete[1])))
+    else:
+      self.m_num_nand.setText(num_nand)
 
     num_and = str(stats.GetTaskLastCount(2))
-    self.m_num_and.setText(num_and)
+    # @WRE: adding first completion
+    if ((int(self.m_stat_task_first_complete[2]) <= 0) and (0 < int(num_and))):
+      self.m_stat_task_first_complete[2] = age_now
+    if ((int(self.m_stat_task_first_complete[2]) > 0) or (0 < int(num_and))):
+      self.m_num_and.setText("%s (1st@ %d)" %(num_and, int(self.m_stat_task_first_complete[2])))
+    else:
+      self.m_num_and.setText(num_and)
 
     num_ornot = str(stats.GetTaskLastCount(3))
-    self.m_num_ornot.setText(num_ornot)
+    # @WRE: adding first completion
+    if ((int(self.m_stat_task_first_complete[3]) <= 0) and (0 < int(num_ornot))):
+      self.m_stat_task_first_complete[3] = age_now
+    if ((int(self.m_stat_task_first_complete[3]) > 0) or (0 < int(num_ornot))):
+      self.m_num_ornot.setText("%s (1st@ %d)" %(num_ornot, int(self.m_stat_task_first_complete[3])))
+    else:
+      self.m_num_ornot.setText(num_ornot)
 
     num_or = str(stats.GetTaskLastCount(4))
-    self.m_num_or.setText(num_or)
+    # @WRE: adding first completion
+    if ((int(self.m_stat_task_first_complete[4]) <= 0) and (0 < int(num_or))):
+      self.m_stat_task_first_complete[4] = age_now
+    if ((int(self.m_stat_task_first_complete[4]) > 0) or (0 < int(num_or))):
+      self.m_num_or.setText("%s (1st@ %d)" %(num_or, int(self.m_stat_task_first_complete[4])))
+    else:
+      self.m_num_or.setText(num_or)
 
     num_andnot = str(stats.GetTaskLastCount(5))
-    self.m_num_andnot.setText(num_andnot)
+    # @WRE: adding first completion
+    if ((int(self.m_stat_task_first_complete[5]) <= 0) and (0 < int(num_andnot))):
+      self.m_stat_task_first_complete[5] = age_now
+    if ((int(self.m_stat_task_first_complete[5]) > 0) or (0 < int(num_andnot))):
+      self.m_num_andnot.setText("%s (1st@ %d)" %(num_andnot, int(self.m_stat_task_first_complete[5])))
+    else:
+      self.m_num_andnot.setText(num_andnot)
 
     num_nor = str(stats.GetTaskLastCount(6))
-    self.m_num_nor.setText(num_nor)
+    # @WRE: adding first completion
+    if ((int(self.m_stat_task_first_complete[6]) <= 0) and (0 < int(num_nor))):
+      self.m_stat_task_first_complete[6] = age_now
+    if ((int(self.m_stat_task_first_complete[6]) > 0) or (0 < int(num_nor))):
+      self.m_num_nor.setText("%s (1st@ %d)" %(num_nor, int(self.m_stat_task_first_complete[6])))
+    else:
+      self.m_num_nor.setText(num_nor)
 
     num_xor = str(stats.GetTaskLastCount(7))
-    self.m_num_xor.setText(num_xor)
+    # @WRE: adding first completion
+    if ((int(self.m_stat_task_first_complete[7]) <= 0) and (0 < int(num_xor))):
+      self.m_stat_task_first_complete[7] = age_now
+    if ((int(self.m_stat_task_first_complete[7]) > 0) or (0 < int(num_xor))):
+      self.m_num_xor.setText("%s (1st @ %d)" %(num_xor, int(self.m_stat_task_first_complete[7])))
+    else:
+      self.m_num_xor.setText(num_xor)
 
     num_equals = str(stats.GetTaskLastCount(8))
-    self.m_num_equals.setText(num_equals)
+    # @WRE: adding first completion
+    if ((int(self.m_stat_task_first_complete[8]) <= 0) and (0 < int(num_equals))):
+      self.m_stat_task_first_complete[8] = age_now
+    if ((int(self.m_stat_task_first_complete[8]) > 0) or (0 < int(num_equals))):
+      self.m_num_equals.setText("%s (1st@ %d)" %(num_equals, int(self.m_stat_task_first_complete[8])))
+    else:
+      self.m_num_equals.setText(num_equals)
     
     if self.m_clicked_cell_number>= 0:
       self.updateOrgReportSlot(self.m_clicked_cell_item)
@@ -468,7 +526,6 @@
     self.m_num_xor.setText(task_last_line_array[8])
     self.m_num_equals.setText(task_last_line_array[9])
 
-
 #    petri_average_file.Load()    
 #    update_number = petri_average_file.GetNumLines()
 #    print "this pop at update number"
@@ -502,3 +559,4 @@
     self.m_num_nor.setText("-")
     self.m_num_xor.setText("-")
     self.m_num_equals.setText("-")
+    self.m_stat_task_first_complete = [0,0,0,0,0,0,0,0,0]

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyWriteToFreezer.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyWriteToFreezer.py	2009-04-16 19:59:43 UTC (rev 3210)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyWriteToFreezer.py	2009-04-16 23:51:28 UTC (rev 3211)
@@ -60,7 +60,7 @@
       del in_dict["POPULATION"]
 
       # When the ANCESTOR_LINKS hash is passed in it has cell location linked
-      # to linage label.  We need to have organism ID linked to linage label.
+      # to lineage label.  We need to have organism ID linked to linage label.
 
       orig_anc_dict = in_dict["ANCESTOR_LINKS"]
       del in_dict["ANCESTOR_LINKS"]




More information about the Avida-cvs mailing list