Changeset c73d871 in sasview for guiframe/local_perspectives


Ignore:
Timestamp:
Jan 7, 2009 2:14:06 PM (16 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:
d054809
Parents:
b6b1669
Message:

working on boxslicer

Location:
guiframe/local_perspectives/plotting
Files:
2 edited

Legend:

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

    r7ab9241 rc73d871  
    317317        self.radius= math.sqrt( math.pow(self.qmax,2)+math.pow(self.qmax,2))  
    318318        print "radius?",self.radius 
    319         Circle = CircularAverage( r_min=0, r_max=self.radius, bin_width=0.001) 
    320         #Circle = CircularAverage( r_min=0, r_max=13705.0, bin_width=BIN_WIDTH ) 
    321         #Circle = CircularAverage( r_min= -1, r_max= 1, bin_width=0.001 ) 
    322         #Circle = CircularAverage( r_min= -1*self.radius, r_max= self.radius, bin_width=0.001 ) 
     319        # bin_width = self.qmax -self.qmin/nbins  
     320        #nbins= 30 
     321        bin_width = (self.qmax +self.qmax)/30 
     322         
     323        Circle = CircularAverage( r_min=0, r_max=self.radius, bin_width=bin_width) 
     324        
    323325        circ = Circle(self.data2D) 
    324326        from sans.guiframe.dataFitting import Data1D 
  • guiframe/local_perspectives/plotting/boxSlicer.py

    rb6b1669 rc73d871  
    2121         Select an annulus through a 2D plot 
    2222    """ 
    23     def __init__(self,base,axes,color='black', zorder=3, x_min=0.0025, x_max=0.0025, y_min=0.0025, y_max=0.0025): 
     23    def __init__(self,base,axes,color='black', zorder=3, 
     24                  x_min=0.0025, x_max=0.0025, y_min=0.0025, y_max=0.0025): 
    2425         
    2526        _BaseInteractor.__init__(self, base, axes, color=color) 
     
    3940        self.count=0 
    4041        self.error=0 
    41         self.main_line = LineInteractor(self, self.base.subplot,color='orange', zorder=zorder, r=self.qmax, 
     42        self.main_line = LineInteractor(self, self.base.subplot,color='orange', 
     43                                         zorder=zorder, r=self.qmax, 
    4244                                           theta= self.theta2) 
    4345        self.main_line.qmax = self.base.qmax 
    4446         
    45         self.left_line = VerticalLine(self, self.base.subplot,color='blue', zorder=zorder,  
    46                                         ymin= self.ymin, ymax= self.ymax, 
    47                                         x=self.xmin, 
     47        self.left_line = VerticalLine(self, self.base.subplot,color='blue',  
     48                                      zorder=zorder, 
     49                                      mline= self.main_line,  
     50                                        ymin= self.ymin ,  
     51                                        ymax= self.ymax , 
     52                                        xmin=self.xmin, 
     53                                        xmax=self.xmin, 
    4854                                        theta2= self.theta2) 
    4955        self.left_line.qmax = self.base.qmax 
    5056         
    51         self.right_line= VerticalLine(self, self.base.subplot,color='black', zorder=zorder, 
    52                                      ymin= self.ymin, ymax= self.ymax, 
    53                                      x=self.xmax, 
    54                                       theta2= self.theta2) 
     57        self.right_line= VerticalLine(self, self.base.subplot,color='black',  
     58                                      zorder=zorder, 
     59                                      mline= self.main_line,  
     60                                     ymin= self.ymin ,  
     61                                     ymax= self.ymax, 
     62                                    xmin= self.xmax, 
     63                                    xmax= self.xmax, 
     64                                    theta2= self.theta2) 
    5565        self.right_line.qmax = self.base.qmax 
    56          
    57         self.top_line= HorizontalLine(self, self.base.subplot,color='green', zorder=zorder, 
     66        """ 
     67        self.left_line = VerticalLine(self, self.base.subplot,color='blue',  
     68                                      zorder=zorder,  
     69                                        ymin= self.main_line.y2 ,  
     70                                        ymax= self.main_line.y1 , 
     71                                        xmin=self.main_line.x2 +self.xmin, 
     72                                        xmax=self.main_line.x1 +self.xmin, 
     73                                        theta2= self.theta2) 
     74        self.left_line.qmax = self.base.qmax 
     75         
     76        self.right_line= VerticalLine(self, self.base.subplot,color='black',  
     77                                      zorder=zorder, 
     78                                     ymin= self.main_line.y2 ,  
     79                                     ymax= self.main_line.y1 , 
     80                                    xmin=self.main_line.x2 +self.xmax, 
     81                                    xmax=self.main_line.x1 +self.xmax, 
     82                                    theta2= self.theta2) 
     83        self.right_line.qmax = self.base.qmax 
     84        self.top_line= HorizontalLine(self, self.base.subplot,color='green',  
     85                                      zorder=zorder, 
    5886                                    y= self.ymax, 
    5987                                    xmin= self.xmin, xmax= self.xmax, 
     
    6189        self.top_line.qmax = self.base.qmax 
    6290         
    63         self.bottom_line= HorizontalLine(self, self.base.subplot,color='red', zorder=zorder, 
     91        self.bottom_line= HorizontalLine(self, self.base.subplot,color='red', 
     92                                          zorder=zorder, 
    6493                                    y =self.ymin, 
    6594                                    xmin= self.xmin, xmax= self.xmax, 
     
    6897        #self.outer_circle.set_cursor(self.base.qmax/1.8, 0) 
    6998         
    70                        
     99           """            
    71100        self.update() 
    72101        #self._post_data() 
     
    105134        self.left_line.clear() 
    106135        self.right_line.clear() 
    107         self.top_line.clear() 
    108         self.bottom_line.clear() 
     136        #self.top_line.clear() 
     137        #self.bottom_line.clear() 
    109138        self.main_line.clear() 
    110139        #self.base.connect.disconnect() 
     
    118147         
    119148        if self.main_line.has_move: 
    120             print "main has move" 
     149             
    121150            self.main_line.update() 
    122             self.left_line.update(mline= self.main_line) 
    123             self.right_line.update(mline= self.main_line) 
    124             self.top_line.update(mline= self.main_line) 
    125             self.bottom_line.update(mline= self.main_line) 
     151            self.left_line.update(mline= self.main_line, 
     152                                  xmin= self.xmin, 
     153                                  xmax= self.xmin, 
     154                                  ymin= self.ymin, 
     155                                  ymax=self.ymax, 
     156                                  translation=True) 
     157            self.right_line.update(mline= self.main_line, 
     158                                   xmin= self.xmax, 
     159                                  xmax= self.xmax, 
     160                                  ymin= self.ymin, 
     161                                  ymax=self.ymax, 
     162                                  translation=True) 
     163            #self.top_line.update(mline= self.main_line) 
     164            #self.bottom_line.update(mline= self.main_line) 
    126165         
    127166        if self.left_line.has_move: 
    128167            print "left has moved" 
    129             self.left_line.update(translation=True) 
    130             self.right_line.update(xmin=-1*self.left_line.xmin, 
    131                                    xmax=-1*self.left_line.xmax, 
    132                                    ymin=self.left_line.ymin, 
    133                                    ymax=self.left_line.ymax, 
     168            self.left_line.update(mline= self.main_line, 
     169                                  xmin= self.xmin, 
     170                                  translation=True) 
     171            self.right_line.update(mline= self.main_line, 
     172                                   xmin=-1*self.xmin, 
    134173                                   translation=True) 
     174            """ 
    135175            self.top_line.update( xmin= self.left_line.xmax ,xmax= self.right_line.xmax, 
    136176                                  translation=True) 
    137177            self.bottom_line.update(xmin= self.left_line.xmin ,xmax= self.right_line.xmin, 
    138178                                    translation=True) 
     179            """ 
    139180        if self.right_line.has_move: 
    140181            print "right has moved" 
    141             self.right_line.update(translation=True) 
    142             self.left_line.update(xmin=-1*self.right_line.xmin, 
    143                                   xmax=-1*self.right_line.xmax, 
     182            self.right_line.update(mline= self.main_line, 
     183                                  xmin= self.xmax, 
    144184                                  translation=True) 
     185            self.left_line.update(mline= self.main_line, 
     186                                   xmin=-1*self.xmax, 
     187                                   translation=True) 
     188            """ 
    145189            self.top_line.update( xmin= self.left_line.xmax ,xmax= self.right_line.xmax, 
    146190                                  translation=True) 
    147191            self.bottom_line.update(xmin= self.left_line.xmin ,xmax= self.right_line.xmin, 
    148192                                    translation=True) 
    149              
    150              
     193            """ 
     194             
     195        """    
    151196        if self.bottom_line.has_move: 
    152197            print "bottom has moved" 
     
    170215            self.right_line.update(ymin= self.bottom_line.ymin ,ymax= self.top_line.ymax, 
    171216                                   translation=True) 
    172              
     217        """ 
    173218     
    174219    def save(self, ev): 
     
    186231        from DataLoader.manipulations import  Boxavg 
    187232        radius = math.sqrt(math.pow(self.qmax,2)+math.pow(self.qmax,2)) 
    188         x_min= self.left_line.x  
    189         x_max= self.right_line.x  
    190         y_min= self.bottom_line.y 
    191         y_max= self.top_line.y 
    192         box =  Boxavg (x_min=x_min, x_max=x_max, y_min=y_min, y_max=y_max) 
     233        x_min= self.left_line.xmin  
     234        x_max= self.right_line.xmax  
     235        #y_min= self.bottom_line.y 
     236        #y_max= self.top_line.y 
     237        #box =  Boxavg (x_min=x_min, x_max=x_max, y_min=y_min, y_max=y_max) 
    193238        
    194         self.count, self.error= box(self.base.data2D) 
     239        #self.count, self.error= box(self.base.data2D) 
    195240         
    196241         
     
    226271    def get_params(self): 
    227272        params = {} 
    228         params["x_min"] = self.left_line.xmin  
    229         params["x_max"] = self.right_line.xmax  
    230         params["y_min"] = self.bottom_line.y 
    231         params["y_max"] = self.top_line.y 
     273        params["x_min"] = self.left_line.L_width 
     274        params["x_max"] = self.right_line.R_width 
     275        #params["y_min"] = self.bottom_line.y 
     276        #params["y_max"] = self.top_line.y 
    232277        params["count"] = self.count 
    233278        params["error"] = self.error 
     
    239284        x_min = params["x_min"]  
    240285        x_max = params["x_max"]  
    241         y_min = params["y_min"] 
    242         y_max = params["y_max"]  
     286        #y_min = params["y_min"] 
     287        #y_max = params["y_max"]  
    243288        theta = params["theta"] 
    244289         
    245290        self.left_line.update(ymin= y_min ,ymax= y_max) 
    246291        self.right_line.update(ymin= y_min ,ymax= y_max) 
    247         self.top_line.update( xmin= x_min ,xmax= xmax) 
    248         self.bottom_line.update(xmin= xmin ,xmax= xmax) 
     292        #self.top_line.update( xmin= x_min ,xmax= xmax) 
     293        #self.bottom_line.update(xmin= xmin ,xmax= xmax) 
    249294        self.main_line.update(theta) 
    250295         
     
    287332        self.deltax=0 
    288333        self.deltay=0 
     334         
    289335        x1= self.xmin*math.cos(self.theta2)- self.y*math.sin(self.theta2) 
    290336        self.ymin= self.xmin*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 
     
    298344                                      visible=True)[0] 
    299345  
    300  
     346         
     347         
    301348        self.npts = 20 
    302349        self.has_move=False 
     
    324371        self.clickx,self.clicky = ev.xdata,ev.ydata 
    325372        print "onclick",self.clickx,self.clicky 
     373         
     374        
    326375        #self.save(ev) 
    327376        return True    
     
    400449        Process move to a new position, making sure that the move is allowed. 
    401450        """ 
     451        """ 
     452        a=(1,1) 
     453        transform = self.base.connect._hasclick.artist.get_transform() 
     454        print "transform", self.base.connect.rotation_matrix(angle=math.pi/4, direction=(1, 0, 0), point=a) 
     455        """ 
    402456         
    403457        self.has_move=True 
     
    427481         Select an annulus through a 2D plot 
    428482    """ 
    429     def __init__(self,base,axes,color='black', zorder=5, ymin=0.0,  
    430                  ymax=0.5,x=0.5, 
     483    def __init__(self,base,axes,color='black', zorder=5, mline=None, ymin=0.0,  
     484                 ymax=0.5,xmin=-0.5,xmax=0.5, 
    431485                 theta2= math.pi/3 ): 
    432486         
     
    434488        self.markers = [] 
    435489        self.axes = axes 
    436         # x coordinate of the vertical line 
    437         self.x= x 
    438         self.save_x = x 
    439          
    440         # minimum value of y coordinate of the vertical line  
    441         self.ymin = ymin 
    442         self.save_ymin = ymin 
    443         # maximum value of y coordinate of the vertical line  
     490        self.L_width=xmin 
     491        self.save_xmin= xmin 
     492        self.R_width=xmax 
     493        self.save_xmax=xmax 
     494        self.ymin=ymin 
     495        self.save_ymin= ymin 
    444496        self.ymax=ymax 
    445         self.save_ymax=ymax 
    446         #insure rotation 
     497        self.save_ymax= ymax 
    447498        self.theta2= theta2 
    448          
    449         # Draw vertical line 
    450         self.xmin= self.x* math.cos(self.theta2)-self.ymin *math.sin(self.theta2) 
    451         self.xmax= self.x* math.cos(self.theta2)-self.ymax *math.sin(self.theta2) 
    452          
    453         self.ymin= self.x* math.sin(self.theta2)+self.ymin *math.cos(self.theta2) 
    454         self.ymax= self.x* math.sin(self.theta2)+self.ymax *math.cos(self.theta2) 
    455          
    456         self.clickx=self.xmin 
    457         self.clicky=self.ymin 
    458         self.clickxf=self.xmin 
    459         self.clickyf=self.ymin 
    460         self.deltax=0 
     499        self.mline= mline 
     500        """ 
     501        x1= self.xmin*math.cos(self.theta2)- self.y*math.sin(self.theta2) 
     502        self.ymin= self.xmin*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 
     503         
     504        x2= self.xmax*math.cos(self.theta2)- self.y*math.sin(self.theta2) 
     505        self.ymax= self.xmax*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 
     506        """ 
     507        self.detax=0 
    461508        self.deltay=0 
    462         self.line = self.axes.plot([self.xmin,self.xmax],[self.ymin,self.ymax], 
     509         
     510        self.clickx=0 
     511        self.clicky=0 
     512        self.clickxf=0 
     513        self.clickyf=0 
     514        self.x1= mline.x1 + xmin*math.cos(math.pi/2 - self.theta2) 
     515        self.x2= mline.x2 + xmin*math.cos(math.pi/2 - self.theta2) 
     516        self.y1= mline.y1 - xmin*math.sin(math.pi/2 - self.theta2) 
     517        self.y2= mline.y2 - xmin*math.sin(math.pi/2 - self.theta2) 
     518         
     519        self.line = self.axes.plot([self.x1,self.x2],[self.y1,self.y2], 
    463520                                      linestyle='-', marker='', 
    464521                                      color=self.color, 
     
    484541            for item in range(len(self.axes.lines)): 
    485542                del self.axes.lines[0] 
    486     def onClick(self, ev): 
    487         """ 
    488         Prepare to move the artist.  Calls save() to preserve the state for 
    489         later restore(). 
    490         """ 
    491         self.clickx,self.clicky = ev.xdata,ev.ydata 
    492         print "onclick",self.clickx,self.clicky 
    493         #self.save(ev) 
    494         return True    
    495  
     543    
     544    #def onClick(self, ev): 
     545    #    """ 
     546        #Prepare to move the artist.  Calls save() to preserve the state for 
     547        #later restore(). 
     548        #""" 
     549    #    self.clickx,self.clicky = ev.xdata,ev.ydata 
     550    #    print "onclick",self.clickx,self.clicky 
     551    #    self.save(ev) 
     552    #    return True    
     553     
    496554    def get_radius(self): 
    497555        return 0 
     
    501559        Draw the new roughness on the graph. 
    502560        """ 
    503         if translation : 
    504             self.deltax = self.clickxf- self.clickx 
    505             self.deltay = self.clickyf-self.clicky 
    506              
    507             self.xmin= self.xmin + self.deltax 
    508             self.xmax=self.xmax + self.deltax 
    509             self.ymin= self.ymin + self.deltay 
    510             self.ymax=self.ymax + self.deltay 
    511              
    512             if xmin !=None: 
    513                 self.xmin=xmin 
    514             if xmax !=None: 
    515                 self.xmax=xmax 
    516             if ymin !=None: 
    517                 self.ymin = ymin 
    518             if ymax !=None: 
    519                 self.ymax = ymax 
    520             self.line.set(xdata=[self.xmin, self.xmax], 
    521                           ydata=[self.ymin, self.ymax]) 
    522         if mline !=None: 
    523              
    524             self.theta2= mline.theta 
    525             delta = mline.get_delta_angle() 
    526             if translation: 
    527                 delta= 0 
    528             self.xmin= self.x* math.cos(self.theta2)-self.ymin *math.sin(self.theta2) 
    529             self.xmax= self.x* math.cos(self.theta2)-self.ymax *math.sin(self.theta2) 
    530          
    531             self.ymin= self.x* math.sin(self.theta2)+self.ymin *math.cos(self.theta2) 
    532             self.ymax= self.x* math.sin(self.theta2)+self.ymax *math.cos(self.theta2) 
    533          
    534  
    535             self.line.set(xdata=[self.xmin,self.xmax], ydata=[self.ymin,self.ymax])   
     561         
     562        if xmin== None: 
     563            xmin= self.L_width 
     564        if xmax== None: 
     565            xmax= self.R_width 
     566        print "vertical line: xmin, xmax , ymin , ymax", xmin, self.mline.theta 
     567        self.x1= self.mline.x1 + xmin*math.cos(math.pi/2 - self.mline.theta) 
     568        self.x2= self.mline.x2 + xmin*math.cos(math.pi/2 - self.mline.theta) 
     569        self.y1= self.mline.y1 - xmin*math.sin(math.pi/2 - self.mline.theta) 
     570        self.y2= self.mline.y2 - xmin*math.sin(math.pi/2 - self.mline.theta) 
     571        print "vertical line: main line  value ", self.mline.x1, self.mline.x2, self.mline.y1,self.mline.y2 
     572        print "vertical line: new value ", self.x1, self.x2, self.y1,self.y2 
     573 
     574        self.line.set(xdata=[self.x1,self.x2], ydata=[self.y1,self.y2])   
    536575            
    537               
    538          
     576        if translation: 
     577            self.deltax= self.clickxf +self.clickx 
     578            self.deltay= self.clickyf +self.clicky 
     579            print"translation deltax deltay", self.deltax, self.deltay 
     580            self.x1=self.x1 +self.deltax 
     581            self.y1=self.y1+ self.deltay 
     582            self.x2=self.x2+ self.deltax 
     583            self.y2=self.y2+self.deltay 
     584            self.line.set(xdata=[self.x1,self.x2], ydata=[self.y1,self.y2])  
    539585    def save(self, ev): 
    540586        """ 
     
    619665             
    620666        # Inner circle 
    621         x1= self.radius*math.cos(self.theta) 
    622         y1= self.radius*math.sin(self.theta) 
    623         x2= -1*self.radius*math.cos(self.theta) 
    624         y2= -1*self.radius*math.sin(self.theta) 
     667        self.x1= self.radius*math.cos(self.theta) 
     668        self.y1= self.radius*math.sin(self.theta) 
     669        self.x2= -1*self.radius*math.cos(self.theta) 
     670        self.y2= -1*self.radius*math.sin(self.theta) 
    625671        
    626         self.line = self.axes.plot([x1,x2],[y1,y2], 
     672        self.line = self.axes.plot([self.x1,self.x2],[self.y1,self.y2], 
    627673                                      linestyle='-', marker='', 
    628674                                      color=self.color, 
     
    672718            self.radius =radius 
    673719        print "update main line", math.degrees(self.theta) 
    674         x1= self.radius*math.cos(self.theta) 
    675         y1= self.radius*math.sin(self.theta) 
    676         x2= -1*self.radius*math.cos(self.theta) 
    677         y2= -1*self.radius*math.sin(self.theta) 
     720        self.x1= self.radius*math.cos(self.theta) 
     721        self.y1= self.radius*math.sin(self.theta) 
     722        self.x2= -1*self.radius*math.cos(self.theta) 
     723        self.y2= -1*self.radius*math.sin(self.theta) 
    678724       
    679         self.line.set(xdata=[x1,x2], ydata=[y1,y2])   
     725        self.line.set(xdata=[self.x1,self.x2], ydata=[self.y1,self.y2])   
    680726      
    681727         
Note: See TracChangeset for help on using the changeset viewer.