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

kaben at myxo.css.msu.edu kaben at myxo.css.msu.edu
Fri Jul 4 01:48:55 PDT 2008


Author: kaben
Date: 2008-07-04 04:48:55 -0400 (Fri, 04 Jul 2008)
New Revision: 2709

Modified:
   branches/developers/avida-edward/source/python/AvidaGui2/pyAvidaStatsInterface.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
   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/pyOneOrganismCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_GraphCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyOnePopulationCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyRightClickDialogCtrl.py
Log:
In Avida-ED expand earlier bugfix: Switch the default export location for graphics and data, in addition to organisms and populations.


Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyAvidaStatsInterface.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyAvidaStatsInterface.py	2008-07-04 07:47:09 UTC (rev 2708)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyAvidaStatsInterface.py	2008-07-04 08:48:55 UTC (rev 2709)
@@ -2,6 +2,7 @@
 from AvidaCore import cInitFile, cString
 from AvidaCore import cPopulation, cStats
 from Numeric import *
+from DefaultExportDir import DefaultExportDir
 from pyButtonListDialog import pyButtonListDialog
 from qt import QFileDialog
 import os.path
@@ -66,7 +67,7 @@
       y_array[line_id] = line.GetWord(coly - 1).AsDouble()
     return x_array, y_array
 
-  def export(self, paths):
+  def export(self, paths, session_mdl):
     """Export stats to a file.  Can export multiple populations now.
     paths is a array of tuples containing short name and full path. """
 
@@ -93,9 +94,17 @@
     if res == []:
       return
 
+    initial_dir = DefaultExportDir(session_mdl.export_directory, "unititled")
+    initial_file_name = os.path.join(initial_dir, "unititled")
+
     fd = QFileDialog.getSaveFileName("", "Text -- Excel compatible (*.txt);;CSV  -- Excel compatible (*.csv)", None,
                                      "export as", dialog_caption)
+    if not fd:
+      return
+
     filename = str(fd)
+    session_mdl.export_directory = os.path.dirname(str(filename))
+
     if (filename[-4:].lower() != ".txt"):
       filename += ".txt"
 

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py	2008-07-04 07:47:09 UTC (rev 2708)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py	2008-07-04 08:48:55 UTC (rev 2709)
@@ -563,7 +563,7 @@
     files2process = self.curr_sel_files.split("\t")
     file_name = files2process[1]
 
-    initial_dir = DefaultExportDir(self.m_session_mdl.export_directory, os.path.dirname(file_name))
+    initial_dir = DefaultExportDir(self.m_session_mdl.export_directory, file_name)
     no_ext_name, file_ext = os.path.splitext(os.path.basename(file_name))
     initial_file_name = os.path.join(initial_dir,no_ext_name + ".aex")
   

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphCtrl.py	2008-07-04 07:47:09 UTC (rev 2708)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphCtrl.py	2008-07-04 08:48:55 UTC (rev 2709)
@@ -365,7 +365,7 @@
       if res == []:
         return
       paths = [(short_name, str(self.m_combo_boxes[short_name].m_petri_dish_dir_path)) for short_name in res]
-      self.m_avida_stats_interface.export(paths)
+      self.m_avida_stats_interface.export(paths, self.m_session_mdl)
 
 
   def petriDropped(self, freezer_item_name): 

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOneAnalyzeCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOneAnalyzeCtrl.py	2008-07-04 07:47:09 UTC (rev 2708)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOneAnalyzeCtrl.py	2008-07-04 08:48:55 UTC (rev 2709)
@@ -3,6 +3,7 @@
 from descr import *
 
 from qt import *
+from DefaultExportDir import DefaultExportDir
 from pyOneAnalyzeView import pyOneAnalyzeView
 from pyImageFileDialog import pyImageFileDialog
 import os.path
@@ -74,6 +75,7 @@
 
     workspace_ctrl.anaview_controlNo_controls_available_in_Analysis_ViewAction.setVisible(True)
 
+    workspace_ctrl.fileExportAction.setVisible(True)
 
   def dragEnterEvent( self, e ):
     freezer_item_list = QString()
@@ -125,7 +127,10 @@
 
   def saveImagesSlot(self):
     "Save image of graph"
+    initial_dir = DefaultExportDir(self.m_session_mdl.export_directory, "unititled")
+    initial_file_name = os.path.join(initial_dir, "unititled")
     dlg = pyImageFileDialog()
-    filename, type = dlg.saveImageDialog()
+    filename, type = dlg.saveImageDialog(initial_file_name)
     if filename:
       self.m_one_ana_graph_ctrl.m_graph_ctrl.saveImage(filename, type)
+      self.m_session_mdl.export_directory = os.path.dirname(str(filename))

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOneOrganismCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOneOrganismCtrl.py	2008-07-04 07:47:09 UTC (rev 2708)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOneOrganismCtrl.py	2008-07-04 08:48:55 UTC (rev 2709)
@@ -3,6 +3,7 @@
 from descr import *
 
 from qt import *
