mailr16718 - in /branches/uf_redesign/gui/components: __init__.py relax_data_meta.py


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

Header


Content

Posted by edward on June 07, 2012 - 12:48:
Author: bugman
Date: Thu Jun  7 12:48:34 2012
New Revision: 16718

URL: http://svn.gna.org/viewcvs/relax?rev=16718&view=rev
Log:
Created a GUI element for displaying and editing the relaxation data metadata.

This is very similar to the relaxation data list GUI element, and it will be 
used in the BMRB export
(and maybe in a window launchable from the relaxation data GUI element 
itself).


Added:
    branches/uf_redesign/gui/components/relax_data_meta.py
      - copied, changed from r16713, 
branches/uf_redesign/gui/components/relax_data.py
Modified:
    branches/uf_redesign/gui/components/__init__.py

Modified: branches/uf_redesign/gui/components/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/components/__init__.py?rev=16718&r1=16717&r2=16718&view=diff
==============================================================================
--- branches/uf_redesign/gui/components/__init__.py (original)
+++ branches/uf_redesign/gui/components/__init__.py Thu Jun  7 12:48:34 2012
@@ -1,6 +1,6 @@
 
###############################################################################
 #                                                                            
 #
-# Copyright (C) 2010-2011 Edward d'Auvergne                                  
 #
+# Copyright (C) 2010-2012 Edward d'Auvergne                                  
 #
 #                                                                            
 #
 # This file is part of the program relax.                                    
 #
 #                                                                            
 #
@@ -28,4 +28,5 @@
            'grid',
            'menu',
            'relax_data',
+           'relax_data_meta',
            'spectrum']

Copied: branches/uf_redesign/gui/components/relax_data_meta.py (from r16713, 
branches/uf_redesign/gui/components/relax_data.py)
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/components/relax_data_meta.py?p2=branches/uf_redesign/gui/components/relax_data_meta.py&p1=branches/uf_redesign/gui/components/relax_data.py&r1=16713&r2=16718&rev=16718&view=diff
==============================================================================
--- branches/uf_redesign/gui/components/relax_data.py (original)
+++ branches/uf_redesign/gui/components/relax_data_meta.py Thu Jun  7 
12:48:34 2012
@@ -41,24 +41,19 @@
 from gui.uf_objects import Uf_storage; uf_store = Uf_storage()
 
 
-class Relax_data_list:
+class Relax_data_meta_list:
     """The GUI element for listing loaded relaxation data."""
 
     # Some IDs for the menu entries.
-    MENU_RELAX_DATA_DELETE = wx.NewId()
     MENU_RELAX_DATA_DISPLAY = wx.NewId()
-    MENU_RELAX_DATA_FRQ = wx.NewId()
     MENU_RELAX_DATA_PEAK_INTENSITY_TYPE = wx.NewId()
     MENU_RELAX_DATA_TEMP_CALIBRATION = wx.NewId()
     MENU_RELAX_DATA_TEMP_CONTROL = wx.NewId()
-    MENU_RELAX_DATA_TYPE = wx.NewId()
-
-
-    def __init__(self, gui=None, parent=None, box=None, id=None, 
buttons=True):
+
+
+    def __init__(self, parent=None, box=None, id=None):
         """Build the relaxation data list GUI element.
 
-        @keyword gui:       The main GUI object.
-        @type gui:          wx.Frame instance
         @keyword parent:    The parent GUI element that this is to be 
attached to (the panel object).
         @type parent:       wx object
         @keyword data:      The data storage container.
@@ -67,20 +62,16 @@
         @type box:          wx.BoxSizer instance
         @keyword id:        A unique identification string.  This is used to 
register the update method with the GUI user function observer object.
         @type id:           str
-        @keyword buttons:   A flag which if True will display the buttons at 
the top.
-        @type buttons:      bool
         """
 
         # Store the arguments.
-        self.gui = gui
         self.parent = parent
 
         # GUI variables.
         self.spacing = 5
         self.border = 5
