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