[Avida-cvs] [Avida2-svn] r253 - trunk/source/python/AvidaGui2

baerb@myxo.css.msu.edu baerb at myxo.css.msu.edu
Fri Jul 22 13:07:00 PDT 2005


Author: baerb
Date: 2005-07-22 16:06:59 -0400 (Fri, 22 Jul 2005)
New Revision: 253

Modified:
   trunk/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py
Log:
The basic part of restart is working -- though there are a number of annoying
problems.



Modified: trunk/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py	2005-07-22 19:17:51 UTC (rev 252)
+++ trunk/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py	2005-07-22 20:06:59 UTC (rev 253)
@@ -6,6 +6,7 @@
 import os
 from pyReadFreezer import pyReadFreezer
 from pyGradientScaleView import pyGradientScaleView
+from pyQuitDialogCtrl import pyQuitDialogCtrl
 
 
 class pyOnePop_PetriDishCtrl(pyOnePop_PetriDishView):
@@ -19,17 +20,12 @@
     self.m_avida = None
     self.dishDisabled = False
 
-    print "*** pyOnePop_PetriDishCtrl.py:consruct about to call m_petri_dish_ctrl.construct ***"
     self.m_petri_dish_ctrl.construct(self.m_session_mdl)
 
-    print "*** pyOnePop_PetriDishCtrl.py:consruct about to call m_gradient_scale_ctrl.construct ***"
     self.m_gradient_scale_ctrl.construct(self.m_session_mdl)
-    print "*** pyOnePop_PetriDishView.py:consruct about to call m_gradient_scale_view.construct ***"
     self.m_gradient_scale_view.construct(self.m_session_mdl)
 
-    print "*** pyOnePop_PetriDishCtrl.py:consruct about to call m_live_controls_ctrl.construct ***"
     self.m_live_controls_ctrl.construct(self.m_session_mdl)
-    print "*** pyOnePop_PetriDishCtrl.py:consruct about to call m_petri_configure_ctrl.construct ***"
     self.m_petri_configure_ctrl.construct(self.m_session_mdl)
     self.connect(self.m_session_mdl.m_session_mdtr,
       PYSIGNAL("freezeDishPhaseISig"),
@@ -41,13 +37,15 @@
     self.connect(self.m_petri_dish_toggle, SIGNAL("clicked()"), 
       self.ToggleDishSlot)
     self.connect(self.m_session_mdl.m_session_mdtr, 
-      PYSIGNAL("doDefrostDishSig"), self.shouldIDefrost)
+      PYSIGNAL("doDefrostDishSig"), self.DefrostSlot)
 #    self.connect(self.m_session_mdl.m_session_mdtr, 
 #       PYSIGNAL("doDefrostDishSig"), self.RenameDishSlot)
 #    self.connect(self.m_session_mdl.m_session_mdtr, 
 #       PYSIGNAL("doDefrostDishSig"), self.MakeConfigVisiableSlot)
     self.connect(self.m_session_mdl.m_session_mdtr, 
        PYSIGNAL("doDisablePetriDishSig"), self.SetDishDisabledSlot)
+    self.connect(self.m_session_mdl.m_session_mdtr, 
+       PYSIGNAL("doEnablePetriDishSig"), self.SetDishEnabledSlot)
     self.connect(self.m_zoom_spinbox, SIGNAL("valueChanged(int)"), 
        self.m_petri_dish_ctrl.zoomSlot)
     self.connect(self.m_petri_dish_ctrl, PYSIGNAL("zoomSig"), 
@@ -56,11 +54,10 @@
        self.modeActivatedSlot)
     self.connect(self.m_session_mdl.m_session_mdtr, 
       PYSIGNAL("petriDishDroppedInPopViewSig"), self.petriDropped)  
-    print "*** pyOnePop_PetriDishCtrl.py:consruct about to call m_mode_combobox.clear ***"
+    self.connect(self.m_session_mdl.m_session_mdtr, 
+      PYSIGNAL("finishedPetriDishSig"), self.finishedPetriDishSlot)  
     self.m_mode_combobox.clear()
-    print "*** pyOnePop_PetriDishCtrl.py:consruct about to call m_mode_combobox.setInsertionPolicy ***"
     self.m_mode_combobox.setInsertionPolicy(QComboBox.AtBottom)
-    print "*** pyOnePop_PetriDishCtrl.py:consruct about to call pyMapProfile ***"
     self.m_map_profile = pyMapProfile(self.m_session_mdl)
     for i in range(self.m_map_profile.getSize()):
       self.m_mode_combobox.insertItem(self.m_map_profile.getModeName(i))
