[Avida-cvs] [Avida2-svn] r89 - branches/developers/kaben/source/python/AvidaGui2

kaben at myxo.css.msu.edu kaben at myxo.css.msu.edu
Wed Mar 30 11:31:18 PST 2005


Author: kaben
Date: 2005-03-30 14:31:17 -0500 (Wed, 30 Mar 2005)
New Revision: 89

Added:
   branches/developers/kaben/source/python/AvidaGui2/pyOneOrg_ScopeCtrl.py
   branches/developers/kaben/source/python/AvidaGui2/pyOneOrg_ScopeView.ui
   branches/developers/kaben/source/python/AvidaGui2/pyOrganismScopeCtrl.py
   branches/developers/kaben/source/python/AvidaGui2/pyOrganismScopeView.py
Modified:
   branches/developers/kaben/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
   branches/developers/kaben/source/python/AvidaGui2/pyOneOrganismCtrl.py
   branches/developers/kaben/source/python/AvidaGui2/pyOneOrganismView.ui
   branches/developers/kaben/source/python/AvidaGui2/pyTemporaryReloads.py
Log:

* Added organism viewer.




Modified: branches/developers/kaben/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
===================================================================
--- branches/developers/kaben/source/python/AvidaGui2/pyEduWorkspaceCtrl.py	2005-03-30 19:28:48 UTC (rev 88)
+++ branches/developers/kaben/source/python/AvidaGui2/pyEduWorkspaceCtrl.py	2005-03-30 19:31:17 UTC (rev 89)
@@ -49,6 +49,7 @@
     #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.connect(self.m_nav_bar_ctrl.m_list_view, SIGNAL("clicked(QListViewItem *)"), self.navBarItemClickedSlot)
     self.connect(self.m_widget_stack, SIGNAL("aboutToShow(QWidget *)"), self.ctrlAboutToShowSlot)

Added: branches/developers/kaben/source/python/AvidaGui2/pyOneOrg_ScopeCtrl.py
===================================================================
--- branches/developers/kaben/source/python/AvidaGui2/pyOneOrg_ScopeCtrl.py	2005-03-30 19:28:48 UTC (rev 88)
+++ branches/developers/kaben/source/python/AvidaGui2/pyOneOrg_ScopeCtrl.py	2005-03-30 19:31:17 UTC (rev 89)
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+
+from pyOneOrg_ScopeView import pyOneOrg_ScopeView
+import qt
+
+class pyOneOrg_ScopeCtrl(pyOneOrg_ScopeView):
+
+  def __init__(self,parent = None,name = None,fl = 0):
+    pyOneOrg_ScopeView.__init__(self,parent,name,fl)
+
+  def construct(self, session_mdl):
+    self.m_session_mdl = session_mdl
+    self.m_organism_scope_ctrl.construct(self.m_session_mdl)
+    self.m_execution_step_slider.setMinValue(0)
+    self.m_execution_step_slider.setMaxValue(0)
+    self.connect(
+      self.m_execution_step_slider, qt.SIGNAL("valueChanged(int)"),
+      self.m_organism_scope_ctrl.showFrame)
+    self.connect(
+      self.m_organism_scope_ctrl, qt.PYSIGNAL("gestationTimeChangedSig"),
+      self.gestationTimeChangedSlot)
+    self.connect(
+      self.m_organism_scope_ctrl, qt.PYSIGNAL("executionStepResetSig"),
+      self.executionStepResetSlot)
+
+  def gestationTimeChangedSlot(self, gestation_time):
+    print "pyOneOrg_ScopeCtrl.gestationTimeChangedSlot called, gestation_time ", gestation_time
+    self.m_execution_step_slider.setMaxValue(gestation_time - 1)
+
+  def executionStepResetSlot(self, execution_step):
+    print "pyOneOrg_ScopeCtrl.executionStepResetSlot called, execution_step ", execution_step
+    self.m_execution_step_slider.setValue(execution_step)
+    # This may be redundant (I'm not sure). @kgn
+    self.m_execution_step_slider.emit(qt.SIGNAL("valueChanged(int)"),(execution_step,))
+

