1 | """ |
---|
2 | Calculator Module |
---|
3 | """ |
---|
4 | ################################################################################ |
---|
5 | #This software was developed by the University of Tennessee as part of the |
---|
6 | #Distributed Data Analysis of Neutron Scattering Experiments (DANSE) |
---|
7 | #project funded by the US National Science Foundation. |
---|
8 | # |
---|
9 | #See the license text in license.txt |
---|
10 | # |
---|
11 | #copyright 2010, University of Tennessee |
---|
12 | ################################################################################ |
---|
13 | |
---|
14 | |
---|
15 | from sans.guiframe.plugin_base import PluginBase |
---|
16 | import logging |
---|
17 | |
---|
18 | class Plugin(PluginBase): |
---|
19 | """ |
---|
20 | This class defines the interface for a Plugin class |
---|
21 | for calculator perspective |
---|
22 | """ |
---|
23 | def __init__(self, standalone=True): |
---|
24 | PluginBase.__init__(self, name="Calculator", standalone=standalone) |
---|
25 | # Log startup |
---|
26 | logging.info("Calculator plug-in started") |
---|
27 | |
---|
28 | def help(self, evt): |
---|
29 | """ |
---|
30 | Show a general help dialog. |
---|
31 | |
---|
32 | :TODO: replace the text with a nice image |
---|
33 | provide more hint on the SLD calculator |
---|
34 | """ |
---|
35 | from help_panel import HelpWindow |
---|
36 | frame = HelpWindow(None, -1) |
---|
37 | frame.Show(True) |
---|
38 | |
---|
39 | def get_tools(self): |
---|
40 | """ |
---|
41 | Returns a set of menu entries for tools |
---|
42 | """ |
---|
43 | kiessig_help = "Approximately computes the " |
---|
44 | kiessig_help += "thickness of a shell or the size of " |
---|
45 | kiessig_help += "particles \n from the width of a Kiessig fringe." |
---|
46 | sld_help = "Computes the Scattering Length Density." |
---|
47 | slit_length_help = "Computes the slit length from the beam profile." |
---|
48 | resolution_help = "Approximately estimates the " |
---|
49 | resolution_help += "resolution of Q in 2D based on the SANS " |
---|
50 | resolution_help += "instrumental parameter values." |
---|
51 | pyconsole_help = "Python Console." |
---|
52 | #data_editor_help = "Meta Data Editor" |
---|
53 | return [("SLD Calculator", sld_help, self.on_calculate_sld), |
---|
54 | ("Slit Size Calculator", slit_length_help, |
---|
55 | self.on_calculate_slit_size), |
---|
56 | ("Kiessig Thickness Calculator", |
---|
57 | kiessig_help, self.on_calculate_kiessig), |
---|
58 | ("SANS Resolution Estimator", |
---|
59 | resolution_help, self.on_calculate_resoltuion), |
---|
60 | ("Python Shell", pyconsole_help, self.on_python_console)] |
---|
61 | |
---|
62 | def on_edit_data(self, event): |
---|
63 | """ |
---|
64 | Edit meta data |
---|
65 | """ |
---|
66 | from data_editor import DataEditorWindow |
---|
67 | frame = DataEditorWindow(parent=self.parent, data=[], |
---|
68 | title="Data Editor") |
---|
69 | frame.Show(True) |
---|
70 | event.Skip() |
---|
71 | |
---|
72 | def on_calculate_kiessig(self, event): |
---|
73 | """ |
---|
74 | Compute the Kiessig thickness |
---|
75 | """ |
---|
76 | from kiessig_calculator_panel import KiessigWindow |
---|
77 | frame = KiessigWindow() |
---|
78 | frame.Show(True) |
---|
79 | |
---|
80 | def on_calculate_sld(self, event): |
---|
81 | """ |
---|
82 | Compute the scattering length density of molecula |
---|
83 | """ |
---|
84 | from sld_panel import SldWindow |
---|
85 | frame = SldWindow(base=self.parent) |
---|
86 | frame.Show(True) |
---|
87 | |
---|
88 | def on_calculate_slit_size(self, event): |
---|
89 | """ |
---|
90 | Compute the slit size a given data |
---|
91 | """ |
---|
92 | from slit_length_calculator_panel import SlitLengthCalculatorWindow |
---|
93 | frame = SlitLengthCalculatorWindow(parent=self.parent) |
---|
94 | frame.Show(True) |
---|
95 | |
---|
96 | def on_calculate_resoltuion(self, event): |
---|
97 | """ |
---|
98 | Estimate the instrumental resolution |
---|
99 | """ |
---|
100 | from resolution_calculator_panel import ResolutionWindow |
---|
101 | frame = ResolutionWindow(parent=self.parent) |
---|
102 | frame.Show(True) |
---|
103 | |
---|
104 | #def on_perspective(self, event): |
---|
105 | """ |
---|
106 | Call back function for the perspective menu item. |
---|
107 | We notify the parent window that the perspective |
---|
108 | has changed. |
---|
109 | |
---|
110 | :param event: menu event |
---|
111 | |
---|
112 | """ |
---|
113 | #self.parent.set_perspective(self.perspective) |
---|
114 | #if event != None: |
---|
115 | # event.Skip() |
---|
116 | def on_python_console(self, event): |
---|
117 | """ |
---|
118 | Open Python Console |
---|
119 | |
---|
120 | :param event: menu event |
---|
121 | """ |
---|
122 | from pyconsole import PyConsole |
---|
123 | frame = PyConsole(parent=self.parent) |
---|
124 | frame.Show(True) |
---|
125 | |
---|
126 | |
---|
127 | |
---|
128 | |
---|