[Avida-cvs] [Avida2-svn] r160 - trunk/source/python/AvidaGui2
jclune at myxo.css.msu.edu
jclune at myxo.css.msu.edu
Wed May 18 10:32:41 PDT 2005
Author: jclune
Date: 2005-05-18 13:32:41 -0400 (Wed, 18 May 2005)
New Revision: 160
Modified:
trunk/source/python/AvidaGui2/Avida_ED_startup.py
trunk/source/python/AvidaGui2/Avida_ED_startup_utils.py
trunk/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
trunk/source/python/AvidaGui2/pyEduWorkspaceView.ui
trunk/source/python/AvidaGui2/pyNavBarCtrl.py
trunk/source/python/AvidaGui2/pyOneAna_GraphCtrl.py
trunk/source/python/AvidaGui2/pyOneAna_GraphView.ui
trunk/source/python/AvidaGui2/pyOneAnalyzeCtrl.py
trunk/source/python/AvidaGui2/pyOneAnalyzeView.ui
Log:
The nav bar is the proper size to see all text, and the switchdown menu defaults to wide open. There are also some changes (not pretty yet) to pyOneAna_GraphCtrl.py
--his line, and those below, will be ignored--
M pyEduWorkspaceCtrl.py
M pyNavBarCtrl.py
M pyOneAna_GraphView.ui
M pyOneAna_GraphCtrl.py
M pyOneAnalyzeView.ui
M pyEduWorkspaceView.ui
M Avida_ED_startup_utils.py
M pyOneAnalyzeCtrl.py
M Avida_ED_startup.py
Modified: trunk/source/python/AvidaGui2/Avida_ED_startup.py
===================================================================
--- trunk/source/python/AvidaGui2/Avida_ED_startup.py 2005-05-16 20:03:43 UTC (rev 159)
+++ trunk/source/python/AvidaGui2/Avida_ED_startup.py 2005-05-18 17:32:41 UTC (rev 160)
@@ -10,5 +10,6 @@
def Interactive():
import IPython
import __builtin__
- ipython_shell = IPython.Shell.IPShell(argv=["-c", "import iqt; import AvidaGui2; from AvidaGui2.Avida_ED_startup_utils import *; AvidaCore.cConfig.InitGroupList(); avida_ed = AvidaEd();"])
+ ipython_shell = IPython.Shell.IPShell(argv=["-c", "import iqt; import AvidaGui2; from AvidaGui2.Avida_ED_startup_utils import *; AvidaCore.cConfig.InitGroupList(); avida_ed = AvidaEd(); edu_workspace_ctrl = Edu_WorkSpace_Ctrl(avida_ed);"])
ipython_shell.mainloop()
+
Modified: trunk/source/python/AvidaGui2/Avida_ED_startup_utils.py
===================================================================
--- trunk/source/python/AvidaGui2/Avida_ED_startup_utils.py 2005-05-16 20:03:43 UTC (rev 159)
+++ trunk/source/python/AvidaGui2/Avida_ED_startup_utils.py 2005-05-18 17:32:41 UTC (rev 160)
@@ -63,3 +63,10 @@
"""
return edu_main_controller
+
+# Get the edu_workspace_ctrl to browse interactively
+def Edu_WorkSpace_Ctrl(avida_ed):
+ session_ctrl = avida_ed.m_main_controller_factory.m_main_controllers_list[1]
+ edu_workspace_ctrl = session_ctrl.m_session_controller_factory.m_session_controllers_list[2]
+ return edu_workspace_ctrl
+
Modified: trunk/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyEduWorkspaceCtrl.py 2005-05-16 20:03:43 UTC (rev 159)
+++ trunk/source/python/AvidaGui2/pyEduWorkspaceCtrl.py 2005-05-18 17:32:41 UTC (rev 160)
@@ -52,7 +52,8 @@
# ctrl.construct(self.m_session_mdl)
self.m_one_population_ctrl.construct(self.m_session_mdl)
self.m_one_organism_ctrl.construct(self.m_session_mdl)
-
+ self.m_one_analyze_ctrl.construct(self.m_session_mdl)
+
self.connect(self, PYSIGNAL("quitAvidaPhaseISig"), self.startQuitProcessSlot)
self.connect(self, PYSIGNAL("quitAvidaPhaseIISig"), qApp, SLOT("quit()"))
self.connect(self.m_nav_bar_ctrl.m_list_view, SIGNAL("clicked(QListViewItem *)"), self.navBarItemClickedSlot)
Modified: trunk/source/python/AvidaGui2/pyEduWorkspaceView.ui
===================================================================
--- trunk/source/python/AvidaGui2/pyEduWorkspaceView.ui 2005-05-16 20:03:43 UTC (rev 159)
+++ trunk/source/python/AvidaGui2/pyEduWorkspaceView.ui 2005-05-18 17:32:41 UTC (rev 160)
@@ -16,7 +16,7 @@
<property name="geometry">
<rect>
<x>0</x>
- <y>22</y>
+ <y>0</y>
<width>1024</width>
<height>700</height>
</rect>
@@ -31,8 +31,8 @@
</property>
<property name="minimumSize">
<size>
- <width>1024</width>
- <height>700</height>
+ <width>195</width>
+ <height>575</height>
</size>
</property>
<property name="maximumSize">
@@ -66,11 +66,39 @@
<property name="name">
<cstring>m_nav_bar_ctrl</cstring>
</property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>145</width>
+ <height>220</height>
+ </size>
+ </property>
</widget>
<widget class="pyFreezerCtrl">
<property name="name">
<cstring>m_freezer_ctrl</cstring>
</property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>145</width>
+ <height>200</height>
+ </size>
+ </property>
</widget>
</widget>
<widget class="QWidgetStack">
@@ -168,6 +196,10 @@
<property type="4">-1</property>
<property type="1">pyFreezerView</property>
<property type="0">-1</property>
+ <property type="1">pyFreezerView</property>
+ <property type="0">-1</property>
+ <property type="1">pyFreezerView</property>
+ <property type="0">-1</property>
<property type="pyFreezerView"></property>
<property type="-1">1</property>
</customwidget>
@@ -197,6 +229,10 @@
<property type="4">-1</property>
<property type="1">pyNavBarView</property>
<property type="0">-1</property>
+ <property type="1">pyNavBarView</property>
+ <property type="0">-1</property>
+ <property type="1">pyNavBarView</property>
+ <property type="0">-1</property>
<property type="pyNavBarView"></property>
<property type="-1">1</property>
</customwidget>
Modified: trunk/source/python/AvidaGui2/pyNavBarCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyNavBarCtrl.py 2005-05-16 20:03:43 UTC (rev 159)
+++ trunk/source/python/AvidaGui2/pyNavBarCtrl.py 2005-05-18 17:32:41 UTC (rev 160)
@@ -13,7 +13,7 @@
def generateCLIGroup(list_view, group_name, first_name, second_name):
group_lvi = QCheckListItem(list_view, group_name, QCheckListItem.RadioButtonController)
group_lvi.setSelectable(False)
- group_lvi.setOpen(False)
+ group_lvi.setOpen(True)
#
second_cli = QCheckListItem(group_lvi, second_name, QCheckListItem.RadioButton)
second_cli.setSelectable(False)
Modified: trunk/source/python/AvidaGui2/pyOneAna_GraphCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyOneAna_GraphCtrl.py 2005-05-16 20:03:43 UTC (rev 159)
+++ trunk/source/python/AvidaGui2/pyOneAna_GraphCtrl.py 2005-05-18 17:32:41 UTC (rev 160)
@@ -1,10 +1,186 @@
# -*- coding: utf-8 -*-
+from AvidaCore import cInitFile, cString
+from Numeric import *
+from pyAvidaStatsInterface import pyAvidaStatsInterface
+from pyOneAna_GraphView import pyOneAna_GraphView
from qt import *
-from pyOneAna_GraphView import pyOneAna_GraphView
+from qwt import *
+class PrintFilter(QwtPlotPrintFilter):
+ def __init__(self):
+ QwtPlotPrintFilter.__init__(self)
+ def color(self, c, item, i):
+ if not (self.options() & QwtPlotPrintFilter.PrintCanvasBackground):
+ if item == QwtPlotPrintFilter.MajorGrid:
+ return Qt.darkGray
+ elif item == QwtPlotPrintFilter.MinorGrid:
+ return Qt.gray
+ if item == QwtPlotPrintFilter.Title:
+ return Qt.black
+ elif item == QwtPlotPrintFilter.AxisScale:
+ return Qt.black
+ elif item == QwtPlotPrintFilter.AxisTitle:
+ return Qt.black
+ return Qt.black
+ def font(self, f, item, i):
+ result = QFont(f)
+ result.setPointSize(int(f.pointSize()*1.25))
+ return result
+
+
class pyOneAna_GraphCtrl(pyOneAna_GraphView):
def __init__(self,parent = None,name = None,fl = 0):
pyOneAna_GraphView.__init__(self,parent,name,fl)
+ self.m_avida_stats_interface = pyAvidaStatsInterface()
+
+ 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.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.connect(
+ self.m_combo_box, SIGNAL("activated(int)"), self.modeActivatedSlot)
+
+ self.m_x_array = zeros(2, Float)
+ self.m_y_array = zeros(2, Float)
+
+ self.m_graph_ctrl.setAxisTitle(QwtPlot.xBottom, "Time (updates)")
+ self.m_graph_ctrl.setAxisAutoScale(QwtPlot.xBottom)
+
+ # Start with second graph mode -- "Average Fitness".
+ self.m_combo_box.setCurrentItem(2)
+ self.modeActivatedSlot(self.m_combo_box.currentItem())
+
+ self.connect(
+ self.m_session_mdl.m_session_mdtr, PYSIGNAL("printGraphSig"),
+ 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()
+
+ x_array = zeros(init_file.GetNumLines(), Float)
+ y_array = zeros(init_file.GetNumLines(), Float)
+
+ for line_id in range(init_file.GetNumLines()):
+ line = init_file.GetLine(line_id)
+ x_array[line_id] = line.GetWord(colx - 1).AsDouble()
+ y_array[line_id] = line.GetWord(coly - 1).AsDouble()
+##
+# self.m_y_array_2[line_id] = line.GetWord(2).AsDouble()
+##
+ return x_array, y_array
+
+ def modeActivatedSlot(self, index):
+ self.m_graph_ctrl.setTitle(self.m_avida_stats_interface.m_entries[index][0])
+ self.m_graph_ctrl.clear()
+ if index:
+
+ fake_index_1 = 1
+ fake_index_2 = 2
+
+ self.m_graph_ctrl.setAxisTitle(QwtPlot.yLeft, self.m_avida_stats_interface.m_entries[fake_index_1][0])
+ self.m_graph_ctrl.setAxisTitle(QwtPlot.yRight, self.m_avida_stats_interface.m_entries[fake_index_2][0])
+
+ self.m_graph_ctrl.setAxisAutoScale(QwtPlot.xBottom)
+ self.m_graph_ctrl.setAxisAutoScale(QwtPlot.yLeft)
+ self.m_graph_ctrl.setAxisAutoScale(QwtPlot.yRight)
+
+ self.m_curve_1_arrays = self.load(
+ self.m_avida_stats_interface.m_entries[fake_index_1][1],
+ 1,
+ self.m_avida_stats_interface.m_entries[fake_index_1][2]
+ )
+ self.m_curve_2_arrays = self.load(
+ self.m_avida_stats_interface.m_entries[fake_index_2][1],
+ 1,
+ self.m_avida_stats_interface.m_entries[fake_index_2][2]
+ )
+
+ self.m_graph_ctrl.m_curve_1 = self.m_graph_ctrl.insertCurve(self.m_avida_stats_interface.m_entries[fake_index_1][0])
+ self.m_graph_ctrl.m_curve_2 = self.m_graph_ctrl.insertCurve(self.m_avida_stats_interface.m_entries[fake_index_2][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.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_1, QPen(Qt.red))
+ self.m_graph_ctrl.setCurvePen(self.m_graph_ctrl.m_curve_2, QPen(Qt.green))
+
+ self.m_graph_ctrl.setCurveYAxis(self.m_graph_ctrl.m_curve_1, QwtPlot.yLeft)
+ self.m_graph_ctrl.setCurveYAxis(self.m_graph_ctrl.m_curve_2, QwtPlot.yRight)
+
+ 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)
+ self.m_graph_ctrl.m_zoomer.setZoomBase(bounding_rect)
+
+ self.m_graph_ctrl.replot()
+
+ def printGraphSlot(self):
+ printer = QPrinter()
+ if printer.setup():
+ filter = PrintFilter()
+ if (QPrinter.GrayScale == printer.colorMode()):
+ filter.setOptions(QwtPlotPrintFilter.PrintAll & ~QwtPlotPrintFilter.PrintCanvasBackground)
+ self.m_graph_ctrl.printPlot(printer, filter)
+
+
+ def avidaUpdatedSlot(self):
+ if self.m_combo_box.currentItem():
+ fake_index_1 = 1
+ fake_index_2 = 2
+
+ self.m_curve_1_arrays[0] = concatenate(
+ (self.m_x_array, [self.m_avida.m_population.GetStats().GetUpdate()]),
+ 1
+ )
+ self.m_curve_2_arrays[0] = concatenate(
+ (self.m_x_array, [self.m_avida.m_population.GetStats().GetUpdate()]),
+ 1
+ )
+
+ self.m_curve_1_arrays[1] = concatenate(
+ (self.m_curve_1_arrays[1],
+ [self.m_avida_stats_interface.getValue(
+ fake_index_1,
+ self.m_avida.m_population.GetStats()
+ )]
+ ),
+ 1
+ )
+ self.m_curve_2_arrays[1] = concatenate(
+ (self.m_curve_2_arrays[1],
+ [self.m_avida_stats_interface.getValue(
+ fake_index_2,
+ self.m_avida.m_population.GetStats()
+ )]
+ ),
+ 1
+ )
+
+ if hasattr(self.m_graph_ctrl, "m_curve_1") and hasattr(self.m_graph_ctrl, "m_curve_2"):
+ 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.setCurveData(self.m_graph_ctrl.m_curve_2, self.m_curve_2_arrays[0], self.m_curve_2_arrays[1])
+
+ # Quick hack: Cause the zoomer to limit zooming-out to the
+ # boundaries of the displayed curve.
+ 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)
+ self.m_graph_ctrl.m_zoomer.setZoomBase(bounding_rect)
+ # Quick hack: If the user has zoomed-in on or -out from the graph,
+ # autoscaling will have been disabled. This reenables it.
+ self.m_graph_ctrl.setAxisAutoScale(QwtPlot.xBottom)
+ self.m_graph_ctrl.setAxisAutoScale(QwtPlot.yLeft)
+ self.m_graph_ctrl.setAxisAutoScale(QwtPlot.yRight)
+ self.m_graph_ctrl.replot()
+
Modified: trunk/source/python/AvidaGui2/pyOneAna_GraphView.ui
===================================================================
--- trunk/source/python/AvidaGui2/pyOneAna_GraphView.ui 2005-05-16 20:03:43 UTC (rev 159)
+++ trunk/source/python/AvidaGui2/pyOneAna_GraphView.ui 2005-05-18 17:32:41 UTC (rev 160)
@@ -134,7 +134,7 @@
</widget>
<widget class="pyGraphCtrl">
<property name="name">
- <cstring>pyGraphCtrl1</cstring>
+ <cstring>m_graph_ctrl</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
@@ -204,7 +204,7 @@
</property>
</item>
<property name="name">
- <cstring>comboBox1</cstring>
+ <cstring>m_combo_box</cstring>
</property>
<property name="font">
<font>
@@ -308,7 +308,7 @@
</sizehint>
<container>0</container>
<sizepolicy>
- <hordata>3</hordata>
+ <hordata>0</hordata>
<verdata>0</verdata>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
@@ -321,6 +321,10 @@
<property type="3">-1</property>
<property type="1">pyGraphCtrl</property>
<property type="4">-1</property>
+ <property type="1">pyGraphCtrl</property>
+ <property type="4">-1</property>
+ <property type="1">pyGraphCtrl</property>
+ <property type="0">-1</property>
<property type="pyGraphCtrl"></property>
<property type="-1">1</property>
</customwidget>
Modified: trunk/source/python/AvidaGui2/pyOneAnalyzeCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyOneAnalyzeCtrl.py 2005-05-16 20:03:43 UTC (rev 159)
+++ trunk/source/python/AvidaGui2/pyOneAnalyzeCtrl.py 2005-05-18 17:32:41 UTC (rev 160)
@@ -8,3 +8,8 @@
def __init__(self,parent = None,name = None,fl = 0):
pyOneAnalyzeView.__init__(self,parent,name,fl)
+
+ def construct(self, session_mdl):
+ self.m_session_mdl = session_mdl
+ self.m_one_ana_graph_ctrl.construct(self.m_session_mdl)
+
Modified: trunk/source/python/AvidaGui2/pyOneAnalyzeView.ui
===================================================================
--- trunk/source/python/AvidaGui2/pyOneAnalyzeView.ui 2005-05-16 20:03:43 UTC (rev 159)
+++ trunk/source/python/AvidaGui2/pyOneAnalyzeView.ui 2005-05-18 17:32:41 UTC (rev 160)
@@ -72,7 +72,7 @@
</property>
<widget class="pyOneAna_GraphCtrl">
<property name="name">
- <cstring>pyOneAna_GraphCtrl1</cstring>
+ <cstring>m_one_ana_graph_ctrl</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
@@ -104,12 +104,14 @@
<container>0</container>
<sizepolicy>
<hordata>5</hordata>
- <verdata>5</verdata>
+ <verdata>0</verdata>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<pixmap>image0</pixmap>
<property type="0">3</property>
+ <property type="1">pyOneAna_GraphCtrl</property>
+ <property type="3">-1</property>
<property type="pyOneAna_GraphCtrl"></property>
<property type="-1">1</property>
</customwidget>
@@ -123,12 +125,14 @@
<container>0</container>
<sizepolicy>
<hordata>5</hordata>
- <verdata>5</verdata>
+ <verdata>0</verdata>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<pixmap>image0</pixmap>
<property type="0">3</property>
+ <property type="1">pyOneAna_PetriDishCtrl</property>
+ <property type="3">-1</property>
<property type="pyOneAna_PetriDishCtrl"></property>
<property type="-1">1</property>
</customwidget>
@@ -142,12 +146,14 @@
<container>0</container>
<sizepolicy>
<hordata>5</hordata>
- <verdata>5</verdata>
+ <verdata>0</verdata>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<pixmap>image0</pixmap>
<property type="0">3</property>
+ <property type="1">pyOneAna_StatsCtrl</property>
+ <property type="3">-1</property>
<property type="pyOneAna_StatsCtrl"></property>
<property type="-1">1</property>
</customwidget>
@@ -161,12 +167,14 @@
<container>0</container>
<sizepolicy>
<hordata>5</hordata>
- <verdata>5</verdata>
+ <verdata>0</verdata>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<pixmap>image0</pixmap>
<property type="0">3</property>
+ <property type="1">pyOneAna_TimelineCtrl</property>
+ <property type="3">-1</property>
<property type="pyOneAna_TimelineCtrl"></property>
<property type="-1">1</property>
</customwidget>
More information about the Avida-cvs
mailing list