Added: branches/developers/kaben/source/python/AvidaGui2/pyOneOrg_ScopeView.ui
===================================================================
--- branches/developers/kaben/source/python/AvidaGui2/pyOneOrg_ScopeView.ui	2005-03-30 19:28:48 UTC (rev 88)
+++ branches/developers/kaben/source/python/AvidaGui2/pyOneOrg_ScopeView.ui	2005-03-30 19:31:17 UTC (rev 89)
@@ -0,0 +1,146 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>pyOneOrg_ScopeView</class>
+<comment>Python:from pyOrganismScopeCtrl import pyOrganismScopeCtrl
+Python:from pyAnalyzeControlsCtrl import pyAnalyzeControlsCtrl
+</comment>
+<widget class="QWidget">
+    <property name="name">
+        <cstring>pyOneOrg_ScopeView</cstring>
+    </property>
+    <property name="geometry">
+        <rect>
+            <x>0</x>
+            <y>0</y>
+            <width>397</width>
+            <height>452</height>
+        </rect>
+    </property>
+    <property name="caption">
+        <string>pyOneOrg_ScopeView</string>
+    </property>
+    <vbox>
+        <property name="name">
+            <cstring>unnamed</cstring>
+        </property>
+        <widget class="pyOrganismScopeCtrl">
+            <property name="name">
+                <cstring>m_organism_scope_ctrl</cstring>
+            </property>
+        </widget>
+        <widget class="QSlider">
+            <property name="name">
+                <cstring>m_execution_step_slider</cstring>
+            </property>
+            <property name="orientation">
+                <enum>Horizontal</enum>
+            </property>
+        </widget>
+        <widget class="QLayoutWidget">
+            <property name="name">
+                <cstring>layout63</cstring>
+            </property>
+            <hbox>
+                <property name="name">
+                    <cstring>unnamed</cstring>
+                </property>
+                <spacer>
+                    <property name="name">
+                        <cstring>spacer35_2</cstring>
+                    </property>
+                    <property name="orientation">
+                        <enum>Horizontal</enum>
+                    </property>
+                    <property name="sizeType">
+                        <enum>Expanding</enum>
+                    </property>
+                    <property name="sizeHint">
+                        <size>
+                            <width>91</width>
+                            <height>20</height>
+                        </size>
+                    </property>
+                </spacer>
+                <widget class="pyAnalyzeControlsCtrl">
+                    <property name="name">
+                        <cstring>pyAnalyzeControlsCtrl1</cstring>
+                    </property>
+                    <property name="sizePolicy">
+                        <sizepolicy>
+                            <hsizetype>3</hsizetype>
+                            <vsizetype>5</vsizetype>
+                            <horstretch>0</horstretch>
+                            <verstretch>0</verstretch>
+                        </sizepolicy>
+                    </property>
+                </widget>
+                <spacer>
+                    <property name="name">
+                        <cstring>spacer35</cstring>
+                    </property>
+                    <property name="orientation">
+                        <enum>Horizontal</enum>
+                    </property>
+                    <property name="sizeType">
+                        <enum>Expanding</enum>
+                    </property>
+                    <property name="sizeHint">
+                        <size>
+                            <width>91</width>
+                            <height>20</height>
+                        </size>
+                    </property>
+                </spacer>
+            </hbox>
+        </widget>
+    </vbox>
+</widget>
+<customwidgets>
+    <customwidget>
+        <class>pyAnalyzeControlsCtrl</class>
+        <header location="global">1</header>
+        <sizehint>
+            <width>-1</width>
+            <height>0</height>
+        </sizehint>
+        <container>0</container>
+        <sizepolicy>
+            <hordata>5</hordata>
+            <verdata>0</verdata>
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+        </sizepolicy>
+        <pixmap>image0</pixmap>
+        <property type="0">3</property>
+        <property type="1">pyAnalyzeControlsCtrl</property>
+        <property type="3">-1</property>
+        <property type="pyAnalyzeControlsCtrl"></property>
+        <property type="-1">1</property>
+    </customwidget>
+    <customwidget>
+        <class>pyOrganismScopeCtrl</class>
+        <header location="local">1</header>
+        <sizehint>
+            <width>-1</width>
+            <height>-1</height>
+        </sizehint>
+        <container>0</container>
+        <sizepolicy>
+            <hordata>5</hordata>
+            <verdata>5</verdata>
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+        </sizepolicy>
+        <pixmap>image0</pixmap>
+    </customwidget>
+</customwidgets>
+<images>
+    <image name="image0">
+        <data format="PNG" length="1002">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000003b149444154789cad945f4c5b551cc73fe7dc4b7b4bcba0762d45c43114323599ee6192609c51d883892ce083f1718b3ebb185f8dc91e972cf39d2d2a2f1af664b6f1e0fe3863a0718969700eb0c52142da0242a1bd6d696f7bcff101585203ceb8fd9ece39f99dcff9fe7edf939f88c562ec465f5f9fe609442c161362173c3e3eae7b7a7ac8e7f36432196cdbfe4f907c3e4f2291201e8fe338cec3737357e9e8e828aded1e229d650e1f2d51754b082110124c13a4dc5ea341eb9dc284c0558a853f3ce8cb0677ef500fde7d39d2596679e326597b8e9abb85d7a770ab16ab6983ec5a05b487a70e36f0f4e10afe408d6a558310980108478dba4a1e8233990c5d474b64ed39aa3a8fe5f3317fbf81dbd70bccfeb205947632fd74f6589c1c6ea2f70d03a58ba0c1f2c9bdc1b66de3b8256a6e11cbe7e3ee1d181b590124fe2693aeee08d223c82c3a2c24b7b874bec8f26288774f7bd054504aef0dde6e99c0eb83f9fb266323cb80a27fb0958141836044605a2ee5523393371cc646fee2da37195aa35d0c0c5b4859ac03d7e91712dcaac5adab3650a3ff9d08ef7dd8404bb48869e5d958b5b87dadc4c9a1464e9f0d0326df7!
 ebd86bd2e310cb1bf62d384d59441f2d70a070e1c60e09489929b988681bdd9cc97170bcc4c65595f71f8e0e3301337fc24a7732467831875a47f289652b0be5e4151e6d07316c1b0c0340d8ab92023e76d66a6b2840e36d2fb7a13fee632475e6edc367ea98a90fb98b7dd6310ca0328a44761582e1bab41befabcc0ec940d28bc5e93b68e064cab84e1d9beaeb48934eac1f53b01c1b000fca496aa54b61a99fcde61662a4b4b4b23d1680be9d426173e4df3602a48ea411989a4fd590f52a8fd156b05ed9d350e3defe3cfdf4b4c7ce770ea7d3fb9f520afbe1620daeee5c26735d20b9b9cfb6811a754a439e4e5c5639a4caa1e5caf586bfc0197b78702005cb9b4cae4cd3267ce8638fe964bd72b393e39d74928d242617303a756a37f284447770dcdbffc6384a05a85de1306e9a52057c7527c7131c3c42d3f475eb2303c82d4fc3276d6811db37efeb148723082d9b08f79f97c1e5729109a9a28307cc622d2d6cdf52b2b24efe548dedb00142009862cfa879ee1a71f6cec928353511472fbf4389148b0b0e0c108081412458dfe21c9f11351e67e7358595468246d1d1e5e38a6e9e851bc39d84ab502a669331dafec0d8ec7e3e8cb06e1a881d727d1ae40180a434a8c9db129a54126ad48a7358c2b4c5352c8c374bcccdab2bb37d8719cba79fab8211f9df218e05!
 82c261e95f8bfc04f1a1e8bc5c4dfe0a19017a725d8c60000000049454e44a!
 e426082<
