source: sasview/calculatorview/perspectives/calculator/calculator.py @ 91f151a

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 91f151a was 91f151a, checked in by Gervaise Alina <gervyh@…>, 14 years ago

working on data editor

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