[Avida-cvs] [avida-svn] r682 - branches/developers/avida-edward/source/python/AvidaGui2

gerrishj@myxo.css.msu.edu gerrishj at myxo.css.msu.edu
Tue May 16 11:45:11 PDT 2006


Author: gerrishj
Date: 2006-05-16 14:45:10 -0400 (Tue, 16 May 2006)
New Revision: 682

Added:
   branches/developers/avida-edward/source/python/AvidaGui2/pyExportCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyExportView.ui
Modified:
   branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceView.ui
   branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyOneAnalyzeCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyOneOrg_ScopeCtrl.py
Log:
Added ability to export stats to comma delimited file.
Fixed Windows organism viewer timer issues.


Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py	2006-05-16 03:58:17 UTC (rev 681)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py	2006-05-16 18:45:10 UTC (rev 682)
@@ -302,6 +302,12 @@
 
   # public slot
 
+  def fileExport(self):
+    "Export Avida analysis to a file"
+    self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("exportAnalyzeSig"), ())
+ 
+  # public slot
+
   def fileExit(self):
     print "pyEduWorkspaceCtrl.fileExit(): Not implemented yet"
 

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceView.ui
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceView.ui	2006-05-16 03:58:17 UTC (rev 681)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceView.ui	2006-05-16 18:45:10 UTC (rev 682)
@@ -153,6 +153,8 @@
         <action name="fileOpenAction"/>
         <action name="fileSaveAsAction"/>
         <separator/>
+        <action name="fileExportAction"/>
+        <separator/>
         <action name="m_graph_print_action"/>
     </item>
     <item text="&amp;Edit" name="editMenu">
@@ -365,6 +367,20 @@
     </action>
     <action>
         <property name="name">
+            <cstring>fileExportAction</cstring>
+        </property>
+        <property name="text">
+            <string>Export Analysis</string>
+        </property>
+        <property name="menuText">
+            <string>&amp;Export Analysis</string>
+        </property>
+        <property name="accel">
+            <string>Ctrl+E</string>
+        </property>
+    </action>
+    <action>
+        <property name="name">
             <cstring>m_graph_print_action</cstring>
         </property>
         <property name="iconSet">
@@ -576,13 +592,13 @@
     </action>
     <action>
         <property name="name">
-            <cstring>fileExportAction</cstring>
+            <cstring>fileExportAction2</cstring>
         </property>
         <property name="text">
-            <string>Export...</string>
+            <string>Export</string>
         </property>
         <property name="menuText">
-            <string>Export...</string>
+            <string>Export</string>
         </property>
     </action>
     <action>
@@ -727,6 +743,12 @@
         <slot>fileSaveAs()</slot>
     </connection>
     <connection>
+        <sender>fileExportAction</sender>
+        <signal>activated()</signal>
+        <receiver>pyEduWorkspaceView</receiver>
+        <slot>fileExport()</slot>
+    </connection>
+    <connection>
         <sender>m_graph_print_action</sender>
         <signal>activated()</signal>
         <receiver>pyEduWorkspaceView</receiver>
@@ -798,6 +820,7 @@
     <slot>fileOpen()</slot>
     <slot>fileSave()</slot>
     <slot>fileSaveAs()</slot>
+    <slot>fileExport()</slot>
     <slot>filePrint()</slot>
     <slot>fileExit()</slot>
     <slot>editUndo()</slot>

Added: branches/developers/avida-edward/source/python/AvidaGui2/pyExportCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyExportCtrl.py	2006-05-16 03:58:17 UTC (rev 681)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyExportCtrl.py	2006-05-16 18:45:10 UTC (rev 682)
@@ -0,0 +1,30 @@
+# Export dialog for exporting stats to Excel
+from qt import *
+from pyExportView import pyExportView
+
+class pyExportCtrl(pyExportView):
+  def __init__(self):
+    pyExportView.__init__(self)
+
+#  def accept(self):
+#    self.export()
+#    pyExportView.accept(self)
+
+  def showDialog(self):
+    "Show the dialog, returning list of stats to export"
+    items = []
+    self.exec_loop()
+    res = self.result()
+    if res == 0:
+      return []
+    else:
+      # PyQt 3.15 missing QListViewItemIterator
+      #for item in QListItemViewIterator(self.listView1):
+      i = self.listView1.firstChild()
+      if i != None and i.isOn():
+        items.append(str(i.text()))
+      while i:
+        i = i.itemBelow()
+        if i != None and i.isOn():
+          items.append(str(i.text()))
+    return items


Property changes on: branches/developers/avida-edward/source/python/AvidaGui2/pyExportCtrl.py
___________________________________________________________________
Name: svn:executable
   + *

