source: sasview/calculatorview/src/sans/perspectives/calculator/calculator.py @ b6b0d05

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since b6b0d05 was 9a56619, checked in by Jae Cho <jhjcho@…>, 13 years ago

added frame icons

  • Property mode set to 100644
File size: 5.1 KB
Line 
1"""
2Calculator 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
15from sans.guiframe.plugin_base import PluginBase
16import logging
17
18class 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        self.put_icon(frame)
77        frame.Show(True)
78        event.Skip()
79
80    def on_calculate_kiessig(self, event):
81        """
82        Compute the Kiessig thickness
83        """
84        from kiessig_calculator_panel import KiessigWindow
85        frame = KiessigWindow()
86        self.put_icon(frame)
87        frame.Show(True) 
88   
89    def on_calculate_sld(self, event):
90        """
91        Compute the scattering length density of molecula
92        """
93        from sld_panel import SldWindow
94        frame = SldWindow(base=self.parent)
95        self.put_icon(frame)
96        frame.Show(True) 
97       
98    def on_calculate_slit_size(self, event):
99        """
100        Compute the slit size a given data
101        """
102        from slit_length_calculator_panel import SlitLengthCalculatorWindow
103        frame = SlitLengthCalculatorWindow(parent=self.parent) 
104        self.put_icon(frame) 
105        frame.Show(True)
106       
107    def on_calculate_resoltuion(self, event):
108        """
109        Estimate the instrumental resolution
110        """
111        from resolution_calculator_panel import ResolutionWindow
112        frame = ResolutionWindow(parent=self.parent)
113        self.put_icon(frame)
114        frame.Show(True) 
115 
116        #def on_perspective(self, event):
117        """
118        Call back function for the perspective menu item.
119        We notify the parent window that the perspective
120        has changed.
121       
122        :param event: menu event
123       
124        """
125        #self.parent.set_perspective(self.perspective)
126        #if event != None:
127        #    event.Skip()
128    def on_python_console(self, event):
129        """
130        Open Python Console
131       
132        :param event: menu event
133        """
134        from pyconsole import PyConsole
135        frame = PyConsole(parent=self.parent)
136        self.put_icon(frame)
137        frame.Show(True) 
138   
139    def put_icon(self, frame):
140        """
141        Put icon in the frame title bar
142        """
143        if hasattr(frame, "IsIconized"):
144            if not frame.IsIconized():
145                try:
146                    icon = self.parent.GetIcon()
147                    frame.SetIcon(icon)
148                except:
149                    pass     
150 
151   
Note: See TracBrowser for help on using the repository browser.