mailr16643 - in /branches/uf_redesign/gui: analyses/__init__.py pipe_editor.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on June 04, 2012 - 18:29:
Author: bugman
Date: Mon Jun  4 18:29:16 2012
New Revision: 16643

URL: http://svn.gna.org/viewcvs/relax?rev=16643&view=rev
Log:
The pipe editor window now handles the pipe bundling concept.

There is a new button for the pipe.bundle user function, a new column showing 
the pipe bundles, and
the pop up menu allows pipes to be associated with bundles if not already 
bundled.


Modified:
    branches/uf_redesign/gui/analyses/__init__.py
    branches/uf_redesign/gui/pipe_editor.py

Modified: branches/uf_redesign/gui/analyses/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/analyses/__init__.py?rev=16643&r1=16642&r2=16643&view=diff
==============================================================================
--- branches/uf_redesign/gui/analyses/__init__.py (original)
+++ branches/uf_redesign/gui/analyses/__init__.py Mon Jun  4 18:29:16 2012
@@ -557,11 +557,11 @@
         status.observers.gui_analysis.notify()
 
 
-    def page_index_from_pipe(self, pipe):
-        """Find the page holding the data pipe and return its page index.
-
-        @param pipe:    The data pipe to find the page of.
-        @type pipe:     str
+    def page_index_from_bundle(self, bundle):
+        """Find the analysis associated with the data pipe bundle and return 
its page index.
+
+        @param bundle:  The data pipe bundle to find the page of.
+        @type bundle:   str
         @return:        The page index.
         @rtype:         int or None
         """
@@ -570,7 +570,7 @@
         index = None
         for i in range(self._num_analyses):
             # Matching page.
-            if ds.relax_gui.analyses[i].pipe_name == pipe:
+            if ds.relax_gui.analyses[i].pipe_bundle == bundle:
                 index = i
                 break
 
@@ -578,17 +578,17 @@
         return index
 
 
-    def page_name_from_pipe(self, pipe):
-        """Find the page holding the data pipe and return its name.
-
-        @param pipe:    The data pipe to find the page of.
-        @type pipe:     str
+    def page_name_from_bundle(self, bundle):
+        """Find the analysis associated with the bundle and return its name.
+
+        @param bundle:  The data pipe bundle to find the page of.
+        @type bundle:   str
         @return:        The page name.
         @rtype:         str or None
         """
 
         # Find the index.
-        index = self.page_index_from_pipe(pipe)
+        index = self.page_index_from_bundle(bundle)
 
         # No matching page.
         if index == None:
@@ -627,7 +627,7 @@
             pipe = pipes.cdp_name()
 
         # Find the page.
-        index = self.page_index_from_pipe(pipe)
+        index = self.page_index_from_bundle(pipes.get_bundle(pipe))
 
         # No matching page.
         if index == None:

Modified: branches/uf_redesign/gui/pipe_editor.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/pipe_editor.py?rev=16643&r1=16642&r2=16643&view=diff
==============================================================================
--- branches/uf_redesign/gui/pipe_editor.py (original)
+++ branches/uf_redesign/gui/pipe_editor.py Mon Jun  4 18:29:16 2012
@@ -29,7 +29,8 @@
 
 # relax module imports.
 from data import Relax_data_store; ds = Relax_data_store()
-from generic_fns.pipes import cdp_name, delete, get_type, pipe_names, switch
+from generic_fns.pipes import cdp_name, delete, get_bundle, get_type, 
pipe_names, switch
+from graphics import fetch_icon
 from status import Status; status = Status()
 
 # relax GUI module imports.
@@ -46,7 +47,7 @@
 class Pipe_editor(wx.Frame):
     """The pipe editor window object."""
 
