Changeset 030873e in sasview for guiframe


Ignore:
Timestamp:
Jan 7, 2009 5:30:29 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:
116da060
Parents:
d5a792a
Message:

working on boxslicer translation

File:
1 edited

Legend:

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

    rd5a792a r030873e  
    4141        self.error=0 
    4242        self.main_line = LineInteractor(self, self.base.subplot,color='orange', 
    43                                          zorder=zorder, r=self.qmax, 
     43                                         zorder=zorder, ymin=y_min ,ymax=y_max, 
    4444                                           theta= self.theta2) 
    4545        self.main_line.qmax = self.base.qmax 
     
    6464                                    theta2= self.theta2) 
    6565        self.right_line.qmax = self.base.qmax 
    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 
     66         
    8467        self.top_line= HorizontalLine(self, self.base.subplot,color='green',  
    8568                                      zorder=zorder, 
    86                                     y= self.ymax, 
    87                                     xmin= self.xmin, xmax= self.xmax, 
    88                                      theta2= self.theta2) 
    89         self.top_line.qmax = self.base.qmax 
    90          
    91         self.bottom_line= HorizontalLine(self, self.base.subplot,color='red', 
    92                                           zorder=zorder, 
    93                                     y =self.ymin, 
    94                                     xmin= self.xmin, xmax= self.xmax, 
    95                                      theta2= self.theta2) 
    96         self.bottom_line.qmax = self.base.qmax 
    97         #self.outer_circle.set_cursor(self.base.qmax/1.8, 0) 
    98          
    99            """            
     69                                      mline= self.main_line, 
     70                                      xmin=self.right_line.x1, 
     71                                      xmax=self.left_line.x1, 
     72                                      ymin=self.right_line.y1, 
     73                                      ymax=self.left_line.y1) 
     74        self.top_line.qmax= self.base.qmax 
     75         
     76        self.bottom_line= HorizontalLine(self, self.base.subplot,color='grey',  
     77                                      zorder=zorder, 
     78                                      mline= self.main_line, 
     79                                      xmin=self.right_line.x2, 
     80                                      xmax=self.left_line.x2, 
     81                                      ymin=self.right_line.y2, 
     82                                      ymax=self.left_line.y2) 
     83        self.bottom_line.qmax= self.base.qmax 
    10084        self.update() 
    10185        #self._post_data() 
     
    134118        self.left_line.clear() 
    135119        self.right_line.clear() 
    136         #self.top_line.clear() 
    137         #self.bottom_line.clear() 
     120        self.top_line.clear() 
     121        self.bottom_line.clear() 
    138122        self.main_line.clear() 
    139123        #self.base.connect.disconnect() 
     
    161145                                  ymax=self.ymax, 
    162146                                  translation=True) 
    163             #self.top_line.update(mline= self.main_line) 
    164             #self.bottom_line.update(mline= self.main_line) 
    165          
     147            self.top_line.update(xmin= self.right_line.x1, 
     148                                 xmax= self.left_line.x1, 
     149                                 ymin= self.right_line.y1, 
     150                                 ymax= self.left_line.y1) 
     151            self.bottom_line.update(xmin= self.right_line.x2, 
     152                                 xmax= self.left_line.x2, 
     153                                 ymin= self.right_line.y2, 
     154                                 ymax= self.left_line.y2) 
    166155        if self.left_line.has_move: 
    167156            print "left has moved" 
    168157            self.left_line.update() 
    169158            self.right_line.update(opline= self.left_line ) 
    170             """ 
    171             self.top_line.update( xmin= self.left_line.xmax ,xmax= self.right_line.xmax, 
    172                                   translation=True) 
    173             self.bottom_line.update(xmin= self.left_line.xmin ,xmax= self.right_line.xmin, 
    174                                     translation=True) 
    175             """ 
     159             
     160            self.top_line.update(xmin= self.right_line.x2, 
     161                                 xmax= self.left_line.x1, 
     162                                 ymin= self.right_line.y2, 
     163                                 ymax= self.left_line.y1) 
     164             
     165             
     166            self.bottom_line.update(xmin= self.right_line.x1, 
     167                                 xmax= self.left_line.x2, 
     168                                 ymin= self.right_line.y1, 
     169                                 ymax= self.left_line.y2) 
     170            
    176171        if self.right_line.has_move: 
    177172            print "right has moved" 
    178173            self.right_line.update() 
    179174            self.left_line.update(opline= self.right_line ) 
    180             """ 
    181             self.top_line.update( xmin= self.left_line.xmax ,xmax= self.right_line.xmax, 
    182                                   translation=True) 
    183             self.bottom_line.update(xmin= self.left_line.xmin ,xmax= self.right_line.xmin, 
    184                                     translation=True) 
    185             """ 
    186              
    187         """    
    188         if self.bottom_line.has_move: 
    189             print "bottom has moved" 
    190             self.bottom_line.update(translation=True) 
    191             self.top_line.update(ymin= -1*self.bottom_line.ymin, 
    192                                  ymax =-1*self.bottom_line.ymax, 
    193                                  translation=True) 
    194             self.left_line.update( ymin= self.bottom_line.ymin ,ymax= self.top_line.ymax, 
    195                                    translation=True) 
    196             self.right_line.update(ymin= self.bottom_line.ymin,ymax= self.top_line.ymax, 
    197                                    translation=True) 
    198              
     175             
     176            self.top_line.update(xmin= self.right_line.x1, 
     177                                 xmax= self.left_line.x2, 
     178                                 ymin= self.right_line.y1, 
     179                                 ymax= self.left_line.y2) 
     180             
     181            self.bottom_line.update(xmin= self.right_line.x2, 
     182                                 xmax= self.left_line.x1, 
     183                                 ymin= self.right_line.y2, 
     184                                 ymax= self.left_line.y1) 
    199185        if self.top_line.has_move: 
    200             print "top has moved" 
    201             self.top_line.update(mline= self.main_line,translation=True) 
    202             self.bottom_line.update(ymin= -1*self.top_line.ymin, 
    203                                     ymax=-1*self.top_line.ymax, 
    204                                     translation=True ) 
    205             self.left_line.update(ymin= self.bottom_line.ymin ,ymax= self.top_line.ymax, 
    206                                   translation=True) 
    207             self.right_line.update(ymin= self.bottom_line.ymin ,ymax= self.top_line.ymax, 
    208                                    translation=True) 
    209         """ 
    210      
     186            self.top_line.update(translation=True) 
    211187    def save(self, ev): 
    212188        """ 
     
    300276         Select an annulus through a 2D plot 
    301277    """ 
    302     def __init__(self,base,axes,color='black', zorder=5, y=0.5, 
     278    def __init__(self,base,axes,color='black', zorder=5,mline=None,ymin=None, ymax=None, y=0.5, 
    303279                 xmin=0.0,xmax=0.5, 
    304280                 theta2= math.pi/3 ): 
     
    308284        self.axes = axes 
    309285         
    310         self.y= y 
    311         self.save_y = y  
    312          
     286        self.ymin= ymin 
     287        self.save_ymin = ymin 
     288        self.mline = mline 
     289        self.ymax= ymax 
     290        self.save_ymax = ymax 
    313291        self.xmin = xmin 
    314292        self.save_xmin = xmin 
    315293        self.xmax = xmax 
    316294        self.save_xmax = xmax 
     295        self.top_hight= self.ymax 
    317296         
    318297        self.theta2 = theta2 
    319298         
    320         self.clickx=self.xmin 
    321         self.clicky=self.y 
    322         self.clickxf=self.xmin 
    323         self.clickyf=self.y 
    324         self.deltax=0 
    325         self.deltay=0 
    326          
    327         x1= self.xmin*math.cos(self.theta2)- self.y*math.sin(self.theta2) 
    328         self.ymin= self.xmin*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 
    329          
    330         x2= self.xmax*math.cos(self.theta2)- self.y*math.sin(self.theta2) 
    331         self.ymax= self.xmax*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 
    332         #print "x1, y1", x1, y1, x2,y2 
    333         self.line = self.axes.plot([x1,x2],[self.ymin,self.ymax], 
     299        self.line = self.axes.plot([self.xmax,self.xmin], 
     300                                   [self.ymax,self.ymin], 
    334301                                      linestyle='-', marker='', 
    335302                                      color=self.color, 
     
    341308        self.has_move=False 
    342309        self.connect_markers([self.line]) 
    343         self.update() 
     310        self.update(xmin= self.xmin, 
     311                    xmax= self.xmax, 
     312                    ymin= self.ymin, 
     313                    ymax=  self.ymax) 
    344314 
    345315    def set_layer(self, n): 
     
    356326            for item in range(len(self.axes.lines)): 
    357327                del self.axes.lines[0] 
    358     def onClick(self, ev): 
    359         """ 
    360         Prepare to move the artist.  Calls save() to preserve the state for 
    361         later restore(). 
    362         """ 
    363         self.clickx,self.clicky = ev.xdata,ev.ydata 
    364         print "onclick",self.clickx,self.clicky 
    365          
    366         
    367         #self.save(ev) 
    368         return True    
     328    
    369329    def get_radius(self): 
    370330         
     
    375335        Draw the new roughness on the graph. 
    376336        """ 
     337        if translation : 
     338            print "translation ",self.top_hight 
     339            self.x1= self.xmax + self.top_hight*math.sin(math.pi/2 + self.mline.theta) 
     340            self.x2= self.xmin + self.top_hight*math.sin(math.pi/2 + self.mline.theta) 
     341            self.y1= self.ymin - self.top_hight*math.cos(math.pi/2 + self.mline.theta) 
     342            self.y2= self.ymax -self.top_hight*math.cos(math.pi/2 + self.mline.theta) 
     343            self.line.set(xdata=[self.x1,self.x2], 
     344                       ydata=[self.y1,self.y2]) 
     345            return 
    377346        #print "update main line", self.has_move 
    378          
    379         if translation : 
    380             self.deltax = self.clickxf- self.clickx 
    381             self.deltay = self.clickyf-self.clicky 
    382              
    383             self.xmin= self.xmin +self.deltax 
    384             self.xmax=self.xmax+self.deltax 
    385             self.ymin= self.ymin +self.deltay 
    386             self.ymax=self.ymax+self.deltay 
    387              
    388             if xmin !=None: 
    389                 self.xmin=xmin 
    390             if xmax !=None: 
    391                 self.xmax=xmax 
    392             if ymin !=None: 
    393                 self.ymin = ymin 
    394             if ymax !=None: 
    395                 self.ymax = ymax 
    396             self.line.set(xdata=[self.xmin, self.xmax], 
    397                           ydata=[self.ymin, self.ymax]) 
    398         if mline !=None: 
    399             self.theta2= mline.theta 
    400              
    401             x1= self.xmin*math.cos(self.theta2)- self.y*math.sin(self.theta2) 
    402             y1= self.xmin*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 
    403          
    404             x2= self.xmax*math.cos(self.theta2)- self.y*math.sin(self.theta2) 
    405             y2= self.xmax*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 
    406              
    407             self.line.set(xdata=[x1,x2], ydata=[y1,y2])  
    408             print x1,x2,y1,y2 
    409             
    410         #else: 
    411         #    self.line.set(xdata=[self.xmin,self.xmax], ydata=[self.y,self.y]) 
    412       
     347        self.xmin=xmin 
     348        self.xmax=xmax 
     349        self.ymin=ymin 
     350        self.ymax=ymax 
     351        self.line.set(xdata=[self.xmin,self.xmax], 
     352                       ydata=[self.ymin,self.ymax]) 
     353     
    413354         
    414355         
     
    421362        self.save_xmax= self.xmax 
    422363        
    423         self.save_y= self.y 
     364        self.save_ymin= self.ymin 
     365        self.save_ymax= self.ymax 
     366        self.top_hight= self.ymax 
    424367        self.base.freeze_axes() 
    425368 
    426369    def moveend(self, ev): 
    427         self.clickxf,self.clickyf = ev.xdata,ev.ydata 
    428         print "move end ",self.clickxf,self.clickyf 
     370        
    429371        self.has_move=False 
    430372        self.base.moveend(ev) 
     
    434376        Restore the roughness for this layer. 
    435377        """ 
     378        self.xmin = self.save_xmin 
     379        self.xmax = self.save_xmax 
    436380        self.ymin = self.save_ymin 
    437381        self.ymax = self.save_ymax 
     
    441385        Process move to a new position, making sure that the move is allowed. 
    442386        """ 
    443         """ 
    444         a=(1,1) 
    445         transform = self.base.connect._hasclick.artist.get_transform() 
    446         print "transform", self.base.connect.rotation_matrix(angle=math.pi/4, direction=(1, 0, 0), point=a) 
    447         """ 
    448          
     387         
     388        self.top_hight= y 
    449389        self.has_move=True 
    450390        self.base.base.update() 
     
    480420        self.markers = [] 
    481421        self.axes = axes 
     422         
    482423        self.L_width=xmin 
     424        self.save_L_width=xmin 
     425         
    483426        self.save_xmin= xmin 
    484427        self.R_width=xmax 
     
    488431        self.ymax=ymax 
    489432        self.save_ymax= ymax 
     433         
    490434        self.theta2= theta2 
     435         
    491436        self.mline= mline 
    492         """ 
    493         x1= self.xmin*math.cos(self.theta2)- self.y*math.sin(self.theta2) 
    494         self.ymin= self.xmin*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 
    495          
    496         x2= self.xmax*math.cos(self.theta2)- self.y*math.sin(self.theta2) 
    497         self.ymax= self.xmax*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 
    498         """ 
     437       
    499438        self.detax=0 
    500439        self.deltay=0 
     
    533472                del self.axes.lines[0] 
    534473    
    535     #def onClick(self, ev): 
    536     #    """ 
    537         #Prepare to move the artist.  Calls save() to preserve the state for 
    538         #later restore(). 
    539         #""" 
    540     #    self.clickx,self.clicky = ev.xdata,ev.ydata 
    541     #    print "onclick",self.clickx,self.clicky 
    542     #    self.save(ev) 
    543     #    return True    
    544474     
    545475    def get_radius(self): 
     
    551481        """ 
    552482        if opline !=None: 
    553             self.line.set(xdata=[-1*opline.x1,-1*opline.x2], 
    554                            ydata=[-opline.y1,-opline.y2])  
     483            self.x1= -1*opline.x1 
     484            self.x2= -1*opline.x2 
     485            self.y1= -1*opline.y1 
     486            self.y2= -1*opline.y2 
     487            self.line.set(xdata=[self.x1,self.x2], 
     488                           ydata=[self.y1,self.y2])  
    555489            return 
    556490        if xmin== None: 
     
    558492        if xmax== None: 
    559493            xmax= self.R_width 
    560         print "vertical line: xmin, xmax , ymin , ymax", xmin, self.mline.theta 
     494        #print "vertical line: xmin, xmax , ymin , ymax", xmin, self.mline.theta 
    561495        self.x1= self.mline.x1 + xmin*math.cos(math.pi/2 - self.mline.theta) 
    562496        self.x2= self.mline.x2 + xmin*math.cos(math.pi/2 - self.mline.theta) 
    563497        self.y1= self.mline.y1 - xmin*math.sin(math.pi/2 - self.mline.theta) 
    564498        self.y2= self.mline.y2 - xmin*math.sin(math.pi/2 - self.mline.theta) 
    565         print "vertical line: main line  value ", self.mline.x1, self.mline.x2, self.mline.y1,self.mline.y2 
    566         print "vertical line: new value ", self.x1, self.x2, self.y1,self.y2 
     499        #print "vertical line: main line  value ", self.mline.x1, self.mline.x2, self.mline.y1,self.mline.y2 
     500        #print "vertical line: new value ", self.x1, self.x2, self.y1,self.y2 
    567501 
    568502        self.line.set(xdata=[self.x1,self.x2], ydata=[self.y1,self.y2])   
     
    572506            return 
    573507        if translation: 
    574             #if xmin !=None: 
    575             #    self.L_width=xmin 
     508            print "xmin L_width", xmin, self.L_width 
    576509            self.x1= self.mline.x1 + self.L_width*math.cos(math.pi/2 - self.mline.theta) 
    577510            self.x2= self.mline.x2 + self.L_width*math.cos(math.pi/2 - self.mline.theta) 
     
    581514            print"translation x1, x2,y1,y2",self.x1, self.x2,self.y1,self.y2 
    582515            self.line.set(xdata=[self.x1,self.x2], ydata=[self.y1,self.y2])  
     516             
     517             
    583518    def save(self, ev): 
    584519        """ 
     
    586521        can restore on Esc. 
    587522        """ 
    588         #self.save_x= self.x 
     523        self.save_L_width= self.L_width 
    589524        self.save_xmin= self.x1 
    590525        self.save_xmax= self.x2 
     
    595530 
    596531    def moveend(self, ev): 
    597         self.clickxf,self.clickyf = ev.xdata,ev.ydata 
    598         print "move end ",self.clickxf,self.clickyf 
     532         
    599533        self.has_move=False 
    600534        self.base.moveend(ev) 
     
    608542        self.ymin = self.save_ymin 
    609543        self.ymax = self.save_ymax 
    610          
     544        self.L_width= self.save_L_width 
    611545         
    612546    def move(self, x, y, ev): 
     
    615549        """ 
    616550        self.has_move=True 
    617         self.L_width=x 
    618          
    619         
     551        self.L_width = x 
     552        print "move L_width", self.L_width 
    620553        self.base.base.update() 
    621554         
     
    651584         Select an annulus through a 2D plot 
    652585    """ 
    653     def __init__(self,base,axes,color='black', zorder=5, r=1.0,theta=math.pi/4): 
     586    def __init__(self,base,axes,color='black', zorder=5, ymin=1.0,ymax=1.0,theta=math.pi/4): 
    654587         
    655588        _BaseInteractor.__init__(self, base, axes, color=color) 
     
    660593        self.theta= theta 
    661594         
    662         self.radius = r 
    663        
     595        self.radius1 = ymax 
     596        self.radius2 = ymin 
    664597        self.scale = 10.0 
    665598             
    666599        # Inner circle 
    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) 
     600        self.x1= self.radius1*math.cos(self.theta) 
     601        self.y1= self.radius1*math.sin(self.theta) 
     602        self.x2= -1*self.radius2*math.cos(self.theta) 
     603        self.y2= -1*self.radius2*math.sin(self.theta) 
    671604        
    672605        self.line = self.axes.plot([self.x1,self.x2],[self.y1,self.y2], 
     
    706639        return self.theta - self.save_theta 
    707640         
    708     def update(self, theta=None,radius=None): 
     641    def update(self, theta=None,radius1=None,radius2=None): 
    709642        """ 
    710643            Draw a line given and angle relative to the x-axis and a radius 
     
    715648        if theta !=None: 
    716649            self.theta= theta 
    717         if radius !=None: 
    718             self.radius =radius 
    719         print "update main line", math.degrees(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) 
     650        if radius1 !=None: 
     651            self.radius1 =radius1 
     652        if radius2 !=None: 
     653            self.radius2 =radius2 
     654        print "update main line", math.degrees(self.theta),self.radius1, self.radius2 
     655        self.x1= self.radius1*math.cos(self.theta) 
     656        self.y1= self.radius1*math.sin(self.theta) 
     657        self.x2= -1*self.radius2*math.cos(self.theta) 
     658        self.y2= -1*self.radius2*math.sin(self.theta) 
    724659       
    725660        self.line.set(xdata=[self.x1,self.x2], ydata=[self.y1,self.y2])   
     
    768703        """ 
    769704        params = {} 
    770         params["radius"] = self.radius 
     705        params["ymax"] = self.radius1 
     706        params["ymin"] = self.radius2 
    771707        params["theta"] = self.theta 
    772708        return params 
     
    777713            @param params: dictionary containing name of parameters and their values 
    778714        """ 
    779         radius = params["radius"] 
     715        radius1 = params["ymax"] 
     716        radius2 = params["ymin"] 
    780717        theta = params["theta"] 
    781         self.update(x, theta= theta , radius = radius ) 
    782          
    783  
    784  
    785  
    786          
     718        self.update(x, theta= theta , radius1 = radius1 ,radius2 = radius2) 
     719         
     720 
     721 
     722 
     723         
Note: See TracChangeset for help on using the changeset viewer.