Package gui :: Package components :: Module relax_data_meta
[hide private]
[frames] | no frames]

Source Code for Module gui.components.relax_data_meta

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2009-2011 Michael Bieri                                       # 
  4  # Copyright (C) 2010-2012 Edward d'Auvergne                                   # 
  5  #                                                                             # 
  6  # This file is part of the program relax.                                     # 
  7  #                                                                             # 
  8  # relax is free software; you can redistribute it and/or modify               # 
  9  # it under the terms of the GNU General Public License as published by        # 
 10  # the Free Software Foundation; either version 2 of the License, or           # 
 11  # (at your option) any later version.                                         # 
 12  #                                                                             # 
 13  # relax is distributed in the hope that it will be useful,                    # 
 14  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 16  # GNU General Public License for more details.                                # 
 17  #                                                                             # 
 18  # You should have received a copy of the GNU General Public License           # 
 19  # along with relax; if not, write to the Free Software                        # 
 20  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 21  #                                                                             # 
 22  ############################################################################### 
 23   
 24  # Module docstring. 
 25  """Module containing the classes for GUI components involving relaxation data.""" 
 26   
 27  # Python module imports. 
 28  import wx 
 29   
 30  # relax module imports. 
 31  from graphics import fetch_icon 
 32  from status import Status; status = Status() 
 33  from user_functions.data import Uf_info; uf_info = Uf_info() 
 34   
 35  # relax GUI module imports. 
 36  from gui.components.base_list import Base_list 
 37  from gui.string_conv import gui_to_str, str_to_gui 
 38  from gui.uf_objects import Uf_storage; uf_store = Uf_storage() 
 39   
 40   
