Ignore:
Timestamp:
Mar 5, 2015 4:37:00 PM (10 years ago)
Author:
Mathieu Doucet <doucetm@…>
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, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
b40ad40
Parents:
090e07e
Message:

pylint fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/guiframe/local_perspectives/plotting/plotting.py

    rb9dbd6b rc039589  
    55#This software was developed by the University of Tennessee as part of the 
    66#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    7 #project funded by the US National Science Foundation.  
     7#project funded by the US National Science Foundation. 
    88# 
    99#See the license text in license.txt 
     
    1616from sas.guiframe.events import EVT_NEW_PLOT 
    1717from sas.guiframe.events import EVT_PLOT_QRANGE 
    18 from sas.guiframe.events import StatusEvent  
    1918from sas.guiframe.events import DeletePlotPanelEvent 
    2019from sas.guiframe.plugin_base import PluginBase 
     
    2524DEFAULT_MENU_ITEM_ID = wx.NewId() 
    2625 
    27 IS_WIN = True     
    28 if sys.platform.count("win32")==0: 
     26IS_WIN = True 
     27if sys.platform.count("win32") == 0: 
    2928    if int(str(wx.__version__).split('.')[0]) == 2: 
    3029        if int(str(wx.__version__).split('.')[1]) < 9: 
     
    3635    Plug-in class to be instantiated by the GUI manager 
    3736    """ 
    38      
     37 
    3938    def __init__(self, standalone=False): 
    4039        PluginBase.__init__(self, name="Plotting", standalone=standalone) 
    41        
     40 
    4241        ## Plot panels 
    4342        self.plot_panels = {} 
     
    4746        self.menu = None 
    4847 
    49       
     48 
    5049    def set_panel_on_focus(self, panel): 
    5150        """ 
    5251        """ 
    5352        self._panel_on_focus = panel 
    54          
     53 
    5554    def is_always_active(self): 
    5655        """ 
    57         return True is this plugin is always active even if the user is  
     56        return True is this plugin is always active even if the user is 
    5857        switching between perspectives 
    5958        """ 
    6059        return True 
    61      
     60 
    6261    def populate_menu(self, parent): 
    6362        """ 
    6463        Create a 'Plot' menu to list the panels 
    6564        available for displaying 
    66          
     65 
    6766        :param id: next available unique ID for wx events 
    6867        :param parent: parent window 
    69          
     68 
    7069        """ 
    7170        return [] 
    72         """ 
    73         self.menu = wx.Menu() 
    74         self.menu.Append(DEFAULT_MENU_ITEM_ID, DEFAULT_MENU_ITEM_LABEL,  
    75                              "No graph available") 
    76         self.menu.FindItemByPosition(0).Enable(False) 
    77         return [(self.menu, "Show")] 
    78         """ 
    79      
     71 
    8072    def get_panels(self, parent): 
    8173        """ 
     
    8981        # We have no initial panels for this plug-in 
    9082        return [] 
    91      
    92     def _on_plot_qrange(self, event= None): 
     83 
     84    def _on_plot_qrange(self, event=None): 
    9385        """ 
    9486        On Qmin Qmax vertical line event 
     
    10395            return 
    10496        panel.on_plot_qrange(event) 
    105              
     97 
    10698    def _on_show_panel(self, event): 
    10799        """show plug-in panel""" 
    108100        pass 
    109      
     101 
    110102    def remove_plot(self, group_id, id): 
    111103        """ 
    112104        remove plot of ID = id from a panel of group ID =group_id 
    113105        """ 
    114          
     106 
    115107        if group_id in self.plot_panels.keys(): 
    116108            panel = self.plot_panels[group_id] 
    117109            panel.remove_data_by_id(id=id) 
    118              
     110 
    119111            return True 
    120112        return False 
    121          
     113 
    122114    def clear_panel(self): 
    123115        """ 
     
    129121            self.hide_panel(group_id) 
    130122        self.plot_panels = {} 
    131      
     123 
    132124    def clear_panel_by_id(self, group_id): 
    133125        """ 
     
    141133            return True 
    142134        return False 
    143              
     135 
    144136    def hide_panel(self, group_id): 
    145137        """ 
     
    148140        # Not implemeted 
    149141        return False 
    150      
     142 
    151143    def create_panel_helper(self, new_panel, data, group_id, title=None): 
    152144        """ 
     
    167159        new_panel.uid = event_id 
    168160        # Ship the plottable to its panel 
    169         wx.CallAfter(new_panel.plot_data, data)  
     161        wx.CallAfter(new_panel.plot_data, data) 
    170162        #new_panel.canvas.set_resizing(new_panel.resizing) 
    171163        self.plot_panels[new_panel.group_id] = new_panel 
    172          
    173         # Set Graph menu and help string         
    174         self.help_string = ' Graph: ' 
    175         for plot in  new_panel.plots.itervalues(): 
    176             help_string += (' ' + plot.label + ';') 
    177         #self.menu.AppendCheckItem(event_id, new_panel.window_caption,  
    178         #                          helpString) 
    179         #self.menu.Check(event_id, IS_WIN) 
    180         #wx.EVT_MENU(self.parent, event_id, self._on_check_menu) 
    181  
    182          
     164 
    183165    def create_1d_panel(self, data, group_id): 
    184166        """ 
    185167        """ 
    186         # Create a new plot panel if none was available         
     168        # Create a new plot panel if none was available 
    187169        if issubclass(data.__class__, Data1D): 
    188170            from Plotter1D import ModelPanel1D 
     
    194176            win = MDIFrame(self.parent, None, 'None', (100, 200)) 
    195177            new_panel = ModelPanel1D(win, -1, xtransform=xtransform, 
    196                      ytransform=ytransform, style=wx.RAISED_BORDER) 
     178                                     ytransform=ytransform, style=wx.RAISED_BORDER) 
    197179            win.set_panel(new_panel) 
    198180            win.Show(False) 
     
    200182            #win.Show(True) 
    201183            return  new_panel 
    202          
     184 
    203185        msg = "1D Panel of group ID %s could not be created" % str(group_id) 
    204186        raise ValueError, msg 
    205      
     187 
    206188    def create_2d_panel(self, data, group_id): 
    207189        """ 
     
    213195            win = MDIFrame(self.parent, None, 'None', (200, 150)) 
    214196            win.Show(False) 
    215             new_panel = ModelPanel2D(win, id = -1, 
    216                                 data2d=data, scale = scale,  
    217                                 style=wx.RAISED_BORDER) 
     197            new_panel = ModelPanel2D(win, id=-1, 
     198                                     data2d=data, scale=scale, 
     199                                     style=wx.RAISED_BORDER) 
    218200            win.set_panel(new_panel) 
    219201            new_panel.frame = win 
    220             #win.Show(True) 
    221202            return new_panel 
    222203        msg = "2D Panel of group ID %s could not be created" % str(group_id) 
    223204        raise ValueError, msg 
    224      
     205 
    225206    def update_panel(self, data, panel): 
    226207        """ 
     
    228209        """ 
    229210        # Check whether we already have a graph with the same units 
    230         # as the plottable we just received.  
    231         _, x_unit =  data.get_xaxis() 
    232         _, y_unit =  data.get_yaxis() 
     211        # as the plottable we just received. 
     212        _, x_unit = data.get_xaxis() 
     213        _, y_unit = data.get_yaxis() 
    233214        flag_x = (panel.graph.prop["xunit"] is not None) and \ 
    234215                    (panel.graph.prop["xunit"].strip() != "") and\ 
     
    237218                    (panel.graph.prop["yunit"].strip() != "") and\ 
    238219                    (y_unit != panel.graph.prop["yunit"]) and False 
    239         if (flag_x and flag_y): 
     220        if flag_x and flag_y: 
    240221            msg = "Cannot add %s" % str(data.name) 
    241222            msg += " to panel %s\n" % str(panel.window_caption) 
     
    253234            panel = self.plot_panels[group_id] 
    254235            uid = panel.uid 
    255             wx.PostEvent(self.parent,  
     236            wx.PostEvent(self.parent, 
    256237                         DeletePlotPanelEvent(name=panel.window_caption, 
    257                                     caption=panel.window_caption)) 
    258             #remove menu item 
    259             #self.delete_menu_item(panel.window_caption, panel.uid) 
     238                                              caption=panel.window_caption)) 
    260239            del self.plot_panels[group_id] 
    261240            if uid in self.parent.plot_panels.keys(): 
     
    265244 
    266245        return False 
    267      
     246 
    268247    def _on_plot_event(self, event): 
    269248        """ 
     
    271250        Check whether we have a panel to put in on, or create 
    272251        a new one 
    273          
     252 
    274253        :param event: EVT_NEW_PLOT event 
    275          
     254 
    276255        """ 
    277256        action_check = False 
     
    285264                    #remove data from panel 
    286265                    if action_string == 'remove': 
    287                         id = event.id 
    288                         return self.remove_plot(group_id, id) 
     266                        return self.remove_plot(group_id, event.id) 
    289267                    if action_string == 'hide': 
    290268                        return self.hide_panel(group_id) 
     
    295273                    if action_string == "clear": 
    296274                        return self.clear_panel_by_id(group_id) 
    297                      
    298         if not hasattr(event, 'plot'):     
     275 
     276        if not hasattr(event, 'plot'): 
    299277            return 
    300278        title = None 
    301279        if hasattr(event, 'title'): 
    302             title = 'Graph'#event.title       
     280            title = 'Graph'  #event.title 
    303281        data = event.plot 
    304         group_id = data.group_id     
     282        group_id = data.group_id 
    305283        if group_id in self.plot_panels.keys(): 
    306284            if action_check: 
    307285                # Check if the plot already exist. if it does, do nothing. 
    308286                if data.id in self.plot_panels[group_id].plots.keys(): 
    309                     return  
    310             #update a panel graph  
     287                    return 
     288            #update a panel graph 
    311289            panel = self.plot_panels[group_id] 
    312290            self.update_panel(data, panel) 
     
    331309                            p_plot.group_id = group_id 
    332310                            return 
    333                  
     311 
    334312                new_panel = self.create_2d_panel(data, group_id) 
    335             self.create_panel_helper(new_panel, data, group_id, title)  
     313            self.create_panel_helper(new_panel, data, group_id, title) 
    336314        return 
    337         frame.Show(True) 
Note: See TracChangeset for help on using the changeset viewer.