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