-        self.height_buttons = 40
-
-        # First create a panel (to allow for tooltips on the buttons).
+
+        # First create a panel.
         self.panel = wx.Panel(self.parent)
         box.Add(self.panel, 0, wx.ALL|wx.EXPAND, 0)
 
@@ -89,19 +80,16 @@
         self.panel.SetSizer(panel_sizer)
 
         # A static box to hold all the widgets, and its sizer.
-        stat_box = wx.StaticBox(self.panel, -1, "Relaxation data list")
-        stat_box.SetFont(font.subtitle)
-        sub_sizer = wx.StaticBoxSizer(stat_box, wx.VERTICAL)
+        self.data_box = wx.StaticBox(self.panel, -1)
+        self.set_box_label()
+        self.data_box.SetFont(font.subtitle)
+        sub_sizer = wx.StaticBoxSizer(self.data_box, wx.VERTICAL)
 
         # Add the sizer to the static box and the static box to the main box.
         panel_sizer.Add(sub_sizer, 0, wx.ALL|wx.EXPAND, 0)
 
         # Add a border.
         box_centre = add_border(sub_sizer, border=self.border)
-
-        # Add buttons.
-        if buttons:
-            self.add_buttons(box_centre)
 
         # Initialise the element.
         box_centre.AddSpacer(self.spacing)
@@ -111,7 +99,7 @@
         self.build_element()
 
         # Initialise observer name.
-        self.name = 'relaxation data list: %s' % id
+        self.name = 'relaxation metadata list: %s' % id
 
         # Register the element for updating when a user function completes.
         self.observer_register()
@@ -124,24 +112,9 @@
         @type enable:       bool
         """
 
-        # Call buttons' methods.
-        self.button_add.Enable(enable)
-        self.button_delete.Enable(enable)
-
-
-    def action_bruker_read(self, event):
-        """Launch the bruker.read user function.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # Launch the dialog.
-        uf_store['bruker.read']()
-
-
-    def action_relax_data_delete(self, event):
-        """Launch the relax_data.delete user function.
+
+    def action_relax_data_display(self, event):
+        """Launch the relax_data.display user function.
 
         @param event:   The wx event.
         @type event:    wx event
@@ -150,59 +123,11 @@
         # The current selection.
         item = self.element.GetFirstSelected()
 
-        # No selection.
-        if item == -1:
-            id = None
-
-        # Selected item.
-        else:
-            # The spectrum ID.
-            id = gui_to_str(self.element.GetItemText(item))
-
-        # Launch the dialog.
-        uf_store['relax_data.delete'](ri_id=id)
-
-
-    def action_relax_data_display(self, event):
-        """Launch the relax_data.display user function.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # The current selection.
-        item = self.element.GetFirstSelected()
-
         # The spectrum ID.
         id = gui_to_str(self.element.GetItemText(item))
 
         # Launch the dialog.
-        uf_store['relax_data.display'](ri_id=id)
-
-
-    def action_relax_data_frq(self, event):
-        """Launch the relax_data.frq user function.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # The current selection.
-        item = self.element.GetFirstSelected()
-
-        # The spectrum ID.
-        id = gui_to_str(self.element.GetItemText(item))
-
-        # The current frequency.
-        frq = None
-        if hasattr(cdp, 'frq') and id in cdp.frq.keys():
-            frq = cdp.frq[id]
-
-        # Launch the dialog.
-        if frq == None:
-            uf_store['relax_data.frq'](ri_id=id)
-        else:
-            uf_store['relax_data.frq'](ri_id=id, frq=frq)
+        uf_store['relax_data.display'](wx_parent=self.parent, ri_id=id)
 
 
     def action_relax_data_peak_intensity_type(self, event):
@@ -225,20 +150,9 @@
 
         # Launch the dialog.
         if type == None:
