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 | if hasattr(frame, "IsIconized"): |
---|
38 | if not frame.IsIconized(): |
---|
39 | try: |
---|
40 | icon = self.parent.GetIcon() |
---|
41 | frame.SetIcon(icon) |
---|
42 | except: |
---|
43 | pass |
---|
44 | frame.Show(True) |
---|
45 | |
---|
46 | def get_tools(self): |
---|
47 | """ |
---|
48 | Returns a set of menu entries for tools |
---|
49 | """ |
---|
50 | kiessig_help = "Approximately computes the " |
---|
51 | kiessig_help += "thickness of a shell or the size of " |
---|
52 | kiessig_help += "particles \n from the width of a Kiessig fringe." |
---|
53 | sld_help = "Computes the Scattering Length Density." |
---|
54 | slit_length_help = "Computes the slit length from the beam profile." |
---|
55 | resolution_help = "Approximately estimates the " |
---|
56 | resolution_help += "resolution of Q in 2D based on the SANS " |
---|
57 | resolution_help += "instrumental parameter values." |
---|
58 | pyconsole_help = "Python Console." |
---|
59 | #data_editor_help = "Meta Data Editor" |
---|
60 | return [("SLD Calculator", sld_help, self.on_calculate_sld), |
---|
61 | ("Slit Size Calculator", slit_length_help, |
---|
62 | self.on_calculate_slit_size), |
---|
63 | ("Kiessig Thickness Calculator", |
---|
64 | kiessig_help, self.on_calculate_kiessig), |
---|
65 | ("SANS Resolution Estimator", |
---|
66 | resolution_help, self.on_calculate_resoltuion), |
---|
67 | ("Python Shell", pyconsole_help, self.on_python_console)] |
---|
68 | |
---|
69 | def on_edit_data(self, event): |
---|
70 | """ |
---|
71 | Edit meta data |
---|
72 | """ |
---|
73 | from data_editor import DataEditorWindow |
---|
74 | frame = DataEditorWindow(parent=self.parent, data=[], |
---|
75 | title="Data Editor") |
---|
76 | frame.Show(True) |
---|
77 | event.Skip() |
---|
78 | |
---|
79 | def on_calculate_kiessig(self, event): |
---|
80 | """ |
---|
81 | Compute the Kiessig thickness |
---|
82 | """ |
---|
83 | from kiessig_calculator_panel import KiessigWindow |
---|
84 | frame = KiessigWindow() |
---|
85 | frame.Show(True) |
---|
86 | |
---|
87 | def on_calculate_sld(self, event): |
---|
88 | """ |
---|
89 | Compute the scattering length density of molecula |
---|
90 | """ |
---|
91 | from sld_panel import SldWindow |
---|
92 | frame = SldWindow(base=self.parent) |
---|
93 | frame.Show(True) |
---|
94 | |
---|
95 | def on_calculate_slit_size(self, event): |
---|
96 | """ |
---|
97 | Compute the slit size a given data |
---|
98 | """ |
---|
99 | from slit_length_calculator_panel import SlitLengthCalculatorWindow |
---|
100 | frame = SlitLengthCalculatorWindow(parent=self.parent) |
---|
101 | frame.Show(True) |
---|
102 | |
---|
103 | def on_calculate_resoltuion(self, event): |
---|
104 | """ |
---|
105 | Estimate the instrumental resolution |
---|
106 | """ |
---|
107 | from resolution_calculator_panel import ResolutionWindow |
---|
108 | frame = ResolutionWindow(parent=self.parent) |
---|
109 | frame.Show(True) |
---|
110 | |
---|
111 | #def on_perspective(self, event): |
---|
112 | """ |
---|
113 | Call back function for the perspective menu item. |
---|
114 | We notify the parent window that the perspective |
---|
115 | has changed. |
---|
116 | |
---|
117 | :param event: menu event |
---|
118 | |
---|
119 | """ |
---|
120 | #self.parent.set_perspective(self.perspective) |
---|
121 | #if event != None: |
---|
122 | # event.Skip() |
---|
123 | def on_python_console(self, event): |
---|
124 | """ |
---|
125 | Open Python Console |
---|
126 | |
---|
127 | :param event: menu event |
---|
128 | """ |
---|
129 | from pyconsole import PyConsole |
---|
130 | frame = PyConsole(parent=self.parent) |
---|
131 | frame.Show(True) |
---|
132 | |
---|
133 | |
---|
134 | |
---|
135 | |
---|