-    def __init__(self, gui=None, size_x=800, size_y=500, border=10):
+    def __init__(self, gui=None, size_x=1000, size_y=600, border=10):
         """Set up the relax controller frame.
         
         @keyword gui:       The main GUI object.
@@ -132,6 +133,7 @@
 
         # Turn off all buttons.
         if status.exec_lock.locked():
+            wx.CallAfter(self.button_bundle.Enable, False)
             wx.CallAfter(self.button_create.Enable, False)
             wx.CallAfter(self.button_copy.Enable, False)
             wx.CallAfter(self.button_delete.Enable, False)
@@ -140,6 +142,7 @@
 
         # Turn on all buttons.
         else:
+            wx.CallAfter(self.button_bundle.Enable, True)
             wx.CallAfter(self.button_create.Enable, True)
             wx.CallAfter(self.button_copy.Enable, True)
             wx.CallAfter(self.button_delete.Enable, True)
@@ -164,31 +167,34 @@
         if not self.selected_pipe:
             return
 
-        # The pipe type.
+        # The pipe type and bundle.
         pipe_type = get_type(self.selected_pipe)
+        pipe_bundle = get_bundle(self.selected_pipe)
 
         # Initialise the menu.
         menu = wx.Menu()
+        items = []
+
+        # Menu entry:  add the data pipe to a bundle.
+        if not pipe_bundle:
+            items.append(build_menu_item(menu, parent=self, text="&Add the 
pipe to a bundle", icon=fetch_icon("relax.pipe_bundle"), fn=self.pipe_bundle))
 
         # Menu entry:  delete the data pipe.
-        item = build_menu_item(menu, parent=self, text="&Delete the pipe", 
icon=icon_16x16.remove, fn=self.pipe_delete)
-        menu.AppendItem(item)
-        if status.exec_lock.locked():
-            item.Enable(False)
+        items.append(build_menu_item(menu, parent=self, text="&Delete the 
pipe", icon=icon_16x16.remove, fn=self.pipe_delete))
  
         # Menu entry:  switch to this data pipe.
-        item = build_menu_item(menu, parent=self, text="&Switch to this 
pipe", icon=icon_16x16.pipe_switch, fn=self.pipe_switch)
-        menu.AppendItem(item)
-        if status.exec_lock.locked():
-            item.Enable(False)
+        items.append(build_menu_item(menu, parent=self, text="&Switch to 
this pipe", icon=icon_16x16.pipe_switch, fn=self.pipe_switch))
  
         # Menu entry:  new auto-analysis tab.
-        if self.gui.analysis.page_index_from_pipe(self.selected_pipe) == 
None and pipe_type in ['noe', 'r1', 'r2', 'mf']:
-            item = build_menu_item(menu, parent=self, text="&Associate with 
a new auto-analysis", icon=icon_16x16.new, fn=self.associate_auto)
+        if pipe_bundle and 
self.gui.analysis.page_index_from_bundle(pipe_bundle) == None and pipe_type 
in ['noe', 'r1', 'r2', 'mf']:
+            items.append(build_menu_item(menu, parent=self, text="&Associate 
with a new auto-analysis", icon=icon_16x16.new, fn=self.associate_auto))
+ 
+        # Set up the entries.
+        for item in items:
             menu.AppendItem(item)
             if status.exec_lock.locked():
                 item.Enable(False)
- 
+
         # Show the menu.
         if status.show_gui:
             self.PopupMenu(menu)
@@ -207,6 +213,14 @@
         # Create a horizontal layout for the buttons.
         button_sizer = wx.BoxSizer(wx.HORIZONTAL)
         sizer.Add(button_sizer, 0, wx.ALL|wx.EXPAND, 0)
+
+        # The bundle button.
+        self.button_bundle = 
wx.lib.buttons.ThemedGenBitmapTextButton(self.main_panel, -1, None, " Bundle")
+        
self.button_bundle.SetBitmapLabel(wx.Bitmap(fetch_icon("relax.pipe_bundle", 
size="22x22"), wx.BITMAP_TYPE_ANY))
+        self.button_bundle.SetFont(font.normal)
+        self.button_bundle.SetToolTipString("Add a data pipe to a data pipe 
bundle.")
+        button_sizer.Add(self.button_bundle, 1, wx.ALL|wx.EXPAND, 0)
+        self.Bind(wx.EVT_BUTTON, self.uf_launch, self.button_bundle)
 
         # The create button.
         self.button_create = 
wx.lib.buttons.ThemedGenBitmapTextButton(self.main_panel, -1, None, " Create")
@@ -257,7 +271,9 @@
         """
 
         # Launch the respective user functions.
