Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

* fluent, *.py: Data and plots returned from functions will now show up in

the navigator window.
This commit is contained in:
Einar Ryeng 2006-04-20 14:29:13 +00:00
parent 78ecadb3ab
commit c09f2ceb92
6 changed files with 52 additions and 35 deletions

8
fluent
View File

@ -24,8 +24,6 @@ import scipy
PROGRAM_NAME = 'fluent'
VERSION = '0.1.0'
GLADEFILENAME = 'system/fluent.glade'
WF_BOX = 'workflow_vbox'
DATA_BOX = 'data_vbox'
class FluentApp:
@ -44,8 +42,6 @@ class FluentApp:
####################
self.navigator = navigator.NavigatorStore(self.project)
self.current_data = None
gtk.glade.set_custom_handler(self.custom_object_factory)
self.widget_tree = gtk.glade.XML(GLADEFILENAME, 'appwindow')
@ -78,7 +74,8 @@ class FluentApp:
return self.large_view
def create_navigator_view(self, str1, str2, int1, int2):
self.navigator_view = navigator.NavigatorView(self.navigator, self)
tree = self.project.data_tree
self.navigator_view = navigator.NavigatorView(tree, self)
self.navigator_view.show()
return self.navigator_view
@ -128,4 +125,3 @@ if __name__ == '__main__':
gtk.main()

View File

@ -4,29 +4,6 @@ import gobject
import plots
import logger
class NavigatorStore (gtk.TreeStore):
def __init__(self,project):
gtk.TreeStore.__init__(self, gobject.TYPE_STRING, plots.Plot)
self.project = project
iter = self.append(None)
self.set_value(iter, 0, ('Sine Plot'))
self.set_value(iter, 1, (plots.SinePlot(project)))
iter = self.append(None)
self.set_value(iter, 0, ('Scatter Plot'))
self.set_value(iter, 1, (plots.ScatterPlot(project)))
iter = self.append(None)
self.set_value(iter, 0, ('Scatter Plot 2'))
self.set_value(iter, 1, (plots.ScatterPlot(project)))
def plot_at(self, path):
iter = self.get_iter(path)
plot = self.get_value(iter, 1)
if plot:
plot.show()
return plot
class NavigatorView (gtk.TreeView):
def __init__(self, nav, app):
gtk.TreeView.__init__(self, nav)
@ -43,6 +20,8 @@ class NavigatorView (gtk.TreeView):
logger.log('debug', 'Initializing naviagor window')
def row_activated_handler(self, widget, path, column):
plot = self.navigator.plot_at(path)
iter = self.navigator.get_iter(path)
object = self.navigator.get_value(iter, 2)
logger.log('notice', 'Button pressed')
self.app.change_plot(plot)
self.app.change_plot(object)

View File

@ -73,7 +73,6 @@ class SmallView (gtk.Table):
def set_child(self, child, col, row):
cur_widget = self.child_views[col][row]
cur_widget.disconnect(cur_widget.parent_signalling)
print cur_widget
self.remove(cur_widget)
self.attach(child, col, col+1, row, row+1)
child.parent_signalling = child.connect('button_press_event', self.__view_button_event__)

View File

@ -1,8 +1,15 @@
import dataset
import plots
import scipy
import gobject
import gtk
class Project:
def __init__(self,name="Testing"):
self.data_tree = gtk.TreeStore(gobject.TYPE_STRING,
gobject.TYPE_STRING,
gobject.TYPE_PYOBJECT)
self.name = name
self.dim_names = []
self._observers = {}
@ -39,6 +46,26 @@ class Project:
"""Returns the current selection object"""
return self.sel_obj.current_selection
def add_data(self, parent, data):
"""Adds a set of data and plots to the navigator.
This method is usually called after a Function in a workflow
has finished and returns its output."""
for d in data:
if isinstance(d, dataset.Dataset):
self.add_dataset(d)
self.data_tree_insert(None, 'data', d)
elif isinstance(d, plots.Plot):
# self.add_view(d)
self.data_tree_insert(None, 'view', d)
def data_tree_insert(self, parent, text, data):
tree = self.data_tree
iter = tree.append(parent)
tree.set_value(iter, 0, text)
tree.set_value(iter, 1, type(data))
tree.set_value(iter, 2, data)
def add_dataset(self,dataset):
"""Appends a new Dataset to the project."""
self.datasets.append(dataset)
@ -52,6 +79,11 @@ class Project:
dim_name = dim_name + "_t"
return dim_name
def object_at(self, path):
"Returns the object at a given path in the tree."
iter = self.get_iter(path)
object = self.get_value(iter, 2)
if object:
object.show()
return object

View File

@ -92,7 +92,7 @@ class WorkflowView (gtk.VBox):
project = self.workflow.app.project
new_data = function.run(project.current_data)
if new_data != None:
project.current_data = new_data
project.add_data(None, new_data)
logger.log('debug', 'Function ended: %s' % function.name)
def button_click_handler(self, button):

View File

@ -2,6 +2,7 @@ import gtk
import logger
from annotations import Annotations
from workflow import *
import plots
#import geneontology
#import gostat
from scipy import array
@ -14,6 +15,7 @@ class EinarsWorkflow (Workflow):
load = Stage('load', 'Load Data')
load.add_function(Function('load', 'Load Microarrays'))
load.add_function(TestDataFunction())
self.add_stage(load)
preproc = Stage('preprocess', 'Preprocessing')
@ -83,3 +85,12 @@ class GODistanceFunction(Function):
return gene_distances
class TestDataFunction(Function):
def __init__(self):
Function.__init__(self, 'test_data', 'Generate Test Data')
def run(self, data):
logger.log('notice', 'Injecting foo test data')
return [plots.SinePlot(None)]