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

jclune at myxo.css.msu.edu jclune at myxo.css.msu.edu
Thu May 19 16:16:02 PDT 2005


Author: jclune
Date: 2005-05-19 19:16:02 -0400 (Thu, 19 May 2005)
New Revision: 166

Modified:
   trunk/source/python/AvidaGui2/pyOneAna_GraphCtrl.py
Log:
You can now choose different colors for your plot lines in analyze mode.


Modified: trunk/source/python/AvidaGui2/pyOneAna_GraphCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyOneAna_GraphCtrl.py	2005-05-19 20:02:44 UTC (rev 165)
+++ trunk/source/python/AvidaGui2/pyOneAna_GraphCtrl.py	2005-05-19 23:16:02 UTC (rev 166)
@@ -53,8 +53,15 @@
       self.m_combo_box_2.insertItem(entry[0])
 
     # set up the plot line color options
-    for entry in self.m_avida_stats_interface.m_entries:
-      self.m_combo_box_1.insertItem(entry[0])
+    self.m_Red = ['red', Qt.red]
+    self.m_Blue = ['blue', Qt.blue]
+    self.m_Green = ['green', Qt.green]
+    self.m_Colors = [self.m_Red, self.m_Blue, self.m_Green]
+    self.m_combo_box_1_color.clear()
+    self.m_combo_box_2_color.clear()
+    for color in self.m_Colors:
+      self.m_combo_box_1_color.insertItem(color[0])
+      self.m_combo_box_2_color.insertItem(color[0])
 
     
     # connect combo boxes to signal
@@ -62,6 +69,10 @@
       self.m_combo_box_1, SIGNAL("activated(int)"), self.modeActivatedSlot)
     self.connect(
       self.m_combo_box_2, SIGNAL("activated(int)"), self.modeActivatedSlot)
+    self.connect(
+      self.m_combo_box_1_color, SIGNAL("activated(int)"), self.modeActivatedSlot)
+    self.connect(
+      self.m_combo_box_2_color, SIGNAL("activated(int)"), self.modeActivatedSlot)
   
 
     self.m_x_array = zeros(2, Float)
@@ -70,12 +81,16 @@
     self.m_graph_ctrl.setAxisTitle(QwtPlot.xBottom, "Time (updates)")
     self.m_graph_ctrl.setAxisAutoScale(QwtPlot.xBottom)
 
-    # Start the left with second graph mode -- "Average Fitness".
+    # Start the left with second graph mode -- "Average Fitness"
     self.m_combo_box_1.setCurrentItem(2)
 
     # Start the right with zeroth mode -- "None"
     self.m_combo_box_2.setCurrentItem(0)
 
+    # Start the left with default of red
+    self.m_combo_box_1_color.setCurrentItem(0)
+    self.m_combo_box_2_color.setCurrentItem(2)
+
     self.modeActivatedSlot(self.m_combo_box_1.currentItem()) 
 
     self.connect(
@@ -83,7 +98,6 @@
       self.printGraphSlot)
 
   def load(self, filename, colx, coly):
-    print "pyOneAna_GraphCtrl.load - loading from file"
     init_file = cInitFile(cString('default.workspace/freezer/2k.full/' + filename))
     init_file.Load()
     init_file.Compress()
@@ -98,12 +112,8 @@
     return x_array, y_array
   
   def modeActivatedSlot(self, index):
-    self.m_graph_ctrl.setTitle(self.m_avida_stats_interface.m_entries[0][0])
     self.m_graph_ctrl.clear()
-    self.m_graph_ctrl.enableYRightAxis(False)
 
- 
-
     if self.m_combo_box_1.currentItem() or self.m_combo_box_2.currentItem():
 
       if self.m_combo_box_1.currentItem():
@@ -118,9 +128,11 @@
         )
         self.m_graph_ctrl.m_curve_1 = self.m_graph_ctrl.insertCurve(self.m_avida_stats_interface.m_entries[index_1][0])
         self.m_graph_ctrl.setCurveData(self.m_graph_ctrl.m_curve_1, self.m_curve_1_arrays[0], self.m_curve_1_arrays[1])
