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