Changeset 824e488 in sasview


Ignore:
Timestamp:
Mar 5, 2015 2:18:47 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:
b5de88e
Parents:
b9dbd6b
Message:

pylint fixes and remove old code

Location:
src/sas
Files:
1 deleted
9 edited

Legend:

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

    r400155b r824e488  
    1 #TODO: the line slicer should listen to all 2DREFRESH events, get the data and slice it 
     1# TODO: the line slicer should listen to all 2DREFRESH events, get the data and slice it 
    22#      before pushing a new 1D data update. 
    33 
    44# 
    5 #TODO: NEED MAJOR REFACTOR 
     5# TODO: NEED MAJOR REFACTOR 
    66# 
    77 
    88import math 
    99import wx 
    10 #from copy import deepcopy  
     10# from copy import deepcopy 
    1111# Debug printout 
    1212from sas.guiframe.events import NewPlotEvent 
     
    2020    """ 
    2121    Select an annulus through a 2D plot. 
    22     This interactor is used to average 2D data  with the region  
     22    This interactor is used to average 2D data  with the region 
    2323    defined by 2 radius. 
    2424    this class is defined by 2 Ringinterators. 
    2525    """ 
    2626    def __init__(self, base, axes, color='black', zorder=3): 
    27          
     27 
    2828        _BaseInteractor.__init__(self, base, axes, color=color) 
    2929        self.markers = [] 
     
    3131        self.base = base 
    3232        self.qmax = min(math.fabs(self.base.data2D.xmax), 
    33                         math.fabs(self.base.data2D.xmin))  #must be positive 
     33                        math.fabs(self.base.data2D.xmin))  # must be positive 
    3434        self.connect = self.base.connect 
    35      
    36         ## Number of points on the plot 
     35 
     36        # # Number of points on the plot 
    3737        self.nbins = 36 
    38         #Cursor position of Rings (Left(-1) or Right(1)) 
     38        # Cursor position of Rings (Left(-1) or Right(1)) 
    3939        self.xmaxd = self.base.data2D.xmax 
    4040        self.xmind = self.base.data2D.xmin 
     
    4646        # Inner circle 
    4747        self.inner_circle = RingInteractor(self, self.base.subplot, 
    48                                             zorder=zorder, 
    49                                             r=self.qmax/2.0, sign=self.sign) 
     48                                           zorder=zorder, 
     49                                           r=self.qmax / 2.0, sign=self.sign) 
    5050        self.inner_circle.qmax = self.qmax 
    5151        self.outer_circle = RingInteractor(self, self.base.subplot, 
    52                                            zorder=zorder+1, r=self.qmax/1.8, 
     52                                           zorder=zorder + 1, r=self.qmax / 1.8, 
    5353                                           sign=self.sign) 
    5454        self.outer_circle.qmax = self.qmax * 1.2 
    5555        self.update() 
    5656        self._post_data() 
    57          
     57 
    5858        # Bind to slice parameter events 
    5959        self.base.Bind(EVT_SLICER_PARS, self._onEVT_SLICER_PARS) 
    60          
     60 
    6161    def _onEVT_SLICER_PARS(self, event): 
    6262        """ 
    6363        receive an event containing parameters values to reset the slicer 
    64          
    65         :param event: event of type SlicerParameterEvent with params as  
     64 
     65        :param event: event of type SlicerParameterEvent with params as 
    6666            attribute 
    67              
     67 
    6868        """ 
    6969        wx.PostEvent(self.base, 
     
    7777        """ 
    7878        Allow adding plot to the same panel 
    79          
     79 
    8080        :param n: the number of layer 
    81          
     81 
    8282        """ 
    8383        self.layernum = n 
    8484        self.update() 
    85          
     85 
    8686    def clear(self): 
    8787        """ 
     
    9393        self.base.connect.clearall() 
    9494        self.base.Unbind(EVT_SLICER_PARS) 
    95          
     95 
    9696    def update(self): 
    9797        """ 
     
    9999        resetting the widgets. 
    100100        """ 
    101         # Update locations         
     101        # Update locations 
    102102        self.inner_circle.update() 
    103103        self.outer_circle.update() 
    104          
     104 
    105105    def save(self, ev): 
    106106        """ 
     
    115115        """ 
    116116        Uses annulus parameters to plot averaged data into 1D data. 
    117          
    118         :param nbins: the number of points to plot  
    119          
    120         """ 
    121         #Data to average 
     117 
     118        :param nbins: the number of points to plot 
     119 
     120        """ 
     121        # Data to average 
    122122        data = self.base.data2D 
    123123        # If we have no data, just return 
    124124        if data == None: 
    125125            return 
    126          
     126 
    127127        from sas.dataloader.manipulations import Ring 
    128128        rmin = min(math.fabs(self.inner_circle.get_radius()), 
    129                   math.fabs(self.outer_circle.get_radius())) 
     129                   math.fabs(self.outer_circle.get_radius())) 
    130130        rmax = max(math.fabs(self.inner_circle.get_radius()), 
    131131                   math.fabs(self.outer_circle.get_radius())) 
    132         #if the user does not specify the numbers of points to plot  
     132        # if the user does not specify the numbers of points to plot 
    133133        # the default number will be nbins= 36 
    134134        if nbins == None: 
     
    136136        else: 
    137137            self.nbins = nbins 
    138         ## create the data1D Q average of data2D     
     138        # # create the data1D Q average of data2D 
    139139        sect = Ring(r_min=rmin, r_max=rmax, nbins=self.nbins) 
    140140        sector = sect(self.base.data2D) 
    141      
     141 
    142142        if hasattr(sector, "dxl"): 
    143143            dxl = sector.dxl 
     
    148148        else: 
    149149            dxw = None 
    150         new_plot = Data1D(x=(sector.x - math.pi) * 180/math.pi, 
     150        new_plot = Data1D(x=(sector.x - math.pi) * 180 / math.pi, 
    151151                          y=sector.y, dy=sector.dy) 
    152152        new_plot.dxl = dxl 
    153153        new_plot.dxw = dxw 
    154         new_plot.name = "AnnulusPhi" +"("+ self.base.data2D.name+")" 
    155          
     154        new_plot.name = "AnnulusPhi" + "(" + self.base.data2D.name + ")" 
     155 
    156156        new_plot.source = self.base.data2D.source 
    157         #new_plot.info=self.base.data2D.info 
     157        # new_plot.info=self.base.data2D.info 
    158158        new_plot.interactive = True 
    159159        new_plot.detector = self.base.data2D.detector 
     
    168168        new_plot.group_id = "AnnulusPhi" + self.base.data2D.name 
    169169        new_plot.id = "AnnulusPhi" + self.base.data2D.name 
    170         new_plot.is_data= True 
     170        new_plot.is_data = True 
    171171        new_plot.xtransform = "x" 
    172172        new_plot.ytransform = "y" 
    173173        self.base.parent.update_theory(data_id=data.id, theory=new_plot) 
    174         wx.PostEvent(self.base.parent, NewPlotEvent(plot=new_plot, 
    175                                                  title="AnnulusPhi")) 
    176          
     174        wx.PostEvent(self.base.parent, NewPlotEvent(plot=new_plot, title="AnnulusPhi")) 
     175 
    177176    def moveend(self, ev): 
    178177        """ 
     
    188187        event.params = self.get_params() 
    189188        wx.PostEvent(self.base, event) 
    190         # create a 1D data plot 
    191         #self._post_data() 
    192              
     189 
    193190    def restore(self): 
    194191        """ 
     
    203200        """ 
    204201        pass 
    205          
     202 
    206203    def set_cursor(self, x, y): 
    207204        pass 
    208          
     205 
    209206    def get_params(self): 
    210207        """ 
    211208        Store a copy of values of parameters of the slicer into a dictionary. 
    212          
     209 
    213210        :return params: the dictionary created 
    214          
     211 
    215212        """ 
    216213        params = {} 
     
    219216        params["nbins"] = self.nbins 
    220217        return params 
    221      
     218 
    222219    def set_params(self, params): 
    223220        """ 
    224         Receive a dictionary and reset the slicer with values contained  
     221        Receive a dictionary and reset the slicer with values contained 
    225222        in the values of the dictionary. 
    226          
    227         :param params: a dictionary containing name of slicer parameters and  
     223 
     224        :param params: a dictionary containing name of slicer parameters and 
    228225            values the user assigned to the slicer. 
    229              
     226 
    230227        """ 
    231228        inner = math.fabs(params["inner_radius"]) 
    232229        outer = math.fabs(params["outer_radius"]) 
    233230        self.nbins = int(params["nbins"]) 
    234         ## Update the picture 
     231        # # Update the picture 
    235232        self.inner_circle.set_cursor(inner, self.inner_circle._inner_mouse_y) 
    236233        self.outer_circle.set_cursor(outer, self.outer_circle._inner_mouse_y) 
    237         ## Post the data given the nbins entered by the user  
     234        # # Post the data given the nbins entered by the user 
    238235        self._post_data(self.nbins) 
    239          
     236 
    240237    def freeze_axes(self): 
    241238        """ 
    242239        """ 
    243240        self.base.freeze_axes() 
    244          
     241 
    245242    def thaw_axes(self): 
    246243        """ 
     
    253250        self.base.draw() 
    254251 
    255          
     252 
    256253class RingInteractor(_BaseInteractor): 
    257254    """ 
    258      Draw a ring Given a radius  
     255     Draw a ring Given a radius 
    259256    """ 
    260257    def __init__(self, base, axes, color='black', zorder=5, r=1.0, sign=1): 
     
    262259        :param: the color of the line that defined the ring 
    263260        :param r: the radius of the ring 
    264         :param sign: the direction of motion the the marker  
    265          
     261        :param sign: the direction of motion the the marker 
     262 
    266263        """ 
    267264        _BaseInteractor.__init__(self, base, axes, color=color) 
     
    270267        # Current radius of the ring 
    271268        self._inner_mouse_x = r 
    272         #Value of the center of the ring 
     269        # Value of the center of the ring 
    273270        self._inner_mouse_y = 0 
    274271        # previous value of that radius 
    275         self._inner_save_x  = r 
    276         #Save value of the center of the ring 
    277         self._inner_save_y  = 0 
    278         #Class instantiating RingIterator class 
     272        self._inner_save_x = r 
     273        # Save value of the center of the ring 
     274        self._inner_save_y = 0 
     275        # Class instantiating RingIterator class 
    279276        self.base = base 
    280         #the direction of the motion of the marker 
     277        # the direction of the motion of the marker 
    281278        self.sign = sign 
    282         ## Create a marker  
     279        # # Create a marker 
    283280        try: 
    284281            # Inner circle marker 
    285282            x_value = [self.sign * math.fabs(self._inner_mouse_x)] 
    286             self.inner_marker = self.axes.plot(x_value, 
    287                                                [0], 
    288                                                 linestyle='', 
    289                                           marker='s', markersize=10, 
    290                                           color=self.color, alpha=0.6, 
    291                                           pickradius=5, label="pick",  
    292                                           zorder=zorder, 
    293                                           visible=True)[0] 
     283            self.inner_marker = self.axes.plot(x_value, [0], linestyle='', 
     284                                               marker='s', markersize=10, 
     285                                               color=self.color, alpha=0.6, 
     286                                               pickradius=5, label="pick", 
     287                                               zorder=zorder, 
     288                                               visible=True)[0] 
    294289        except: 
    295290            x_value = [self.sign * math.fabs(self._inner_mouse_x)] 
    296             self.inner_marker = self.axes.plot(x_value, 
    297                                                [0],  
    298                                                linestyle='', 
    299                                           marker='s', markersize=10, 
    300                                           color=self.color, alpha=0.6, 
    301                                           label="pick",  
    302                                           visible=True)[0] 
    303             message  = "\nTHIS PROTOTYPE NEEDS THE LATEST" 
     291            self.inner_marker = self.axes.plot(x_value, [0], linestyle='', 
     292                                               marker='s', markersize=10, 
     293                                               color=self.color, alpha=0.6, 
     294                                               label="pick", 
     295                                               visible=True)[0] 
     296            message = "\nTHIS PROTOTYPE NEEDS THE LATEST" 
    304297            message += " VERSION OF MATPLOTLIB\n" 
    305298            message += "Get the SVN version that is at " 
    306299            message += " least as recent as June 1, 2007" 
    307              
     300 
    308301            owner = self.base.base.parent 
    309             wx.PostEvent(owner,  
    310                          StatusEvent(status="AnnulusSlicer: %s" % message)) 
    311              
    312         # Draw a circle  
    313         [self.inner_circle] = self.axes.plot([], [], 
    314                                       linestyle='-', marker='', 
    315                                       color=self.color) 
     302            wx.PostEvent(owner, StatusEvent(status="AnnulusSlicer: %s" % message)) 
     303 
     304        # Draw a circle 
     305        [self.inner_circle] = self.axes.plot([], [], linestyle='-', marker='', color=self.color) 
    316306        # the number of points that make the ring line 
    317307        self.npts = 40 
    318              
     308 
    319309        self.connect_markers([self.inner_marker]) 
    320310        self.update() 
     
    323313        """ 
    324314        Allow adding plot to the same panel 
    325           
     315 
    326316        :param n: the number of layer 
    327          
     317 
    328318        """ 
    329319        self.layernum = n 
    330320        self.update() 
    331          
     321 
    332322    def clear(self): 
    333323        """ 
     
    342332            for item in range(len(self.axes.lines)): 
    343333                del self.axes.lines[0] 
    344          
     334 
    345335    def get_radius(self): 
    346336        """ 
     
    348338        """ 
    349339        return self._inner_mouse_x 
    350          
     340 
    351341    def update(self): 
    352342        """ 
     
    358348        for i in range(self.npts): 
    359349            phi = 2.0 * math.pi / (self.npts - 1) * i 
    360              
    361             xval = 1.0 * self._inner_mouse_x * math.cos(phi)  
    362             yval = 1.0 * self._inner_mouse_x * math.sin(phi)  
    363              
     350 
     351            xval = 1.0 * self._inner_mouse_x * math.cos(phi) 
     352            yval = 1.0 * self._inner_mouse_x * math.sin(phi) 
     353 
    364354            x.append(xval) 
    365355            y.append(yval) 
    366              
    367         self.inner_marker.set(xdata=[self.sign*math.fabs(self._inner_mouse_x)], 
     356 
     357        self.inner_marker.set(xdata=[self.sign * math.fabs(self._inner_mouse_x)], 
    368358                              ydata=[0]) 
    369         self.inner_circle.set_data(x, y)         
     359        self.inner_circle.set_data(x, y) 
    370360 
    371361    def save(self, ev): 
     
    383373        """ 
    384374        self.base.moveend(ev) 
    385              
     375 
    386376    def restore(self): 
    387377        """ 
     
    398388        self._inner_mouse_y = y 
    399389        self.base.base.update() 
    400          
     390 
    401391    def set_cursor(self, x, y): 
    402392        """ 
    403         draw the ring given x, y value  
     393        draw the ring given x, y value 
    404394        """ 
    405395        self.move(x, y, None) 
    406396        self.update() 
    407          
    408          
     397 
     398 
    409399    def get_params(self): 
    410400        """ 
    411401        Store a copy of values of parameters of the slicer into a dictionary. 
    412          
     402 
    413403        :return params: the dictionary created 
    414          
     404 
    415405        """ 
    416406        params = {} 
    417407        params["radius"] = math.fabs(self._inner_mouse_x) 
    418408        return params 
    419      
     409 
    420410    def set_params(self, params): 
    421411        """ 
    422         Receive a dictionary and reset the slicer with values contained  
     412        Receive a dictionary and reset the slicer with values contained 
    423413        in the values of the dictionary. 
    424          
    425         :param params: a dictionary containing name of slicer parameters and  
     414 
     415        :param params: a dictionary containing name of slicer parameters and 
    426416            values the user assigned to the slicer. 
    427              
    428         """ 
    429         x = params["radius"]  
     417 
     418        """ 
     419        x = params["radius"] 
    430420        self.set_cursor(x, self._inner_mouse_y) 
    431          
     421 
    432422class CircularMask(_BaseInteractor): 
    433423    """ 
    434      Draw a ring Given a radius  
     424     Draw a ring Given a radius 
    435425    """ 
    436426    def __init__(self, base, axes, color='grey', zorder=3, side=None): 
    437427        """ 
    438          
    439428        :param: the color of the line that defined the ring 
    440429        :param r: the radius of the ring 
    441         :param sign: the direction of motion the the marker  
    442          
     430        :param sign: the direction of motion the the marker 
    443431        """ 
    444432        _BaseInteractor.__init__(self, base, axes, color=color) 
     
    448436        self.is_inside = side 
    449437        self.qmax = min(math.fabs(self.base.data.xmax), 
    450                         math.fabs(self.base.data.xmin))  #must be positive 
     438                        math.fabs(self.base.data.xmin))  # must be positive 
    451439        self.connect = self.base.connect 
    452          
    453         #Cursor position of Rings (Left(-1) or Right(1)) 
     440 
     441        # Cursor position of Rings (Left(-1) or Right(1)) 
    454442        self.xmaxd = self.base.data.xmax 
    455443        self.xmind = self.base.data.xmin 
     
    461449        # Inner circle 
    462450        self.outer_circle = RingInteractor(self, self.base.subplot, 'blue', 
    463                                             zorder=zorder+1, r=self.qmax/1.8, 
    464                                             sign=self.sign) 
     451                                           zorder=zorder + 1, r=self.qmax / 1.8, 
     452                                           sign=self.sign) 
    465453        self.outer_circle.qmax = self.qmax * 1.2 
    466454        self.update() 
    467455        self._post_data() 
    468          
     456 
    469457        # Bind to slice parameter events 
    470         #self.base.Bind(EVT_SLICER_PARS, self._onEVT_SLICER_PARS) 
    471          
     458        # self.base.Bind(EVT_SLICER_PARS, self._onEVT_SLICER_PARS) 
     459 
    472460    def _onEVT_SLICER_PARS(self, event): 
    473461        """ 
    474462        receive an event containing parameters values to reset the slicer 
    475          
    476         :param event: event of type SlicerParameterEvent with params as  
     463 
     464        :param event: event of type SlicerParameterEvent with params as 
    477465            attribute 
    478466        """ 
     
    487475        """ 
    488476        Allow adding plot to the same panel 
    489           
     477 
    490478        :param n: the number of layer 
    491          
     479 
    492480        """ 
    493481        self.layernum = n 
    494482        self.update() 
    495          
     483 
    496484    def clear(self): 
    497485        """ 
     
    501489        self.outer_circle.clear() 
    502490        self.base.connect.clearall() 
    503         #self.base.Unbind(EVT_SLICER_PARS) 
    504          
     491        # self.base.Unbind(EVT_SLICER_PARS) 
     492 
    505493    def update(self): 
    506494        """ 
     
    508496        resetting the widgets. 
    509497        """ 
    510         # Update locations         
     498        # Update locations 
    511499        self.outer_circle.update() 
    512         #if self.is_inside != None: 
     500        # if self.is_inside != None: 
    513501        out = self._post_data() 
    514502        return out 
     
    525513        """ 
    526514        Uses annulus parameters to plot averaged data into 1D data. 
    527          
    528         :param nbins: the number of points to plot  
    529          
    530         """ 
    531         #Data to average 
     515 
     516        :param nbins: the number of points to plot 
     517 
     518        """ 
     519        # Data to average 
    532520        data = self.base.data 
    533                
     521 
    534522        # If we have no data, just return 
    535523        if data == None: 
    536524            return 
    537         mask = data.mask   
     525        mask = data.mask 
    538526        from sas.dataloader.manipulations import Ringcut 
    539      
     527 
    540528        rmin = 0 
    541529        rmax = math.fabs(self.outer_circle.get_radius()) 
    542530 
    543         ## create the data1D Q average of data2D     
    544         mask = Ringcut(r_min=rmin, r_max= rmax) 
     531        # # create the data1D Q average of data2D 
     532        mask = Ringcut(r_min=rmin, r_max=rmax) 
    545533 
    546534        if self.is_inside: 
     
    548536        else: 
    549537            out = (mask(data)) 
    550         #self.base.data.mask=out 
    551         return out                     
    552  
    553           
     538        # self.base.data.mask=out 
     539        return out 
     540 
     541 
    554542    def moveend(self, ev): 
    555543        """ 
     
    562550        # create a 1D data plot 
    563551        self._post_data() 
    564              
     552 
    565553    def restore(self): 
    566554        """ 
     
    574562        """ 
    575563        pass 
    576          
     564 
    577565    def set_cursor(self, x, y): 
    578566        pass 
    579          
     567 
    580568    def get_params(self): 
    581569        """ 
    582570        Store a copy of values of parameters of the slicer into a dictionary. 
    583          
     571 
    584572        :return params: the dictionary created 
    585          
     573 
    586574        """ 
    587575        params = {} 
    588576        params["outer_radius"] = math.fabs(self.outer_circle._inner_mouse_x) 
    589577        return params 
    590      
     578 
    591579    def set_params(self, params): 
    592580        """ 
    593         Receive a dictionary and reset the slicer with values contained  
     581        Receive a dictionary and reset the slicer with values contained 
    594582        in the values of the dictionary. 
    595          
    596         :param params: a dictionary containing name of slicer parameters and  
     583 
     584        :param params: a dictionary containing name of slicer parameters and 
    597585            values the user assigned to the slicer. 
    598586        """ 
    599         outer = math.fabs(params["outer_radius"] ) 
    600         ## Update the picture 
     587        outer = math.fabs(params["outer_radius"]) 
     588        # # Update the picture 
    601589        self.outer_circle.set_cursor(outer, self.outer_circle._inner_mouse_y) 
    602         ## Post the data given the nbins entered by the user  
     590        # # Post the data given the nbins entered by the user 
    603591        self._post_data() 
    604          
     592 
    605593    def freeze_axes(self): 
    606594        self.base.freeze_axes() 
    607          
     595 
    608596    def thaw_axes(self): 
    609597        self.base.thaw_axes() 
     
    611599    def draw(self): 
    612600        self.base.update() 
    613                
     601 
  • src/sas/guiframe/local_perspectives/plotting/Arc.py

    r79492222 r824e488  
    66from BaseInteractor import _BaseInteractor 
    77from sas.guiframe.events import SlicerParameterEvent 
    8   
     8 
    99class ArcInteractor(_BaseInteractor): 
    1010    """ 
    1111    Select an annulus through a 2D plot 
    1212    """ 
    13     def __init__(self, base, axes, color='black', zorder=5, r=1.0,  
    14                  theta1=math.pi/8, theta2=math.pi/4): 
    15          
     13    def __init__(self, base, axes, color='black', zorder=5, r=1.0, 
     14                 theta1=math.pi / 8, theta2=math.pi / 4): 
    1615        _BaseInteractor.__init__(self, base, axes, color=color) 
    1716        self.markers = [] 
     
    1918        self._mouse_x = r 
    2019        self._mouse_y = 0 
    21          
    22         self._save_x  = r 
    23         self._save_y  = 0 
    24          
     20        self._save_x = r 
     21        self._save_y = 0 
    2522        self.scale = 10.0 
    26          
    2723        self.theta1 = theta1 
    2824        self.theta2 = theta2 
    2925        self.radius = r 
    30         [self.arc] = self.axes.plot([], [], 
    31                                       linestyle='-', marker='', 
    32                                       color=self.color) 
     26        [self.arc] = self.axes.plot([], [], linestyle='-', marker='', color=self.color) 
    3327        self.npts = 20 
    34         self.has_move = False     
     28        self.has_move = False 
    3529        self.connect_markers([self.arc]) 
    3630        self.update() 
     
    4337        self.layernum = n 
    4438        self.update() 
    45          
     39 
    4640    def clear(self): 
    4741        """ 
     
    5751            for item in range(len(self.axes.lines)): 
    5852                del self.axes.lines[0] 
    59          
     53 
    6054    def get_radius(self): 
    6155        """ 
     
    6559                           math.pow(self._mouse_y, 2)) 
    6660        return radius 
    67          
     61 
    6862    def update(self, theta1=None, theta2=None, nbins=None, r=None): 
    6963        """ 
     
    8579        while self.theta2 >= (self.theta1 + 2 * math.pi): 
    8680            self.theta2 -= (2 * math.pi) 
    87         npts = int((self.theta2 - self.theta1)/(math.pi/120))   
    88               
     81        npts = int((self.theta2 - self.theta1) / (math.pi / 120)) 
     82 
    8983        if r == None: 
    90             self.radius =  math.sqrt(math.pow(self._mouse_x, 2) + \ 
     84            self.radius = math.sqrt(math.pow(self._mouse_x, 2) + \ 
    9185                                     math.pow(self._mouse_y, 2)) 
    9286        else: 
    9387            self.radius = r 
    9488        for i in range(self.npts): 
    95             phi = (self.theta2 - self.theta1)/(self.npts - 1) * i + self.theta1 
    96             xval = 1.0 * self.radius * math.cos(phi)  
    97             yval = 1.0 * self.radius * math.sin(phi)  
    98              
     89            phi = (self.theta2 - self.theta1) / (self.npts - 1) * i + self.theta1 
     90            xval = 1.0 * self.radius * math.cos(phi) 
     91            yval = 1.0 * self.radius * math.sin(phi) 
     92 
    9993            x.append(xval) 
    10094            y.append(yval) 
    101         #self.marker.set(xdata=[self._mouse_x],ydata=[0]) 
    102         self.arc.set_data(x, y)  
    103          
     95        # self.marker.set(xdata=[self._mouse_x],ydata=[0]) 
     96        self.arc.set_data(x, y) 
     97 
    10498    def save(self, ev): 
    10599        """ 
     
    109103        self._save_x = self._mouse_x 
    110104        self._save_y = self._mouse_y 
    111         #self._save_x = ev.xdata 
    112         #self._save_y = ev.ydata 
     105        # self._save_x = ev.xdata 
     106        # self._save_y = ev.ydata 
    113107        self.base.freeze_axes() 
    114108 
     
    119113        """ 
    120114        self.has_move = False 
    121          
     115 
    122116        event = SlicerParameterEvent() 
    123117        event.type = self.__class__.__name__ 
    124118        event.params = self.get_params() 
    125119        self.base.moveend(ev) 
    126              
     120 
    127121    def restore(self): 
    128122        """ 
     
    131125        self._mouse_x = self._save_x 
    132126        self._mouse_y = self._save_y 
    133         
     127 
    134128    def move(self, x, y, ev): 
    135129        """ 
    136130        Process move to a new position, making sure that the move is allowed. 
    137131        """ 
    138         #print "ring move x, y", x,y 
     132        # print "ring move x, y", x,y 
    139133        self._mouse_x = x 
    140134        self._mouse_y = y 
    141135        self.has_move = True 
    142136        self.base.base.update() 
    143          
     137 
    144138    def set_cursor(self, radius, phi_min, phi_max, nbins): 
    145139        """ 
     
    157151        params["theta2"] = self.theta2 
    158152        return params 
    159      
     153 
    160154    def set_params(self, params): 
    161155        """ 
    162156        """ 
    163         x = params["radius"]  
     157        x = params["radius"] 
    164158        phi_max = self.theta2 
    165159        nbins = self.npts 
    166160        self.set_cursor(x, self._mouse_y, phi_max, nbins) 
    167          
    168      
     161 
  • src/sas/guiframe/local_perspectives/plotting/AzimutSlicer.py

    r79492222 r824e488  
    1 #TODO: the line slicer should listen to all 2DREFRESH events, get the data and slice it 
    2 #      before pushing a new 1D data update. 
    3  
     1# TODO: the line slicer should listen to all 2DREFRESH events, get the data and slice it 
     2#       before pushing a new 1D data update. 
    43# 
    5 #TODO: NEED MAJOR REFACTOR 
     4# TODO: NEED MAJOR REFACTOR 
    65# 
    7  
    8  
    9 # Debug printout 
    106import math 
    117import wx 
    12 from copy import deepcopy 
    138from BaseInteractor import _BaseInteractor 
    149from sas.guiframe.events import NewPlotEvent 
    15 from sas.guiframe.events import StatusEvent 
    16 from sas.guiframe.events import SlicerParameterEvent 
    1710from sas.guiframe.events import EVT_SLICER_PARS 
    18  
    1911 
    2012class SectorInteractor(_BaseInteractor): 
     
    3022        self.qmax = self.base.data2D.xmax 
    3123        self.connect = self.base.connect 
    32          
    33         ## Number of points on the plot 
     24 
     25        # # Number of points on the plot 
    3426        self.nbins = 20 
    35         theta1 = math.pi/8 
    36         theta2 = math.pi/2 
    37         theta1 = 2 * math.pi/3 
    38         theta2 = -2 * math.pi/3 
    39         r1 = self.qmax/2.0 
    40         r2 = self.qmax/1.8 
    41         
     27        theta1 = 2 * math.pi / 3 
     28        theta2 = -2 * math.pi / 3 
     29 
    4230        # Inner circle 
    4331        from Arc import ArcInteractor 
    4432        self.inner_circle = ArcInteractor(self, self.base.subplot, 
    45                                            zorder=zorder, 
    46                                            r=self.qmax/2.0, 
    47                                            theta1=theta1, 
    48                                            theta2=theta2) 
     33                                          zorder=zorder, 
     34                                          r=self.qmax / 2.0, 
     35                                          theta1=theta1, 
     36                                          theta2=theta2) 
    4937        self.inner_circle.qmax = self.qmax 
    5038        self.outer_circle = ArcInteractor(self, self.base.subplot, 
    51                                           zorder=zorder+1, 
    52                                           r=self.qmax/1.8, 
     39                                          zorder=zorder + 1, 
     40                                          r=self.qmax / 1.8, 
    5341                                          theta1=theta1, 
    54                                            theta2=theta2) 
     42                                          theta2=theta2) 
    5543        self.outer_circle.qmax = self.qmax * 1.2 
    56         #self.outer_circle.set_cursor(self.base.qmax/1.8, 0) 
     44        # self.outer_circle.set_cursor(self.base.qmax/1.8, 0) 
    5745        from Edge import RadiusInteractor 
    58         self.right_edge= RadiusInteractor(self, self.base.subplot, 
    59                                           zorder=zorder+1, 
    60                                              arc1=self.inner_circle, 
    61                                              arc2=self.outer_circle, 
    62                                             theta=theta1) 
    63         self.left_edge= RadiusInteractor(self, self.base.subplot, 
    64                                          zorder=zorder+1, 
    65                                              arc1=self.inner_circle, 
    66                                              arc2=self.outer_circle, 
    67                                             theta=theta2) 
     46        self.right_edge = RadiusInteractor(self, self.base.subplot, 
     47                                           zorder=zorder + 1, 
     48                                           arc1=self.inner_circle, 
     49                                           arc2=self.outer_circle, 
     50                                           theta=theta1) 
     51        self.left_edge = RadiusInteractor(self, self.base.subplot, 
     52                                          zorder=zorder + 1, 
     53                                          arc1=self.inner_circle, 
     54                                          arc2=self.outer_circle, 
     55                                          theta=theta2) 
    6856        self.update() 
    6957        self._post_data() 
     
    7462        """ 
    7563        """ 
    76         #printEVT("AnnulusSlicer._onEVT_SLICER_PARS") 
     64        # printEVT("AnnulusSlicer._onEVT_SLICER_PARS") 
    7765        event.Skip() 
    7866        if event.type == self.__class__.__name__: 
     
    8573        self.layernum = n 
    8674        self.update() 
    87          
     75 
    8876    def clear(self): 
    8977        """ 
     
    9482        self.right_edge.clear() 
    9583        self.left_edge.clear() 
    96         #self.base.connect.disconnect() 
     84        # self.base.connect.disconnect() 
    9785        self.base.parent.Unbind(EVT_SLICER_PARS) 
    98          
     86 
    9987    def update(self): 
    10088        """ 
     
    10290        resetting the widgets. 
    10391        """ 
    104         # Update locations    
    105         if self.inner_circle.has_move:     
    106             #print "inner circle has moved"  
     92        # Update locations 
     93        if self.inner_circle.has_move: 
     94            # print "inner circle has moved" 
    10795            self.inner_circle.update() 
    10896            r1 = self.inner_circle.get_radius() 
     
    11098            self.right_edge.update(r1, r2) 
    11199            self.left_edge.update(r1, r2) 
    112         if self.outer_circle.has_move:     
    113             #print "outer circle has moved"  
     100        if self.outer_circle.has_move: 
     101            # print "outer circle has moved" 
    114102            self.outer_circle.update() 
    115103            r1 = self.inner_circle.get_radius() 
     
    118106            self.right_edge.update(r1, r2) 
    119107        if self.right_edge.has_move: 
    120             #print "right edge has moved" 
     108            # print "right edge has moved" 
    121109            self.right_edge.update() 
    122110            self.inner_circle.update(theta1=self.right_edge.get_angle(), 
     
    125113                                     theta2=None) 
    126114        if  self.left_edge.has_move: 
    127             #print "left Edge has moved" 
     115            # print "left Edge has moved" 
    128116            self.left_edge.update() 
    129117            self.inner_circle.update(theta1=None, 
     
    131119            self.outer_circle.update(theta1=None, 
    132120                                     theta2=self.left_edge.get_angle()) 
    133               
     121 
    134122    def save(self, ev): 
    135123        """ 
     
    142130        self.right_edge.save(ev) 
    143131        self.left_edge.save(ev) 
    144          
     132 
    145133    def _post_data(self): 
    146134        pass 
    147      
    148     def post_data(self,new_sector ): 
     135 
     136    def post_data(self, new_sector): 
    149137        """ post data averaging in Q""" 
    150138        if self.inner_circle.get_radius() < self.outer_circle.get_radius(): 
     
    159147        else: 
    160148            phimin = self.left_edge.get_angle() 
    161             phimax = self.right_edge.get_angle()    
    162         #print "phimin, phimax, rmin ,rmax",math.degrees(phimin), 
     149            phimax = self.right_edge.get_angle() 
     150        # print "phimin, phimax, rmin ,rmax",math.degrees(phimin), 
    163151        # math.degrees(phimax), rmin ,rmax 
    164         #from sas.dataloader.manipulations import SectorQ 
    165          
     152        # from sas.dataloader.manipulations import SectorQ 
     153 
    166154        sect = new_sector(r_min=rmin, r_max=rmax, 
    167155                          phi_min=phimin, phi_max=phimax) 
    168156        sector = sect(self.base.data2D) 
    169          
     157 
    170158        from sas.guiframe.dataFitting import Data1D 
    171159        if hasattr(sector, "dxl"): 
     
    180168                          dxl=dxl, dxw=dxw) 
    181169        new_plot.name = str(new_sector.__name__) + \ 
    182                         "("+ self.base.data2D.name+")" 
     170                        "(" + self.base.data2D.name + ")" 
    183171        new_plot.source = self.base.data2D.source 
    184172        new_plot.interactive = True 
    185         #print "loader output.detector",output.source 
     173        # print "loader output.detector",output.source 
    186174        new_plot.detector = self.base.data2D.detector 
    187175        # If the data file does not tell us what the axes are, just assume... 
     
    192180                                       theory=new_plot) 
    193181        wx.PostEvent(self.base.parent, 
    194                     NewPlotEvent(plot=new_plot, title=str(new_sector.__name__))) 
    195          
     182                     NewPlotEvent(plot=new_plot, title=str(new_sector.__name__))) 
     183 
    196184    def moveend(self, ev): 
    197         #self.base.thaw_axes() 
    198          
    199         # Post paramters 
    200         #event = SlicerParameterEvent() 
    201         #event.type = self.__class__.__name__ 
    202         #event.params = self.get_params() 
    203         #print "main moveend ", event.params 
    204         #wx.PostEvent(self.base.parent, event) 
    205         #self._post_data() 
    206         pass 
    207              
     185        #TODO: why is this empty? 
     186        pass 
     187 
    208188    def restore(self): 
    209189        """ 
     
    220200        """ 
    221201        pass 
    222          
     202 
    223203    def set_cursor(self, x, y): 
    224204        """ 
    225205        """ 
    226206        pass 
    227          
     207 
    228208    def get_params(self): 
    229209        """ 
     
    236216        params["nbins"] = self.nbins 
    237217        return params 
    238      
     218 
    239219    def set_params(self, params): 
    240220        """ 
    241221        """ 
    242         #print "setparams on main slicer ",params 
    243         inner = params["r_min"]  
    244         outer = params["r_max"]  
    245         phi_min= params["phi_min"] 
    246         phi_max=params["phi_max"] 
     222        # print "setparams on main slicer ",params 
     223        inner = params["r_min"] 
     224        outer = params["r_max"] 
     225        phi_min = params["phi_min"] 
     226        phi_max = params["phi_max"] 
    247227        self.nbins = int(params["nbins"]) 
    248          
    249         self.inner_circle.set_cursor(inner, phi_min, phi_max,self.nbins) 
    250         self.outer_circle.set_cursor(outer,  phi_min, phi_max, self.nbins) 
     228 
     229        self.inner_circle.set_cursor(inner, phi_min, phi_max, self.nbins) 
     230        self.outer_circle.set_cursor(outer, phi_min, phi_max, self.nbins) 
    251231        self.right_edge.set_cursor(inner, outer, phi_min) 
    252232        self.left_edge.set_cursor(inner, outer, phi_max) 
    253233        self._post_data() 
    254          
     234 
    255235    def freeze_axes(self): 
    256236        """ 
    257237        """ 
    258238        self.base.freeze_axes() 
    259          
     239 
    260240    def thaw_axes(self): 
    261241        """ 
     
    275255        """ 
    276256        SectorInteractor.__init__(self, base, axes, color=color) 
    277         self.base=base 
    278         self._post_data() 
    279          
     257        self.base = base 
     258        self._post_data() 
     259 
    280260    def _post_data(self): 
    281261        """ 
    282262        """ 
    283263        from sas.dataloader.manipulations import SectorQ 
    284         self.post_data(SectorQ)    
    285          
     264        self.post_data(SectorQ) 
     265 
    286266 
    287267class SectorInteractorPhi(SectorInteractor): 
     
    292272        """ 
    293273        SectorInteractor.__init__(self, base, axes, color=color) 
    294         self.base=base 
    295         self._post_data() 
    296          
     274        self.base = base 
     275        self._post_data() 
     276 
    297277    def _post_data(self): 
    298278        """ 
    299279        """ 
    300280        from sas.dataloader.manipulations import SectorPhi 
    301         self.post_data(SectorPhi )    
    302          
    303          
     281        self.post_data(SectorPhi) 
     282 
  • src/sas/guiframe/local_perspectives/plotting/BaseInteractor.py

    r79492222 r824e488  
    88profile_colors = [rho_color, mu_color, P_color, theta_color] 
    99 
    10 class _BaseInteractor: 
     10class _BaseInteractor(object): 
    1111    """ 
    1212    Share some functions between the interface interactor and various layer 
    1313    interactors. 
    14      
     14 
    1515    Individual interactors need the following functions: 
    16      
     16 
    1717        save(ev)  - save the current state for later restore 
    1818        restore() - restore the old state 
     
    2020        moveend(ev) - end the drag event 
    2121        update() - draw the interactors 
    22          
     22 
    2323    The following are provided by the base class: 
    24      
     24 
    2525        connect_markers(markers) - register callbacks for all markers 
    2626        clear_markers() - remove all items in self.markers 
     
    3131        onDrag(ev) - mouse move: calls move() or restore() 
    3232        onKey(ev) - keyboard move: calls move() or restore() 
    33          
     33 
    3434    Interactor attributes: 
    35      
     35 
    3636        base  - model we are operating on 
    3737        axes  - axes holding the interactor 
    3838        color - color of the interactor in non-active state 
    3939        markers - list of handles for the interactor 
    40          
     40 
    4141    """ 
    4242    def __init__(self, base, axes, color='black'): 
     
    4949        self.clicky = None 
    5050        self.markers = [] 
    51          
     51 
    5252    def clear_markers(self): 
    5353        """ 
     
    6363        """ 
    6464        pass 
    65      
     65 
    6666    def restore(self, ev): 
    6767        """ 
    6868        """ 
    6969        pass 
    70      
     70 
    7171    def move(self, x, y, ev): 
    7272        """ 
    7373        """ 
    7474        pass 
    75      
     75 
    7676    def moveend(self, ev): 
    7777        """ 
     
    8383        Connect markers to callbacks 
    8484        """ 
    85         
     85 
    8686        for h in markers: 
    8787            connect = self.base.connect 
     
    109109        self.base.draw() 
    110110        return True 
    111              
     111 
    112112    def onClick(self, ev): 
    113113        """ 
     
    138138        self.base.update() 
    139139        return True 
    140      
     140 
    141141    def onKey(self, ev): 
    142142        """ 
    143143        Respond to keyboard events.  Arrow keys move the widget.  Escape 
    144144        restores it to the position before the last click. 
    145          
     145 
    146146        Calls move() to update the state.  Calls restore() on escape. 
    147147        """ 
     
    173173        px, py = ax.transData.inverse_xy_tup((x, y)) 
    174174        if nudge: 
    175             nx, ny = ax.transData.xy_tup((px+0.2, py+0.2)) 
     175            nx, ny = ax.transData.xy_tup((px + 0.2, py + 0.2)) 
    176176        else: 
    177             nx, ny = ax.transData.xy_tup((px+1.0, py+1.0)) 
    178         dx, dy = nx-x, ny-y 
     177            nx, ny = ax.transData.xy_tup((px + 1.0, py + 1.0)) 
     178        dx, dy = nx - x, ny - y 
    179179        return dx, dy 
    180180 
  • src/sas/guiframe/local_perspectives/plotting/appearanceDialog.py

    r79492222 r824e488  
    1919        Initialization of the Panel 
    2020        """ 
    21         super(appearanceDialog, self).__init__(parent, title=title,  
    22                         size=(570,450),  
    23                         style=wx.DEFAULT_FRAME_STYLE|wx.FRAME_FLOAT_ON_PARENT) 
     21        super(appearanceDialog, 
     22              self).__init__(parent, title=title, size=(570, 450), 
     23                             style=wx.DEFAULT_FRAME_STYLE | wx.FRAME_FLOAT_ON_PARENT) 
    2424 
    2525        self.okay_clicked = False 
     
    4545        ivbox1 = wx.BoxSizer(wx.VERTICAL) 
    4646        ivbox2 = wx.BoxSizer(wx.VERTICAL) 
    47   
     47 
    4848        ihbox1 = wx.BoxSizer(wx.HORIZONTAL) 
    4949        ihbox2 = wx.BoxSizer(wx.HORIZONTAL) 
     
    6161        # selection widgets 
    6262        self.symbollistbox = wx.ListBox(panel, -1, size=(200, 200)) 
    63         self.colorlistbox = wx.ComboBox(panel, style=wx.CB_READONLY,  
     63        self.colorlistbox = wx.ComboBox(panel, style=wx.CB_READONLY, 
    6464                                        size=(185, -1)) 
    65         self.sizecombobox = wx.ComboBox(panel, style=wx.CB_READONLY,  
     65        self.sizecombobox = wx.ComboBox(panel, style=wx.CB_READONLY, 
    6666                                        size=(90, -1)) 
    6767        self.sizecombobox.Bind(wx.EVT_COMBOBOX, self.combo_click) 
    6868        self.sizecustombutton = wx.Button(panel, label='Custom...') 
    6969        self.sizecustombutton.Bind(wx.EVT_BUTTON, self.custom_size) 
    70         self.labeltextbox = wx.TextCtrl(panel, -1, "",  size=(440, -1)) 
     70        self.labeltextbox = wx.TextCtrl(panel, -1, "", size=(440, -1)) 
    7171 
    7272        # buttons 
     
    7777 
    7878        # now Add all the widgets to relevant spacer - tricky 
    79         ivbox1.Add(symboltext, flag=wx.ALL|wx.ALIGN_LEFT, border=10) 
    80         ivbox1.Add(self.symbollistbox, flag=wx.ALL|wx.ALIGN_LEFT, border=10) 
    81  
    82         ihbox1.Add(sizetext, flag=wx.ALL|wx.ALIGN_LEFT, border=10) 
    83         ihbox1.Add(self.sizecombobox,  
    84                    flag= wx.ALL|wx.RIGHT|wx.ALIGN_LEFT, border=10) 
    85         ihbox1.Add(self.sizecustombutton,  
    86                    flag=wx.ALIGN_LEFT|wx.ALL, border=10) 
    87  
    88         ihbox2.Add(colortext, flag=wx.ALL|wx.ALIGN_LEFT, border=10) 
    89         ihbox2.Add(self.colorlistbox, flag=wx.ALL|wx.ALIGN_LEFT, border=10) 
     79        ivbox1.Add(symboltext, flag=wx.ALL | wx.ALIGN_LEFT, border=10) 
     80        ivbox1.Add(self.symbollistbox, flag=wx.ALL | wx.ALIGN_LEFT, border=10) 
     81 
     82        ihbox1.Add(sizetext, flag=wx.ALL | wx.ALIGN_LEFT, border=10) 
     83        ihbox1.Add(self.sizecombobox, 
     84                   flag=wx.ALL | wx.RIGHT | wx.ALIGN_LEFT, border=10) 
     85        ihbox1.Add(self.sizecustombutton, 
     86                   flag=wx.ALIGN_LEFT | wx.ALL, border=10) 
     87 
     88        ihbox2.Add(colortext, flag=wx.ALL | wx.ALIGN_LEFT, border=10) 
     89        ihbox2.Add(self.colorlistbox, flag=wx.ALL | wx.ALIGN_LEFT, border=10) 
    9090 
    9191        ivbox2.Add(ihbox1, flag=wx.ALIGN_LEFT, border=10) 
     
    9595        hbox1.Add(ivbox2, flag=wx.ALIGN_LEFT, border=10) 
    9696 
    97         hbox2.Add(okbutton, flag=wx.ALL| wx.ALIGN_RIGHT, border=10) 
    98         hbox2.Add(cancelbutton, flag=wx.ALL|wx.ALIGN_RIGHT, border=10) 
    99  
    100         hbox3.Add(labeltext, flag=wx.EXPAND|wx.ALL|wx.ALIGN_LEFT, border=10) 
    101         hbox3.Add(self.labeltextbox, flag=wx.EXPAND|wx.ALL|wx.ALIGN_LEFT, border=10) 
    102    
    103         symbolstaticboxsizer.Add(hbox1, flag=wx.ALL|wx.EXPAND, border=10) 
    104         vbox.Add(symbolstaticboxsizer, flag=wx.ALL|wx.EXPAND, border=10) 
    105         vbox.Add(hbox3, flag=wx.EXPAND|wx.RIGHT, border=10) 
    106         vbox.Add(wx.StaticLine(panel), 0, wx.ALL|wx.EXPAND, 5) 
    107         vbox.Add(hbox2, flag=wx.RIGHT|wx.ALIGN_RIGHT, border=10) 
     97        hbox2.Add(okbutton, flag=wx.ALL | wx.ALIGN_RIGHT, border=10) 
     98        hbox2.Add(cancelbutton, flag=wx.ALL | wx.ALIGN_RIGHT, border=10) 
     99 
     100        hbox3.Add(labeltext, flag=wx.EXPAND | wx.ALL | wx.ALIGN_LEFT, border=10) 
     101        hbox3.Add(self.labeltextbox, flag=wx.EXPAND | wx.ALL | wx.ALIGN_LEFT, border=10) 
     102 
     103        symbolstaticboxsizer.Add(hbox1, flag=wx.ALL | wx.EXPAND, border=10) 
     104        vbox.Add(symbolstaticboxsizer, flag=wx.ALL | wx.EXPAND, border=10) 
     105        vbox.Add(hbox3, flag=wx.EXPAND | wx.RIGHT, border=10) 
     106        vbox.Add(wx.StaticLine(panel), 0, wx.ALL | wx.EXPAND, 5) 
     107        vbox.Add(hbox2, flag=wx.RIGHT | wx.ALIGN_RIGHT, border=10) 
    108108 
    109109        panel.SetSizer(vbox) 
     
    119119        On custom size 
    120120        """ 
    121         dlg = wx.TextEntryDialog(self,  
    122                                  'Enter custom size',  
    123                                  'Custom size',  
    124                                  str(self.final_size)) 
    125         if(dlg.ShowModal() == wx.ID_OK): 
    126             if(float(dlg.GetValue()) < 0): 
     121        dlg = wx.TextEntryDialog(self, 'Enter custom size', 'Custom size', str(self.final_size)) 
     122        if dlg.ShowModal() == wx.ID_OK: 
     123            if float(dlg.GetValue()) < 0: 
    127124                msg = "Unfortunately imaginary icons are not yet supported." 
    128125                msg += "Please enter a positive value" 
    129                 dial = wx.MessageDialog(None, msg, 'Error', 
    130                                          wx.OK|wx.ICON_ERROR) 
     126                dial = wx.MessageDialog(None, msg, 'Error', wx.OK | wx.ICON_ERROR) 
    131127                dial.ShowModal() 
    132128                dlg.Destroy() 
     
    145141        # set up gui values 
    146142        self.labeltextbox.SetValue(label) 
    147         if(size % 1 == 0 and size > 1 and size < 11): 
     143        if size % 1 == 0 and size > 1 and size < 11: 
    148144            self.sizecombobox.SetSelection(int(size) - 1) 
    149145        else: 
    150146            self.sizecombobox.SetSelection(4) 
    151147        self.symbollistbox.SetSelection(self.sorted_sym_dic[symbol]) 
    152         colorname = appearanceDialog.find_key(self.parent.get_color_label(),  
    153                                               color) 
     148        colorname = appearanceDialog.find_key(self.parent.get_color_label(), color) 
    154149        self.colorlistbox.SetStringSelection(colorname) 
    155150 
     
    158153        Populate Symbols 
    159154        """ 
    160         self.sorted_symbo_labels = sorted(self.symbo_labels.iteritems(),  
     155        self.sorted_symbo_labels = sorted(self.symbo_labels.iteritems(), 
    161156                                          key=operator.itemgetter(1)) 
    162157        self.sorted_sym_dic = {} 
     
    171166        Populate Colors 
    172167        """ 
    173         sortedcolor_labels = sorted(self.color_labels.iteritems(),  
    174                                    key=operator.itemgetter(1)) 
     168        sortedcolor_labels = sorted(self.color_labels.iteritems(), 
     169                                    key=operator.itemgetter(1)) 
    175170        for color in sortedcolor_labels: 
    176171            self.colorlistbox.Append(str(color[0])) 
    177   
     172 
    178173    def populate_size(self): 
    179174        """ 
     
    203198        """ 
    204199        return [k for k, v in dic.iteritems() if v == val][0] 
    205          
    206     def get_current_values(self):  
     200 
     201    def get_current_values(self): 
    207202        """ 
    208203        Get Current Values 
     
    212207        name = str(self.labeltextbox.GetValue()) 
    213208        seltuple = self.symbollistbox.GetSelections() 
    214         symbol = appearanceDialog.find_key(self.sorted_sym_dic,  
     209        symbol = appearanceDialog.find_key(self.sorted_sym_dic, 
    215210                                           int(seltuple[0])) 
    216         color = str(self.colorlistbox.GetValue())  
     211        color = str(self.colorlistbox.GetValue()) 
    217212        return(size, color, symbol, name) 
    218213 
  • src/sas/guiframe/local_perspectives/plotting/binder.py

    r79492222 r824e488  
    22Extension to MPL to support the binding of artists to key/mouse events. 
    33""" 
    4  
    5 class Selection: 
     4import logging 
     5import sys 
     6 
     7class Selection(object): 
    68    """ 
    79    Store and compare selections. 
     
    911    # TODO: We need some way to check in prop matches, preferably 
    1012    # TODO: without imposing structure on prop. 
    11          
     13 
    1214    artist = None 
    1315    prop = {} 
    1416    def __init__(self, artist=None, prop={}): 
    1517        self.artist, self.prop = artist, self.prop 
    16          
     18 
    1719    def __eq__(self, other): 
    1820        return self.artist is other.artist 
    19      
     21 
    2022    def __ne__(self, other): 
    2123        return self.artist is not other.artist 
    22      
     24 
    2325    def __nonzero__(self): 
    2426        return self.artist is not None 
    2527 
    26 class BindArtist: 
    27  
    28     # Track keyboard modifiers for events. 
    29     # TODO: Move keyboard modifier support into the backend.  We cannot 
    30     # TODO: properly support it from outside the windowing system since there 
    31     # TODO: is no way to recognized whether shift is held down when the mouse 
    32     # TODO: first clicks on the the application window. 
     28class BindArtist(object): 
     29    """ 
     30        Track keyboard modifiers for events. 
     31        TODO: Move keyboard modifier support into the backend.  We cannot 
     32        TODO: properly support it from outside the windowing system since there 
     33        TODO: is no way to recognized whether shift is held down when the mouse 
     34        TODO: first clicks on the the application window. 
     35    """ 
    3336    control, shift, alt, meta = False, False, False, False 
    3437 
     
    3639    dclick_threshhold = 0.25 
    3740    _last_button, _last_time = None, 0 
    38      
     41 
    3942    # Mouse/keyboard events we can bind to 
    4043    events = ['enter', 'leave', 'motion', 'click', 'dclick', 'drag', 'release', 
    41              'scroll', 'key', 'keyup'] 
     44              'scroll', 'key', 'keyup'] 
    4245    # TODO: Need our own event structure 
    4346    def __init__(self, figure): 
     
    5457            ] 
    5558        except: 
    56             #print "bypassing scroll_event: wrong matplotlib version" 
     59            # print "bypassing scroll_event: wrong matplotlib version" 
    5760            self._connections = [ 
    5861                canvas.mpl_connect('motion_notify_event', self._onMotion), 
     
    6669            canvas.mpl_disconnect(canvas.button_pick_id) 
    6770            canvas.mpl_disconnect(canvas.scroll_pick_id) 
    68         except:  
    69             pass 
     71        except: 
     72            logging.error(sys.exc_value) 
    7073        self.canvas = canvas 
    7174        self.figure = figure 
    7275        self.clearall() 
    73          
     76 
    7477    def clear(self, *artists): 
    7578        """ 
    7679        self.clear(h1,h2,...) 
    7780            Remove connections for artists h1, h2, ... 
    78              
     81 
    7982        Use clearall() to reset all connections. 
    80          
     83 
    8184        """ 
    8285        for h in artists: 
     
    9295        if self._haskey.artist in artists: 
    9396            self._haskey = Selection() 
    94          
     97 
    9598    def clearall(self): 
    9699        """ 
    97100        Clear connections to all artists. 
    98          
     101 
    99102        Use clear(h1,h2,...) to reset specific artists. 
    100103        """ 
     
    113116        In case we need to disconnect from the canvas... 
    114117        """ 
    115         try:  
     118        try: 
    116119            for cid in self._connections: 
    117120                self.canvas.mpl_disconnect(cid) 
    118         except:  
     121        except: 
    119122            pass 
    120123        self._connections = [] 
     
    125128    def __call__(self, trigger, artist, action): 
    126129        """Register a callback for an artist to a particular trigger event. 
    127          
     130 
    128131        usage: 
    129132            self.connect(eventname,artist,action) 
    130      
     133 
    131134        where: 
    132135            eventname is a string 
     
    148151            key: key pressed when mouse is on the artist 
    149152            keyrelease: key released for the artist 
    150      
     153 
    151154        The event received by action has a number of attributes: 
    152155            name is the event name which was triggered 
     
    158161            shift,control,alt,meta are flags which are true if the 
    159162                corresponding key is pressed at the time of the event. 
    160             details is a dictionary of artist specific details, such as the  
     163            details is a dictionary of artist specific details, such as the 
    161164                id(s) of the point that were clicked. 
    162                  
     165 
    163166        When receiving an event, first check the modifier state to be 
    164167        sure it applies.  E.g., the callback for 'press' might be: 
     
    175178        :TODO: Attach multiple callbacks to the same event? 
    176179        :TODO: Clean up interaction with toolbar modes 
    177         :TODO: push/pushclear/pop context so that binding changes  
     180        :TODO: push/pushclear/pop context so that binding changes 
    178181            for the duration 
    179182        :TODO:   e.g., to support ? context sensitive help 
    180          
     183 
    181184        """ 
    182185        # Check that the trigger is valid 
     
    186189        # Register the trigger callback 
    187190        self._actions[trigger][artist] = action 
    188         #print "==> added",artist,[artist],"to",trigger,":", 
    189         #self._actions[trigger].keys() 
     191        # print "==> added",artist,[artist],"to",trigger,":", 
     192        # self._actions[trigger].keys() 
    190193        # Maintain a list of all artists 
    191         if artist not in self._artists:  
     194        if artist not in self._artists: 
    192195            self._artists.append(artist) 
    193196 
     
    231234        # print "search"," ".join([str(h) for h in self._artists]) 
    232235        found = Selection() 
    233         #print "searching in",self._artists 
     236        # print "searching in",self._artists 
    234237        for artist in self._artists: 
    235238            # TODO: should contains() return false if invisible? 
    236             if not artist.get_visible():  
     239            if not artist.get_visible(): 
    237240                continue 
    238241            # TODO: optimization - exclude artists not inaxes 
    239242            try: 
    240                 inside,prop = artist.contains(event) 
     243                inside, prop = artist.contains(event) 
    241244            except: 
    242245                # Probably an old version of matplotlib 
     
    245248                found.artist, found.prop = artist, prop 
    246249                break 
    247         #print "found",found.artist 
    248          
     250        # print "found",found.artist 
     251 
    249252        # TODO: how to check if prop is equal? 
    250253        if found != self._current: 
     
    253256        self._current = found 
    254257        return found 
    255          
     258 
    256259    def _onMotion(self, event): 
    257260        """ 
     
    259262        other artists are invisible. 
    260263        """ 
    261         ## Can't kill double-click on motion since Windows produces 
    262         ## spurious motion events. 
    263         #self._last_button = None 
    264          
     264        # # Can't kill double-click on motion since Windows produces 
     265        # # spurious motion events. 
     266        # self._last_button = None 
     267 
    265268        # Dibs on the motion event for the clicked artist 
    266269        if self._hasclick: 
    267270            # Make sure the x,y data use the coordinate system of the 
    268271            # artist rather than the default axes coordinates. 
    269              
     272 
    270273            transform = self._hasclick.artist.get_transform() 
    271             #x,y = event.xdata,event.ydata 
     274            # x,y = event.xdata,event.ydata 
    272275            x, y = event.x, event.y 
    273276            try: 
     
    280283        else: 
    281284            found = self._find_current(event) 
    282             #print "found",found.artist 
     285            # print "found",found.artist 
    283286            self.trigger(found, 'motion', event) 
    284287 
     
    288291        """ 
    289292        import time 
    290          
     293 
    291294        # Check for double-click 
    292295        event_time = time.time() 
    293         #print event_time,self._last_time,self.dclick_threshhold 
    294         #print (event_time > self._last_time + self.dclick_threshhold) 
    295         #print event.button,self._last_button 
     296        # print event_time,self._last_time,self.dclick_threshhold 
     297        # print (event_time > self._last_time + self.dclick_threshhold) 
     298        # print event.button,self._last_button 
    296299        if (event.button != self._last_button) or \ 
    297300                (event_time > self._last_time + self.dclick_threshhold): 
     
    301304        self._last_button = event.button 
    302305        self._last_time = event_time 
    303          
     306 
    304307        # If an artist is already dragging, feed any additional button 
    305308        # presses to that artist. 
     
    311314        else: 
    312315            found = self._find_current(event) 
    313         #print "button %d pressed"%event.button 
     316        # print "button %d pressed"%event.button 
    314317        # Note: it seems like if "click" returns False then hasclick should 
    315318        # not be set.  The problem is that there are two reasons it can 
     
    346349        self.trigger(self._hasclick, 'release', event) 
    347350        self._hasclick = Selection() 
    348              
     351 
    349352    def _onKey(self, event): 
    350353        """ 
     
    355358        # TODO: Can we tab between items? 
    356359        # TODO: How do unhandled events get propogated to axes, figure and 
    357         # TODO: finally to application?  Do we need to implement a full tags  
     360        # TODO: finally to application?  Do we need to implement a full tags 
    358361        # TODO: architecture a la Tk? 
    359362        # TODO: Do modifiers cause a grab?  Does the artist see the modifiers? 
     
    368371        self.trigger(found, 'key', event) 
    369372        self._haskey = found 
    370      
     373 
    371374    def _onKeyRelease(self, event): 
    372375        """ 
  • src/sas/perspectives/calculator/gen_scatter_panel.py

    r49ab5d7 r824e488  
    20362036        self.Destroy() 
    20372037 
    2038 #    def on_help(self, event):     
    2039 #        """ 
    2040 #       Gen scatter angle help panel 
    2041 #        """ 
    2042 #        from sas.perspectives.calculator.help_panel import  HelpWindow 
    2043 #        # Get models help model_function path 
    2044 #        import sas.perspectives.calculator as calmedia 
    2045 # 
    2046 #        media = calmedia.get_data_path(media='media') 
    2047 #        path = os.path.join(media,"gen_sas_help.html")  
    2048 #        name = "Generic Scattering Calculator" 
    2049 #        frame = HelpWindow(self, -1,  
    2050 #                           title=' Help: GenSAS',   
    2051 #                           pageToOpen=path, size=(865, 450))    
    2052 #        try:  
    2053 #            frame.splitter.DetachWindow(frame.lpanel) 
    2054 #            # Display only the right side one 
    2055 #            frame.lpanel.Hide()  
    2056 #            frame.Show(True) 
    2057 #            add_icon(self.parent, frame) 
    2058 #        except: 
    2059 #            frame.Destroy()  
    2060 #            msg = 'Display Error\n' 
    2061 #            info = "Info" 
    2062 #            wx.MessageBox(msg, info) 
    2063  
    20642038if __name__ == "__main__": 
    20652039    app = wx.PySimpleApp() 
  • src/sas/perspectives/fitting/fitting.py

    r2f4b430 r824e488  
    424424        else: 
    425425            self.batch_page = self.fit_panel.add_sim_page(caption=caption) 
    426  
    427     def help(self, evt): 
    428         """ 
    429         Show a general help dialog. 
    430         """ 
    431         from help_panel import  HelpWindow 
    432         frame = HelpWindow(None, -1, 'HelpWindow') 
    433         if hasattr(frame, "IsIconized"): 
    434             if not frame.IsIconized(): 
    435                 try: 
    436                     icon = self.parent.GetIcon() 
    437                     frame.SetIcon(icon) 
    438                 except: 
    439                     pass 
    440         frame.Show(True) 
    441426 
    442427    def get_context_menu(self, plotpanel=None): 
  • src/sas/perspectives/invariant/invariant.py

    r78a205a r824e488  
    4747        # Log startup 
    4848        logging.info("Invariant plug-in started") 
    49  
    50     def help(self, evt): 
    51         """ 
    52         Show a general help dialog. 
    53         """ 
    54         from help_panel import  HelpWindow 
    55         frame = HelpWindow(None, -1) 
    56         if hasattr(frame, "IsIconized"): 
    57             if not frame.IsIconized(): 
    58                 try: 
    59                     icon = self.parent.GetIcon() 
    60                     frame.SetIcon(icon) 
    61                 except: 
    62                     logging.error(sys.exc_value) 
    63         frame.Show(True) 
    6449 
    6550    def get_data(self): 
Note: See TracChangeset for help on using the changeset viewer.