/data>
+    </image>
+</images>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+    <includehint>pyorganismscopectrl.h</includehint>
+    <includehint>pyanalyzecontrolsctrl.h</includehint>
+</includehints>
+</UI>

Modified: branches/developers/kaben/source/python/AvidaGui2/pyOneOrganismCtrl.py
===================================================================
--- branches/developers/kaben/source/python/AvidaGui2/pyOneOrganismCtrl.py	2005-03-30 19:28:48 UTC (rev 88)
+++ branches/developers/kaben/source/python/AvidaGui2/pyOneOrganismCtrl.py	2005-03-30 19:31:17 UTC (rev 89)
@@ -8,3 +8,7 @@
 
   def __init__(self,parent = None,name = None,fl = 0):
     pyOneOrganismView.__init__(self,parent,name,fl)
+
+  def construct(self, session_mdl):
+    self.m_session_mdl = session_mdl
+    self.m_one_org_scope_ctrl.construct(self.m_session_mdl)

Modified: branches/developers/kaben/source/python/AvidaGui2/pyOneOrganismView.ui
===================================================================
--- branches/developers/kaben/source/python/AvidaGui2/pyOneOrganismView.ui	2005-03-30 19:28:48 UTC (rev 88)
+++ branches/developers/kaben/source/python/AvidaGui2/pyOneOrganismView.ui	2005-03-30 19:31:17 UTC (rev 89)
@@ -1,6 +1,6 @@
 <!DOCTYPE UI><UI version="3.3" stdsetdef="1">
 <class>pyOneOrganismView</class>
