Ignore:
Timestamp:
Mar 5, 2015 2:49:03 PM (9 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:
7d56795
Parents:
824e488
Message:

pylint fixes

File:
1 edited

Legend:

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

    r79492222 rb5de88e  
    33""" 
    44################################################################################ 
    5 #This software was developed by the University of Tennessee as part of the 
    6 #Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    7 #project funded by the US National Science Foundation.  
     5# This software was developed by the University of Tennessee as part of the 
     6# Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
     7# project funded by the US National Science Foundation. 
    88# 
    9 #If you use DANSE applications to do scientific research that leads to  
    10 #publication, we ask that you acknowledge the use of the software with the  
    11 #following sentence: 
     9# If you use DANSE applications to do scientific research that leads to 
     10# publication, we ask that you acknowledge the use of the software with the 
     11# following sentence: 
    1212# 
    13 #This work benefited from DANSE software developed under NSF award DMR-0520547.  
     13# This work benefited from DANSE software developed under NSF award DMR-0520547. 
    1414# 
    15 #copyright 2008, University of Tennessee 
     15# copyright 2008, University of Tennessee 
    1616################################################################################ 
    1717 
    1818 
    19 ##Todo: cleaning up, improving the maskplotpanel initialization, and testing. 
     19# #Todo: cleaning up, improving the maskplotpanel initialization, and testing. 
    2020import wx 
    2121import sys 
     
    3939_STATICBOX_WIDTH = 380 
    4040 
    41 #SLD panel size  
     41# SLD panel size 
    4242if sys.platform.count("win32") > 0: 
    4343    PANEL_SIZE = 350 
     
    4646    PANEL_SIZE = 300 
    4747    FONT_VARIANT = 1 
    48      
     48 
    4949from sas.data_util.calcthread import CalcThread 
    5050 
     
    5454    """ 
    5555    def __init__(self, 
    56                  id = -1, 
    57                  panel = None, 
    58                  image = None, 
    59                  completefn = None, 
    60                  updatefn   = None, 
    61                  elapsed = 0, 
    62                  yieldtime  = 0.01, 
    63                  worktime   = 0.01 
     56                 id=-1, 
     57                 panel=None, 
     58                 image=None, 
     59                 completefn=None, 
     60                 updatefn=None, 
     61                 elapsed=0, 
     62                 yieldtime=0.01, 
     63                 worktime=0.01 
    6464                 ): 
    6565        """ 
     
    7070                 worktime) 
    7171        self.starttime = 0 
    72         self.id = id  
     72        self.id = id 
    7373        self.panel = panel 
    7474        self.image = image 
    75          
    76          
     75 
     76 
    7777    def compute(self): 
    7878        """ 
     
    8080        """ 
    8181        elapsed = time.time() - self.starttime 
    82         
     82 
    8383        self.complete(panel=self.panel, image=self.image, elapsed=elapsed) 
    84          
    85          
     84 
     85 
    8686class MaskPanel(wx.Dialog): 
    8787    """ 
    8888    Provides the Mask Editor GUI. 
    8989    """ 
    90     ## Internal nickname for the window, used by the AUI manager 
     90    # # Internal nickname for the window, used by the AUI manager 
    9191    window_name = "Mask Editor" 
    92     ## Name to appear on the window title bar 
     92    # # Name to appear on the window title bar 
    9393    window_caption = "Mask Editor" 
    94     ## Flag to tell the AUI manager to put this panel in the center pane 
     94    # # Flag to tell the AUI manager to put this panel in the center pane 
    9595    CENTER_PANE = True 
    96     def __init__(self, parent=None, base=None,  
     96    def __init__(self, parent=None, base=None, 
    9797                 data=None, id=-1, *args, **kwds): 
    9898        kwds["style"] = wx.DEFAULT_DIALOG_STYLE 
    99         kwds["size"] = wx.Size(_STATICBOX_WIDTH*0.8, PANEL_SIZE)  
    100         wx.Dialog.__init__(self, parent, id=id,  *args, **kwds) 
    101          
     99        kwds["size"] = wx.Size(_STATICBOX_WIDTH * 0.8, PANEL_SIZE) 
     100        wx.Dialog.__init__(self, parent, id=id, *args, **kwds) 
     101 
    102102        if data != None: 
    103             #Font size  
     103            # Font size 
    104104            kwds = [] 
    105105            self.SetWindowVariant(variant=FONT_VARIANT) 
     
    108108            self.data = data 
    109109            self.str = self.data.__str__() 
    110             ## mask for 2D 
     110            # # mask for 2D 
    111111            self.mask = data.mask 
    112112            self.default_mask = copy.deepcopy(data.mask) 
    113             ## masked data from GUI 
     113            # # masked data from GUI 
    114114            self.slicer_mask = None 
    115115            self.slicer = None 
    116116            self.slicer_z = 5 
    117117            self.data.interactive = True 
    118             ## when 2 data have the same id override the 1 st plotted 
     118            # # when 2 data have the same id override the 1 st plotted 
    119119            self.name = self.data.name 
    120120            # Panel for 2D plot 
     
    122122                                           style=wx.TRANSPARENT_WINDOW) 
    123123            self.cmap = DEFAULT_CMAP 
    124             ## Create Artist and bind it 
     124            # # Create Artist and bind it 
    125125            self.subplot = self.plotpanel.subplot 
    126126            self.connect = BindArtist(self.subplot.figure) 
     
    128128            self.newplot = Data2D(image=self.data.data) 
    129129            self.newplot.setValues(self.data) 
    130             self.plotpanel.add_image(self.newplot)  
     130            self.plotpanel.add_image(self.newplot) 
    131131            self._update_mask(self.mask) 
    132132            self.Centre() 
     
    134134            # bind evt_close to _draw in fitpage 
    135135            self.Bind(wx.EVT_CLOSE, self.OnClose) 
    136              
     136 
    137137    def ShowMessage(self, msg=''): 
    138138        """ 
     
    143143        mssg += msg 
    144144        wx.MessageBox(mssg, 'Error', wx.OK | wx.ICON_ERROR) 
    145      
     145 
    146146    def _setup_layout(self): 
    147147        """ 
     
    149149        """ 
    150150        note = "Note: This masking applies\n     only to %s." % self.data.name 
    151         note_txt = wx.StaticText(self, -1, note)  
     151        note_txt = wx.StaticText(self, -1, note) 
    152152        note_txt.SetForegroundColour(wx.RED) 
    153153        shape = "Select a Shape for Masking:" 
     
    155155        sizer = wx.GridBagSizer(10, 10) 
    156156        #---------inputs---------------- 
    157         shape_txt = wx.StaticText(self, -1, shape)   
    158         sizer.Add(shape_txt, (1, 1), flag=wx.TOP|wx.LEFT|wx.BOTTOM, border=5) 
     157        shape_txt = wx.StaticText(self, -1, shape) 
     158        sizer.Add(shape_txt, (1, 1), flag=wx.TOP | wx.LEFT | wx.BOTTOM, border=5) 
    159159        self.innersector_rb = wx.RadioButton(self, -1, "Double Wings") 
    160160        self.Bind(wx.EVT_RADIOBUTTON, self.onInnerSectorMask, 
    161161                  id=self.innersector_rb.GetId()) 
    162         sizer.Add(self.innersector_rb, (2, 1),  
    163                   flag=wx.RIGHT|wx.BOTTOM, border=5) 
     162        sizer.Add(self.innersector_rb, (2, 1), 
     163                  flag=wx.RIGHT | wx.BOTTOM, border=5) 
    164164        self.innercircle_rb = wx.RadioButton(self, -1, "Circular Disk") 
    165165        self.Bind(wx.EVT_RADIOBUTTON, self.onInnerRingMask, 
    166166                  id=self.innercircle_rb.GetId()) 
    167167        sizer.Add(self.innercircle_rb, (3, 1), 
    168                    flag=wx.RIGHT|wx.BOTTOM, border=5) 
    169          
     168                   flag=wx.RIGHT | wx.BOTTOM, border=5) 
     169 
    170170        self.innerbox_rb = wx.RadioButton(self, -1, "Rectangular Disk") 
    171171        self.Bind(wx.EVT_RADIOBUTTON, self.onInnerBoxMask, 
    172172                  id=self.innerbox_rb.GetId()) 
    173         sizer.Add(self.innerbox_rb, (4, 1), flag=wx.RIGHT|wx.BOTTOM, border=5) 
     173        sizer.Add(self.innerbox_rb, (4, 1), flag=wx.RIGHT | wx.BOTTOM, border=5) 
    174174 
    175175        self.outersector_rb = wx.RadioButton(self, -1, "Double Wing Window") 
    176         self.Bind(wx.EVT_RADIOBUTTON, self.onOuterSectorMask,  
     176        self.Bind(wx.EVT_RADIOBUTTON, self.onOuterSectorMask, 
    177177                  id=self.outersector_rb.GetId()) 
    178178        sizer.Add(self.outersector_rb, (5, 1), 
    179                   flag=wx.RIGHT|wx.BOTTOM, border=5) 
    180          
    181         #outersector_y_txt = wx.StaticText(self, -1, 'Outer Sector') 
     179                  flag=wx.RIGHT | wx.BOTTOM, border=5) 
     180 
     181        # outersector_y_txt = wx.StaticText(self, -1, 'Outer Sector') 
    182182        self.outercircle_rb = wx.RadioButton(self, -1, "Circular Window") 
    183183        self.Bind(wx.EVT_RADIOBUTTON, self.onOuterRingMask, 
    184184                  id=self.outercircle_rb.GetId()) 
    185         sizer.Add(self.outercircle_rb, (6, 1),  
    186                   flag=wx.RIGHT|wx.BOTTOM, border=5) 
    187         #outerbox_txt = wx.StaticText(self, -1, 'Outer Box') 
     185        sizer.Add(self.outercircle_rb, (6, 1), 
     186                  flag=wx.RIGHT | wx.BOTTOM, border=5) 
     187        # outerbox_txt = wx.StaticText(self, -1, 'Outer Box') 
    188188        self.outerbox_rb = wx.RadioButton(self, -1, "Rectangular Window") 
    189         self.Bind(wx.EVT_RADIOBUTTON, self.onOuterBoxMask,  
     189        self.Bind(wx.EVT_RADIOBUTTON, self.onOuterBoxMask, 
    190190                  id=self.outerbox_rb.GetId()) 
    191         sizer.Add(self.outerbox_rb, (7, 1), flag=wx.RIGHT|wx.BOTTOM, border=5) 
    192         sizer.Add(note_txt, (8, 1), flag=wx.RIGHT|wx.BOTTOM, border=5) 
     191        sizer.Add(self.outerbox_rb, (7, 1), flag=wx.RIGHT | wx.BOTTOM, border=5) 
     192        sizer.Add(note_txt, (8, 1), flag=wx.RIGHT | wx.BOTTOM, border=5) 
    193193        self.innercircle_rb.SetValue(False) 
    194         self.outercircle_rb.SetValue(False)         
     194        self.outercircle_rb.SetValue(False) 
    195195        self.innerbox_rb.SetValue(False) 
    196196        self.outerbox_rb.SetValue(False) 
    197197        self.innersector_rb.SetValue(False) 
    198198        self.outersector_rb.SetValue(False) 
    199         sizer.Add(self.plotpanel, (0, 2), (13, 13),  
    200                   wx.EXPAND|wx.LEFT|wx.RIGHT, 15) 
     199        sizer.Add(self.plotpanel, (0, 2), (13, 13), 
     200                  wx.EXPAND | wx.LEFT | wx.RIGHT, 15) 
    201201 
    202202        #-----Buttons------------1 
     
    204204        button_add = wx.Button(self, id_button, "Add") 
    205205        button_add.SetToolTipString("Add the mask drawn.") 
    206         button_add.Bind(wx.EVT_BUTTON, self.onAddMask, id=button_add.GetId())  
     206        button_add.Bind(wx.EVT_BUTTON, self.onAddMask, id=button_add.GetId()) 
    207207        sizer.Add(button_add, (13, 7)) 
    208208        id_button = wx.NewId() 
     
    210210        button_erase.SetToolTipString("Erase the mask drawn.") 
    211211        button_erase.Bind(wx.EVT_BUTTON, self.onEraseMask, 
    212                           id=button_erase.GetId())  
     212                          id=button_erase.GetId()) 
    213213        sizer.Add(button_erase, (13, 8)) 
    214214        id_button = wx.NewId() 
     
    216216        button_reset.SetToolTipString("Reset the mask.") 
    217217        button_reset.Bind(wx.EVT_BUTTON, self.onResetMask, 
    218                           id=button_reset.GetId())  
    219         sizer.Add(button_reset, (13, 9), flag=wx.RIGHT|wx.BOTTOM, border=15) 
     218                          id=button_reset.GetId()) 
     219        sizer.Add(button_reset, (13, 9), flag=wx.RIGHT | wx.BOTTOM, border=15) 
    220220        id_button = wx.NewId() 
    221221        button_reset = wx.Button(self, id_button, "Clear") 
    222222        button_reset.SetToolTipString("Clear all mask.") 
    223223        button_reset.Bind(wx.EVT_BUTTON, self.onClearMask, 
    224                           id=button_reset.GetId())  
    225         sizer.Add(button_reset, (13, 10), flag=wx.RIGHT|wx.BOTTOM, border=15) 
     224                          id=button_reset.GetId()) 
     225        sizer.Add(button_reset, (13, 10), flag=wx.RIGHT | wx.BOTTOM, border=15) 
    226226        sizer.AddGrowableCol(3) 
    227227        sizer.AddGrowableRow(2) 
     
    234234        Call Draw Box Slicer and get mask inside of the box 
    235235        """ 
    236         #get ready for next evt 
    237         event.Skip()         
    238         #from boxMask import BoxMask 
     236        # get ready for next evt 
     237        event.Skip() 
     238        # from boxMask import BoxMask 
    239239        if event != None: 
    240             self.onClearSlicer(event)          
     240            self.onClearSlicer(event) 
    241241        self.slicer_z += 1 
    242         self.slicer =  BoxMask(self, self.subplot, 
     242        self.slicer = BoxMask(self, self.subplot, 
    243243                               zorder=self.slicer_z, side=True) 
    244244        self.subplot.set_ylim(self.data.ymin, self.data.ymax) 
     
    246246        self.update() 
    247247        self.slicer_mask = self.slicer.update() 
    248          
     248 
    249249    def onOuterBoxMask(self, event=None): 
    250250        """ 
    251251        Call Draw Box Slicer and get mask outside of the box 
    252252        """ 
    253         event.Skip()         
    254         #from boxMask import BoxMask 
     253        event.Skip() 
     254        # from boxMask import BoxMask 
    255255        if event != None: 
    256             self.onClearSlicer(event)       
     256            self.onClearSlicer(event) 
    257257        self.slicer_z += 1 
    258         self.slicer =  BoxMask(self, self.subplot, 
     258        self.slicer = BoxMask(self, self.subplot, 
    259259                               zorder=self.slicer_z, side=False) 
    260260        self.subplot.set_ylim(self.data.ymin, self.data.ymax) 
     
    272272            self.onClearSlicer(event) 
    273273        self.slicer_z += 1 
    274         self.slicer =  SectorMask(self, self.subplot, 
     274        self.slicer = SectorMask(self, self.subplot, 
    275275                                  zorder=self.slicer_z, side=True) 
    276276        self.subplot.set_ylim(self.data.ymin, self.data.ymax) 
    277         self.subplot.set_xlim(self.data.xmin, self.data.xmax)    
     277        self.subplot.set_xlim(self.data.xmin, self.data.xmax) 
    278278        self.update() 
    279         self.slicer_mask = self.slicer.update()  
     279        self.slicer_mask = self.slicer.update() 
    280280 
    281281    def onOuterSectorMask(self, event=None): 
     
    288288            self.onClearSlicer(event) 
    289289        self.slicer_z += 1 
    290         self.slicer =  SectorMask(self, self.subplot, 
     290        self.slicer = SectorMask(self, self.subplot, 
    291291                                  zorder=self.slicer_z, side=False) 
    292292        self.subplot.set_ylim(self.data.ymin, self.data.ymax) 
    293         self.subplot.set_xlim(self.data.xmin, self.data.xmax)     
    294         self.update()      
    295         self.slicer_mask = self.slicer.update()    
     293        self.subplot.set_xlim(self.data.xmin, self.data.xmax) 
     294        self.update() 
     295        self.slicer_mask = self.slicer.update() 
    296296 
    297297    def onInnerRingMask(self, event=None): 
     
    307307                                   zorder=self.slicer_z, side=True) 
    308308        self.subplot.set_ylim(self.data.ymin, self.data.ymax) 
    309         self.subplot.set_xlim(self.data.xmin, self.data.xmax)    
     309        self.subplot.set_xlim(self.data.xmin, self.data.xmax) 
    310310        self.update() 
    311         self.slicer_mask = self.slicer.update()  
     311        self.slicer_mask = self.slicer.update() 
    312312 
    313313    def onOuterRingMask(self, event=None): 
     
    321321        self.slicer_z += 1 
    322322        self.slicer = CircularMask(self, self.subplot, 
    323                                    zorder=self.slicer_z, side=False)    
     323                                   zorder=self.slicer_z, side=False) 
    324324        self.subplot.set_ylim(self.data.ymin, self.data.ymax) 
    325325        self.subplot.set_xlim(self.data.xmin, self.data.xmax) 
    326326        self.update() 
    327         self.slicer_mask = self.slicer.update()      
    328          
     327        self.slicer_mask = self.slicer.update() 
     328 
    329329    def onAddMask(self, event): 
    330330        """ 
    331         Add new mask to old mask  
     331        Add new mask to old mask 
    332332        """ 
    333333        if not self.slicer == None: 
     
    337337            data.mask = self.data.mask & self.slicer_mask 
    338338            self._check_display_mask(data.mask, event) 
    339              
     339 
    340340    def _check_display_mask(self, mask, event): 
    341341        """ 
    342342        check if the mask valid and update the plot 
    343          
     343 
    344344        :param mask: mask data 
    345345        """ 
    346         ## Redraw the current image 
     346        # # Redraw the current image 
    347347        self._update_mask(mask) 
    348348 
     
    356356            mask[self.slicer_mask == False] = True 
    357357            self._check_display_mask(mask, event) 
    358              
     358 
    359359    def onResetMask(self, event): 
    360360        """ 
    361         Reset mask to the original mask  
    362         """         
     361        Reset mask to the original mask 
     362        """ 
    363363        self.slicer_z += 1 
    364         self.slicer =  BoxMask(self, self.subplot,  
     364        self.slicer = BoxMask(self, self.subplot, 
    365365                               zorder=self.slicer_z, side=True) 
    366366        self.subplot.set_ylim(self.data.ymin, self.data.ymax) 
    367         self.subplot.set_xlim(self.data.xmin, self.data.xmax)    
     367        self.subplot.set_xlim(self.data.xmin, self.data.xmax) 
    368368        mask = copy.deepcopy(self.default_mask) 
    369369        self.data.mask = mask 
    370370        # update mask plot 
    371371        self._check_display_mask(mask, event) 
    372          
     372 
    373373    def onClearMask(self, event): 
    374374        """ 
    375375        Clear mask 
    376         """             
     376        """ 
    377377        self.slicer_z += 1 
    378         self.slicer =  BoxMask(self, self.subplot, 
     378        self.slicer = BoxMask(self, self.subplot, 
    379379                               zorder=self.slicer_z, side=True) 
    380380        self.subplot.set_ylim(self.data.ymin, self.data.ymax) 
    381         self.subplot.set_xlim(self.data.xmin, self.data.xmax)    
    382         #mask = copy.deepcopy(self.default_mask) 
     381        self.subplot.set_xlim(self.data.xmin, self.data.xmax) 
     382        # mask = copy.deepcopy(self.default_mask) 
    383383        mask = numpy.ones(len(self.data.mask), dtype=bool) 
    384384        self.data.mask = mask 
    385385        # update mask plot 
    386386        self._check_display_mask(mask, event) 
    387          
     387 
    388388    def onClearSlicer(self, event): 
    389389        """ 
     
    397397    def update(self, draw=True): 
    398398        """ 
    399         Respond to changes in the model by recalculating the  
     399        Respond to changes in the model by recalculating the 
    400400        profiles and resetting the widgets. 
    401401        """ 
    402402        self.plotpanel.draw() 
    403          
     403 
    404404    def _set_mask(self, mask): 
    405405        """ 
     
    407407        """ 
    408408        self.data.mask = mask 
    409          
     409 
    410410    def set_plot_unfocus(self): 
    411411        """ 
     
    413413        """ 
    414414        pass 
    415      
     415 
    416416    def _update_mask(self, mask): 
    417417        """ 
    418418        Respond to changes in masking 
    419         """  
     419        """ 
    420420        # the case of liitle numbers of True points 
    421421        if (len(mask[mask]) < 10 and self.data != None): 
     
    430430        # temp_data default is None 
    431431        # This method is to distinguish between masked point and data point = 0. 
    432         temp_mask = temp_mask/temp_mask 
     432        temp_mask = temp_mask / temp_mask 
    433433        temp_mask[mask] = temp_data.data[mask] 
    434         # set temp_data value for self.mask==True, else still None  
    435         #temp_mask[mask] = temp_data[mask] 
    436          
    437         #TODO: refactor this horrible logic  
     434        # set temp_data value for self.mask==True, else still None 
     435        # temp_mask[mask] = temp_data[mask] 
     436 
     437        # TODO: refactor this horrible logic 
    438438        temp_data.data[mask == False] = temp_mask[mask == False] 
    439439        self.plotpanel.clear() 
     
    444444        event = self._getEmptySlicerEvent() 
    445445        wx.PostEvent(self, event) 
    446         
    447         ##use this method 
    448         #set zmax and zmin to plot: Fix it w/ data. 
     446 
     447        # #use this method 
     448        # set zmax and zmin to plot: Fix it w/ data. 
    449449        if self.plotpanel.scale == 'log_{10}': 
    450             zmax = math.log10(max(self.data.data[self.data.data>0])) 
    451             zmin = math.log10(min(self.data.data[self.data.data>0])) 
     450            zmax = math.log10(max(self.data.data[self.data.data > 0])) 
     451            zmin = math.log10(min(self.data.data[self.data.data > 0])) 
    452452        else: 
    453             zmax = max(self.data.data[self.data.data>0]) 
    454             zmin = min(self.data.data[self.data.data>0]) 
    455         #plot     
     453            zmax = max(self.data.data[self.data.data > 0]) 
     454            zmin = min(self.data.data[self.data.data > 0]) 
     455        # plot 
    456456        plot = self.plotpanel.image(data=temp_mask, 
    457457                       qx_data=self.data.qx_data, 
     
    470470        self.plotpanel.render() 
    471471        self.plotpanel.subplot.figure.canvas.draw_idle() 
    472          
     472 
    473473    def _getEmptySlicerEvent(self): 
    474474        """ 
    475         create an empty slicervent  
     475        create an empty slicervent 
    476476        """ 
    477477        self.innerbox_rb.SetValue(False) 
     
    483483        return SlicerEvent(type=None, 
    484484                           params=None, 
    485                            obj_class=None)  
    486               
     485                           obj_class=None) 
     486 
    487487    def _draw_model(self, event): 
    488488        """ 
     
    490490        """ 
    491491        pass 
    492          
     492 
    493493    def freeze_axes(self): 
    494494        """ 
     
    496496        """ 
    497497        self.plotpanel.axes_frozen = True 
    498          
     498 
    499499    def thaw_axes(self): 
    500500        """ 
    501501        thaw axes 
    502502        """ 
    503         self.plotpanel.axes_frozen = False        
    504           
     503        self.plotpanel.axes_frozen = False 
     504 
    505505    def onMouseMotion(self, event): 
    506506        """ 
     
    508508        """ 
    509509        pass 
    510      
     510 
    511511    def onWheel(self, event): 
    512512        """ 
    513513        on wheel event 
    514514        """ 
    515         pass   
    516      
     515        pass 
     516 
    517517    def OnClose(self, event): 
    518518        """ 
     
    524524            # when called by data panel 
    525525            event.Skip() 
    526             pass    
     526            pass 
    527527 
    528528class FloatPanel(wx.Dialog): 
     
    530530    Provides the Mask Editor GUI. 
    531531    """ 
    532     ## Internal nickname for the window, used by the AUI manager 
     532    # # Internal nickname for the window, used by the AUI manager 
    533533    window_name = "Plot" 
    534     ## Name to appear on the window title bar 
     534    # # Name to appear on the window title bar 
    535535    window_caption = "Plot" 
    536     ## Flag to tell the AUI manager to put this panel in the center pane 
     536    # # Flag to tell the AUI manager to put this panel in the center pane 
    537537    CENTER_PANE = False 
    538538    ID = wx.NewId() 
    539     def __init__(self, parent=None, base=None,  
     539    def __init__(self, parent=None, base=None, 
    540540                 data=None, dimension=1, id=ID, *args, **kwds): 
    541541        kwds["style"] = wx.DEFAULT_DIALOG_STYLE 
    542         kwds["size"] = wx.Size(PANEL_SIZE*1.5, PANEL_SIZE*1.5)  
    543         wx.Dialog.__init__(self, parent, id=id,  *args, **kwds) 
    544          
     542        kwds["size"] = wx.Size(PANEL_SIZE * 1.5, PANEL_SIZE * 1.5) 
     543        wx.Dialog.__init__(self, parent, id=id, *args, **kwds) 
     544 
    545545        if data != None: 
    546             #Font size  
     546            # Font size 
    547547            kwds = [] 
    548548            self.SetWindowVariant(variant=FONT_VARIANT) 
     
    551551            self.data = data 
    552552            self.str = self.data.__str__() 
    553             ## when 2 data have the same id override the 1 st plotted 
     553            # # when 2 data have the same id override the 1 st plotted 
    554554            self.name = self.data.name 
    555555            self.dimension = dimension 
     
    560560            self.plotpanel.prevXtrans = "x" 
    561561            self.plotpanel.prevYtrans = "y" 
    562              
     562 
    563563            self.cmap = DEFAULT_CMAP 
    564             ## Create Artist and bind it 
     564            # # Create Artist and bind it 
    565565            self.subplot = self.plotpanel.subplot 
    566566            self._setup_layout() 
    567567            if self.dimension == 1: 
    568                 self.newplot = Data1D(x=data.x, y=data.y,  
     568                self.newplot = Data1D(x=data.x, y=data.y, 
    569569                                      dx=data.dx, dy=data.dy) 
    570570                self.newplot.name = data.name 
    571             else:     
     571            else: 
    572572                self.newplot = Data2D(image=self.data.data) 
    573573                self.newplot.setValues(self.data) 
    574574                    # Compute and get the image plot 
    575575            self.get_plot() 
    576             #self.plotpanel.add_image(self.newplot)  
     576            # self.plotpanel.add_image(self.newplot) 
    577577            self.Centre() 
    578578            self.Layout() 
    579      
     579 
    580580    def get_plot(self): 
    581581        """ 
    582582        Get Plot panel 
    583583        """ 
    584         cal_plot = CalcPlot(panel=self.plotpanel,  
    585                                    image=self.newplot,  
     584        cal_plot = CalcPlot(panel=self.plotpanel, 
     585                                   image=self.newplot, 
    586586                                   completefn=self.complete) 
    587587        cal_plot.queue() 
    588      
     588 
    589589    def complete(self, panel, image, elapsed=None): 
    590590        """ 
    591591        Plot image 
    592          
     592 
    593593        :param image: newplot [plotpanel] 
    594594        """ 
    595         wx.CallAfter(panel.add_image, image)  
    596          
     595        wx.CallAfter(panel.add_image, image) 
     596 
    597597    def _setup_layout(self): 
    598598        """ 
     
    605605            if len(self.data.data) > 3600: 
    606606                note += "Rotation disabled for pixels > 60x60." 
    607             note_txt = wx.StaticText(self, -1, note)  
     607            note_txt = wx.StaticText(self, -1, note) 
    608608            note_txt.SetForegroundColour(wx.RED) 
    609             sizer.Add(note_txt, (0, 2), flag=wx.RIGHT|wx.TOP, border=5) 
    610          
    611         sizer.Add(self.plotpanel, (1, 0), (9, 9),  
    612                   wx.EXPAND|wx.ALL, 15) 
     609            sizer.Add(note_txt, (0, 2), flag=wx.RIGHT | wx.TOP, border=5) 
     610 
     611        sizer.Add(self.plotpanel, (1, 0), (9, 9), 
     612                  wx.EXPAND | wx.ALL, 15) 
    613613 
    614614        sizer.AddGrowableCol(3) 
    615615        sizer.AddGrowableRow(2) 
    616          
     616 
    617617        self.SetSizerAndFit(sizer) 
    618618        self.Centre() 
    619619        self.Show(True) 
    620          
     620 
    621621    def set_plot_unfocus(self): 
    622622        """ 
     
    624624        """ 
    625625        pass 
    626      
     626 
    627627 
    628628    def _draw_model(self, event): 
     
    631631        """ 
    632632        pass 
    633          
     633 
    634634    def freeze_axes(self): 
    635635        """ 
     
    637637        """ 
    638638        self.plotpanel.axes_frozen = True 
    639          
     639 
    640640    def thaw_axes(self): 
    641641        """ 
    642642        thaw axes 
    643643        """ 
    644         self.plotpanel.axes_frozen = False        
    645      
     644        self.plotpanel.axes_frozen = False 
     645 
    646646    def OnClose(self, event): 
    647647        """ 
     
    655655            pass 
    656656 
    657                  
     657 
    658658class Maskplotpanel(PlotPanel): 
    659659    """ 
    660660    PlotPanel for Quick plot and masking plot 
    661661    """ 
    662     def __init__(self, parent, id=-1, dimension=2, color=None,  
     662    def __init__(self, parent, id=-1, dimension=2, color=None, 
    663663                                            dpi=None, **kwargs): 
    664664        """ 
    665665        """ 
    666666        PlotPanel.__init__(self, parent, id=id, color=color, dpi=dpi, **kwargs) 
    667          
     667 
    668668        # Keep track of the parent Frame 
    669669        self.parent = parent 
    670         # Internal list of plottable names (because graph  
     670        # Internal list of plottable names (because graph 
    671671        # doesn't have a dictionary of handles for the plottables) 
    672672        self.dimension = dimension 
    673673        self.plots = {} 
    674674        self.graph = Graph() 
    675         #add axis labels 
     675        # add axis labels 
    676676        self.graph.xaxis('\\rm{x} ', '') 
    677677        self.graph.yaxis('\\rm{y} ', '') 
    678          
     678 
    679679    def add_toolbar(self): 
    680         """  
     680        """ 
    681681        Add toolbar 
    682682        """ 
    683683        # Not implemented 
    684684        pass 
    685      
     685 
    686686    def on_set_focus(self, event): 
    687687        """ 
     
    691691            pass 
    692692        else: 
    693             self.draw()    
    694           
     693            self.draw() 
     694 
    695695    def add_image(self, plot): 
    696696        """ 
     
    698698        """ 
    699699        self.plots[plot.name] = plot 
    700         #init graph 
     700        # init graph 
    701701        self.graph = Graph() 
    702         #add plot 
     702        # add plot 
    703703        self.graph.add(plot) 
    704         #add axes 
     704        # add axes 
    705705        if self.dimension == 1: 
    706706            self.xaxis_label = '\\rm{x} ' 
     
    708708            self.yaxis_label = '\\rm{y} ' 
    709709            self.yaxis_unit = '' 
    710         #draw 
     710        # draw 
    711711        # message 
    712         status_type = 'progress'  
     712        status_type = 'progress' 
    713713        msg = 'Plotting...' 
    714714        self._status_info(msg, status_type) 
    715         status_type = 'stop'            
     715        status_type = 'stop' 
    716716        self.graph.render(self) 
    717717        self.subplot.figure.canvas.resizing = False 
     
    723723        msg = 'Plotting Completed.' 
    724724        self._status_info(msg, status_type) 
    725          
     725 
    726726    def onMouseMotion(self, event): 
    727727        """ 
     
    729729        """ 
    730730        pass 
    731      
     731 
    732732    def onWheel(self, event): 
    733733        """ 
    734734        """ 
    735         pass  
    736       
     735        pass 
     736 
    737737    def onLeftDown(self, event): 
    738738        """ 
     
    740740        """ 
    741741        pass 
    742      
     742 
    743743    def onPick(self, event): 
    744744        """ 
     
    746746        """ 
    747747        pass 
    748      
     748 
    749749    def draw(self): 
    750750        """ 
     
    752752        """ 
    753753        # message 
    754         status_type = 'progress'  
     754        status_type = 'progress' 
    755755        msg = 'Plotting...' 
    756756        self._status_info(msg, status_type) 
    757         status_type = 'stop'            
    758          
     757        status_type = 'stop' 
     758 
    759759        if self.dimension == 3: 
    760760            pass 
    761761        else: 
    762             self.subplot.figure.canvas.draw_idle()  
    763          
     762            self.subplot.figure.canvas.draw_idle() 
     763 
    764764        msg = 'Plotting Completed.' 
    765765        self._status_info(msg, status_type) 
    766         
     766 
    767767    def onContextMenu(self, event): 
    768768        """ 
     
    771771        # Selective Slicer plot popup menu 
    772772        slicerpop = wx.Menu() 
    773          
     773 
    774774        id = wx.NewId() 
    775775        slicerpop.Append(id, '&Print Image', 'Print image') 
     
    779779        slicerpop.Append(id, '&Copy to Clipboard', 'Copy to the clipboard') 
    780780        wx.EVT_MENU(self, id, self.OnCopyFigureMenu) 
    781          
     781 
    782782        if self.dimension == 1: 
    783783            id = wx.NewId() 
     
    789789            slicerpop.Append(id_cm, '&Toggle Linear/Log scale') 
    790790            wx.EVT_MENU(self, id_cm, self._onToggleScale) 
    791                 
     791 
    792792        pos = event.GetPosition() 
    793793        pos = self.ScreenToClient(pos) 
    794794        self.PopupMenu(slicerpop, pos) 
    795          
    796     def _status_info(self, msg = '', type = "update"): 
     795 
     796    def _status_info(self, msg='', type="update"): 
    797797        """ 
    798798        Status msg 
     
    801801            label = "Plotting..." 
    802802            able = True 
    803         else:    
     803        else: 
    804804            label = "Wait..." 
    805805            able = False 
    806806        if self.parent.parent.parent != None: 
    807                 wx.PostEvent(self.parent.parent.parent,  
    808                              StatusEvent(status = msg, type = type )) 
     807                wx.PostEvent(self.parent.parent.parent, 
     808                             StatusEvent(status=msg, type=type)) 
    809809 
    810810class ViewerFrame(wx.Frame): 
     
    825825class ViewApp(wx.App): 
    826826    def OnInit(self): 
    827         frame = ViewerFrame(None, -1, 'testView')     
     827        frame = ViewerFrame(None, -1, 'testView') 
    828828        frame.Show(True) 
    829         #self.SetTopWindow(frame) 
    830          
     829        # self.SetTopWindow(frame) 
     830 
    831831        return True 
    832                 
    833 if __name__ == "__main__":  
     832 
     833if __name__ == "__main__": 
    834834    app = ViewApp(0) 
    835     app.MainLoop()      
     835    app.MainLoop() 
Note: See TracChangeset for help on using the changeset viewer.