+from DefaultExportDir import DefaultExportDir
 from pyOneOrganismView import pyOneOrganismView
 from pyButtonListDialog import pyButtonListDialog
 from pyImageFileDialog import pyImageFileDialog
@@ -79,6 +80,8 @@
     self.workspace_ctrl.orgview_controlGo_To_StartAction.setVisible(True)
     self.workspace_ctrl.orgview_controlGo_To_EndAction.setVisible(True)
 
+    self.workspace_ctrl.fileExportAction.setVisible(False)
+
   def generatePixmaps(self, objects):
     pixmap = QPixmap()
 
@@ -169,15 +172,17 @@
     img_dlg = pyImageFileDialog()
     name = str(self.m_one_org_scope_ctrl.m_organism_scope_ctrl.m_organism_name)
     execution_step = self.m_one_org_scope_ctrl.m_execution_step_slider.value()
+    full_name = name + "-organism-step-" + str(execution_step)
+    initial_dir = DefaultExportDir(self.m_session_mdl.export_directory, full_name)
+    initial_file_name = os.path.join(initial_dir, full_name)
     filename, type = img_dlg.saveImageDialog(
-      name +
-      "-organism-step-" +
-      str(execution_step)
+      initial_file_name
     )
 
     # Save pixmap to image file.
     if filename:
       pixmap.save(filename, type, 100)
+      self.m_session_mdl.export_directory = os.path.dirname(str(filename))
 
 
   def printOrgSlot(self):

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_GraphCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_GraphCtrl.py	2008-07-04 07:47:09 UTC (rev 2708)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_GraphCtrl.py	2008-07-04 08:48:55 UTC (rev 2709)
@@ -138,4 +138,5 @@
     "Export stats to a file"
     if self.m_combo_box.currentItem():
       self.m_avida_stats_interface.export(
-        [("", self.m_session_mdl.m_tempdir_out)])
+        [("", self.m_session_mdl.m_tempdir_out)],
+        self.m_session_mdl)

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOnePopulationCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOnePopulationCtrl.py	2008-07-04 07:47:09 UTC (rev 2708)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOnePopulationCtrl.py	2008-07-04 08:48:55 UTC (rev 2709)
@@ -4,6 +4,7 @@
 
 from pyAvida import pyAvida
 from qt import *
+from DefaultExportDir import DefaultExportDir
 from pyOnePopulationView import pyOnePopulationView
 from pyButtonListDialog import pyButtonListDialog
 from pyGraphCtrl import PrintFilter
@@ -92,6 +93,8 @@
     workspace_ctrl.popview_controlNext_UpdateAction.setVisible(True)
     workspace_ctrl.popview_controlRestart_ExpAction.setVisible(True)
 
+    workspace_ctrl.fileExportAction.setVisible(True)
+
   def dragEnterEvent( self, e ):
 
     freezer_item_list = QString()
@@ -163,16 +166,22 @@
 
     # Save the image
     if res[0] == "Petri Dish":
-      filename, type = img_dlg.saveImageDialog(
-        name + "-" + "petridish-update" + str(update))
+      full_name = name + "-" + "petridish-update" + str(update)
+      initial_dir = DefaultExportDir(self.m_session_mdl.export_directory, full_name)
+      initial_file_name = os.path.join(initial_dir, full_name)
+      filename, type = img_dlg.saveImageDialog(initial_file_name)
       p = self.m_one_pop_petri_dish_ctrl.getPetriDishPixmap()
       if filename:
         p.save(filename, type, 100)
+        self.m_session_mdl.export_directory = os.path.dirname(str(filename))
     else:
-      filename, type = img_dlg.saveImageDialog(
-        name + "-" + "graph-update" + str(update))
+      full_name = name + "-" + "graph-update" + str(update)
+      initial_dir = DefaultExportDir(self.m_session_mdl.export_directory, full_name)
+      initial_file_name = os.path.join(initial_dir, full_name)
+      filename, type = img_dlg.saveImageDialog(initial_file_name)
       if filename:
         self.m_one_pop_graph_ctrl.m_graph_ctrl.saveImage(filename, type)
+        self.m_session_mdl.export_directory = os.path.dirname(str(filename))
 
   def printSlot(self):
     "Let user choose what object to print and send signal to appropriate slot"

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyRightClickDialogCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyRightClickDialogCtrl.py	2008-07-04 07:47:09 UTC (rev 2708)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyRightClickDialogCtrl.py	2008-07-04 08:48:55 UTC (rev 2709)
@@ -113,7 +113,7 @@
       # QFileDialog.getSaveFileName seems to require an absolute path
 
       user_dir = os.path.expanduser("~")
-      initial_dir = DefaultExportDir(self.session_mdl.export_directory, os.path.dirname)
+      initial_dir = DefaultExportDir(self.session_mdl.export_directory, self.file_dir)
       no_ext_name, ext = os.path.splitext(self.file_core_name)
       initial_file_name = os.path.join(initial_dir,no_ext_name + ".aex")
 




More information about the Avida-cvs mailing list