source: sasview/calculatorview/perspectives/calculator/calculator.py @ 6137b150

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

disable data editor

  • Property mode set to 100644
File size: 5.2 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        sld_help = "Provides computation related to Scattering Length Density"
115        slit_length_help = "Provides computation related to Slit Length Density"
116        data_editor_help = "Meta Data Editor"
117        return [("SLD Calculator", sld_help, self.on_calculate_sld),
118                ("Slit Size Calculator", slit_length_help,
119                                self.on_calculate_slit_size)]#,
120                #("Data Editor", data_editor_help, self.on_edit_data)]
121             
122    def on_edit_data(self, event):
123        """
124        Edit meta data
125        """
126        from data_editor import DataEditorWindow
127        frame = DataEditorWindow(parent=self.parent, data=[], title="Data Editor")
128        frame.Show(True)
129       
130    def on_calculate_sld(self, event):
131        """
132        Compute the scattering length density of molecula
133        """
134        from sld_panel import SldWindow
135        frame = SldWindow(base=self.parent)
136        frame.Show(True) 
137   
138    def on_calculate_slit_size(self, event):
139        """
140        Compute the slit size a given data
141        """
142        from slit_length_calculator_panel import SlitLengthCalculatorWindow
143        frame = SlitLengthCalculatorWindow(parent=self.parent)   
144        frame.Show(True)
145       
146    def on_perspective(self, event):
147        """
148        Call back function for the perspective menu item.
149        We notify the parent window that the perspective
150        has changed.
151       
152        :param event: menu event
153       
154        """
155        self.parent.set_perspective(self.perspective)
156       
157   
158    def post_init(self):
159        """
160        Post initialization call back to close the loose ends
161        """
162        pass
163   
164 
165   
Note: See TracBrowser for help on using the repository browser.