-        if event.GetEventObject() == self.button_create:
+        if event.GetEventObject() == self.button_bundle:
+            uf_store['pipe.bundle'](event, wx_parent=self)
+        elif event.GetEventObject() == self.button_create:
             uf_store['pipe.create'](event, wx_parent=self)
         elif event.GetEventObject() == self.button_copy:
             uf_store['pipe.copy'](event, wx_parent=self)
@@ -293,14 +309,15 @@
         # Grid of all data pipes.
         self.grid = wx.grid.Grid(self.main_panel, -1)
 
-        # Initialise to a single row and 4 columns.
-        self.grid.CreateGrid(1, 4)
+        # Initialise to a single row and 5 columns.
+        self.grid.CreateGrid(1, 5)
 
         # Set the headers.
         self.grid.SetColLabelValue(0, "Data pipe")
         self.grid.SetColLabelValue(1, "Type")
-        self.grid.SetColLabelValue(2, "Current")
-        self.grid.SetColLabelValue(3, "Analysis tab")
+        self.grid.SetColLabelValue(2, "Bundle")
+        self.grid.SetColLabelValue(3, "Current")
+        self.grid.SetColLabelValue(4, "Analysis tab")
 
         # Properties.
         self.grid.SetDefaultCellFont(font.normal)
@@ -359,6 +376,17 @@
         self.Hide()
 
 
+    def pipe_bundle(self, event):
+        """Bundle the date pipe.
+
+        @param event:   The wx event.
+        @type event:    wx event
+        """
+
+        # Bundle the data pipe.
+        uf_store['pipe.bundle'](event, wx_parent=self, 
pipe=self.selected_pipe)
+
+
     def pipe_delete(self, event):
         """Delete the date pipe.
 
@@ -410,7 +438,7 @@
         x, y = self.grid.GetSize()
 
         # Number of columns.
-        n = 4
+        n = 5
 
         # The width of the current data pipe column.
         width_col_curr = 80
@@ -420,8 +448,8 @@
 
         # Set the column sizes.
         for i in range(n):
-            # The cdp column.
-            if i == 2:
+            # The narrower cdp column.
+            if i == 3:
                 self.grid.SetColSize(i, width_col_curr)
 
             # All others.
@@ -471,12 +499,15 @@
             # Set the pipe type.
             self.grid.SetCellValue(i, 1, str_to_gui(get_type(pipe_list[i])))
 
+            # Set the pipe bundle.
+            self.grid.SetCellValue(i, 2, 
str_to_gui(get_bundle(pipe_list[i])))
+
             # Set the current pipe.
             if pipe_list[i] == cdp_name():
-                self.grid.SetCellValue(i, 2, str_to_gui("cdp"))
+                self.grid.SetCellValue(i, 3, str_to_gui("cdp"))
 
             # Set the tab the pipe belongs to.
-            self.grid.SetCellValue(i, 3, 
str_to_gui(self.gui.analysis.page_name_from_pipe(pipe_list[i])))
+            self.grid.SetCellValue(i, 4, 
str_to_gui(self.gui.analysis.page_name_from_bundle(get_bundle(pipe_list[i]))))
 
         # Set the grid properties once finalised.
         for i in range(self.grid.GetNumberRows()):




Related Messages


Powered by MHonArc, Updated Mon Jun 04 18:40:01 2012