source: sasview/calculatorview/perspectives/calculator/calculator.py @ 74b1770

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

added kiessig fringe calculator and fixed slit length by ½ as our definition of slit length

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