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

baerb@myxo.css.msu.edu baerb at myxo.css.msu.edu
Thu Jun 23 12:25:18 PDT 2005


Author: baerb
Date: 2005-06-23 15:25:18 -0400 (Thu, 23 Jun 2005)
New Revision: 220

Modified:
   trunk/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
   trunk/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py
   trunk/source/python/AvidaGui2/pyPetriConfigureCtrl.py
   trunk/source/python/AvidaGui2/pyPetriDishCtrl.py
   trunk/source/python/AvidaGui2/pyQuitDialogCtrl.py
   trunk/source/python/AvidaGui2/pyQuitDialogView.ui
Log:
Fixed code to correctly prompt to save full petri dish if it had not been
saved immediately before quiting.



Modified: trunk/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyEduWorkspaceCtrl.py	2005-06-23 00:37:12 UTC (rev 219)
+++ trunk/source/python/AvidaGui2/pyEduWorkspaceCtrl.py	2005-06-23 19:25:18 UTC (rev 220)
@@ -238,24 +238,20 @@
     if self.startStatus:
       self.m_session_mdl.m_session_mdtr.emit(
         PYSIGNAL("fromLiveCtrlStartAvidaSig"), ())
-      print "send start signal"
     else:
       self.m_session_mdl.m_session_mdtr.emit(
         PYSIGNAL("fromLiveCtrlPauseAvidaSig"), ())
-      print "send pause signal"
     
   def setAvidaSlot(self, avida):
     print "pyEduWorkspaceCtrl.setAvidaSlot() ..."
     old_avida = self.m_avida
     self.m_avida = avida
     if old_avida:
-      print "pyEduWorkspaceCtrl.setAvidaSlot() disconnecting old_avida ..."
       self.disconnect(
         old_avida.m_avida_thread_mdtr, PYSIGNAL("AvidaUpdatedSig"),
         self.avidaUpdatedSlot)
       del old_avida
     if self.m_avida:
-      print "pyEduWorkspaceCtrl.setAvidaSlot() connecting self.m_avida ..."
       self.connect(
         self.m_avida.m_avida_thread_mdtr, PYSIGNAL("AvidaUpdatedSig"),
         self.avidaUpdatedSlot)
@@ -274,12 +270,19 @@
     self.startStatus = False
     
   def startQuitProcessSlot(self):
-    print "*** full_saved = " + str(self.m_one_population_ctrl.m_session_mdl.saved_full_dish)
-    m_quit_avida_ed = pyQuitDialogCtrl()
-    quit_return = m_quit_avida_ed.showDialog()
-    if quit_return == m_quit_avida_ed.QuitFlag:
+
+    # Check if there unsaved petri dishes if there are ask the user if they 
+    # want to save them, just quit the program or cancel the quit.  If there
+    # are no unsaved populations just quit.
+    # (actually only works with one population will need to expand to
+    # two populations in the future)
+
+    if (not self.m_one_population_ctrl.m_session_mdl.saved_full_dish):
+      m_quit_avida_ed = pyQuitDialogCtrl()
+      quit_return = m_quit_avida_ed.showDialog()
+      if quit_return == m_quit_avida_ed.QuitFlag:
+        self.emit(PYSIGNAL("quitAvidaPhaseIISig"), ())
+      elif quit_return == m_quit_avida_ed.FreezeQuitFlag:
+        self.m_one_population_ctrl.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("freezeDishPhaseISig"), (False, True, ))
+    else:
       self.emit(PYSIGNAL("quitAvidaPhaseIISig"), ())
-    elif quit_return == m_quit_avida_ed.FreezeQuitFlag:
-      print "at pyEduWorkspaceCtrl:startQuitProcessSlot emited FreezeDishPhaseISig"
-      self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("FreezeDishPhaseISig"), (False, True, ))
-

Modified: trunk/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py	2005-06-23 00:37:12 UTC (rev 219)
+++ trunk/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py	2005-06-23 19:25:18 UTC (rev 220)
@@ -22,7 +22,6 @@
     self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("freezeDishPhaseISig"), self.m_petri_dish_ctrl.extractPopulationSlot)
     self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("freezeDishPhaseISig"), self.freezeDishPhaseISlot)
 
-    self.connect(self.m_petri_dish_ctrl, PYSIGNAL("freezeDishPhaseIISig"), self.m_petri_configure_ctrl.FreezePetriSlot)
     self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("setAvidaSig"), self.setAvidaSlot)
     self.connect(self.m_petri_dish_toggle, SIGNAL("clicked()"), self.ToggleDishSlot)
     self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("doDefrostDishSig"), self.shouldIDefrost)