-<comment>Python:from pyTwoOrg_VivisectionCtrl import pyTwoOrg_VivisectionCtrl
+<comment>Python:from pyOneOrg_ScopeCtrl import pyOneOrg_ScopeCtrl
 Python:from pyTimelineCtrl import pyTimelineCtrl
 </comment>
 <widget class="QWidget">
@@ -142,16 +142,16 @@
                 </widget>
             </hbox>
         </widget>
-        <widget class="pyTwoOrg_VivisectionCtrl">
+        <widget class="pyOneOrg_ScopeCtrl">
             <property name="name">
-                <cstring>pyTwoOrg_VivisectionCtrl1</cstring>
+                <cstring>m_one_org_scope_ctrl</cstring>
             </property>
             <property name="sizePolicy">
                 <sizepolicy>
-                    <hsizetype>3</hsizetype>
+                    <hsizetype>5</hsizetype>
                     <vsizetype>3</vsizetype>
                     <horstretch>0</horstretch>
-                    <verstretch>5</verstretch>
+                    <verstretch>1</verstretch>
                 </sizepolicy>
             </property>
         </widget>
@@ -180,7 +180,7 @@
         </sizehint>
         <container>0</container>
         <sizepolicy>
-            <hordata>3</hordata>
+            <hordata>0</hordata>
             <verdata>0</verdata>
             <horstretch>0</horstretch>
             <verstretch>0</verstretch>
@@ -193,15 +193,17 @@
         <property type="3">-1</property>
         <property type="1">pyTimelineCtrl</property>
         <property type="4">-1</property>
+        <property type="1">pyTimelineCtrl</property>
+        <property type="4">-1</property>
         <property type="pyTimelineCtrl"></property>
         <property type="-1">1</property>
     </customwidget>
     <customwidget>
-        <class>pyTwoOrg_VivisectionCtrl</class>
-        <header location="global">1</header>
+        <class>pyOneOrg_ScopeCtrl</class>
+        <header location="local">1</header>
         <sizehint>
             <width>-1</width>
-            <height>0</height>
+            <height>-1</height>
         </sizehint>
         <container>0</container>
         <sizepolicy>
@@ -211,9 +213,6 @@
             <verstretch>0</verstretch>
         </sizepolicy>
         <pixmap>image2</pixmap>
-        <property type="0">3</property>
-        <property type="pyTwoOrg_VivisectionCtrl"></property>
-        <property type="-1">1</property>
     </customwidget>
 </customwidgets>
 <images>
@@ -229,7 +228,7 @@
 </images>
 <layoutdefaults spacing="6" margin="11"/>
 <includehints>
-    <includehint>pytwoorg_vivisectionctrl.h</includehint>
+    <includehint>pyoneorg_scopectrl.h</includehint>
     <includehint>pytimelinectrl.h</includehint>
 </includehints>
 </UI>

