Trees | Indices | Help |
|
---|
|
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 (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 status import Status; status = Status() 32 from user_functions.data import Uf_info; uf_info = Uf_info() 33 34 # relax GUI module imports. 35 from gui.components.base_list import Base_list 36 from gui.string_conv import gui_to_str, str_to_gui 37 from gui.uf_objects import Uf_storage; uf_store = Uf_storage() 38 3941 """The GUI element for listing loaded relaxation data.""" 4225244 """Launch the relax_data.display user function. 45 46 @param event: The wx event. 47 @type event: wx event 48 """ 49 50 # The current selection. 51 item = self.element.GetFirstSelected() 52 53 # The spectrum ID. 54 id = gui_to_str(self.element.GetItemText(item)) 55 56 # Launch the dialog. 57 uf_store['relax_data.display'](wx_parent=self.parent, ri_id=id)58 5961 """Launch the relax_data.peak_intensity_type user function. 62 63 @param event: The wx event. 64 @type event: wx event 65 """ 66 67 # The current selection. 68 item = self.element.GetFirstSelected() 69 70 # The spectrum ID. 71 id = gui_to_str(self.element.GetItemText(item)) 72 73 # The current type. 74 type = None 75 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'peak_intensity_type') and id in cdp.exp_info.peak_intensity_type.keys(): 76 type = cdp.exp_info.peak_intensity_type[id] 77 78 # Launch the dialog. 79 if type == None: 80 uf_store['relax_data.peak_intensity_type'](wx_parent=self.parent, ri_id=id) 81 else: 82 uf_store['relax_data.peak_intensity_type'](wx_parent=self.parent, ri_id=id, type=type)83 8486 """Launch the relax_data.temp_calibration user function. 87 88 @param event: The wx event. 89 @type event: wx event 90 """ 91 92 # The current selection. 93 item = self.element.GetFirstSelected() 94 95 # The spectrum ID. 96 id = gui_to_str(self.element.GetItemText(item)) 97 98 # The current method. 99 method = None 100 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'temp_calibration') and id in cdp.exp_info.temp_calibration.keys(): 101 method = cdp.exp_info.temp_calibration[id] 102 103 # Launch the dialog. 104 if method == None: 105 uf_store['relax_data.temp_calibration'](wx_parent=self.parent, ri_id=id) 106 else: 107 uf_store['relax_data.temp_calibration'](wx_parent=self.parent, ri_id=id, method=method)108 109111 """Launch the relax_data.temp_control user function. 112 113 @param event: The wx event. 114 @type event: wx event 115 """ 116 117 # The current selection. 118 item = self.element.GetFirstSelected() 119 120 # The spectrum ID. 121 id = gui_to_str(self.element.GetItemText(item)) 122 123 # The current method. 124 method = None 125 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'temp_control') and id in cdp.exp_info.temp_control.keys(): 126 method = cdp.exp_info.temp_control[id] 127 128 # Launch the dialog. 129 if method == None: 130 uf_store['relax_data.temp_control'](wx_parent=self.parent, ri_id=id) 131 else: 132 uf_store['relax_data.temp_control'](wx_parent=self.parent, ri_id=id, method=method)133 134136 """Determine if the data input is complete. 137 138 @return: The answer to the question. 139 @rtype: bool 140 """ 141 142 # No relaxation data. 143 if not hasattr(cdp, 'ri_ids'): 144 return True 145 146 # The number of IDs. 147 n = len(cdp.ri_ids) 148 149 # Add all the data. 150 for i in range(n): 151 # The ID. 152 id = cdp.ri_ids[i] 153 154 # Check the peak intensity types. 155 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(): 156 return False 157 158 # Check the temperature calibration methods. 159 if not hasattr(cdp, 'exp_info') or not hasattr(cdp.exp_info, 'temp_calibration') or not id in cdp.exp_info.temp_calibration.keys(): 160 return False 161 162 # Check the temperature control methods. 163 if not hasattr(cdp, 'exp_info') or not hasattr(cdp.exp_info, 'temp_control') or not id in cdp.exp_info.temp_control.keys(): 164 return False 165 166 # Data input is complete! 167 return True168 169171 """Set the label of the StaticBox.""" 172 173 # Determine if the data input is complete. 174 label = self.title 175 if self.is_complete(): 176 label += " (complete)" 177 else: 178 label += " (incomplete)" 179 180 # Set the label. 181 self.data_box.SetLabel(label)182 183185 """Override the base variables.""" 186 187 # GUI variables. 188 self.title = "Relaxation data metadata" 189 self.observer_base_name = "relaxation metadata list" 190 self.button_placement = None 191 192 # The column titles. 193 self.columns = [ 194 "Relaxation data ID", 195 "Peak intensity type", 196 "Temperature calibration", 197 "Temperature control" 198 ] 199 200 # The right click popup menu. 201 self.popup_menus = [ 202 { 203 'id': wx.NewId(), 204 'text': "Dis&play the relaxation data", 205 'icon': fetch_icon(uf_info.get_uf('relax_data.display').gui_icon), 206 'method': self.action_relax_data_display 207 }, { 208 'id': wx.NewId(), 209 'text': "Set the peak &intensity type", 210 'icon': fetch_icon(uf_info.get_uf('relax_data.peak_intensity_type').gui_icon), 211 'method': self.action_relax_data_peak_intensity_type 212 }, { 213 'id': wx.NewId(), 214 'text': "Set the temperature &calibration", 215 'icon': fetch_icon(uf_info.get_uf('relax_data.temp_calibration').gui_icon), 216 'method': self.action_relax_data_temp_calibration 217 }, { 218 'id': wx.NewId(), 219 'text': "Set the temperature c&ontrol", 220 'icon': fetch_icon(uf_info.get_uf('relax_data.temp_control').gui_icon), 221 'method': self.action_relax_data_temp_control 222 } 223 ]224 225227 """Method called from self.build_element_safe() to update the list data.""" 228 229 # Expand the number of rows to match the number of relaxation IDs, and add the IDs. 230 n = 0 231 if hasattr(cdp, 'ri_ids'): 232 # The number of IDs. 233 n = len(cdp.ri_ids) 234 235 # Add all the data. 236 for i in range(n): 237 # Set the IDs. 238 id = cdp.ri_ids[i] 239 self.element.InsertStringItem(i, str_to_gui(id)) 240 241 # Set the peak intensity types. 242 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'peak_intensity_type') and id in cdp.exp_info.peak_intensity_type.keys(): 243 self.element.SetStringItem(i, 1, str_to_gui(cdp.exp_info.peak_intensity_type[id])) 244 245 # Set the temperature calibration methods. 246 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'temp_calibration') and id in cdp.exp_info.temp_calibration.keys(): 247 self.element.SetStringItem(i, 2, str_to_gui(cdp.exp_info.temp_calibration[id])) 248 249 # Set the temperature control methods. 250 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'temp_control') and id in cdp.exp_info.temp_control.keys(): 251 self.element.SetStringItem(i, 3, str_to_gui(cdp.exp_info.temp_control[id]))
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Apr 10 15:06:30 2013 | http://epydoc.sourceforge.net |