-            uf_store['relax_data.peak_intensity_type'](ri_id=id)
-        else:
-            uf_store['relax_data.peak_intensity_type'](ri_id=id, type=type)
-
-
-    def action_relax_data_read(self, event):
-        """Launch the relax_data.read user function.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # Launch the dialog.
-        uf_store['relax_data.read']()
+            
uf_store['relax_data.peak_intensity_type'](wx_parent=self.parent, ri_id=id)
+        else:
+            
uf_store['relax_data.peak_intensity_type'](wx_parent=self.parent, ri_id=id, 
type=type)
 
 
     def action_relax_data_temp_calibration(self, event):
@@ -261,9 +175,9 @@
 
         # Launch the dialog.
         if method == None:
-            uf_store['relax_data.temp_calibration'](ri_id=id)
-        else:
-            uf_store['relax_data.temp_calibration'](ri_id=id, method=method)
+            uf_store['relax_data.temp_calibration'](wx_parent=self.parent, 
ri_id=id)
+        else:
+            uf_store['relax_data.temp_calibration'](wx_parent=self.parent, 
ri_id=id, method=method)
 
 
     def action_relax_data_temp_control(self, event):
@@ -286,73 +200,9 @@
 
         # Launch the dialog.
         if method == None:
-            uf_store['relax_data.temp_control'](ri_id=id)
-        else:
-            uf_store['relax_data.temp_control'](ri_id=id, method=method)
-
-
-    def action_relax_data_type(self, event):
-        """Launch the relax_data.type user function.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # The current selection.
-        item = self.element.GetFirstSelected()
-
-        # The spectrum ID.
-        id = gui_to_str(self.element.GetItemText(item))
-
-        # The current type.
-        type = None
-        if hasattr(cdp, 'ri_type') and id in cdp.ri_type.keys():
-            type = cdp.ri_type[id]
-
-        # Launch the dialog.
-        if type == None:
-            uf_store['relax_data.type'](ri_id=id)
-        else:
-            uf_store['relax_data.type'](ri_id=id, ri_type=type)
-
-
-    def add_buttons(self, sizer):
-        """Add the buttons for peak list manipulation.
-
-        @param sizer:   The sizer element to pack the buttons into.
-        @type sizer:    wx.BoxSizer instance
-        """
-
-        # Button Sizer
-        button_sizer = wx.BoxSizer(wx.HORIZONTAL)
-        sizer.Add(button_sizer, 0, wx.ALL|wx.EXPAND, 0)
-
-        # Add button.
-        self.button_add = 
wx.lib.buttons.ThemedGenBitmapTextButton(self.panel, -1, None, " Add")
-        
self.button_add.SetBitmapLabel(wx.Bitmap(fetch_icon('oxygen.actions.list-add-relax-blue',
 "22x22"), wx.BITMAP_TYPE_ANY))