Added: branches/developers/kaben/source/python/AvidaGui2/pyOrganismScopeCtrl.py
===================================================================
--- branches/developers/kaben/source/python/AvidaGui2/pyOrganismScopeCtrl.py	2005-03-30 19:28:48 UTC (rev 88)
+++ branches/developers/kaben/source/python/AvidaGui2/pyOrganismScopeCtrl.py	2005-03-30 19:31:17 UTC (rev 89)
@@ -0,0 +1,180 @@
+# -*- coding: utf-8 -*-
+
+from pyOrganismScopeView import pyOrganismScopeView
+
+import AvidaCore
+
+from qt import *
+
+import os
+import tempfile
+
+
+class pyOrganismScopeCtrl(pyOrganismScopeView):
+
+  def __init__(self,parent = None,name = None,fl = 0):
+    pyOrganismScopeView.__init__(self,parent,name,fl)
+
+    if not name: self.setName("pyOrganismScopeCtrl")
+
+  def construct(self, session_mdl):
+    self.m_session_mdl = session_mdl
+    self.m_avida = None
+    self.connect(
+      self.m_session_mdl.m_session_mdtr, PYSIGNAL("setAvidaSig"),
+      self.setAvidaSlot)
+    self.connect(
+      self.m_session_mdl.m_session_mdtr, PYSIGNAL("setDebugOrganismFileSig"),
+      self.setDebugOrganismFileSlot)
+
+  def setAvidaSlot(self, avida):
+    old_avida = self.m_avida
+    self.m_avida = avida
+    if(old_avida): del old_avida
+
+  def setDebugOrganismFileSlot(self, organism_filename):
+    if self.m_avida:
+      # Analysis files.
+      genebank_dirname = self.m_session_mdl.m_tempdir
+      organism_file_basename = os.path.basename(str(organism_filename))
+      analyze_filename = '%s/organism_analyze.cfg' % self.m_session_mdl.m_tempdir
+      trace_filename = '%s/%s.trace' % (genebank_dirname, organism_file_basename)
+      genotype_filename = '%s/%s.gen' % (genebank_dirname, organism_file_basename)
+
+      # Analysis results files.
+      is_viable_info_filename = '%s/is_viable.info' % self.m_session_mdl.m_tempdir
+      gestation_time_info_filename = '%s/gestation_time.info' % self.m_session_mdl.m_tempdir
+      fitness_info_filename = '%s/fitness.info' % self.m_session_mdl.m_tempdir
+      size_info_filename = '%s/size.info' % self.m_session_mdl.m_tempdir
+      genome_info_filename = '%s/genome.info' % self.m_session_mdl.m_tempdir
+      tasks_info_filename = '%s/tasks.info' % self.m_session_mdl.m_tempdir
+      ihead_info_filename = '%s/ihead.info' % self.m_session_mdl.m_tempdir
+      rhead_info_filename = '%s/rhead.info' % self.m_session_mdl.m_tempdir
+      whead_info_filename = '%s/whead.info' % self.m_session_mdl.m_tempdir
+      fhead_info_filename = '%s/fhead.info' % self.m_session_mdl.m_tempdir
+
+      # Create a temporary analyze file using organism file name.
+      analyze_file = open(analyze_filename, 'w')
+      analyze_file.write('LOAD_ORGANISM %s\n' % organism_filename)
+      analyze_file.write('RECALCULATE\n')
+      analyze_file.write('TRACE %s\n' % genebank_dirname)
+      analyze_file.write('PRINT %s\n' % genebank_dirname)
+      analyze_file.close()
+
+      # Create an analyze object using the temporary analyze file and
+      # the environment of the current avida object.
+      AvidaCore.cConfig.SetAnalyzeFilename(AvidaCore.cString(analyze_filename))
+      avida_driver_analyze = AvidaCore.cAvidaDriver_Analyze(
+        False, self.m_avida.m_environment)
+      avida_driver_analyze.Run()
+
+      # Extract organism viability, gestation time, fitness, and size numbers.
+      os.system( 'cat ' + genotype_filename + ' | grep Is | grep Viable | cut -d\  -f4-20  > ' + is_viable_info_filename)
+      os.system( 'cat ' + genotype_filename + ' | grep Gestation | cut -d\  -f4-20  > ' + gestation_time_info_filename)
+      os.system( 'cat ' + genotype_filename + ' | grep Fitness | cut -d\  -f4-20  > ' + fitness_info_filename)
+      os.system( 'cat ' + genotype_filename + ' | grep Genome | cut -d\  -f4-20  > ' + size_info_filename)
+      # Extract genome info.
+      os.system( 'cat ' + trace_filename + ' | grep Mem | cut -d\  -f6 > ' + genome_info_filename)
+      # Extract the tasks done at each point in execution.
+      os.system( 'cat ' + trace_filename + ' | grep Task | cut -d\  -f9-17 > ' + tasks_info_filename)
+      # Extract the instruction pointer locations from the trace file.
+      os.system( 'cat ' + trace_filename + ' | grep IP | cut -d\  -f2 | cut -b4-7 > ' + ihead_info_filename)
+      # Extract the read/write/flow head info.
+      os.system( 'cat ' + trace_filename + ' | grep "R-Head" | cut -d\  -f3 | cut -d\: -f2 > ' + rhead_info_filename)
+      os.system( 'cat ' + trace_filename + ' | grep "W-Head" | cut -d\  -f4 | cut -d\: -f2 > ' + whead_info_filename)
+      os.system( 'cat ' + trace_filename + ' | grep "F-Head" | cut -d\  -f5 | cut -d\: -f2 > ' + fhead_info_filename)
+
+      # Load organism viability, gestation time, fitness, and size.
+      def load_info(info_filename):
+        info_file = file(info_filename, 'rU')
+        info = info_file.read()
+        info_file.close()
+        return info.strip()
+
+      ( is_viable_info_string,
+        gestation_time_info_string,
+        fitness_info_string,
+        size_info_string,
+      ) = [load_info(info_filename) for info_filename in (
+        is_viable_info_filename,
+        gestation_time_info_filename,
+        fitness_info_filename,
+        size_info_filename,)]
+      is_viable_info = bool(int(is_viable_info_string))
+      gestation_time_info = int(gestation_time_info_string)
+      fitness_info = float(fitness_info_string)
+      size_info = int(size_info_string)
+
+      # Load genome, tasks, and heads at each point in execution.
+      def load_info_lines(info_filename):
+        info_file = file(info_filename, 'rU')
+        info_lines = info_file.readlines()
+        info_file.close()
+        return [info_line.strip() for info_line in info_lines]
+
+      ( genome_info,
+        tasks_info_strings,
+        ihead_info_strings,
+        rhead_info_strings,
+        whead_info_strings,
+        fhead_info_strings,
+      ) = [load_info_lines(info_filename) for info_filename in (
+        genome_info_filename,
+        tasks_info_filename,
+        ihead_info_filename,
+        rhead_info_filename,
+        whead_info_filename,
+        fhead_info_filename,)]
+      tasks_info = [[bool(int(task)) for task in tasks] for tasks in [line.split() for line in tasks_info_strings]]
+      ihead_info = [int(line) for line in ihead_info_strings]
+      rhead_info = [int(line) for line in rhead_info_strings]
+      whead_info = [int(line) for line in whead_info_strings]
+      fhead_info = [int(line) for line in fhead_info_strings]
+
+      class pyMdl: pass
+      frames = pyMdl()
+      frames.m_is_viable = is_viable_info
+      frames.m_gestation_time = gestation_time_info
+      frames.m_fitness = fitness_info
+      frames.m_size = size_info
+      frames.m_genome_info = genome_info
+      frames.m_tasks_info = tasks_info
+      frames.m_ihead_info = ihead_info
+      frames.m_rhead_info = rhead_info
+      frames.m_whead_info = whead_info
+      frames.m_fhead_info = fhead_info
+
+      # Delete analyze files and analysis results files.
+      #for filename in (
+      #  analyze_filename,
+      #  trace_filename,
+      #  genotype_filename,
+      #  is_viable_info_filename,
+      #  gestation_time_info_filename,
+      #  fitness_info_filename,
+      #  size_info_filename,
+      #  genome_info_filename,
+      #  tasks_info_filename,
+      #  ihead_info_filename,
+      #  rhead_info_filename,
+      #  whead_info_filename,
+      #  fhead_info_filename,
+      #):
+      #  os.remove(filename)
+
+      # Translate from string genome representation to actual command names.
+      inst_names = {}
+      inst_set = self.m_avida.m_environment.GetInstSet()
+      instruction = AvidaCore.cInstruction()
+      for id in range(inst_set.GetSize()):
+        instruction.SetOp(id)
+        inst_names[instruction.GetSymbol()] = str(inst_set.GetName(instruction))
+
+      self.setInstNames(inst_names)
+      self.setFrames(frames)
+
+      # load task info
+      #   determine points at which tasks appear, both in genome and
+      #   frame number
+
+      pass