-        self.m_graph_ctrl.setCurvePen(self.m_graph_ctrl.m_curve_1, QPen(Qt.red))
+        self.m_graph_ctrl.setCurvePen(self.m_graph_ctrl.m_curve_1, QPen(self.m_Colors[self.m_combo_box_1_color.currentItem()][1]))  
         self.m_graph_ctrl.setCurveYAxis(self.m_graph_ctrl.m_curve_1, QwtPlot.yLeft)
-        self.m_graph_ctrl.setTitle(self.m_avida_stats_interface.m_entries[index_1][0])
+        if not self.m_combo_box_2.currentItem():
+          self.m_graph_ctrl.enableYRightAxis(False)
+          self.m_graph_ctrl.setTitle(self.m_avida_stats_interface.m_entries[index_1][0])
       else:
         self.m_graph_ctrl.enableYLeftAxis(False)
 
@@ -137,16 +149,17 @@
         )
         self.m_graph_ctrl.m_curve_2 = self.m_graph_ctrl.insertCurve(self.m_avida_stats_interface.m_entries[index_2][0])
         self.m_graph_ctrl.setCurveData(self.m_graph_ctrl.m_curve_2, self.m_curve_2_arrays[0], self.m_curve_2_arrays[1])
-        self.m_graph_ctrl.setCurvePen(self.m_graph_ctrl.m_curve_2, QPen(Qt.green))
+        self.m_graph_ctrl.setCurvePen(self.m_graph_ctrl.m_curve_2, QPen(self.m_Colors[self.m_combo_box_2_color.currentItem()][1]))
         self.m_graph_ctrl.setCurveYAxis(self.m_graph_ctrl.m_curve_2, QwtPlot.yRight)
-        self.m_graph_ctrl.setTitle(self.m_avida_stats_interface.m_entries[index_2][0])
+        if not self.m_combo_box_1.currentItem():
+          self.m_graph_ctrl.setTitle(self.m_avida_stats_interface.m_entries[index_2][0])
 
 
       self.m_graph_ctrl.setAxisAutoScale(QwtPlot.xBottom)
 
       if self.m_combo_box_1.currentItem() and self.m_combo_box_2.currentItem():    
-        self.m_graph_ctrl.setTitle(self.m_avida_stats_interface.m_entries[self.m_combo_box_1.currentItem()][0]+ ' (red) and ' + self.m_avida_stats_interface.m_entries[self.m_combo_box_2.currentItem()][0]+ 
-' (green)')
+        self.m_graph_ctrl.setTitle(self.m_avida_stats_interface.m_entries[self.m_combo_box_1.currentItem()][0]+ ' (' + self.m_Colors[self.m_combo_box_1_color.currentItem()][0] \
+        + ') and ' + self.m_avida_stats_interface.m_entries[self.m_combo_box_2.currentItem()][0]+ ' (' +  self.m_Colors[self.m_combo_box_2_color.currentItem()][0] +')')
         bounding_rect_1 = self.m_graph_ctrl.curve(self.m_graph_ctrl.m_curve_1).boundingRect()
         bounding_rect_2 = self.m_graph_ctrl.curve(self.m_graph_ctrl.m_curve_2).boundingRect()
         bounding_rect = bounding_rect_1.unite(bounding_rect_2)
@@ -158,6 +171,7 @@
       self.m_graph_ctrl.m_zoomer.setZoomBase(bounding_rect)
   
     else:   # goes with '   if self.m_combo_box_1.currentItem() or self.m_combo_box_2.currentItem():'
+       self.m_graph_ctrl.setTitle(self.m_avida_stats_interface.m_entries[0][0])
        self.m_graph_ctrl.setAxisTitle(QwtPlot.yLeft, self.m_avida_stats_interface.m_entries[0][0])
 
     self.m_graph_ctrl.replot()




More information about the Avida-cvs mailing list