41 -class Relax_data_meta_list(Base_list):
42 """The GUI element for listing loaded relaxation data.""" 43
44 - def action_relax_data_display(self, event):
45 """Launch the relax_data.display user function. 46 47 @param event: The wx event. 48 @type event: wx event 49 """ 50 51 # The current selection. 52 item = self.element.GetFirstSelected() 53 54 # The spectrum ID. 55 id = gui_to_str(self.element.GetItemText(item)) 56 57 # Launch the dialog. 58 uf_store['relax_data.display'](wx_parent=self.parent, ri_id=id)
59 60
62 """Launch the relax_data.peak_intensity_type user function. 63 64 @param event: The wx event. 65 @type event: wx event 66 """ 67 68 # The current selection. 69 item = self.element.GetFirstSelected() 70 71 # The spectrum ID. 72 id = gui_to_str(self.element.GetItemText(item)) 73 74 # The current type. 75 type = None 76 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'peak_intensity_type') and id in cdp.exp_info.peak_intensity_type.keys(): 77 type = cdp.exp_info.peak_intensity_type[id] 78 79 # Launch the dialog. 80 if type == None: 81 uf_store['relax_data.peak_intensity_type'](wx_parent=self.parent, ri_id=id) 82 else: 83 uf_store['relax_data.peak_intensity_type'](wx_parent=self.parent, ri_id=id, type=type)
84 85
86 - def action_relax_data_temp_calibration(self, event):
87 """Launch the relax_data.temp_calibration user function. 88 89 @param event: The wx event. 90 @type event: wx event 91 """ 92 93 # The current selection. 94 item = self.element.GetFirstSelected() 95 96 # The spectrum ID. 97 id = gui_to_str(self.element.GetItemText(item)) 98 99 # The current method. 100 method = None 101 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'temp_calibration') and id in cdp.exp_info.temp_calibration.keys(): 102 method = cdp.exp_info.temp_calibration[id] 103 104 # Launch the dialog. 105 if method == None: 106 uf_store['relax_data.temp_calibration'](wx_parent=self.parent, ri_id=id) 107 else: 108 uf_store['relax_data.temp_calibration'](wx_parent=self.parent, ri_id=id, method=method)
109 110
111 - def action_relax_data_temp_control(self, event):
112 """Launch the relax_data.temp_control user function. 113 114 @param event: The wx event. 115 @type event: wx event 116 """ 117 118 # The current selection. 119 item = self.element.GetFirstSelected() 120 121 # The spectrum ID. 122 id = gui_to_str(self.element.GetItemText(item)) 123 124 # The current method. 125 method = None 126 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'temp_control') and id in cdp.exp_info.temp_control.keys(): 127 method = cdp.exp_info.temp_control[id] 128 129 # Launch the dialog. 130 if method == None: 131 uf_store['relax_data.temp_control'](wx_parent=self.parent, ri_id=id) 132 else: 133 uf_store['relax_data.temp_control'](wx_parent=self.parent, ri_id=id, method=method)
134 135
136 - def is_complete(self):
137 """Determine if the data input is complete. 138 139 @return: The answer to the question. 140 @rtype: bool 141 """ 142 143 # No relaxation data. 144 if not hasattr(cdp, 'ri_ids'): 145 return True 146 147 # The number of IDs. 148 n = len(cdp.ri_ids) 149 150 # Add all the data. 151 for i in range(n): 152 # The ID. 153 id = cdp.ri_ids[i] 154 155 # Check the peak intensity types. 156 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(): 157 return False 158 159 # Check the temperature calibration methods. 160 if not hasattr(cdp, 'exp_info') or not hasattr(cdp.exp_info, 'temp_calibration') or not id in cdp.exp_info.temp_calibration.keys(): 161 return False 162 163 # Check the temperature control methods. 164 if not hasattr(cdp, 'exp_info') or not hasattr(cdp.exp_info, 'temp_control') or not id in cdp.exp_info.temp_control.keys(): 165 return False 166 167 # Data input is complete! 168 return True
169 170
171 - def set_box_label(self):
172 """Set the label of the StaticBox.""" 173 174 # Determine if the data input is complete. 175 label = self.title 176 if self.is_complete(): 177 label += " (complete)" 178 else: 179 label += " (incomplete)" 180 181 # Set the label. 182 self.data_box.SetLabel(label)
183 184
185 - def setup(self):
186 """Override the base variables.""" 187 188 # GUI variables. 189 self.title = "Relaxation data metadata" 190 self.observer_base_name = "relaxation metadata list" 191 self.button_placement = None 192 193 # The column titles. 194 self.columns = [ 195 "Relaxation data ID", 196 "Peak intensity type", 197 "Temperature calibration", 198 "Temperature control" 199 ] 200 201 # The right click popup menu. 202 self.popup_menus = [ 203 { 204 'id': wx.NewId(), 205 'text': "Dis&play the relaxation data", 206 'icon': fetch_icon(uf_info.get_uf('relax_data.display').gui_icon), 207 'method': self.action_relax_data_display 208 }, { 209 'id': wx.NewId(), 210 'text': "Set the peak &intensity type", 211 'icon': fetch_icon(uf_info.get_uf('relax_data.peak_intensity_type').gui_icon), 212 'method': self.action_relax_data_peak_intensity_type 213 }, { 214 'id': wx.NewId(), 215 'text': "Set the temperature &calibration", 216 'icon': fetch_icon(uf_info.get_uf('relax_data.temp_calibration').gui_icon), 217 'method': self.action_relax_data_temp_calibration 218 }, { 219 'id': wx.NewId(), 220 'text': "Set the temperature c&ontrol", 221 'icon': fetch_icon(uf_info.get_uf('relax_data.temp_control').gui_icon), 222 'method': self.action_relax_data_temp_control 223 } 224 ]
225 226
227 - def update_data(self):
228 """Method called from self.build_element_safe() to update the list data.""" 229 230 # Expand the number of rows to match the number of relaxation IDs, and add the IDs. 231 n = 0 232 if hasattr(cdp, 'ri_ids'): 233 # The number of IDs. 234 n = len(cdp.ri_ids) 235 236 # Add all the data. 237 for i in range(n): 238 # Set the IDs. 239 id = cdp.ri_ids[i] 240 self.element.InsertStringItem(i, str_to_gui(id)) 241 242 # Set the peak intensity types. 243 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'peak_intensity_type') and id in cdp.exp_info.peak_intensity_type.keys(): 244 self.element.SetStringItem(i, 1, str_to_gui(cdp.exp_info.peak_intensity_type[id])) 245 246 # Set the temperature calibration methods. 247 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'temp_calibration') and id in cdp.exp_info.temp_calibration.keys(): 248 self.element.SetStringItem(i, 2, str_to_gui(cdp.exp_info.temp_calibration[id])) 249 250 # Set the temperature control methods. 251 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'temp_control') and id in cdp.exp_info.temp_control.keys(): 252 self.element.SetStringItem(i, 3, str_to_gui(cdp.exp_info.temp_control[id]))
253