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 import dep_check
32 from graphics import fetch_icon
33 from gui.components.base_list import Base_list
34 from gui.components.relax_data_meta import Relax_data_meta_list
35 from gui.icons import Relax_icons
36 from gui.misc import add_border
37 from gui.string_conv import float_to_gui, gui_to_str, str_to_gui
38 from gui.uf_objects import Uf_storage; uf_store = Uf_storage()
39 from gui.wizards.wiz_objects import Wiz_window
40 from lib.text.gui import r1, r2
41 from status import Status; status = Status()
42 from user_functions.data import Uf_info; uf_info = Uf_info()
43
44
45
46 MENU_RELAX_DATA_DELETE = wx.NewId()
47 MENU_RELAX_DATA_DISPLAY = wx.NewId()
48 MENU_SPECTROMETER_FREQUENCY = wx.NewId()
49 MENU_RELAX_DATA_PEAK_INTENSITY_TYPE = wx.NewId()
50 MENU_RELAX_DATA_TEMP_CALIBRATION = wx.NewId()
51 MENU_RELAX_DATA_TEMP_CONTROL = wx.NewId()
52 MENU_RELAX_DATA_TYPE = wx.NewId()
53
54
55
57 """The GUI element for listing loaded relaxation data."""
58
60 """Launch the relax_data.delete user function.
61
62 @param event: The wx event.
63 @type event: wx event
64 """
65
66
67 item = self.element.GetFirstSelected()
68
69
70 if item == -1:
71 id = None
72
73
74 else:
75
76 id = gui_to_str(self.element.GetItemText(item))
77
78
79 uf_store['relax_data.delete'](ri_id=id)
80
81
83 """Launch the relax_data.display user function.
84
85 @param event: The wx event.
86 @type event: wx event
87 """
88
89
90 item = self.element.GetFirstSelected()
91
92
93 id = gui_to_str(self.element.GetItemText(item))
94
95
96 uf_store['relax_data.display'](ri_id=id)
97
98
122
123
147
148
172
173
175 """Launch the relax_data.type user function.
176
177 @param event: The wx event.
178 @type event: wx event
179 """
180
181
182 item = self.element.GetFirstSelected()
183
184
185 id = gui_to_str(self.element.GetItemText(item))
186
187
188 type = None
189 if hasattr(cdp, 'ri_type') and id in cdp.ri_type:
190 type = cdp.ri_type[id]
191
192
193 if type == None:
194 uf_store['relax_data.type'](ri_id=id)
195 else:
196 uf_store['relax_data.type'](ri_id=id, ri_type=type)
197
198
200 """Launch the spectrometer.frequency user function.
201
202 @param event: The wx event.
203 @type event: wx event
204 """
205
206
207 item = self.element.GetFirstSelected()
208
209
210 id = gui_to_str(self.element.GetItemText(item))
211
212
213 frq = None
214 if hasattr(cdp, 'spectrometer_frq') and id in cdp.spectrometer_frq:
215 frq = cdp.spectrometer_frq[id]
216
217
218 if frq == None:
219 uf_store['spectrometer.frequency'](id=id)
220 else:
221 uf_store['spectrometer.frequency'](id=id, frq=frq)
222
223
225 """Override the base variables."""
226
227
228 self.title = "Relaxation data list"
229 self.observer_base_name = "relaxation data list"
230
231
232 self.columns = [
233 "Relaxation data ID",
234 "Data type",
235 "Frequency (Hz)"
236 ]
237
238
239 self.button_placement = 'top'
240 self.button_size = (170, 40)
241 self.button_info = [
242 {
243 'object': 'button_add',
244 'label': ' Add',
245 'icon': fetch_icon('oxygen.actions.list-add-relax-blue', "22x22"),
246 'method': self.wizard_relax_data,
247 'tooltip': "Read relaxation data from a file."
248 }, {
249 'object': 'button_bruker',
250 'label': ' Add',
251 'icon': fetch_icon('relax.bruker_add', "22x22"),
252 'method': self.wizard_bruker,
253 'tooltip': "Read a Bruker Dynamics Center relaxation data file."
254 }, {
255 'object': 'button_delete',
256 'label': ' Delete',
257 'icon': fetch_icon('oxygen.actions.list-remove', "22x22"),
258 'method': self.action_relax_data_delete,
259 'tooltip': "Delete loaded relaxation data from the relax data store."
260 }, {
261 'object': 'button_metadata',
262 'label': ' View metadata',
263 'icon': fetch_icon('oxygen.mimetypes.text-x-texinfo', "22x22"),
264 'method': self.view_metadata,
265 'tooltip': "View and edit the relaxation data metadata."
266 }
267 ]
268
269
270 self.popup_menus = [
271 {
272 'id': MENU_RELAX_DATA_DELETE,
273 'text': "&Delete the relaxation data",
274 'icon': fetch_icon(uf_info.get_uf('relax_data.delete').gui_icon),
275 'method': self.action_relax_data_delete
276 }, {
277 'id': MENU_RELAX_DATA_DISPLAY,
278 'text': "Dis&play the relaxation data",
279 'icon': fetch_icon(uf_info.get_uf('relax_data.display').gui_icon),
280 'method': self.action_relax_data_display
281 }, {
282 'id': MENU_SPECTROMETER_FREQUENCY,
283 'text': "Set the relaxation data &frequency",
284 'icon': fetch_icon(uf_info.get_uf('spectrometer.frequency').gui_icon),
285 'method': self.action_spectrometer_frequency
286 }, {
287 'id': MENU_RELAX_DATA_PEAK_INTENSITY_TYPE,
288 'text': "Set the peak &intensity type",
289 'icon': fetch_icon(uf_info.get_uf('relax_data.peak_intensity_type').gui_icon),
290 'method': self.action_relax_data_peak_intensity_type
291 }, {
292 'id': MENU_RELAX_DATA_TEMP_CALIBRATION,
293 'text': "Set the temperature &calibration",
294 'icon': fetch_icon(uf_info.get_uf('relax_data.temp_calibration').gui_icon),
295 'method': self.action_relax_data_temp_calibration
296 }, {
297 'id': MENU_RELAX_DATA_TEMP_CONTROL,
298 'text': "Set the temperature c&ontrol",
299 'icon': fetch_icon(uf_info.get_uf('relax_data.temp_control').gui_icon),
300 'method': self.action_relax_data_temp_control
301 }, {
302 'id': MENU_RELAX_DATA_TYPE,
303 'text': "Set the relaxation data &type",
304 'icon': fetch_icon(uf_info.get_uf('relax_data.type').gui_icon),
305 'method': self.action_relax_data_type
306 }
307 ]
308
309
311 """Method called from self.build_element_safe() to update the list data."""
312
313
314 table = {
315 "NOE": "Steady-state NOE",
316 "R1": "%s longitudinal relaxation" % r1,
317 "R2": "%s transverse relaxation" % r2
318 }
319
320
321 n = 0
322 if hasattr(cdp, 'ri_ids'):
323
324 n = len(cdp.ri_ids)
325
326
327 for i in range(n):
328
329 id = cdp.ri_ids[i]
330 if dep_check.wx_classic:
331 self.element.InsertStringItem(i, str_to_gui(id))
332 else:
333 self.element.InsertItem(i, str_to_gui(id))
334
335
336 if dep_check.wx_classic:
337 self.element.SetStringItem(i, 1, str_to_gui(table[cdp.ri_type[id]]))
338 else:
339 self.element.SetItem(i, 1, str_to_gui(table[cdp.ri_type[id]]))
340
341
342 if dep_check.wx_classic:
343 self.element.SetStringItem(i, 2, float_to_gui(cdp.spectrometer_frq[id]))
344 else:
345 self.element.SetItem(i, 2, float_to_gui(cdp.spectrometer_frq[id]))
346
347
357
358
360 """Launch the Bruker Dynamics Centre data reading wizard.
361
362 @param event: The wx event.
363 @type event: wx event
364 """
365
366
367 self.wizard_exec(bruker=True)
368
369
371 """Launch the Rx peak loading wizard.
372
373 @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
374 @type bruker: bool
375 """
376
377
378 wx.BeginBusyCursor()
379
380
381 if bruker:
382 title = "The Bruker Dynamics Centre data reading wizard"
383 else:
384 title = "The relaxation data reading wizard"
385
386
387 if hasattr(self, 'wizard'):
388 self.wizard.Destroy()
389
390
391 self.wizard = Wiz_window(parent=self.gui, size_x=1000, size_y=750, title=title)
392 self.page_indices = {}
393
394
395 if bruker:
396 page = uf_store['bruker.read'].create_page(self.wizard, sync=True)
397 else:
398 page = uf_store['relax_data.read'].create_page(self.wizard, sync=True)
399 self.page_indices['read'] = self.wizard.add_page(page, skip_button=True, proceed_on_error=False)
400
401
402 page = uf_store['relax_data.peak_intensity_type'].create_page(self.wizard, sync=True)
403 self.page_indices['peak_intensity_type'] = self.wizard.add_page(page, apply_button=True, skip_button=True)
404 page.on_display_post = self.wizard_update_int_type
405
406
407 page = uf_store['relax_data.temp_calibration'].create_page(self.wizard, sync=True)
408 self.page_indices['temp_calibration'] = self.wizard.add_page(page, apply_button=True, skip_button=True)
409 page.on_display_post = self.wizard_update_temp_calibration
410
411
412 page = uf_store['relax_data.temp_control'].create_page(self.wizard, sync=True)
413 self.page_indices['temp_control'] = self.wizard.add_page(page, apply_button=True)
414 page.on_display_post = self.wizard_update_temp_control
415
416
417 if wx.IsBusy():
418 wx.EndBusyCursor()
419
420
421 self.wizard.run()
422
423
425 """Launch the relaxation data reading wizard.
426
427 @param event: The wx event.
428 @type event: wx event
429 """
430
431
432 self.wizard_exec(bruker=False)
433
434
436 """Update the relax_data.peak_intensity_type page based on previous data."""
437
438
439 page = self.wizard.get_page(self.page_indices['read'])
440
441
442 id = page.uf_args['ri_id'].GetValue()
443
444
445 page = self.wizard.get_page(self.page_indices['peak_intensity_type'])
446 page.uf_args['ri_id'].SetValue(value=id)
447
448
450 """Update the relax_data.temp_calibration page based on previous data."""
451
452
453 page = self.wizard.get_page(self.page_indices['read'])
454
455
456 id = page.uf_args['ri_id'].GetValue()
457
458
459 page = self.wizard.get_page(self.page_indices['temp_calibration'])
460 page.uf_args['ri_id'].SetValue(value=id)
461
462
464 """Update the relax_data.temp_control page based on previous data."""
465
466
467 page = self.wizard.get_page(self.page_indices['read'])
468
469
470 id = page.uf_args['ri_id'].GetValue()
471
472
473 page = self.wizard.get_page(self.page_indices['temp_control'])
474 page.uf_args['ri_id'].SetValue(value=id)
475
476
477
559