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