-        self.button_add.SetFont(font.normal)
-        self.button_add.SetSize((80, self.height_buttons))
-        button_sizer.Add(self.button_add, 0, 0, 0)
-        self.gui.Bind(wx.EVT_BUTTON, self.action_relax_data_read, 
self.button_add)
-        self.button_add.SetToolTipString("Read relaxation data from a file.")
-
-        # Bruker button.
-        self.button_bruker = 
wx.lib.buttons.ThemedGenBitmapTextButton(self.panel, -1, None, " Add")
-        
self.button_bruker.SetBitmapLabel(wx.Bitmap(fetch_icon('relax.bruker_add', 
"22x22"), wx.BITMAP_TYPE_ANY))
-        self.button_bruker.SetFont(font.normal)
-        self.button_bruker.SetSize((80, self.height_buttons))
-        button_sizer.Add(self.button_bruker, 0, 0, 0)
-        self.gui.Bind(wx.EVT_BUTTON, self.action_bruker_read, 
self.button_bruker)
-        self.button_bruker.SetToolTipString("Read a Bruker Dynamics Center 
relaxation data file.")
-
-        # Delete button.
-        self.button_delete = 
wx.lib.buttons.ThemedGenBitmapTextButton(self.panel, -1, None, " Delete")
-        
self.button_delete.SetBitmapLabel(wx.Bitmap(fetch_icon('oxygen.actions.list-remove',
 "22x22"), wx.BITMAP_TYPE_ANY))
-        self.button_delete.SetFont(font.normal)
-        self.button_delete.SetSize((80, self.height_buttons))
-        button_sizer.Add(self.button_delete, 0, 0, 0)
-        self.gui.Bind(wx.EVT_BUTTON, self.action_relax_data_delete, 
self.button_delete)
-        self.button_delete.SetToolTipString("Delete loaded relaxation data 
from the relax data store.")
+            uf_store['relax_data.temp_control'](wx_parent=self.parent, 
ri_id=id)
+        else:
+            uf_store['relax_data.temp_control'](wx_parent=self.parent, 
ri_id=id, method=method)
 
 
     def build_element(self):
@@ -371,6 +221,9 @@
 
         # First freeze the element, so that the GUI element doesn't update 
until the end.
         self.element.Freeze()
+
+        # Update the label.
+        self.set_box_label()
 
         # Delete the previous data.
         self.element.DeleteAllItems()
@@ -387,11 +240,17 @@
                 id = cdp.ri_ids[i]
                 self.element.InsertStringItem(i, str_to_gui(id))
 
-                # Set the data types.
-                self.element.SetStringItem(i, 1, str_to_gui(cdp.ri_type[id]))
-
-                # Set the frequencies.
-                self.element.SetStringItem(i, 2, float_to_gui(cdp.frq[id]))
+                # Set the peak intensity types.
+                if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 
'peak_intensity_type') and id in cdp.exp_info.peak_intensity_type.keys():
+                    self.element.SetStringItem(i, 1, 
str_to_gui(cdp.exp_info.peak_intensity_type[id]))
+
+                # Set the temperature calibration methods.
+                if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 
'temp_calibration') and id in cdp.exp_info.temp_calibration.keys():
+                    self.element.SetStringItem(i, 2, 
str_to_gui(cdp.exp_info.temp_calibration[id]))
+
+                # Set the temperature control methods.
+                if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 
'temp_control') and id in cdp.exp_info.temp_control.keys():
+                    self.element.SetStringItem(i, 3, 
str_to_gui(cdp.exp_info.temp_control[id]))
 
         # Size the columns.
         self.size_cols()
@@ -429,10 +288,11 @@
         # List of relaxation data.
         self.element = wx.ListCtrl(self.panel, -1, 
style=wx.BORDER_SUNKEN|wx.LC_REPORT)
 
-        # Initialise to 3 columns.
+        # Initialise to 4 columns.
         self.element.InsertColumn(0, str_to_gui("Relaxation data ID"))
-        self.element.InsertColumn(1, str_to_gui("Data type"))
-        self.element.InsertColumn(2, str_to_gui("Frequency (Hz)"))
+        self.element.InsertColumn(1, str_to_gui("Peak intensity type"))
+        self.element.InsertColumn(2, str_to_gui("Temperature calibration"))
+        self.element.InsertColumn(3, str_to_gui("Temperature control"))
 
         # Properties.
         self.element.SetFont(font.normal)
@@ -449,6 +309,38 @@
         sizer.Add(self.element, 0, wx.ALL|wx.EXPAND, 0)
 
 
