[Avida-cvs] [avida-svn] r764 - branches/developers/avida-edward/source/python/AvidaGui2
gerrishj@myxo.css.msu.edu
gerrishj at myxo.css.msu.edu
Wed Jun 21 14:24:27 PDT 2006
Author: gerrishj
Date: 2006-06-21 17:24:27 -0400 (Wed, 21 Jun 2006)
New Revision: 764
Modified:
branches/developers/avida-edward/source/python/AvidaGui2/pyAvidaStatsInterface.py
branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphCtrl.py
branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphView.ui
branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_PetriDishCtrl.py
branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_GraphCtrl.py
Log:
Multiple populations can be analyzed in Analyze Mode now.
pyAvidaStatsInterface redesigned, added class interface to stat entries.
Spreadsheet (CSV) export can export multiple populations at a time now.
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyAvidaStatsInterface.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyAvidaStatsInterface.py 2006-06-21 01:15:57 UTC (rev 763)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyAvidaStatsInterface.py 2006-06-21 21:24:27 UTC (rev 764)
@@ -6,9 +6,24 @@
from qt import QFileDialog
import os.path
+class pyAvidaStatsEntry:
+ def __init__(self, name, file, index, func):
+ self.name = name
+ self.file = file
+ self.index = index
+ self.func = func
+ def setname(self, name):
+ self.name = name
+ def setfile(self, file):
+ self.file = file
+ def setindex(self, index):
+ self.index = index
+ def setfunc(self, func):
+ self.func = func
+
class pyAvidaStatsInterface:
def __init__(self):
- self.m_entries = (
+ self.m_e = (
('None', None, 0, None),
('Average Metabolic Rate', 'average.dat', 2, lambda s: s.GetAveMerit()),
('Average Fitness', 'average.dat', 4, lambda s: s.GetAveFitness()),
@@ -27,10 +42,14 @@
# ('Number of Births', 'count.dat', 9, lambda s: s.GetNumBirths()),
# ('Number of Deaths', 'count.dat', 10, lambda s: s.GetNumDeaths()),
)
+ self.m_entries = []
+ for entry in self.m_e:
+ self.m_entries.append(pyAvidaStatsEntry(entry[0], entry[1], entry[2],
+ entry[3]))
def getValue(self, entry_index, stats):
if entry_index:
- return self.m_entries[entry_index][3](stats)
+ return self.m_entries[entry_index].func(stats)
def load(self, path, filename, colx, coly):
"Load stats from file"
@@ -47,8 +66,9 @@
y_array[line_id] = line.GetWord(coly - 1).AsDouble()
return x_array, y_array
- def export(self, path):
- "Export stats to a file"
+ def export(self, paths):
+ """Export stats to a file. Can export multiple populations now.
+ paths is a array of tuples containing short name and full path. """
dialog_caption = "Export Analysis"
fd = QFileDialog.getSaveFileName("", "CSV (Excel compatible) (*.txt);;CSV (Excel compatible) (*.csv)", None,
"export as", dialog_caption)
@@ -62,9 +82,9 @@
stat_cnt = 0
for stat in self.m_entries:
# Note: this relies on labeling dummy stats with None
- if stat[0] != "None":
- stats[stat[0]] = stat_cnt
- checks.append(stat[0])
+ if stat.name != "None":
+ stats[stat.name] = stat_cnt
+ checks.append(stat.name)
stat_cnt += 1
dialog = pyButtonListDialog(dialog_caption, "Choose stats to export",
@@ -80,20 +100,43 @@
data = {}
# Load stats for selected exports
- # TODO: more efficient loading
- for item in res:
- idx = stats[item]
- label1 = self.m_entries[idx][0]
- data[item] = self.load(path, self.m_entries[idx][1], 1,
- self.m_entries[idx][2])
+ for population, path in paths:
+ data[population] = {}
+ for item in res:
+ idx = stats[item]
+ label1 = self.m_entries[idx].name
+ data[population][item] = self.load(path, self.m_entries[idx].file, 1,
+ self.m_entries[idx].index)
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):
- out_file.write("%d,%s\n"
- % (i, ",".join([str(data[elem][1][i]) for elem in res])))
+ # write out the header
+ out_file.write("Update,")
+ header = ""
+ for population, path in paths:
+ if header != "":
+ header += ","
+ header += ",".join(["%s %s" % (population, item) for item in res])
+ header += "\n"
+ out_file.write(header)
+
+ max_updates = 0
+ # find the number of updates in each population
+ for population, path in paths:
+ data[population]["num_updates"] = len(data[population][res[0]][0])
+ if data[population]["num_updates"] > max_updates:
+ max_updates = data[population]["num_updates"]
+
+ # write out the data
+ for i in range(max_updates):
+ tmp = "%d" % (i)
+ for population, path in paths:
+ tmp += ","
+ if data[population]["num_updates"] > i:
+ tmp += ",".join([str(data[population][elem][1][i]) for elem in res])
+ else:
+ tmp += ",".join(["" for elem in res])
+ tmp += "\n"
+ out_file.write(tmp)
+
out_file.close()
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphCtrl.py 2006-06-21 01:15:57 UTC (rev 763)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphCtrl.py 2006-06-21 21:24:27 UTC (rev 764)
@@ -4,165 +4,275 @@
from pyAvidaStatsInterface import pyAvidaStatsInterface
from pyOneAna_GraphView import pyOneAna_GraphView
from pyGraphCtrl import PrintFilter
+from pyButtonListDialog import pyButtonListDialog
from qt import *
from qwt import *
import os.path
+# This class deals with the graphing information for a single population
+# It also holds the widget for control of the graph
+class pyPopulationGraph:
+ def __init__(self, parent = None, label = None):
+ "Add another combo box group for new population"
+ if not parent:
+ print "No parent for population widget"
+ return None
+
+ if not label:
+ print "No label for box"
+ return None
+
+ self.label = label
+
+ # Setup the combo boxes that control the graph
+ self.layout = QHBoxLayout(None, 0, 6, "row%s_layout" %(label))
+
+ self.layout.spacer200_1 = QSpacerItem(23, 16, QSizePolicy.Preferred,
+ QSizePolicy.Minimum)
+ self.layout.addItem(self.layout.spacer200_1)
+
+ self.layout.m_population = QLabel(parent, "row%s_m_population" % (label))
+ self.layout.m_population.setMinimumWidth(100)
+ self.layout.addWidget(self.layout.m_population)
+
+ self.layout.m_combo_box_1 = QComboBox(0, parent, "row%s_m_combo_box_1" % (label))
+ self.layout.m_combo_box_1_font = QFont(self.layout.m_combo_box_1.font())
+ self.layout.m_combo_box_1_font.setPointSize(11)
+ self.layout.m_combo_box_1.setFont(self.layout.m_combo_box_1_font)
+ self.layout.addWidget(self.layout.m_combo_box_1)
+
+ self.layout.m_combo_box_1_color = QComboBox(0, parent,
+ "row%s_m_combo_box_1_color" %(label))
+ self.layout.addWidget(self.layout.m_combo_box_1_color)
+ self.layout.spacer200_2 = QSpacerItem(40, 16, QSizePolicy.Expanding,
+ QSizePolicy.Minimum)
+ self.layout.addItem(self.layout.spacer200_2)
+
+ self.layout.m_combo_box_2 = QComboBox(0, parent,
+ "row%s_m_combo_box_2" % (label))
+ self.layout.m_combo_box_2_font = QFont(self.layout.m_combo_box_2.font())
+ self.layout.m_combo_box_2_font.setPointSize(11)
+ self.layout.m_combo_box_2.setFont(self.layout.m_combo_box_2_font)
+ self.layout.addWidget(self.layout.m_combo_box_2)
+
+ self.layout.m_combo_box_2_color = QComboBox(0, parent,
+ "row%s_m_combo_box_2_color" %(label))
+ self.layout.addWidget(self.layout.m_combo_box_2_color)
+
+ self.layout.spacer200_3 = QSpacerItem(40, 16, QSizePolicy.Expanding,
+ QSizePolicy.Minimum)
+ self.layout.addItem(self.layout.spacer200_3)
+
+ self.layout.m_del_button = QPushButton("-", parent)
+ self.layout.addWidget(self.layout.m_del_button)
+
+ self.layout.spacer200_4 = QSpacerItem(75, 16, QSizePolicy.Expanding,
+ QSizePolicy.Minimum)
+ self.layout.addItem(self.layout.spacer200_4)
+
+ self.layout.m_population.setText(label)
+
+ self.parent = parent
+
+ parent.layout().addItem(self.layout)
+
+ def del_population_slot(self):
+ "Remove this population's controls from the display"
+ self.parent.layout().removeItem(self.layout)
+ # hide the widgets
+ self.layout.m_population.hide()
+ self.layout.m_combo_box_1.hide()
+ self.layout.m_combo_box_1_color.hide()
+ self.layout.m_combo_box_2.hide()
+ self.layout.m_combo_box_2_color.hide()
+ self.layout.m_del_button.hide()
+ del self.parent.m_combo_boxes[self.label]
+
+ self.parent.modeActivatedSlot()
+
class pyOneAna_GraphCtrl(pyOneAna_GraphView):
- def __init__(self,parent = None,name = None,fl = 0):
+ def __init__(self, parent = None, name = None, fl = 0):
pyOneAna_GraphView.__init__(self,parent,name,fl)
self.m_avida_stats_interface = pyAvidaStatsInterface()
+ self.m_combo_boxes = {}
+
+ def construct_box(self, widget):
+ "Initialize new combo box group with stat information"
+ widget.layout.m_combo_box_1.clear()
+ widget.layout.m_combo_box_2.clear()
+ widget.layout.m_combo_box_1.setInsertionPolicy(QComboBox.AtBottom)
+ widget.layout.m_combo_box_2.setInsertionPolicy(QComboBox.AtBottom)
+
+ # set up the combo boxes with plot options
+ for entry in self.m_avida_stats_interface.m_entries:
+ widget.layout.m_combo_box_1.insertItem(entry.name)
+ for entry in self.m_avida_stats_interface.m_entries:
+ widget.layout.m_combo_box_2.insertItem(entry.name)
+
+ widget.layout.m_combo_box_1_color.clear()
+ widget.layout.m_combo_box_2_color.clear()
+ for color in self.m_Colors:
+ widget.layout.m_combo_box_1_color.insertItem(color[0])
+ widget.layout.m_combo_box_2_color.insertItem(color[0])
+
+ # connect combo boxes to signal
+ self.connect(widget.layout.m_combo_box_1, SIGNAL("activated(int)"),
+ self.modeActivatedSlot)
+ self.connect(widget.layout.m_combo_box_2, SIGNAL("activated(int)"),
+ self.modeActivatedSlot)
+ self.connect(widget.layout.m_combo_box_1_color, SIGNAL("activated(int)"),
+ self.modeActivatedSlot)
+ self.connect(widget.layout.m_combo_box_2_color, SIGNAL("activated(int)"),
+ self.modeActivatedSlot)
+ self.connect(widget.layout.m_del_button, SIGNAL("clicked()"),
+ widget.del_population_slot)
+
+ # Start the left with second graph mode -- "Average Fitness"
+ widget.layout.m_combo_box_1.setCurrentItem(2)
+
+ # Start the right with zeroth mode -- "None"
+ widget.layout.m_combo_box_2.setCurrentItem(0)
+
+ # Start the left with default of red
+ widget.layout.m_combo_box_1_color.setCurrentItem(0)
+ widget.layout.m_combo_box_2_color.setCurrentItem(2)
+
+ self.resize(self.sizeHint())
+
+ # Show the contents
+ widget.layout.m_population.show()
+ widget.layout.m_combo_box_1.show()
+ widget.layout.m_combo_box_1_color.show()
+ widget.layout.m_combo_box_2.show()
+ widget.layout.m_combo_box_2_color.show()
+ widget.layout.m_del_button.show()
+
def construct(self, session_mdl):
self.m_session_mdl = session_mdl
self.m_avida = None
self.m_graph_ctrl.construct(self.m_session_mdl)
- self.m_combo_box_1.clear()
- self.m_combo_box_2.clear()
- self.m_combo_box_1.setInsertionPolicy(QComboBox.AtBottom)
- self.m_combo_box_2.setInsertionPolicy(QComboBox.AtBottom)
self.m_petri_dish_dir_path = ' '
self.m_petri_dish_dir_exists_flag = False
self.connect( self.m_session_mdl.m_session_mdtr,
PYSIGNAL("freezerItemDoubleClickedOnInOneAnaSig"),
- self.freezerItemDoubleClickedOn)
+ self.freezerItemDoubleClickedOn)
-
- # set up the combo boxes with plot options
- for entry in self.m_avida_stats_interface.m_entries:
- self.m_combo_box_1.insertItem(entry[0])
- for entry in self.m_avida_stats_interface.m_entries:
- self.m_combo_box_2.insertItem(entry[0])
-
# set up the plot line color options
self.m_Red = ['red', Qt.red]
self.m_Blue = ['blue', Qt.blue]
self.m_Green = ['green', Qt.green]
self.m_ThickBlue = ['thick', Qt.blue]
self.m_Colors = [self.m_Red, self.m_Blue, self.m_Green, self.m_ThickBlue]
- 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
- self.connect(
- 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.connect( self.m_session_mdl.m_session_mdtr, PYSIGNAL("freezerItemDroppedInOneAnalyzeSig"),
- self.petriDropped)
+ self.connect(self.m_session_mdl.m_session_mdtr,
+ PYSIGNAL("freezerItemDroppedInOneAnalyzeSig"),
+ self.petriDropped)
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"
- self.m_combo_box_1.setCurrentItem(2)
+ def graph_row(self, row):
+ layout = row.layout
+ if row.layout.m_combo_box_1.currentItem() or row.layout.m_combo_box_2.currentItem():
- # Start the right with zeroth mode -- "None"
- self.m_combo_box_2.setCurrentItem(0)
+ if row.layout.m_combo_box_1.currentItem():
+ index_1 = row.layout.m_combo_box_1.currentItem()
- # 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()
-
- def modeActivatedSlot(self, index = None): #note: index is not used
- self.m_graph_ctrl.clear()
-
- #check to see if we have a valid directory path to analyze
- if self.m_petri_dish_dir_exists_flag == False:
- return
-
- if self.m_combo_box_1.currentItem() or self.m_combo_box_2.currentItem():
-
- if self.m_combo_box_1.currentItem():
- index_1 = self.m_combo_box_1.currentItem()
-
#check to see if the file exists
- if os.path.isfile(os.path.join(str(self.m_petri_dish_dir_path), self.m_avida_stats_interface.m_entries[index_1][1])):
+ if os.path.isfile(os.path.join(
+ str(row.m_petri_dish_dir_path),
+ self.m_avida_stats_interface.m_entries[index_1].file)):
pass
else:
print "error: there is no data file in the directory to load from"
- 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.setTitle(
+ self.m_avida_stats_interface.m_entries[0].name)
+ self.m_graph_ctrl.setAxisTitle(
+ QwtPlot.yLeft, self.m_avida_stats_interface.m_entries[0].name)
self.m_graph_ctrl.replot()
return
- self.m_graph_ctrl.setAxisTitle(QwtPlot.yLeft, self.m_avida_stats_interface.m_entries[index_1][0])
+ self.m_graph_ctrl.setAxisTitle(
+ QwtPlot.yLeft, self.m_avida_stats_interface.m_entries[index_1].name)
self.m_graph_ctrl.enableYLeftAxis(True)
self.m_graph_ctrl.setAxisAutoScale(QwtPlot.yLeft)
- print "index_1[2] is"
- print self.m_avida_stats_interface.m_entries[index_1][2]
self.m_curve_1_arrays = self.m_avida_stats_interface.load(
- str(self.m_petri_dish_dir_path),
- self.m_avida_stats_interface.m_entries[index_1][1],
+ str(row.m_petri_dish_dir_path),
+ self.m_avida_stats_interface.m_entries[index_1].file,
1,
- self.m_avida_stats_interface.m_entries[index_1][2]
+ self.m_avida_stats_interface.m_entries[index_1].index
)
- 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(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)
- if not self.m_combo_box_2.currentItem():
+ row.m_curve_1 = self.m_graph_ctrl.insertCurve(self.m_avida_stats_interface.m_entries[index_1].name)
+ self.m_graph_ctrl.setCurveData(row.m_curve_1, self.m_curve_1_arrays[0], self.m_curve_1_arrays[1])
+ self.m_graph_ctrl.setCurvePen(row.m_curve_1, QPen(self.m_Colors[row.layout.m_combo_box_1_color.currentItem()][1]))
+ self.m_graph_ctrl.setCurveYAxis(row.m_curve_1, QwtPlot.yLeft)
+ if not row.layout.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])
+ self.m_graph_ctrl.setTitle(self.m_avida_stats_interface.m_entries[index_1].name)
else:
self.m_graph_ctrl.enableYLeftAxis(False)
- if self.m_combo_box_2.currentItem():
- index_2 = self.m_combo_box_2.currentItem()
- self.m_graph_ctrl.setAxisTitle(QwtPlot.yRight, self.m_avida_stats_interface.m_entries[index_2][0])
+ if row.layout.m_combo_box_2.currentItem():
+ index_2 = row.layout.m_combo_box_2.currentItem()
+ self.m_graph_ctrl.setAxisTitle(QwtPlot.yRight, self.m_avida_stats_interface.m_entries[index_2].name)
self.m_graph_ctrl.enableYRightAxis(True)
self.m_graph_ctrl.setAxisAutoScale(QwtPlot.yRight)
self.m_curve_2_arrays = self.m_avida_stats_interface.load(
- str(self.m_petri_dish_dir_path),
- self.m_avida_stats_interface.m_entries[index_2][1],
+ str(row.m_petri_dish_dir_path),
+ self.m_avida_stats_interface.m_entries[index_2].file,
1,
- self.m_avida_stats_interface.m_entries[index_2][2]
+ self.m_avida_stats_interface.m_entries[index_2].index
)
- 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])
- if self.m_Colors[self.m_combo_box_2_color.currentItem()][0] is 'thick':
- self.m_graph_ctrl.setCurvePen(self.m_graph_ctrl.m_curve_2, QPen(self.m_Colors[self.m_combo_box_2_color.currentItem()][1],3))
+ row.m_curve_2 = self.m_graph_ctrl.insertCurve(self.m_avida_stats_interface.m_entries[index_2].name)
+ self.m_graph_ctrl.setCurveData(row.m_curve_2, self.m_curve_2_arrays[0], self.m_curve_2_arrays[1])
+ if self.m_Colors[row.layout.m_combo_box_2_color.currentItem()][0] is 'thick':
+ self.m_graph_ctrl.setCurvePen(row.m_curve_2, QPen(self.m_Colors[row.layout.m_combo_box_2_color.currentItem()][1],3))
else:
- 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)
- 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.setCurvePen(row.m_curve_2, QPen(self.m_Colors[row.layout.m_combo_box_2_color.currentItem()][1]))
+ self.m_graph_ctrl.setCurveYAxis(row.m_curve_2, QwtPlot.yRight)
+ if not row.layout.m_combo_box_1.currentItem():
+ self.m_graph_ctrl.setTitle(self.m_avida_stats_interface.m_entries[index_2].name)
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]+ ' (' + 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()
+ if row.layout.m_combo_box_1.currentItem() and row.layout.m_combo_box_2.currentItem():
+ self.m_graph_ctrl.setTitle(self.m_avida_stats_interface.m_entries[row.layout.m_combo_box_1.currentItem()].name + ' (' + self.m_Colors[row.layout.m_combo_box_1_color.currentItem()][0] \
+ + ') and ' + self.m_avida_stats_interface.m_entries[row.layout.m_combo_box_2.currentItem()].name+ ' (' + self.m_Colors[row.layout.m_combo_box_2_color.currentItem()][0] +')')
+ bounding_rect_1 = self.m_graph_ctrl.curve(row.m_curve_1).boundingRect()
+ bounding_rect_2 = self.m_graph_ctrl.curve(row.m_curve_2).boundingRect()
bounding_rect = bounding_rect_1.unite(bounding_rect_2)
- elif self.m_combo_box_1.currentItem():
- bounding_rect = self.m_graph_ctrl.curve(self.m_graph_ctrl.m_curve_1).boundingRect()
+ elif row.layout.m_combo_box_1.currentItem():
+ bounding_rect = self.m_graph_ctrl.curve(row.m_curve_1).boundingRect()
else:
- bounding_rect = self.m_graph_ctrl.curve(self.m_graph_ctrl.m_curve_2).boundingRect()
+ bounding_rect = self.m_graph_ctrl.curve(row.m_curve_2).boundingRect()
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])
+ else: # goes with ' if row.layout.m_combo_box_1.currentItem() or row.layout.m_combo_box_2.currentItem():'
+ self.m_graph_ctrl.setTitle(self.m_avida_stats_interface.m_entries[0].name)
+ self.m_graph_ctrl.setAxisTitle(QwtPlot.yLeft, self.m_avida_stats_interface.m_entries[0].name)
+ def modeActivatedSlot(self, selected = None, index = None):
+
+ #check to see if we have a valid directory path to analyze
+ if self.m_petri_dish_dir_exists_flag == False:
+ return
+
+ if index:
+ self.graph_row(self.m_combo_boxes[index])
+ else:
+ self.m_graph_ctrl.clear()
+ # loop through the different populations we are analyzing
+ for row in self.m_combo_boxes.keys():
+ self.graph_row(self.m_combo_boxes[row])
+
self.m_graph_ctrl.replot()
def printSlot(self):
@@ -175,8 +285,18 @@
def exportSlot(self):
"Export analysis data to a file"
- if self.m_combo_box_1.currentItem():
- self.m_avida_stats_interface.export(str(self.m_petri_dish_dir_path))
+ if len(self.m_combo_boxes) > 0:
+ # Choose populations to export
+ dialog_caption = "Export Analysis"
+ dialog = pyButtonListDialog(dialog_caption,
+ "Choose populations to export",
+ self.m_combo_boxes.keys(), True)
+ [button.setOn(True) for button in dialog.buttons]
+ res = dialog.showDialog()
+ 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)
def petriDropped(self, e):
@@ -186,8 +306,15 @@
freezer_item_name = QString()
if ( QTextDrag.decode( e, freezer_item_name ) ) :
freezer_item_name = str(e.encodedData("text/plain"))
- self.m_petri_dish_dir_path = freezer_item_name
- self.modeActivatedSlot()
+ short_name = os.path.splitext(os.path.split(freezer_item_name)[1])[0]
+ if short_name in self.m_combo_boxes:
+ print "Already being graphed"
+ return
+ self.m_combo_boxes[short_name] = pyPopulationGraph(self, short_name)
+ if self.m_combo_boxes[short_name]:
+ self.construct_box(self.m_combo_boxes[short_name])
+ self.m_combo_boxes[short_name].m_petri_dish_dir_path = freezer_item_name
+ self.modeActivatedSlot(None, short_name)
return
pm = QPixmap()
@@ -220,7 +347,18 @@
def freezerItemDoubleClickedOn(self, freezer_item_name):
# a check in pyOneAnalyzeCtrl.py makes sure this is a valid path
self.m_petri_dish_dir_exists_flag = True
- self.m_petri_dish_dir_path = os.path.split(freezer_item_name)[0]
- self.modeActivatedSlot()
-
+ short_name = os.path.split(os.path.splitext(os.path.split(freezer_item_name)[0])[0])[1]
+ if short_name in self.m_combo_boxes:
+ print "Already being graphed"
+ return
+
+ self.m_combo_boxes[short_name] = pyPopulationGraph(self, short_name)
+ if self.m_combo_boxes[short_name]:
+ self.construct_box(self.m_combo_boxes[short_name])
+ self.m_combo_boxes[short_name].m_petri_dish_dir_path = os.path.split(freezer_item_name)[0]
+ self.modeActivatedSlot(None, short_name)
+
+ def delPopulationSlot(self):
+ print "test"
+ return
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphView.ui
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphView.ui 2006-06-21 01:15:57 UTC (rev 763)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphView.ui 2006-06-21 21:24:27 UTC (rev 764)
@@ -154,129 +154,6 @@
</size>
</property>
</widget>
- <widget class="QLayoutWidget">
- <property name="name">
- <cstring>layout12</cstring>
- </property>
- <hbox>
- <property name="name">
- <cstring>unnamed</cstring>
- </property>
- <spacer>
- <property name="name">
- <cstring>spacer200_2</cstring>
- </property>
- <property name="orientation">
- <enum>Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>Expanding</enum>
- </property>
- <property name="sizeHint">
- <size>
- <width>23</width>
- <height>16</height>
- </size>
- </property>
- </spacer>
- <widget class="QComboBox">
- <item>
- <property name="text">
- <string>Merit</string>
- </property>
- </item>
- <property name="name">
- <cstring>m_combo_box_1</cstring>
- </property>
- <property name="font">
- <font>
- <pointsize>11</pointsize>
- </font>
- </property>
- <property name="toolTip" stdset="0">
- <string>Variable for Line #1</string>
- </property>
- </widget>
- <widget class="QComboBox">
- <item>
- <property name="text">
- <string>-</string>
- </property>
- </item>
- <property name="name">
- <cstring>m_combo_box_1_color</cstring>
- </property>
- <property name="toolTip" stdset="0">
- <string>Color for line #1</string>
- </property>
- </widget>
- <spacer>
- <property name="name">
- <cstring>spacer200_3</cstring>
- </property>
- <property name="orientation">
- <enum>Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>Expanding</enum>
- </property>
- <property name="sizeHint">
- <size>
- <width>40</width>
- <height>16</height>
- </size>
- </property>
- </spacer>
- <widget class="QComboBox">
- <item>
- <property name="text">
- <string>Merit</string>
- </property>
- </item>
- <property name="name">
- <cstring>m_combo_box_2</cstring>
- </property>
- <property name="font">
- <font>
- <pointsize>11</pointsize>
- </font>
- </property>
- <property name="toolTip" stdset="0">
- <string>Variable for line #2</string>
- </property>
- </widget>
- <widget class="QComboBox">
- <item>
- <property name="text">
- <string>-</string>
- </property>
- </item>
- <property name="name">
- <cstring>m_combo_box_2_color</cstring>
- </property>
- <property name="toolTip" stdset="0">
- <string>Color for line #2</string>
- </property>
- </widget>
- <spacer>
- <property name="name">
- <cstring>spacer200</cstring>
- </property>
- <property name="orientation">
- <enum>Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>Expanding</enum>
- </property>
- <property name="sizeHint">
- <size>
- <width>75</width>
- <height>16</height>
- </size>
- </property>
- </spacer>
- </hbox>
- </widget>
</vbox>
</widget>
<customwidgets>
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_PetriDishCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_PetriDishCtrl.py 2006-06-21 01:15:57 UTC (rev 763)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_PetriDishCtrl.py 2006-06-21 21:24:27 UTC (rev 764)
@@ -17,12 +17,12 @@
self.m_ana_petri_dish_ctrl.hide()
self.m_ana_gradient_scale_ctrl.hide()
self.m_ana_live_controls_ctrl.hide()
- self.connect( self.m_session_mdl.m_session_mdtr,
- PYSIGNAL("freezerItemDroppedInOneAnalyzeSig"),
- self.freezerItemDropped)
- self.connect( self.m_session_mdl.m_session_mdtr,
- PYSIGNAL("freezerItemDoubleClickedOnInOneAnaSig"),
- self.freezerItemDoubleClickedOn)
+# self.connect( self.m_session_mdl.m_session_mdtr,
+# PYSIGNAL("freezerItemDroppedInOneAnalyzeSig"),
+# self.freezerItemDropped)
+# self.connect( self.m_session_mdl.m_session_mdtr,
+# PYSIGNAL("freezerItemDoubleClickedOnInOneAnaSig"),
+# self.freezerItemDoubleClickedOn)
def freezerItemDropped(self, e):
@@ -31,8 +31,10 @@
freezer_item_name = QString()
if ( QTextDrag.decode( e, freezer_item_name ) ) :
freezer_item_name = str(e.encodedData("text/plain"))
- self.m_one_ana_pop_name.setText(os.path.splitext((os.path.split(freezer_item_name)[1]))[0])
+ short_name = os.path.splitext((os.path.split(freezer_item_name)[1]))[0]
+ self.m_one_ana_pop_name.setText(short_name)
def freezerItemDoubleClickedOn(self, freezer_item_name):
- self.m_one_ana_pop_name.setText(os.path.split(os.path.splitext(os.path.split(freezer_item_name)[0])[0])[1])
+ short_name = os.path.split(os.path.splitext(os.path.split(freezer_item_name)[0])[0])[1]
+ self.m_one_ana_pop_name.setText(short_name)
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_GraphCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_GraphCtrl.py 2006-06-21 01:15:57 UTC (rev 763)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_GraphCtrl.py 2006-06-21 21:24:27 UTC (rev 764)
@@ -25,7 +25,7 @@
self.m_combo_box.clear()
self.m_combo_box.setInsertionPolicy(QComboBox.AtBottom)
for entry in self.m_avida_stats_interface.m_entries:
- self.m_combo_box.insertItem(entry[0])
+ self.m_combo_box.insertItem(entry.name)
self.connect(
self.m_combo_box, SIGNAL("activated(int)"), self.modeActivatedSlot)
@@ -52,17 +52,18 @@
filename, colx, coly)
def modeActivatedSlot(self, index):
-# self.m_graph_ctrl.setTitle(self.m_avida_stats_interface.m_entries[index][0])
- self.m_graph_title.setText(self.m_avida_stats_interface.m_entries[index][0])
+# self.m_graph_ctrl.setTitle(self.m_avida_stats_interface.m_entries[index].name)
+ self.m_graph_title.setText(
+ self.m_avida_stats_interface.m_entries[index].name)
self.m_graph_ctrl.clear()
if index:
self.load(
self.m_session_mdl.m_tempdir_out,
- self.m_avida_stats_interface.m_entries[index][1],
+ self.m_avida_stats_interface.m_entries[index].file,
1,
- self.m_avida_stats_interface.m_entries[index][2]
+ self.m_avida_stats_interface.m_entries[index].index
)
- self.m_graph_ctrl.m_curve = self.m_graph_ctrl.insertCurve(self.m_avida_stats_interface.m_entries[index][0])
+ self.m_graph_ctrl.m_curve = self.m_graph_ctrl.insertCurve(self.m_avida_stats_interface.m_entries[index].name)
self.m_graph_ctrl.setCurveData(self.m_graph_ctrl.m_curve, self.m_x_array, self.m_y_array)
self.m_graph_ctrl.setCurvePen(self.m_graph_ctrl.m_curve, QPen(Qt.red))
self.m_graph_ctrl.m_zoomer.setZoomBase(self.m_graph_ctrl.curve(self.m_graph_ctrl.m_curve).boundingRect())
@@ -125,7 +126,7 @@
self.m_combo_box.clear()
self.m_combo_box.setInsertionPolicy(QComboBox.AtBottom)
for entry in self.m_avida_stats_interface.m_entries:
- self.m_combo_box.insertItem(entry[0])
+ self.m_combo_box.insertItem(entry.name)
self.connect(
self.m_combo_box, SIGNAL("activated(int)"), self.modeActivatedSlot)
@@ -141,5 +142,6 @@
def exportSlot(self):
"Export stats to a file"
- if self.m_combo_box.currentItem():
- self.m_avida_stats_interface.export(self.m_session_mdl.m_tempdir_out)
+ if self.m_combo_box.currentItem():
+ self.m_avida_stats_interface.export(
+ [("", self.m_session_mdl.m_tempdir_out)])
More information about the Avida-cvs
mailing list