Added: branches/developers/avida-edward/source/python/AvidaGui2/pyExportView.ui
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyExportView.ui	2006-05-16 03:58:17 UTC (rev 681)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyExportView.ui	2006-05-16 18:45:10 UTC (rev 682)
@@ -0,0 +1,147 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>pyExportView</class>
+<widget class="QDialog">
+    <property name="name">
+        <cstring>pyExportView</cstring>
+    </property>
+    <property name="geometry">
+        <rect>
+            <x>0</x>
+            <y>0</y>
+            <width>352</width>
+            <height>344</height>
+        </rect>
+    </property>
+    <property name="caption">
+        <string>Choose Values to Export</string>
+    </property>
+    <property name="sizeGripEnabled">
+        <bool>true</bool>
+    </property>
+    <widget class="QListView">
+        <column>
+            <property name="text">
+                <string>Export</string>
+            </property>
+            <property name="clickable">
+                <bool>true</bool>
+            </property>
+            <property name="resizable">
+                <bool>true</bool>
+            </property>
+        </column>
+        <property name="name">
+            <cstring>listView1</cstring>
+        </property>
+        <property name="geometry">
+            <rect>
+                <x>50</x>
+                <y>10</y>
+                <width>250</width>
+                <height>250</height>
+            </rect>
+        </property>
+    </widget>
+    <widget class="QLayoutWidget">
+        <property name="name">
+            <cstring>Layout1</cstring>
+        </property>
+        <property name="geometry">
+            <rect>
+                <x>10</x>
+                <y>300</y>
+                <width>330</width>
+                <height>33</height>
+            </rect>
+        </property>
+        <hbox>
+            <property name="name">
+                <cstring>unnamed</cstring>
+            </property>
+            <property name="margin">
+                <number>0</number>
+            </property>
+            <property name="spacing">
+                <number>6</number>
+            </property>
+            <widget class="QPushButton">
+                <property name="name">
+                    <cstring>buttonHelp</cstring>
+                </property>
+                <property name="text">
+                    <string>&amp;Help</string>
+                </property>
+                <property name="accel">
+                    <string>F1</string>
+                </property>
+                <property name="autoDefault">
+                    <bool>true</bool>
+                </property>
+            </widget>
+            <spacer>
+                <property name="name">
+                    <cstring>Horizontal Spacing2</cstring>
+                </property>
+                <property name="orientation">
+                    <enum>Horizontal</enum>
+                </property>
+                <property name="sizeType">
+                    <enum>Expanding</enum>
+                </property>
+                <property name="sizeHint">
+                    <size>
+                        <width>20</width>
+                        <height>20</height>
+                    </size>
+                </property>
+            </spacer>
+            <widget class="QPushButton">
+                <property name="name">
+                    <cstring>buttonOk</cstring>
+                </property>
+                <property name="text">
+                    <string>&amp;OK</string>
+                </property>
+                <property name="accel">
+                    <string></string>
+                </property>
+                <property name="autoDefault">
+                    <bool>true</bool>
+                </property>
+                <property name="default">
+                    <bool>true</bool>
+                </property>
+            </widget>
+            <widget class="QPushButton">
+                <property name="name">
+                    <cstring>buttonCancel</cstring>
+                </property>
+                <property name="text">
+                    <string>&amp;Cancel</string>
+                </property>
+                <property name="accel">
+                    <string></string>
+                </property>
+                <property name="autoDefault">
+                    <bool>true</bool>
+                </property>
+            </widget>
+        </hbox>
+    </widget>
+</widget>
+<connections>
+    <connection>
+        <sender>buttonOk</sender>
+        <signal>clicked()</signal>
+        <receiver>pyExportView</receiver>
+        <slot>accept()</slot>
+    </connection>
+    <connection>
+        <sender>buttonCancel</sender>
+        <signal>clicked()</signal>
+        <receiver>pyExportView</receiver>
+        <slot>reject()</slot>
+    </connection>
+</connections>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>


Property changes on: branches/developers/avida-edward/source/python/AvidaGui2/pyExportView.ui
___________________________________________________________________
Name: svn:executable
   + *

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphCtrl.py	2006-05-16 03:58:17 UTC (rev 681)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphCtrl.py	2006-05-16 18:45:10 UTC (rev 682)
@@ -4,6 +4,7 @@
 from Numeric import *
 from pyAvidaStatsInterface import pyAvidaStatsInterface
 from pyOneAna_GraphView import pyOneAna_GraphView
+from pyExportCtrl import pyExportCtrl
 from qt import *
 from qwt import *
 import os.path
@@ -106,7 +107,6 @@
     init_file.Load()
     init_file.Compress()
 
-
     x_array = zeros(init_file.GetNumLines(), Float)
     y_array = zeros(init_file.GetNumLines(), Float)
 
@@ -211,6 +211,55 @@
         filter.setOptions(QwtPlotPrintFilter.PrintAll & ~QwtPlotPrintFilter.PrintCanvasBackground)
       self.m_graph_ctrl.printPlot(printer, filter)
 