Added: branches/developers/kaben/source/python/AvidaGui2/pyOrganismScopeView.py
===================================================================
--- branches/developers/kaben/source/python/AvidaGui2/pyOrganismScopeView.py	2005-03-30 19:28:48 UTC (rev 88)
+++ branches/developers/kaben/source/python/AvidaGui2/pyOrganismScopeView.py	2005-03-30 19:31:17 UTC (rev 89)
@@ -0,0 +1,144 @@
+# -*- coding: utf-8 -*-
+
+
+from qt import *
+from qtcanvas import *
+
+
+class pyOrganismScopeView(QCanvasView):
+  def __init__(self,parent = None,name = None,fl = 0):
+    QCanvasView.__init__(self,parent,name,fl)
+    if not name: self.setName("pyOrganismScopeView")
+
+    self.setVScrollBarMode(QScrollView.AlwaysOff)
+    self.setHScrollBarMode(QScrollView.AlwaysOff)
+    self.m_canvas = QCanvas()
+    self.setCanvas(self.m_canvas)
+    self.reset()
+
+  def reset(self):
+    self.m_instruction_items = None
+    self.m_task_items = None
+    self.m_ihead_item = None
+    self.m_rhead_item = None
+    self.m_whead_item = None
+    self.m_fhead_item = None
+
+    self.m_task_names = None
+    self.m_inst_names = None
+
+    self.m_frames = None
+    self.m_max_genome_size = 0
+    self.m_current_frame_number = 0
+    self.m_current_genome = None
+    self.m_current_tasks = None
+    self.m_current_ihead = None
+    self.m_current_rhead = None
+    self.m_current_whead = None
+    self.m_current_fhead = None
+
+    # Hmm; can't emit gestationTimeChangedSig(0) without causing absurd slider values. @kgn
+    self.emit(PYSIGNAL("gestationTimeChangedSig"),(1,))
+    self.emit(PYSIGNAL("executionStepResetSig"),(0,))
+
+  def setTaskNames(self, task_names = None):
+    old_task_names = self.m_task_names
+    self.m_task_names = task_names
+
+  def setInstNames(self, inst_names = None):
+    old_inst_names = self.m_inst_names
+    self.m_inst_names = inst_names
+
+  def setFrames(self, frames = None):
+    self.reset()
+    self.m_frames = frames
+    if self.m_frames is not None:
+      if self.m_frames.m_genome_info is not None:
+        self.m_max_genome_size = max([len(genome) for genome in self.m_frames.m_genome_info])
+        self.m_instruction_items = [QCanvasText(self.m_canvas) for i in range(self.m_max_genome_size)]
+      self.updateCircle()
+      self.emit(PYSIGNAL("gestationTimeChangedSig"),(self.m_frames.m_gestation_time,))
+      self.showFrame(0)
+
+  def resizeEvent(self, resize_event):
+    new_size = resize_event.size()
+    self.m_canvas.resize(new_size.width(), new_size.height())
+    QCanvasView.resizeEvent(self, resize_event)
+
+  def updateCircle(self):
+    if self.m_instruction_items is not None:
+      x = 0
+      for instruction_item in self.m_instruction_items:
+        x += 5
+        instruction_item.setX(x)
+        instruction_item.setY(100)
+        instruction_item.setText('@')
+        instruction_item.hide()
+
+  def showFrame(self, frame_number = 0):
+    old_frame_number = self.m_current_frame_number
+    old_genome = self.m_current_genome
+    old_tasks = self.m_current_tasks
+    old_ihead = self.m_current_ihead
+    old_rhead = self.m_current_rhead
+    old_whead = self.m_current_whead
+    old_fhead = self.m_current_fhead
+
+    self.m_current_frame_number = 0
+    self.m_current_genome = None
+    self.m_current_tasks = None
+    self.m_current_ihead = None
+    self.m_current_rhead = None
+    self.m_current_whead = None
+    self.m_current_fhead = None
+
+    if self.m_frames is not None and frame_number < self.m_frames.m_gestation_time:
+      self.m_current_frame_number = frame_number
+      if self.m_frames.m_genome_info is not None:
+        self.m_current_genome = self.m_frames.m_genome_info[frame_number]
+        if old_genome is None:
+          # Update all instruction_items.
+          for i in range(len(self.m_current_genome)):
+            self.m_instruction_items[i].setText(self.m_current_genome[i])
+            self.m_instruction_items[i].show()
+        else:
+          # Update changed instruction_items.
+          old_length = len(old_genome)
+          new_length = len(self.m_current_genome)
+          compare_max = min(old_length, new_length)
+          range_end = max(old_length, new_length)
+          for i in range(compare_max):
+            if old_genome[i] == self.m_current_genome[i]:
+              pass
+            else:
+              self.m_instruction_items[i].setText(self.m_current_genome[i])
+
+          if old_length < new_length:
+            for i in range(compare_max, range_end):
+              self.m_instruction_items[i].setText(self.m_current_genome[i])
+              self.m_instruction_items[i].show()
+          else:
+            for i in range(compare_max, range_end):
+              self.m_instruction_items[i].hide()
+
+      if self.m_frames.m_tasks_info is not None:
+        self.m_current_tasks = self.m_frames.m_tasks_info[frame_number]
+        # Update tasks_item.
+
+      if self.m_frames.m_ihead_info is not None:
+        self.m_current_ihead = self.m_frames.m_ihead_info[frame_number]
+        # Update changed ihead_item.
+
+      if self.m_frames.m_rhead_info is not None:
+        self.m_current_rhead = self.m_frames.m_rhead_info[frame_number]
+        # Update changed rhead_item.
+
+      if self.m_frames.m_whead_info is not None:
+        self.m_current_whead = self.m_frames.m_whead_info[frame_number]
+        # Update changed whead_item.
+
+      if self.m_frames.m_fhead_info is not None:
+        self.m_current_fhead = self.m_frames.m_fhead_info[frame_number]
+        # Update changed fhead_item.
+
+    self.m_canvas.update()