@@ -112,6 +109,9 @@
   def SetDishDisabledSlot(self):
     self.dishDisabled = True
 
+  def SetDishEnabledSlot(self):
+    self.dishDisabled = False
+
   def modeActivatedSlot(self, index):
     self.m_avida and self.m_avida.m_avida_threaded_driver.m_lock.acquire()
     self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("mapModeChangedSig"), (self.m_map_profile.getModeName(index),))
@@ -148,9 +148,8 @@
     if update: self.m_update_label.setText(QString("%1").arg(update))
     
   def RenameDishSlot(self, dishName):
-    if self.dishDisabled:
-      return
-    self.PopulationTextLabel.setText(dishName)
+    if (not self.dishDisabled):
+      self.PopulationTextLabel.setText(dishName)
     
   # Dummy routine
     
@@ -169,10 +168,10 @@
         return
       elif freezer_item_name[-4:] == 'full':
         freezer_item_name_temp = os.path.join(str(freezer_item_name), 'petri_dish')
-        self.m_session_mdl.saved_full_dish = True
+        self.m_session_mdl.new_full_dish = True
       else:
         freezer_item_name_temp = str(freezer_item_name)
-        self.m_session_mdl.saved_empty_dish = True
+        self.m_session_mdl.new_empty_dish = True
       thawed_item = pyReadFreezer(freezer_item_name_temp)
       self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("doDefrostDishSig"),  
         (os.path.splitext((os.path.split(str(freezer_item_name))[1]))[0], thawed_item,))
@@ -181,11 +180,56 @@
       current_page_int = self.m_petri_dish_widget_stack.id(current_page)
       self.MakeConfigVisiableSlot()
 
-  def shouldIDefrost(self, dishName):
+  def DefrostSlot(self, dish_name, petri_dict):
     if self.isVisible():
-      self.RenameDishSlot(dishName)
+
+      Restart_Only_Flag = False
+      # If the petri dish is already filled prompt the user if they want to 
+      # freeze the existing dish
+
+      if self.m_petri_configure_ctrl.DishDisabled:
+
+        self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("doPauseAvidaSig"), ())
+
+        # check to see if the user needs/wants to save (recycle the quit dialog
+        # widget) the dish
+
+        if (not self.m_session_mdl.saved_full_dish):
+          m_check_to_freeze = pyQuitDialogCtrl("Restart")
+          quit_return = m_check_to_freeze.showDialog()
+          if quit_return == m_check_to_freeze.QuitFlag:
+            Restart_Only_Flag = True
+            self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("doEnablePetriDishSig"), ())
+          elif quit_return == m_check_to_freeze.FreezeQuitFlag:
+            print "BDB: Freeze than Restart" 
+            self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("doEnablePetriDishSig"), ())
+            self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("freezeDishPhaseISig"), (True, False, ))
+  
+          # if the user clicked the cancel button
+  
+          else:
+            print "BDB: hit cancel button"
+            return
+
+      self.RenameDishSlot(dish_name)
       self.MakeConfigVisiableSlot()
+      self.finishedPetriDish = False
+      self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("FillDishSig"), 
+        (dish_name, petri_dict, ))
+ 
+      # Be sure that the petri dish is finished being filled before going on
 
+      while (not self.finishedPetriDish):
+        pass
+
+      if (Restart_Only_Flag):
+        print "BDB: sending reset signal from pyPetriConfigureCtrl:FillDishSlot"
+        self.m_session_mdl.m_session_mdtr.emit(
+          PYSIGNAL("restartPopulationSig"), (self.m_session_mdl, ))
+
+  def finishedPetriDishSlot(self):
+    self.finishedPetriDish = True
+
   def restart(self, session_mdl):
     print "pyOnePop_PetriDishCtrl.py:restart called"
     self.dishDisabled = False
@@ -204,7 +248,7 @@
     # self.disconnect(self.m_petri_dish_toggle, SIGNAL("clicked()"), 
     #   self.ToggleDishSlot)
     # self.disconnect(self.m_session_mdl.m_session_mdtr, 
-    #   PYSIGNAL("doDefrostDishSig"), self.shouldIDefrost)
+    #   PYSIGNAL("doDefrostDishSig"), self.DefrostSlot)
     # self.disconnect(self.m_session_mdl.m_session_mdtr, 
     #    PYSIGNAL("doDisablePetriDishSig"), self.SetDishDisabledSlot)
     # self.disconnect(self.m_zoom_spinbox, SIGNAL("valueChanged(int)"), 




More information about the Avida-cvs mailing list