Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Added a selection view tab, placed next to the "Log" tab. The tab currently

only displays the current selection.
This commit is contained in:
Einar Ryeng 2006-08-07 14:14:42 +00:00
parent 57cb203316
commit b769288b3b
6 changed files with 140 additions and 11 deletions

View File

@ -267,4 +267,4 @@ class Selection:
"""Handles selected identifiers along each dimension of a dataset""" """Handles selected identifiers along each dimension of a dataset"""
def __init__(self): def __init__(self):
self.current_selection={} self.current_selection={}

View File

@ -622,8 +622,107 @@
<child> <child>
<widget class="GtkLabel" id="label1"> <widget class="GtkLabel" id="label1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">Log</property> <property name="label" translatable="yes">_Log</property>
<property name="use_underline">False</property> <property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkHPaned" id="hpaned4">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="position">400</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow6">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkViewport" id="viewport1">
<property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="Custom" id="selection_tree">
<property name="visible">True</property>
<property name="creation_function">create_selection_tree</property>
<property name="int1">0</property>
<property name="int2">0</property>
<property name="last_modification_time">Fri, 04 Aug 2006 12:42:10 GMT</property>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">False</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow7">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkViewport" id="viewport2">
<property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="Custom" id="identifier_list">
<property name="visible">True</property>
<property name="creation_function">create_identifier_list</property>
<property name="int1">0</property>
<property name="int2">0</property>
<property name="last_modification_time">Fri, 04 Aug 2006 12:42:25 GMT</property>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">True</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="label" translatable="yes">_Selections</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property> <property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property> <property name="wrap">False</property>

View File

@ -12,7 +12,7 @@ import gnome
import gnome.ui import gnome.ui
import scipy import scipy
import pango import pango
from system import project, workflow, dataset, logger, plots, navigator, dialogs from system import project, workflow, dataset, logger, plots, navigator, dialogs, selections
PROGRAM_NAME = 'fluents' PROGRAM_NAME = 'fluents'
@ -31,6 +31,7 @@ class FluentApp:
gtk.glade.set_custom_handler(self.custom_object_factory) gtk.glade.set_custom_handler(self.custom_object_factory)
self.widget_tree = gtk.glade.XML(GLADEFILENAME, 'appwindow') self.widget_tree = gtk.glade.XML(GLADEFILENAME, 'appwindow')
self.workflow = wf(self) self.workflow = wf(self)
self['selection_tree'].set_identifier_list(self['identifier_list'])
def init_gui(self): def init_gui(self):
self['appwindow'].set_size_request(800, 600) self['appwindow'].set_size_request(800, 600)
@ -69,6 +70,7 @@ class FluentApp:
self.project = project self.project = project
self.workflow.add_project(self.project) self.workflow.add_project(self.project)
self.navigator_view.add_project(self.project) self.navigator_view.add_project(self.project)
self['selection_tree'].set_project(self.project)
def set_workflow(self, workflow): def set_workflow(self, workflow):
self.workflow = workflow self.workflow = workflow
@ -130,6 +132,16 @@ class FluentApp:
self.navigator_view.show() self.navigator_view.show()
return self.navigator_view return self.navigator_view
def create_selection_tree(self, str1, str2, int1, int2):
self.selection_tree = selections.SelectionTree()
self.selection_tree.show()
return self.selection_tree
def create_identifier_list(self, str1, str2, int1, int2):
self.identifier_list = selections.IdentifierList()
self.identifier_list.show()
return self.identifier_list
# Event handlers. # Event handlers.
# These methods are called by the gtk framework in response to events and # These methods are called by the gtk framework in response to events and
# should not be called directly. # should not be called directly.

View File

@ -134,3 +134,4 @@ class NavigatorView (gtk.TreeView):
else: else:
t = type(obj) t = type(obj)
logger.log('debug', 'Activated datatype was %s. Don\'t know what to do.' % t) logger.log('debug', 'Activated datatype was %s. Don\'t know what to do.' % t)

View File

@ -6,26 +6,40 @@ from system import dataset, plots
class Project: class Project:
def __init__(self,name="Testing"): def __init__(self,name="Testing"):
self.data_tree = gtk.TreeStore(gobject.TYPE_STRING, self.data_tree = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
gobject.TYPE_STRING, gobject.TYPE_PYOBJECT, gobject.TYPE_STRING,
gobject.TYPE_PYOBJECT,gobject.TYPE_STRING,gobject.TYPE_STRING, gobject.TYPE_DOUBLE) gobject.TYPE_STRING, gobject.TYPE_DOUBLE)
self.name = name self.name = name
self.dim_names = [] self.dim_names = []
self._selection_observers = [] self._selection_observers = []
self._dataset_observers = []
self.current_data = [] self.current_data = []
self.datasets = [] self.datasets = []
self.sel_obj = dataset.Selection() self.sel_obj = dataset.Selection()
def notify_selection_listeners(self): def add_selection_observer(self, observer):
self._selection_observers.append(observer)
observer.selection_changed(self.get_selection())
def notify_selection_listeners(self, dim_name):
"""Notifies observers""" """Notifies observers"""
for observer in self._selection_observers: for observer in self._selection_observers:
observer.selection_changed(self.get_selection()) observer.selection_changed(self.get_selection())
def set_selection(self,dim_name,selection): def add_dataset_observer(self, observer):
self._dataset_observers.append(observer)
observer.dataset_changed()
def notify_dataset_listeners(self):
"""Notifies observers when new datasets are added"""
for observer in self._dataset_observers:
observer.dataset_changed()
def set_selection(self, dim_name, selection):
"""Sets a current selection and notify observers""" """Sets a current selection and notify observers"""
self.sel_obj.current_selection[dim_name] = set(selection) self.sel_obj.current_selection[dim_name] = set(selection)
self.notify_selection_listeners() self.notify_selection_listeners(dim_name)
def get_selection(self): def get_selection(self):
"""Returns the current selection object""" """Returns the current selection object"""
@ -79,6 +93,7 @@ class Project:
if dim_name not in self.dim_names: if dim_name not in self.dim_names:
self.dim_names.append(dim_name) self.dim_names.append(dim_name)
self.sel_obj.current_selection[dim_name] = set() self.sel_obj.current_selection[dim_name] = set()
self.notify_dataset_listeners()
def object_at(self, path): def object_at(self, path):

View File

@ -110,8 +110,10 @@ class TestDataFunction(workflow.Function):
graph.add_edge(x, y, 3) graph.add_edge(x, y, 3)
ds = dataset.GraphDataset(array(networkx.adj_matrix(graph))) ds = dataset.GraphDataset(array(networkx.adj_matrix(graph)))
ds_plot = plots.NetworkPlot(ds) ds_plot = plots.NetworkPlot(ds)
print ds.get_dim_name()
return [X, ds, plots.SinePlot(), p, ds_plot] ds_scatter = plots.ScatterPlot(ds, ds, 'rows_0', 'rows_0', '0_1', '0_2')
return [X, ds, plots.SinePlot(), p, ds_plot, ds_scatter]
class DatasetLog(workflow.Function): class DatasetLog(workflow.Function):
def __init__(self): def __init__(self):