+  def exportSlot(self):
+    "Export analysis data to a file"
+    dialog_caption = "Export analysis as:"
+    fd = QFileDialog.getSaveFileName("", "CSV (Excel compatible) (*.csv)", None,
+                                     "export as", dialog_caption)
+    filename = str(fd)
+    if (filename[-4:].lower() != ".csv"):
+      filename += ".csv"
+
+    dialog = pyExportCtrl()
+    checks = []
+    # dictionary indexed by stat name so we can lookup stats to export
+    stats = {}
+    stat_cnt = 0
+    for stat in self.m_avida_stats_interface.m_entries:
+      # Note: this relies on labeling dummy stats with None
+      if stat[0] != "None":
+        stats[stat[0]] = stat_cnt
+        checks.append(QCheckListItem(dialog.listView1, stat[0],
+                                     QCheckListItem.CheckBox))
+        # enable last added checkbox
+        checks[len(checks) - 1].setOn(True)
+      stat_cnt += 1
+
+    res = dialog.showDialog()
+    if res == []:
+      return
+
+    data = {}
+    if self.m_combo_box_1.currentItem():
+      # Load stats for selected exports
+      # TODO: more efficient loading
+      for item in res:
+        idx = stats[item]
+        label1 = self.m_avida_stats_interface.m_entries[idx][0]
+        data[item] = self.load(self.m_avida_stats_interface.m_entries[idx][1],
+                               1,
+                               self.m_avida_stats_interface.m_entries[idx][2])
+
+      out_file = open(filename, 'w')
+      out_file.write("Update,%s\n" % (",".join(res)))
+      # TODO: get it working with zip
+      #print zip([data[elem][1][i] for elem in res])        
+      num_updates = len(data[res[0]][0])
+      for i in range(num_updates - 1):
+        out_file.write("%d,%s\n"
+                       % (i, ",".join([str(data[elem][1][i]) for elem in res])))
+      out_file.close()
+
   def petriDropped(self, e): 
       # a check in pyOneAnalyzeCtrl.py makes sure this is a valid path
       self.m_petri_dish_dir_exists_flag = True

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOneAnalyzeCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOneAnalyzeCtrl.py	2006-05-16 03:58:17 UTC (rev 681)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOneAnalyzeCtrl.py	2006-05-16 18:45:10 UTC (rev 682)
@@ -37,6 +37,11 @@
       self.m_session_mdl.m_session_mdtr,
       PYSIGNAL("printGraphSig"),
       self.m_one_ana_graph_ctrl.printGraphSlot)
+    # Disconnect export signal
+    self.disconnect(
+      self.m_session_mdl.m_session_mdtr,
+      PYSIGNAL("exportAnalyzeSig"),
+      self.m_one_ana_graph_ctrl.exportSlot)
   def aboutToBeRaised(self):
     """Connects "Print Graph..." menu item to One-Analyze Graph controller."""
     descr()
@@ -44,6 +49,10 @@
       self.m_session_mdl.m_session_mdtr,
       PYSIGNAL("printGraphSig"),
       self.m_one_ana_graph_ctrl.printGraphSlot)
+    # Connect export
+    self.connect(self.m_session_mdl.m_session_mdtr,
+                 PYSIGNAL("exportAnalyzeSig"),
+                 self.m_one_ana_graph_ctrl.exportSlot)
 
   def dragEnterEvent( self, e ):
     descr(e)

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOneOrg_ScopeCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOneOrg_ScopeCtrl.py	2006-05-16 03:58:17 UTC (rev 681)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOneOrg_ScopeCtrl.py	2006-05-16 18:45:10 UTC (rev 682)
@@ -14,7 +14,7 @@
     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.m_clock = qt.QTime()
+#    self.m_clock = qt.QTime()
     self.m_timer = qt.QTimer()
     self.m_next = qt.QTimer()
     self.m_timer_interval = 250
@@ -91,8 +91,8 @@
   def playSlot(self):
     print "pyOneOrg_ScopeCtrl.playSlot()."
     self.m_analyze_controls_ctrl.m_widget_stack.raiseWidget(self.m_analyze_controls_ctrl.m_pause_page)
-    self.m_timer.start(self.m_timer_interval, True)
-    self.m_clock.start()
+    self.m_timer.start(self.m_timer_interval, False)
+#    self.m_clock.start()
 
   def advanceSlot(self):
     #print "pyOneOrg_ScopeCtrl.advanceSlot()."
@@ -101,4 +101,4 @@
       self.pauseSlot()
     else:
       self.m_execution_step_slider.setValue(slider_value + 1)
-      self.m_timer.start(min(0, self.m_timer_interval - self.m_clock.restart(), True))
+#        self.m_timer.start(min(0, self.m_timer_interval - self.m_clock.restart(), True))




More information about the Avida-cvs mailing list