Ignore:
Timestamp:
Mar 3, 2009 2:12:26 PM (15 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
fe2ade9
Parents:
18a3ee9
Message:

add comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • guiframe/local_perspectives/plotting/boxSum.py

    r6d920cd reba08f1a  
    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  
    4 # 
    5 #TODO: NEED MAJOR REFACTOR 
    6 # 
    7  
    8  
    9 # Debug printout 
    10 #from config import printEVT 
     1 
     2 
     3 
     4import math 
     5import wx 
     6from copy import deepcopy 
    117from BaseInteractor import _BaseInteractor 
    12 from copy import deepcopy 
    13 import math 
    14  
    15 #from Plotter1D import AddPlotEvent 
    16 import SlicerParameters 
    17 import wx 
    18  
    198from sans.guicomm.events import SlicerParamUpdateEvent,EVT_SLICER_PARS,StatusEvent 
     9 
     10 
    2011class BoxSum(_BaseInteractor): 
    2112    """ 
    22          Select an annulus through a 2D plot 
     13        Boxsum Class: determine 2 rectangular area to compute the sum of pixel of 
     14        a Data.  
     15        Uses PointerInteractor , VerticalDoubleLine,HorizontalDoubleLine. 
     16        @param zorder:  Artists with lower zorder values are drawn first. 
     17        @param x_min: the minimum value of the x coordinate 
     18        @param x_max: the maximum value of the x coordinate 
     19        @param y_min: the minimum value of the y coordinate 
     20        @param y_max: the maximum value of the y coordinate 
     21 
    2322    """ 
    24     def __init__(self,base,axes,color='black', zorder=3, x_min=0.008, x_max=0.008, y_min=0.0025, y_max=0.0025): 
     23    def __init__(self,base,axes,color='black', zorder=3, x_min=0.008, 
     24                  x_max=0.008, y_min=0.0025, y_max=0.0025): 
    2525         
    2626        _BaseInteractor.__init__(self, base, axes, color=color) 
     27        ## class initialization 
     28        ## list of Boxsmun markers 
    2729        self.markers = [] 
    2830        self.axes = axes 
     31        ## connect the artist for the motion 
     32        self.connect = self.base.connect 
     33        ## when qmax is reached the selected line is reset the its previous value 
    2934        self.qmax = min(self.base.data2D.xmax, self.base.data2D.xmin) 
    30         self.connect = self.base.connect 
     35        ## Define the boxsum limits 
    3136        self.xmin= -1* 0.5*min(math.fabs(self.base.data2D.xmax),math.fabs( self.base.data2D.xmin)) 
    3237        self.ymin= -1* 0.5*min(math.fabs(self.base.data2D.xmax),math.fabs( self.base.data2D.xmin)) 
    33         #self.xmax= x_max 
    34         #self.ymax=  y_max 
     38        
    3539        self.xmax= 0.5*min(math.fabs(self.base.data2D.xmax),math.fabs( self.base.data2D.xmin)) 
    3640        self.ymax=  0.5*min(math.fabs(self.base.data2D.xmax),math.fabs( self.base.data2D.xmin)) 
    37         # center of the figure 
     41        ## center of the boxSum 
    3842        self.center_x= 0.0002 
    3943        self.center_y= 0.0003 
    40         
    4144        ## Number of points on the plot 
    4245        self.nbins = 20 
     46        ## Define initial result the summation  
    4347        self.count=0 
    4448        self.error=0 
     49        ## Flag to determine if the current figure has moved 
     50        ## set to False == no motion , set to True== motion 
    4551        self.has_move= False 
    46      
    47         self.horizontal_lines= Horizontal_DoubleLine(self, self.base.subplot,color='blue', 
     52        ## Create Boxsum edges  
     53        self.horizontal_lines= HorizontalDoubleLine(self, self.base.subplot,color='blue', 
    4854                                                      zorder=zorder, 
    4955                                    y= self.ymax, 
     
    5359        self.horizontal_lines.qmax = self.qmax 
    5460         
    55         self.vertical_lines= Vertical_DoubleLine(self, self.base.subplot,color='black', 
     61        self.vertical_lines= VerticalDoubleLine(self, self.base.subplot,color='black', 
    5662                                                      zorder=zorder, 
    5763                                    y= self.ymax, 
     
    6066                                    center_y= self.center_y) 
    6167        self.vertical_lines.qmax = self.qmax 
     68         
    6269        self.center= PointInteractor(self, self.base.subplot,color='grey', 
    6370                                                      zorder=zorder, 
    6471                                    center_x= self.center_x, 
    6572                                    center_y= self.center_y) 
    66        
    67              
    68         #self.connect_markers([]) 
    69         self.panel_name=""       
     73        ## Save the name of the slicer panel associate with this slicer  
     74        self.panel_name=""     
     75        ## Update and post slicer parameters   
    7076        self.update() 
    7177        self._post_data() 
    72          
    73         # Bind to slice parameter events 
    74         #print "box sum  self.base.parent",self.base.parent 
     78        ## Bind to slice parameter events 
    7579        self.base.Bind(EVT_SLICER_PARS, self._onEVT_SLICER_PARS) 
    7680         
     81         
    7782    def set_panel_name(self, name): 
     83        """ 
     84            Store the name of the panel associated to this slicer 
     85            @param name: the name of this panel 
     86        """ 
    7887        self.panel_name= name 
    7988         
    8089         
    8190    def _onEVT_SLICER_PARS(self, event): 
     91        """ 
     92            receive an event containing parameters values to reset the slicer 
     93            @param event: event of type SlicerParameterEvent with params as  
     94            attribute 
     95        """ 
     96        ## Post e message to declare what kind of event has being received 
    8297        wx.PostEvent(self.base.parent, StatusEvent(status="Boxsum._onEVT_SLICER_PARS")) 
    83         #print "receiving value ",event.params 
    8498        event.Skip() 
     99        ## reset the slicer with the values contains the event.params dictionary 
    85100        if event.type == self.__class__.__name__: 
    86101            self.set_params(event.params) 
    87102            self.base.update() 
    88103 
    89     def update_and_post(self): 
    90         self.update() 
    91         self._post_data() 
    92  
    93     def save_data(self, path, image, x, y): 
    94         output = open(path, 'w') 
    95          
    96         data_x, data_y = self.get_data(image, x, y) 
    97          
    98         output.write("<phi>  <average>\n") 
    99         for i in range(len(data_x)): 
    100             output.write("%g  %g\n" % (data_x[i], data_y[i])) 
    101         output.close() 
    102104 
    103105    def set_layer(self, n): 
     106        """ 
     107             Allow adding plot to the same panel 
     108             @param n: the number of layer 
     109        """ 
    104110        self.layernum = n 
    105111        self.update() 
    106112         
     113         
    107114    def clear(self): 
     115        """ 
     116            Clear the slicer and all connected events related to this slicer 
     117        """ 
    108118        self.clear_markers() 
    109119        self.horizontal_lines.clear() 
     
    111121        self.center.clear() 
    112122        self.base.connect.clearall() 
    113         #self.base.connect.disconnect() 
    114123        self.base.Unbind(EVT_SLICER_PARS) 
    115124         
     125         
    116126    def update(self): 
    117127        """ 
    118         Respond to changes in the model by recalculating the profiles and 
    119         resetting the widgets. 
    120         """ 
     128            Respond to changes in the model by recalculating the profiles and 
     129            resetting the widgets. 
     130        """ 
     131        ## check if the center point has moved and update the figure accordingly  
    121132        if self.center.has_move: 
    122             #print "center has move" 
    123133            self.center.update() 
    124134            self.horizontal_lines.update( center= self.center) 
    125135            self.vertical_lines.update( center= self.center) 
    126              
     136        ## check if the horizontal lines have moved and update the figure accordingly     
    127137        if self.horizontal_lines.has_move: 
    128             #print "top has moved" 
    129138            self.horizontal_lines.update() 
    130139            self.vertical_lines.update(y1=self.horizontal_lines.y1, 
    131140                                       y2=self.horizontal_lines.y2, 
    132141                                       height= self.horizontal_lines.half_height ) 
     142        ## check if the vertical lines have moved and update the figure accordingly     
    133143        if self.vertical_lines.has_move: 
    134             #print "right has moved" 
    135144            self.vertical_lines.update() 
    136145            self.horizontal_lines.update(x1=self.vertical_lines.x1, 
     
    150159         
    151160    def _post_data(self): 
    152         # Compute data 
    153         print  
    154          
     161        """ 
     162            Get the limits of the boxsum and compute the sum of the pixel 
     163            contained in that region and the error on that sum 
     164        """ 
     165        ## Data 2D for which the pixel will be summed 
    155166        data = self.base.data2D 
    156         from DataLoader.manipulations import  Boxavg 
    157         #radius = math.sqrt(math.pow(self.qmax,2)+math.pow(self.qmax,2)) 
     167        ## the region of the summation 
    158168        x_min= self.horizontal_lines.x2  
    159169        x_max= self.horizontal_lines.x1  
    160170        y_min= self.vertical_lines.y2 
    161171        y_max= self.vertical_lines.y1 
    162         #print "xmin, xmax, ymin , ymax", x_min, x_max, y_min, y_max 
     172        ##computation of the sum and its error 
     173        from DataLoader.manipulations import  Boxavg 
    163174        box =  Boxavg (x_min=x_min, x_max=x_max, y_min=y_min, y_max=y_max) 
    164175        self.count, self.error = box(self.base.data2D) 
    165         #print "box_sum output",box(self.base.data2D) 
     176 
    166177                           
    167178    def moveend(self, ev): 
     179        """ 
     180            After a dragging motion this function is called to compute 
     181            the error and the sum of pixel of a given data 2D  
     182        """ 
    168183        self.base.thaw_axes() 
    169         # Post paramters 
     184        ## compute error an d sum of data's pixel 
    170185        self._post_data() 
    171         
     186        ## Create and event ( posted to guiframe)that  set the  
     187        ##current slicer parameter to a panel of name self.panel_name 
    172188        self.type= self.__class__.__name__ 
    173189        params= self.get_params() 
     
    184200        self.vertical_lines.restore() 
    185201        self.center.restore() 
     202         
     203         
    186204    def move(self, x, y, ev): 
    187205        """ 
     
    189207        """ 
    190208        pass 
     209     
    191210     
    192211    def set_cursor(self, x, y): 
    193212        pass 
    194213         
     214         
    195215    def get_params(self): 
     216        """ 
     217            Store a copy of values of parameters of the slicer into a dictionary. 
     218            @return params: the dictionary created 
     219        """ 
    196220        params = {} 
    197         
    198221        params["Width"] = math.fabs(self.vertical_lines.half_width)*2 
    199222        params["Height"] = math.fabs(self.horizontal_lines.half_height)*2  
    200          
    201223        params["center_x"] = self.center.x 
    202224        params["center_y"] =self.center.y 
    203225        params["count"] = self.count 
    204226        params["errors"]= self.error 
    205          
    206227        return params 
    207228     
     
    218239         
    219240    def set_params(self, params): 
    220          
     241        """ 
     242            Receive a dictionary and reset the slicer with values contained  
     243            in the values of the dictionary. 
     244            @param params: a dictionary containing name of slicer parameters and  
     245            values the user assigned to the slicer. 
     246        """ 
    221247        x_max = math.fabs(params["Width"] )/2 
    222248        y_max = math.fabs(params["Height"] )/2 
     
    224250        self.center_x=params["center_x"]  
    225251        self.center_y=params["center_y"] 
    226         
     252        #update the slicer given values of params 
    227253        self.center.update(center_x=self.center_x,center_y=self.center_y) 
    228         
    229254        self.horizontal_lines.update(center= self.center, 
    230255                                     width=x_max, 
     
    233258                                    width=x_max, 
    234259                                    height=y_max) 
    235          
     260        #compute the new error and sum given values of params 
    236261        self._post_data() 
    237262         
     
    241266        self.base.freeze_axes() 
    242267         
     268         
    243269    def thaw_axes(self): 
    244270        self.base.thaw_axes() 
    245271 
     272 
    246273    def draw(self): 
    247274        self.base.draw() 
     275         
     276         
     277         
    248278class PointInteractor(_BaseInteractor): 
    249279    """ 
    250          Select an annulus through a 2D plot 
     280         Draw a point that can be dragged with the marker. 
     281         this class controls the motion the center of the BoxSum  
    251282    """ 
    252283    def __init__(self,base,axes,color='black', zorder=5, 
     
    255286         
    256287        _BaseInteractor.__init__(self, base, axes, color=color) 
     288        ## Initialization the class  
    257289        self.markers = [] 
    258290        self.axes = axes 
    259         # center 
     291        # center coordinates 
    260292        self.x = center_x 
    261293        self.y = center_y 
    262          
     294        ## saved value of the center coordinates 
    263295        self.save_x = center_x 
    264296        self.save_y = center_y 
    265           
    266          
     297        ## Create a marker  
    267298        try: 
    268299            self.center_marker = self.axes.plot([self.x],[self.y], linestyle='', 
     
    280311            message  = "\nTHIS PROTOTYPE NEEDS THE LATEST VERSION OF MATPLOTLIB\n" 
    281312            message += "Get the SVN version that is at least as recent as June 1, 2007" 
    282              
    283             #raise "Version error", message 
    284              
    285         # line 
     313            owner=self.base.base.parent 
     314            wx.PostEvent(owner, StatusEvent(status="AnnulusSlicer: %s"%message)) 
     315             
     316        ## Draw a point 
    286317        self.center = self.axes.plot([self.x],[self.y], 
    287318                                      linestyle='-', marker='', 
    288319                                      color=self.color, 
    289320                                      visible=True)[0] 
    290      
    291         self.npts = 30 
    292         self.has_move=False     
     321        ## Flag to determine the motion this point  
     322        self.has_move=False    
     323        ## connecting the marker to allow them to move  
    293324        self.connect_markers([self.center_marker]) 
    294         self.update() 
     325        ## Update the figure 
     326        self.update() 
     327     
    295328     
    296329    def set_layer(self, n): 
     330        """ 
     331            Allow adding plot to the same panel 
     332            @param n: the number of layer 
     333        """ 
    297334        self.layernum = n 
    298335        self.update() 
    299336         
     337         
    300338    def clear(self): 
     339        """ 
     340            Clear this figure and its markers 
     341        """ 
    301342        self.clear_markers() 
    302343        try: 
     
    307348            for item in range(len(self.axes.lines)): 
    308349                del self.axes.lines[0] 
    309          
    310     def get_radius(self): 
    311          
    312         return 0 
     350   
    313351    
    314352    def update(self, center_x=None,center_y=None): 
    315353        """ 
    316         Draw the new roughness on the graph. 
     354            Draw the new roughness on the graph. 
    317355        """ 
    318356        if center_x !=None: self.x= center_x 
     
    323361         
    324362         
    325          
    326          
    327363    def save(self, ev): 
    328364        """ 
     
    332368        self.save_x= self.x 
    333369        self.save_y= self.y 
    334          
    335370        self.base.freeze_axes() 
     371 
    336372 
    337373    def moveend(self, ev): 
     
    346382        self.y= self.save_y 
    347383        self.x= self.save_x 
     384         
    348385         
    349386    def move(self, x, y, ev): 
     
    357394        self.base.base.update() 
    358395         
     396         
    359397    def set_cursor(self, x, y): 
    360398        self.move(x, y, None) 
     
    366404        params["x"] = self.x 
    367405        params["y"] = self.y 
    368          
    369406        return params 
     407     
    370408     
    371409    def set_params(self, params): 
     
    375413        
    376414         
    377 class Vertical_DoubleLine(_BaseInteractor): 
     415class VerticalDoubleLine(_BaseInteractor): 
    378416    """ 
    379          Select an annulus through a 2D plot 
     417         Draw 2 vertical lines moving in opposite direction and centered on  
     418         a point (PointInteractor) 
    380419    """ 
    381420    def __init__(self,base,axes,color='black', zorder=5, x=0.5,y=0.5, 
     
    384423         
    385424        _BaseInteractor.__init__(self, base, axes, color=color) 
     425        ## Initialization the class  
    386426        self.markers = [] 
    387427        self.axes = axes 
    388         # center 
     428        ## Center coordinates 
    389429        self.center_x = center_x 
    390430        self.center_y = center_y 
    391          
    392         
    393          
     431        ## defined end points vertical lignes and their saved values 
    394432        self.y1     = y + self.center_y 
    395433        self.save_y1= self.y1 
     
    405443        self.x2= self.center_x - delta 
    406444        self.save_x2 = self.x2 
    407          
    408         self.color=color 
    409          
     445        ## save the color of the line 
     446        self.color = color 
     447        ## the height of the rectangle 
    410448        self.half_height= math.fabs(y) 
    411449        self.save_half_height= math.fabs(y) 
    412          
     450        ## the with of the rectangle 
    413451        self.half_width= math.fabs(self.x1- self.x2)/2 
    414452        self.save_half_width=math.fabs(self.x1- self.x2)/2 
    415          
     453        ## Create marker  
    416454        try: 
    417455            self.right_marker = self.axes.plot([self.x1],[0], linestyle='', 
     
    429467            message  = "\nTHIS PROTOTYPE NEEDS THE LATEST VERSION OF MATPLOTLIB\n" 
    430468            message += "Get the SVN version that is at least as recent as June 1, 2007" 
    431              
    432             #raise "Version error", message 
    433              
    434         # line 
     469            owner=self.base.base.parent 
     470            wx.PostEvent(owner, StatusEvent(status="AnnulusSlicer: %s"%message)) 
     471             
     472        ## define the left and right lines of the rectangle 
    435473        self.right_line = self.axes.plot([self.x1,self.x1],[self.y1,self.y2], 
    436474                                      linestyle='-', marker='', 
     
    441479                                      color=self.color, 
    442480                                      visible=True)[0] 
    443      
    444         self.npts = 30 
    445         self.has_move=False     
     481        ## Flag to determine if the lines have moved 
     482        self.has_move=False   
     483        ## connection the marker and draw the pictures   
    446484        self.connect_markers([self.right_marker]) 
    447485        self.update() 
     
    449487 
    450488    def set_layer(self, n): 
     489        """ 
     490            Allow adding plot to the same panel 
     491            @param n: the number of layer 
     492        """ 
    451493        self.layernum = n 
    452494        self.update() 
    453495         
     496         
    454497    def clear(self): 
     498        """ 
     499            Clear this figure and its markers 
     500        """ 
    455501        self.clear_markers() 
    456502        try: 
     
    462508            for item in range(len(self.axes.lines)): 
    463509                del self.axes.lines[0] 
    464          
    465     def get_radius(self): 
    466          
    467         return 0 
     510    
    468511    
    469512    def update(self,x1=None,x2=None, y1=None,y2=None,width=None, height=None, center=None): 
    470513        """ 
    471         Draw the new roughness on the graph. 
    472         """ 
    473         #print "self.half_height",self.half_height,self.half_width 
     514            Draw the new roughness on the graph. 
     515            @param x1: new maximum value of x coordinates 
     516            @param x2: new minimum value of x coordinates 
     517            @param y1: new maximum value of y coordinates 
     518            @param y2: new minimum value of y coordinates 
     519            @param width: is the width of the new rectangle 
     520            @param height: is the height of the new rectangle 
     521            @param center: provided x, y  coordinates of the center point 
     522        """ 
     523        ## save the new height, witdh of the rectangle if given as a param 
    474524        if width!=None: 
    475525            self.half_width= width 
    476526        if height!=None: 
    477527            self.half_height= height 
     528        ## If new  center coordinates are given draw the rectangle  
     529        ##given these value  
    478530        if center!=None: 
    479531            self.center_x= center.x 
    480532            self.center_y= center.y 
    481             #print "vertical width",self.half_width ,self.center_x 
     533             
    482534            self.x1 = self.half_width + self.center_x 
    483535            self.x2= -self.half_width + self.center_x 
     
    490542            self.left_line.set(xdata=[self.x2,self.x2], ydata=[self.y1,self.y2]) 
    491543            return  
     544        ## if x1, y1, y2, y3 are given draw the rectangle with this value 
    492545        if x1 !=None:  
    493546            self.x1= x1 
     
    498551        if y2 !=None:  
    499552            self.y2= y2 
    500          
    501         
    502         
     553        ## Draw 2 vertical lines and a marker  
    503554        self.right_marker.set(xdata=[self.x1],ydata=[self.center_y]) 
    504555        self.right_line.set(xdata=[self.x1,self.x1], ydata=[self.y1,self.y2]) 
     
    518569         
    519570        self.save_half_height= self.half_height 
    520         #self.save_half_width = math.fabs(self.x1-self.x2)/2 
    521571        self.save_half_width = self.half_width 
     572         
    522573        self.base.freeze_axes() 
    523574 
     575 
    524576    def moveend(self, ev): 
    525          
     577        """ 
     578            After a dragging motion reset the flag self.has_move to False 
     579        """ 
    526580        self.has_move=False 
    527581        self.base.moveend(ev) 
    528582             
     583             
    529584    def restore(self): 
    530585        """ 
     
    538593         
    539594        self.half_height= self.save_half_height 
    540         #self.half_width= math.fabs(self.x1-self.x2)/2 
    541595        self.half_width= self.save_half_width 
     596        
    542597        
    543598    def move(self, x, y, ev): 
     
    550605         
    551606        self.half_width= math.fabs(self.x1-self.x2)/2 
    552         #print "Move vert: vertical width",self.half_width ,self.center_x 
     607         
    553608        self.has_move=True 
    554609        self.base.base.update() 
    555610         
     611         
    556612    def set_cursor(self, x, y): 
     613        """ 
     614            Update the figure given x and y  
     615        """ 
    557616        self.move(x, y, None) 
    558617        self.update() 
     
    560619         
    561620    def get_params(self): 
     621        """ 
     622            Store a copy of values of parameters of the slicer into a dictionary. 
     623            @return params: the dictionary created 
     624        """ 
    562625        params = {} 
    563626        params["x"] = self.x1 
     
    567630     
    568631    def set_params(self, params): 
     632        """ 
     633            Receive a dictionary and reset the slicer with values contained  
     634            in the values of the dictionary. 
     635            @param params: a dictionary containing name of slicer parameters and  
     636            values the user assigned to the slicer. 
     637        """ 
    569638        x = params["x"]  
    570639        y = params["y"]  
    571640        self.update(x=x, y=y, center_x=None,center_y=None) 
    572641 
    573 class Horizontal_DoubleLine(_BaseInteractor): 
     642 
     643class HorizontalDoubleLine(_BaseInteractor): 
    574644    """ 
    575645         Select an annulus through a 2D plot 
     
    580650         
    581651        _BaseInteractor.__init__(self, base, axes, color=color) 
     652        ## Initialization the class  
    582653        self.markers = [] 
    583654        self.axes = axes 
    584         # center 
     655        ## Center coordinates 
    585656        self.center_x = center_x 
    586657        self.center_y = center_y 
     
    623694            message  = "\nTHIS PROTOTYPE NEEDS THE LATEST VERSION OF MATPLOTLIB\n" 
    624695            message += "Get the SVN version that is at least as recent as June 1, 2007" 
    625              
    626             #raise "Version error", message 
    627              
    628         # line 
     696            owner=self.base.base.parent 
     697            wx.PostEvent(owner, StatusEvent(status="AnnulusSlicer: %s"%message)) 
     698             
     699        # Define 2 horizotnal lines 
    629700        self.top_line = self.axes.plot([self.x1,-self.x1],[self.y1,self.y1], 
    630701                                      linestyle='-', marker='', 
     
    635706                                      color=self.color, 
    636707                                      visible=True)[0] 
    637      
    638         self.npts = 30 
     708        ## Flag to determine if the lines have moved 
    639709        self.has_move=False     
     710        ## connection the marker and draw the pictures  
    640711        self.connect_markers([self.top_marker]) 
    641712        self.update() 
     
    643714 
    644715    def set_layer(self, n): 
     716        """ 
     717            Allow adding plot to the same panel 
     718            @param n: the number of layer 
     719        """ 
    645720        self.layernum = n 
    646721        self.update() 
    647722         
     723         
    648724    def clear(self): 
     725        """ 
     726            Clear this figure and its markers 
     727        """ 
    649728        self.clear_markers() 
    650729        try: 
     
    656735            for item in range(len(self.axes.lines)): 
    657736                del self.axes.lines[0] 
    658          
    659     def get_radius(self): 
    660          
    661         return 0 
     737     
    662738    
    663739    def update(self,x1=None,x2=None, y1=None,y2=None,width=None,height=None, center=None): 
    664740        """ 
    665         Draw the new roughness on the graph. 
    666         """ 
    667         #print "self.half_width",self.half_width 
    668         if width!=None: 
    669             self.half_width= width 
    670         if height!=None: 
     741            Draw the new roughness on the graph. 
     742            @param x1: new maximum value of x coordinates 
     743            @param x2: new minimum value of x coordinates 
     744            @param y1: new maximum value of y coordinates 
     745            @param y2: new minimum value of y coordinates 
     746            @param width: is the width of the new rectangle 
     747            @param height: is the height of the new rectangle 
     748            @param center: provided x, y  coordinates of the center point 
     749        """ 
     750        ## save the new height, witdh of the rectangle if given as a param 
     751        if width != None: 
     752            self.half_width = width 
     753        if height!= None: 
    671754            self.half_height= height 
     755        ## If new  center coordinates are given draw the rectangle  
     756        ##given these value  
    672757        if center!=None: 
    673758            self.center_x= center.x 
     
    684769            self.bottom_line.set(xdata=[self.x1,self.x2], ydata=[self.y2,self.y2]) 
    685770            return  
     771        ## if x1, y1, y2, y3 are given draw the rectangle with this value 
    686772        if x1 !=None:  
    687773            self.x1= x1 
     
    692778        if y2 !=None:  
    693779            self.y2= y2 
    694         
    695               
     780        ## Draw 2 vertical lines and a marker  
    696781        self.top_marker.set(xdata=[self.center_x],ydata=[self.y1]) 
    697782        self.top_line.set(xdata=[self.x1,self.x2], ydata=[self.y1,self.y1]) 
     
    699784        
    700785         
    701          
    702786    def save(self, ev): 
    703787        """ 
     
    717801 
    718802    def moveend(self, ev): 
    719          
     803        """ 
     804            After a dragging motion reset the flag self.has_move to False 
     805        """ 
    720806        self.has_move=False 
    721807        self.base.moveend(ev) 
     808            
    722809             
    723810    def restore(self): 
     
    732819        self.half_height= self.save_half_height 
    733820        self.half_width= self.save_half_width 
     821         
    734822         
    735823    def move(self, x, y, ev): 
     
    744832        self.base.base.update() 
    745833         
     834         
    746835    def set_cursor(self, x, y): 
     836        """ 
     837            Update the figure given x and y  
     838        """ 
    747839        self.move(x, y, None) 
    748840        self.update() 
     
    750842         
    751843    def get_params(self): 
     844        """ 
     845            Store a copy of values of parameters of the slicer into a dictionary. 
     846            @return params: the dictionary created 
     847        """ 
    752848        params = {} 
    753849        params["x"] = self.x 
    754850        params["y"] = self.y 
    755          
    756851        return params 
    757852     
     853     
    758854    def set_params(self, params): 
     855        """ 
     856            Receive a dictionary and reset the slicer with values contained  
     857            in the values of the dictionary. 
     858            @param params: a dictionary containing name of slicer parameters and  
     859            values the user assigned to the slicer. 
     860        """ 
    759861        x = params["x"]  
    760862        y = params["y"]  
    761863        self.update(x=x, y=y, center_x=None,center_y=None) 
    762864          
     865          
     866          
Note: See TracChangeset for help on using the changeset viewer.