source: sasview/calculatorview/perspectives/calculator/calculator.py @ 3be3a80

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 3be3a80 was 3be3a80, checked in by Jae Cho <jhjcho@…>, 14 years ago

implemented a resolution estimating tool

  • Property mode set to 100644
File size: 6.3 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#import wx
15import logging
16
17class Plugin:
18    """
19    This class defines the interface for a Plugin class
20    for calculator perspective
21    """
22    def __init__(self, standalone=True):
23        """
24        Abstract class for gui_manager Plugins.
25        """
26        ## Plug-in name. It will appear on the application menu.
27        self.sub_menu = "Calculator"       
28        #standalone flag
29        self.standalone = standalone
30        ## Reference to the parent window. Filled by get_panels() below.
31        self.parent = None
32       
33        ## List of panels that you would like to open in AUI windows
34        #  for your plug-in. This defines your plug-in "perspective"
35        self.perspective = []
36        # Log startup
37        logging.info("Calculator plug-in started")   
38       
39    def populate_menu(self, id, owner):
40        """
41        Create and return the list of application menu
42        items for the plug-in.
43       
44        :param id: deprecated. Un-used.
45        :param parent: parent window
46       
47        :return: plug-in menu
48       
49        """
50        return []
51     
52    def get_panels(self, parent):
53        """
54        Create and return the list of wx.Panels for your plug-in.
55        Define the plug-in perspective.
56       
57        Panels should inherit from DefaultPanel defined below,
58        or should present the same interface. They must define
59        "window_caption" and "window_name".
60       
61        :param parent: parent window
62       
63        :return: list of panels
64       
65        """
66        ## Save a reference to the parent
67        self.parent = parent
68       
69        return []
70       
71   
72    def help(self, evt):
73        """
74        Show a general help dialog.
75       
76        :TODO: replace the text with a nice image
77            provide more hint on the SLD calculator
78        """
79        from help_panel import  HelpWindow
80        frame = HelpWindow(None, -1)   
81        frame.Show(True)
82        #evt.Skip()
83       
84    def get_context_menu(self, graph=None):
85        """
86        This method is optional.
87   
88        When the context menu of a plot is rendered, the
89        get_context_menu method will be called to give you a
90        chance to add a menu item to the context menu.
91       
92        A ref to a Graph object is passed so that you can
93        investigate the plot content and decide whether you
94        need to add items to the context menu. 
95       
96        This method returns a list of menu items.
97        Each item is itself a list defining the text to
98        appear in the menu, a tool-tip help text, and a
99        call-back method.
100           
101            @param graph: the Graph object to which we attach the context menu
102            @return: a list of menu items with call-back function
103        """
104        return []   
105   
106    def get_perspective(self):
107        """
108        Get the list of panel names for this perspective
109        """
110        return self.perspective
111       
112   
113    def get_tools(self):
114        """
115        Returns a set of menu entries for tools
116        """
117        kiessig_help = "This tool is to approximatly compute the "
118        kiessig_help += "thickness of a shell or the size of "
119        kiessig_help += "particles \n from the width of a Kiessig fringe."
120        sld_help = "Provides computation related to Scattering Length Density"
121        slit_length_help = "Provides computation related to Slit Length Density"
122        #data_editor_help = "Meta Data Editor"
123        return [("SLD Calculator", sld_help, self.on_calculate_sld),
124                ("Slit Size Calculator", slit_length_help,
125                        self.on_calculate_slit_size),
126                ("Kiessig Thickness Calculator", 
127                        kiessig_help, self.on_calculate_kiessig),
128                          ("SANS Resolution Estimator", 
129                        kiessig_help, self.on_calculate_resoltuion)]#,
130                #("Data Editor", data_editor_help, self.on_edit_data)]
131             
132    def on_edit_data(self, event):
133        """
134        Edit meta data
135        """
136        from data_editor import DataEditorWindow
137        frame = DataEditorWindow(parent=self.parent, data=[],
138                                  title="Data Editor")
139        frame.Show(True)
140        event.Skip()
141
142    def on_calculate_kiessig(self, event):
143        """
144        Compute the Kiessig thickness
145        """
146        from kiessig_calculator_panel import KiessigWindow
147        frame = KiessigWindow()
148        frame.Show(True) 
149   
150    def on_calculate_sld(self, event):
151        """
152        Compute the scattering length density of molecula
153        """
154        from sld_panel import SldWindow
155        frame = SldWindow(base=self.parent)
156        frame.Show(True) 
157       
158    def on_calculate_slit_size(self, event):
159        """
160        Compute the slit size a given data
161        """
162        from slit_length_calculator_panel import SlitLengthCalculatorWindow
163        frame = SlitLengthCalculatorWindow(parent=self.parent)   
164        frame.Show(True)
165       
166    def on_calculate_resoltuion(self, event):
167        """
168        Estimate the instrumental resolution
169        """
170        from resolution_calculator_panel import ResolutionWindow
171        frame = ResolutionWindow(parent=self.parent)
172        frame.Show(True) 
173 
174    def on_perspective(self, event):
175        """
176        Call back function for the perspective menu item.
177        We notify the parent window that the perspective
178        has changed.
179       
180        :param event: menu event
181       
182        """
183        self.parent.set_perspective(self.perspective)
184        event.Skip()
185       
186    def post_init(self):
187        """
188        Post initialization call back to close the loose ends
189        """
190        pass
191   
192 
193   
Note: See TracBrowser for help on using the repository browser.