1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 """Module containing the classes for GUI components involving relaxation data."""
25
26
27 import wx
28 import wx.lib.buttons
29
30
31 from graphics import fetch_icon
32 from gui.components.base_list import Base_list
33 from gui.components.relax_data_meta import Relax_data_meta_list
34 from gui.icons import relax_icons
35 from gui.misc import add_border
36 from gui.string_conv import float_to_gui, gui_to_str, str_to_gui
37 from gui.uf_objects import Uf_storage; uf_store = Uf_storage()
38 from gui.wizards.wiz_objects import Wiz_window
39 from lib.text.gui import r1, r2
40 from status import Status; status = Status()
41 from user_functions.data import Uf_info; uf_info = Uf_info()
42
43
45 """The GUI element for listing loaded relaxation data."""
46
48 """Launch the relax_data.delete user function.
49
50 @param event: The wx event.
51 @type event: wx event
52 """
53
54
55 item = self.element.GetFirstSelected()
56
57
58 if item == -1:
59 id = None
60
61
62 else:
63
64 id = gui_to_str(self.element.GetItemText(item))
65
66
67 uf_store['relax_data.delete'](ri_id=id)
68
69
71 """Launch the relax_data.display user function.
72
73 @param event: The wx event.
74 @type event: wx event
75 """
76
77
78 item = self.element.GetFirstSelected()
79
80
81 id = gui_to_str(self.element.GetItemText(item))
82
83
84 uf_store['relax_data.display'](ri_id=id)
85
86
88 """Launch the relax_data.peak_intensity_type user function.
89
90 @param event: The wx event.
91 @type event: wx event
92 """
93
94
95 item = self.element.GetFirstSelected()
96
97
98 id = gui_to_str(self.element.GetItemText(item))
99
100
101 type = None
102 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'peak_intensity_type') and id in cdp.exp_info.peak_intensity_type.keys():
103 type = cdp.exp_info.peak_intensity_type[id]
104
105
106 if type == None:
107 uf_store['relax_data.peak_intensity_type'](ri_id=id)
108 else:
109 uf_store['relax_data.peak_intensity_type'](ri_id=id, type=type)
110
111
113 """Launch the relax_data.temp_calibration user function.
114
115 @param event: The wx event.
116 @type event: wx event
117 """
118
119
120 item = self.element.GetFirstSelected()
121
122
123 id = gui_to_str(self.element.GetItemText(item))
124
125
126 method = None
127 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'temp_calibration') and id in cdp.exp_info.temp_calibration.keys():
128 method = cdp.exp_info.temp_calibration[id]
129
130
131 if method == None:
132 uf_store['relax_data.temp_calibration'](ri_id=id)
133 else:
134 uf_store['relax_data.temp_calibration'](ri_id=id, method=method)
135
136
138 """Launch the relax_data.temp_control user function.
139
140 @param event: The wx event.
141 @type event: wx event
142 """
143
144
145 item = self.element.GetFirstSelected()
146
147
148 id = gui_to_str(self.element.GetItemText(item))
149
150
151 method = None
152 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'temp_control') and id in cdp.exp_info.temp_control.keys():
153 method = cdp.exp_info.temp_control[id]
154
155
156 if method == None:
157 uf_store['relax_data.temp_control'](ri_id=id)
158 else:
159 uf_store['relax_data.temp_control'](ri_id=id, method=method)
160
161
163 """Launch the relax_data.type user function.
164
165 @param event: The wx event.
166 @type event: wx event
167 """
168
169
170 item = self.element.GetFirstSelected()
171
172
173 id = gui_to_str(self.element.GetItemText(item))
174
175
176 type = None
177 if hasattr(cdp, 'ri_type') and id in cdp.ri_type.keys():
178 type = cdp.ri_type[id]
179
180
181 if type == None:
182 uf_store['relax_data.type'](ri_id=id)
183 else:
184 uf_store['relax_data.type'](ri_id=id, ri_type=type)
185
186
188 """Launch the spectrometer.frequency user function.
189
190 @param event: The wx event.
191 @type event: wx event
192 """
193
194
195 item = self.element.GetFirstSelected()
196
197
198 id = gui_to_str(self.element.GetItemText(item))
199
200
201 frq = None
202 if hasattr(cdp, 'spectrometer_frq') and id in cdp.spectrometer_frq.keys():
203 frq = cdp.spectrometer_frq[id]
204
205
206 if frq == None:
207 uf_store['spectrometer.frequency'](id=id)
208 else:
209 uf_store['spectrometer.frequency'](id=id, frq=frq)
210
211
213 """Override the base variables."""
214
215
216 self.title = "Relaxation data list"
217 self.observer_base_name = "relaxation data list"
218
219
220 self.columns = [
221 "Relaxation data ID",
222 "Data type",
223 "Frequency (Hz)"
224 ]
225
226
227 self.button_placement = 'top'
228 self.button_size = (170, 40)
229 self.button_info = [
230 {
231 'object': 'button_add',
232 'label': ' Add',
233 'icon': fetch_icon('oxygen.actions.list-add-relax-blue', "22x22"),
234 'method': self.wizard_relax_data,
235 'tooltip': "Read relaxation data from a file."
236 }, {
237 'object': 'button_bruker',
238 'label': ' Add',
239 'icon': fetch_icon('relax.bruker_add', "22x22"),
240 'method': self.wizard_bruker,
241 'tooltip': "Read a Bruker Dynamics Center relaxation data file."
242 }, {
243 'object': 'button_delete',
244 'label': ' Delete',
245 'icon': fetch_icon('oxygen.actions.list-remove', "22x22"),
246 'method': self.action_relax_data_delete,
247 'tooltip': "Delete loaded relaxation data from the relax data store."
248 }, {
249 'object': 'button_metadata',
250 'label': ' View metadata',
251 'icon': fetch_icon('oxygen.mimetypes.text-x-texinfo', "22x22"),
252 'method': self.view_metadata,
253 'tooltip': "View and edit the relaxation data metadata."
254 }
255 ]
256
257
258 self.popup_menus = [
259 {
260 'id': wx.NewId(),
261 'text': "&Delete the relaxation data",
262 'icon': fetch_icon(uf_info.get_uf('relax_data.delete').gui_icon),
263 'method': self.action_relax_data_delete
264 }, {
265 'id': wx.NewId(),
266 'text': "Dis&play the relaxation data",
267 'icon': fetch_icon(uf_info.get_uf('relax_data.display').gui_icon),
268 'method': self.action_relax_data_display
269 }, {
270 'id': wx.NewId(),
271 'text': "Set the relaxation data &frequency",
272 'icon': fetch_icon(uf_info.get_uf('spectrometer.frequency').gui_icon),
273 'method': self.action_spectrometer_frequency
274 }, {
275 'id': wx.NewId(),
276 'text': "Set the peak &intensity type",
277 'icon': fetch_icon(uf_info.get_uf('relax_data.peak_intensity_type').gui_icon),
278 'method': self.action_relax_data_peak_intensity_type
279 }, {
280 'id': wx.NewId(),
281 'text': "Set the temperature &calibration",
282 'icon': fetch_icon(uf_info.get_uf('relax_data.temp_calibration').gui_icon),
283 'method': self.action_relax_data_temp_calibration
284 }, {
285 'id': wx.NewId(),
286 'text': "Set the temperature c&ontrol",
287 'icon': fetch_icon(uf_info.get_uf('relax_data.temp_control').gui_icon),
288 'method': self.action_relax_data_temp_control
289 }, {
290 'id': wx.NewId(),
291 'text': "Set the relaxation data &type",
292 'icon': fetch_icon(uf_info.get_uf('relax_data.type').gui_icon),
293 'method': self.action_relax_data_type
294 }
295 ]
296
297
299 """Method called from self.build_element_safe() to update the list data."""
300
301
302 table = {
303 "NOE": "Steady-state NOE",
304 "R1": "%s longitudinal relaxation" % r1,
305 "R2": "%s transverse relaxation" % r2
306 }
307
308
309 n = 0
310 if hasattr(cdp, 'ri_ids'):
311
312 n = len(cdp.ri_ids)
313
314
315 for i in range(n):
316
317 id = cdp.ri_ids[i]
318 self.element.InsertStringItem(i, str_to_gui(id))
319
320
321 self.element.SetStringItem(i, 1, str_to_gui(table[cdp.ri_type[id]]))
322
323
324 self.element.SetStringItem(i, 2, float_to_gui(cdp.spectrometer_frq[id]))
325
326
336
337
339 """Launch the Bruker Dynamics Centre data reading wizard.
340
341 @param event: The wx event.
342 @type event: wx event
343 """
344
345
346 self.wizard_exec(bruker=True)
347
348
350 """Launch the Rx peak loading wizard.
351
352 @keyword bruker: A flag which if True will launch the Bruker Dynamics Centre data reading wizard and if False will launch the relaxation data reading wizard
353 @type bruker: bool
354 """
355
356
357 wx.BeginBusyCursor()
358
359
360 if bruker:
361 title = "The Bruker Dynamics Centre data reading wizard"
362 else:
363 title = "The relaxation data reading wizard"
364
365
366 self.wizard = Wiz_window(parent=self.gui, size_x=1000, size_y=800, title=title)
367 self.page_indices = {}
368
369
370 if bruker:
371 page = uf_store['bruker.read'].create_page(self.wizard, sync=True)
372 else:
373 page = uf_store['relax_data.read'].create_page(self.wizard, sync=True)
374 self.page_indices['read'] = self.wizard.add_page(page, skip_button=True, proceed_on_error=False)
375
376
377 page = uf_store['relax_data.peak_intensity_type'].create_page(self.wizard, sync=True)
378 self.page_indices['peak_intensity_type'] = self.wizard.add_page(page, apply_button=True, skip_button=True)
379 page.on_display_post = self.wizard_update_int_type
380
381
382 page = uf_store['relax_data.temp_calibration'].create_page(self.wizard, sync=True)
383 self.page_indices['temp_calibration'] = self.wizard.add_page(page, apply_button=True, skip_button=True)
384 page.on_display_post = self.wizard_update_temp_calibration
385
386
387 page = uf_store['relax_data.temp_control'].create_page(self.wizard, sync=True)
388 self.page_indices['temp_control'] = self.wizard.add_page(page, apply_button=True)
389 page.on_display_post = self.wizard_update_temp_control
390
391
392 if wx.IsBusy():
393 wx.EndBusyCursor()
394
395
396 self.wizard.run()
397
398
400 """Launch the relaxation data reading wizard.
401
402 @param event: The wx event.
403 @type event: wx event
404 """
405
406
407 self.wizard_exec(bruker=False)
408
409
411 """Update the relax_data.peak_intensity_type page based on previous data."""
412
413
414 page = self.wizard.get_page(self.page_indices['read'])
415
416
417 id = page.uf_args['ri_id'].GetValue()
418
419
420 page = self.wizard.get_page(self.page_indices['peak_intensity_type'])
421 page.uf_args['ri_id'].SetValue(value=id)
422
423
425 """Update the relax_data.temp_calibration page based on previous data."""
426
427
428 page = self.wizard.get_page(self.page_indices['read'])
429
430
431 id = page.uf_args['ri_id'].GetValue()
432
433
434 page = self.wizard.get_page(self.page_indices['temp_calibration'])
435 page.uf_args['ri_id'].SetValue(value=id)
436
437
439 """Update the relax_data.temp_control page based on previous data."""
440
441
442 page = self.wizard.get_page(self.page_indices['read'])
443
444
445 id = page.uf_args['ri_id'].GetValue()
446
447
448 page = self.wizard.get_page(self.page_indices['temp_control'])
449 page.uf_args['ri_id'].SetValue(value=id)
450
451
452
534