@@ -143,8 +142,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
       else:
         freezer_item_name_temp = str(freezer_item_name)
+        self.m_session_mdl.saved_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,))

Modified: trunk/source/python/AvidaGui2/pyPetriConfigureCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyPetriConfigureCtrl.py	2005-06-23 00:37:12 UTC (rev 219)
+++ trunk/source/python/AvidaGui2/pyPetriConfigureCtrl.py	2005-06-23 19:25:18 UTC (rev 220)
@@ -164,6 +164,7 @@
        self.DeathTextLabel2.setEnabled(True)
        self.DeathTextLabel3.setEnabled(True)
        self.LifeSpanSpinBox.setEnabled(True)
+    self.m_session_mdl.saved_empty_dish = True
        
   def DisablePetriConfigureSlot(self):
 
@@ -313,11 +314,15 @@
       PYSIGNAL("doRefreshFreezerInventorySig"), ())
     if send_reset_signal:
       print "sending reset signal from pyPetriConfigureCtrl:FreezePetriSlot" 
+
+    # If the send_quit_signal flag was sent to this routine kill the application
+    # (Instead of killing the application directly a signal should be sent
+    # upto the workspace moderator)
+
     if send_quit_signal:
-      print "sending quit signal from pyPetriConfigureCtrl:FreezePetriSlot"
-      self.m_session_mdl.m_session_mdtr.emit(
-        PYSIGNAL("quitAvidaPhaseIISig"), ())
+      qApp.quit()
 
+
   def doLoadPetriDishConfigFileSlot(self, genesisFileName = None):
     genesis = cGenesis()
     genesis.Open(cString(genesisFileName))

Modified: trunk/source/python/AvidaGui2/pyPetriDishCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyPetriDishCtrl.py	2005-06-23 00:37:12 UTC (rev 219)
+++ trunk/source/python/AvidaGui2/pyPetriDishCtrl.py	2005-06-23 19:25:18 UTC (rev 220)
@@ -181,7 +181,8 @@
             organism = cell.GetOrganism()
             genome = organism.GetGenome()
             population_dict[cell.GetID()] = str(genome.AsString())
-    self.emit(PYSIGNAL("freezeDishPhaseIISig"), (population_dict, send_reset_signal, send_quit_signal, ))
+    self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("freezeDishPhaseIISig"), 
+      (population_dict, send_reset_signal, send_quit_signal, ))
 
   def zoomSlot(self, zoom_factor):
     if self.m_canvas_view:

Modified: trunk/source/python/AvidaGui2/pyQuitDialogCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyQuitDialogCtrl.py	2005-06-23 00:37:12 UTC (rev 219)
+++ trunk/source/python/AvidaGui2/pyQuitDialogCtrl.py	2005-06-23 19:25:18 UTC (rev 220)
@@ -20,7 +20,6 @@
     self.QuitPushButton.setDown(True)
     
   def showDialog(self):
-    self.SaveToFreezerPushButton.setHidden(True)
     dialog_result = 1
     while (dialog_result > 0):
       while (self.exec_loop() and self.result() == 0):

Modified: trunk/source/python/AvidaGui2/pyQuitDialogView.ui
===================================================================
--- trunk/source/python/AvidaGui2/pyQuitDialogView.ui	2005-06-23 00:37:12 UTC (rev 219)
+++ trunk/source/python/AvidaGui2/pyQuitDialogView.ui	2005-06-23 19:25:18 UTC (rev 220)
@@ -9,7 +9,7 @@
             <x>0</x>
             <y>0</y>
             <width>324</width>
-            <height>135</height>
+            <height>113</height>
         </rect>
     </property>
     <property name="caption">
@@ -19,6 +19,14 @@
         <property name="name">
             <cstring>unnamed</cstring>
         </property>
+        <widget class="QLabel">
+            <property name="name">
+                <cstring>WarningLabel</cstring>
+            </property>
+            <property name="text">
+                <string>The current petri dish has not been saved in the freezer.</string>
+            </property>
+        </widget>
         <widget class="QLayoutWidget">
             <property name="name">
                 <cstring>layout21</cstring>
@@ -53,16 +61,6 @@
                 </widget>
             </hbox>
         </widget>
-        <widget class="QLabel">
-            <property name="name">
-                <cstring>WarningLabel</cstring>
-            </property>
-            <property name="text">
-                <string>&lt;b&gt;WARNING!&lt;/b&gt; Quiting will not save current work&lt;br&gt;
-Select Cancel and click on "Freeze Petri Dish" &lt;br&gt;
-button to save current population and/or settings.</string>
-            </property>
-        </widget>
     </vbox>
 </widget>
 <connections>




More information about the Avida-cvs mailing list