Ignore:
Timestamp:
Aug 12, 2016 4:58:10 AM (8 years ago)
Author:
lewis
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
32c5983
Parents:
a47d0c8
Message:

Implement context menu for corfunc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/corfunc/corfunc.py

    rda19985 r1925a8e  
    4949 
    5050        return [self.corfunc_panel] 
     51 
     52    def get_context_menu(self, plotpanel=None): 
     53        """ 
     54        Get the context menu items available for Corfunc. 
     55 
     56        :param plotpanel: A Plotter1D panel 
     57 
     58        :return: a list of menu items with call-back function 
     59 
     60        :note: if Data1D was generated from Theory1D 
     61                the fitting option is not allowed 
     62        """ 
     63        graph = plotpanel.graph 
     64        if graph.selected_plottable not in plotpanel.plots: 
     65            return [] 
     66        data = plotpanel.plots[graph.selected_plottable] 
     67        if data.id == IQ_DATA_LABEL or data.id == IQ_EXTRAPOLATED_DATA_LABEL or data.id == TRANSFORM_LABEL: 
     68            return [] 
     69        item = plotpanel.plots[graph.selected_plottable] 
     70        if item.__class__.__name__ is "Data2D": 
     71            return [] 
     72        elif item.__class__.__name__ is "Data1D": 
     73            return [["Select data in corfunc", 
     74                "Send this data to the correlation function perspective", 
     75                self._on_select_data]] 
     76 
     77 
    5178 
    5279    def set_state(self, state=None, datainfo=None): 
     
    163190        wx.PostEvent(self.parent, 
    164191            NewPlotEvent(action='clear', group_id=GROUP_ID_IQ_DATA)) 
     192 
     193    def _on_select_data(self, event): 
     194        panel = event.GetEventObject() 
     195        if not panel.graph.selected_plottable in panel.plots: 
     196            return 
     197        data = panel.plots[panel.graph.selected_plottable] 
     198        print "Data id is: {}".format(data.id) 
     199        self.set_data([data]) 
Note: See TracChangeset for help on using the changeset viewer.