+    def is_complete(self):
+        """Determine if the data input is complete.
+
+        @return:    The answer to the question.
+        @rtype:     bool
+        """
+
+        # The number of IDs.
+        n = len(cdp.ri_ids)
+
+        # Add all the data.
+        for i in range(n):
+            # The ID.
+            id = cdp.ri_ids[i]
+
+            # Check the peak intensity types.
+            if not hasattr(cdp, 'exp_info') or not hasattr(cdp.exp_info, 
'peak_intensity_type') or not id in cdp.exp_info.peak_intensity_type.keys():
+                return False
+
+
+            # Check the temperature calibration methods.
+            if not hasattr(cdp, 'exp_info') or not hasattr(cdp.exp_info, 
'temp_calibration') or not id in cdp.exp_info.temp_calibration.keys():
+                return False
+
+            # Check the temperature control methods.
+            if not hasattr(cdp, 'exp_info') or not hasattr(cdp.exp_info, 
'temp_control') or not id in cdp.exp_info.temp_control.keys():
+                return False
+
+        # Data input is complete!
+        return True
+
+
     def observer_register(self, remove=False):
         """Register and unregister methods with the observer objects.
 
@@ -480,22 +372,16 @@
         menu = wx.Menu()
 
         # Add some menu items for the spin user functions.
-        menu.AppendItem(build_menu_item(menu, 
id=self.MENU_RELAX_DATA_DELETE, text="&Delete the relaxation data", 
icon=fetch_icon(uf_info.get_uf('relax_data.delete').gui_icon)))
         menu.AppendItem(build_menu_item(menu, 
id=self.MENU_RELAX_DATA_DISPLAY, text="Dis&play the relaxation data", 
icon=fetch_icon(uf_info.get_uf('relax_data.display').gui_icon)))
-        menu.AppendItem(build_menu_item(menu, id=self.MENU_RELAX_DATA_FRQ, 
text="Set the relaxation data &frequency", 
icon=fetch_icon(uf_info.get_uf('relax_data.frq').gui_icon)))
         menu.AppendItem(build_menu_item(menu, 
id=self.MENU_RELAX_DATA_PEAK_INTENSITY_TYPE, text="Set the peak &intensity 
type", 
icon=fetch_icon(uf_info.get_uf('relax_data.peak_intensity_type').gui_icon)))
         menu.AppendItem(build_menu_item(menu, 
id=self.MENU_RELAX_DATA_TEMP_CALIBRATION, text="Set the temperature 
&calibration", 
icon=fetch_icon(uf_info.get_uf('relax_data.temp_calibration').gui_icon)))
         menu.AppendItem(build_menu_item(menu, 
id=self.MENU_RELAX_DATA_TEMP_CONTROL, text="Set the temperature c&ontrol", 
icon=fetch_icon(uf_info.get_uf('relax_data.temp_control').gui_icon)))
-        menu.AppendItem(build_menu_item(menu, id=self.MENU_RELAX_DATA_TYPE, 
text="Set the relaxation data &type", 
icon=fetch_icon(uf_info.get_uf('relax_data.type').gui_icon)))
 
         # Bind clicks.
-        self.element.Bind(wx.EVT_MENU, self.action_relax_data_delete, 
id=self.MENU_RELAX_DATA_DELETE)
         self.element.Bind(wx.EVT_MENU, self.action_relax_data_display, 
id=self.MENU_RELAX_DATA_DISPLAY)
-        self.element.Bind(wx.EVT_MENU, self.action_relax_data_frq, 
id=self.MENU_RELAX_DATA_FRQ)
         self.element.Bind(wx.EVT_MENU, 
self.action_relax_data_peak_intensity_type, 
id=self.MENU_RELAX_DATA_PEAK_INTENSITY_TYPE)
         self.element.Bind(wx.EVT_MENU, 
self.action_relax_data_temp_calibration, 
id=self.MENU_RELAX_DATA_TEMP_CALIBRATION)
         self.element.Bind(wx.EVT_MENU, self.action_relax_data_temp_control, 
id=self.MENU_RELAX_DATA_TEMP_CONTROL)
-        self.element.Bind(wx.EVT_MENU, self.action_relax_data_type, 
id=self.MENU_RELAX_DATA_TYPE)
 
         # Pop up the menu.
         if status.show_gui:
@@ -517,6 +403,20 @@
         event.Skip()
 
 
+    def set_box_label(self):
+        """Set the label of the StaticBox."""
+
+        # Determine if the data input is complete.
+        label = "Relaxation data metadata "
+        if self.is_complete():
+            label += "(complete)"
+        else:
+            label += "(incomplete)"
+
+        # Set the label.
+        self.data_box.SetLabel(label)
+
+
     def size_cols(self):
         """Set the column sizes."""
 




Related Messages


Powered by MHonArc, Updated Thu Jun 07 13:40:02 2012