Modified: branches/developers/kaben/source/python/AvidaGui2/pyTemporaryReloads.py
===================================================================
--- branches/developers/kaben/source/python/AvidaGui2/pyTemporaryReloads.py	2005-03-30 19:28:48 UTC (rev 88)
+++ branches/developers/kaben/source/python/AvidaGui2/pyTemporaryReloads.py	2005-03-30 19:31:17 UTC (rev 89)
@@ -45,6 +45,7 @@
 nontest_module_names = [
   "AvidaGui2.pyAnalyzeControlsView",
   "AvidaGui2.pyAnalyzeControlsCtrl",
+  "AvidaGui2.pyAvidaStatsInterface",
   "AvidaGui2.pyFreezeDialogView",
   "AvidaGui2.pyFreezeDialogCtrl",
   "AvidaGui2.pyFreezerView",
@@ -58,6 +59,8 @@
   "AvidaGui2.pyLiveControlsCtrl",
   "AvidaGui2.pyNavBarView",
   "AvidaGui2.pyNavBarCtrl",
+  "AvidaGui2.pyOrganismScopeView",
+  "AvidaGui2.pyOrganismScopeCtrl",
   "AvidaGui2.pyPetriConfigureView",
   "AvidaGui2.pyPetriConfigureCtrl",
   "AvidaGui2.pyPetriDishView",
@@ -79,6 +82,9 @@
   "AvidaGui2.pyOneAna_TimelineView",
   "AvidaGui2.pyOneAna_TimelineCtrl",
 
+  "AvidaGui2.pyOneOrg_ScopeView",
+  "AvidaGui2.pyOneOrg_ScopeCtrl",
+
   "AvidaGui2.pyOnePop_GraphView",
   "AvidaGui2.pyOnePop_GraphCtrl",
   "AvidaGui2.pyOnePop_PetriDishView",




More information about the Avida-cvs mailing list