Changeset 78ed1ad in sasview


Ignore:
Timestamp:
Jan 6, 2009 5:16:32 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:
86c1832
Parents:
7ab9241
Message:

working on boxslicer

Location:
guiframe/local_perspectives/plotting
Files:
1 added
1 edited

Legend:

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

    r7ab9241 r78ed1ad  
    4444        self.left_line = VerticalLine(self, self.base.subplot,color='blue', zorder=zorder,  
    4545                                        ymin= self.ymin, ymax= self.ymax, 
    46                                         x= self.xmin, 
     46                                        xmin= self.xmin,xmax= self.xmin, 
    4747                                        theta2= self.theta2) 
    4848        self.left_line.qmax = self.base.qmax 
     
    5050        self.right_line= VerticalLine(self, self.base.subplot,color='black', zorder=zorder, 
    5151                                     ymin= self.ymin, ymax= self.ymax, 
    52                                      x=self.xmax, 
     52                                     xmin=self.xmax,xmax=self.xmax, 
    5353                                      theta2= self.theta2) 
    5454        self.right_line.qmax = self.base.qmax 
     
    127127            print "left has moved" 
    128128            self.left_line.update(mline= self.main_line,translation=True) 
    129             self.right_line.update(mline= self.main_line,translation=True) 
     129            self.right_line.update(x=-1*self.left_line.x,mline= self.main_line,translation=True) 
    130130            #self.right_line.update(xmin= self.left_line.x ,xmax=-1*self.left_line.x) 
    131131            self.top_line.update( xmin= self.left_line.x ,xmax= self.right_line.x, 
     
    136136            print "right has moved" 
    137137            self.right_line.update(mline= self.main_line,translation=True) 
    138             self.left_line.update(mline= self.main_line,translation=True) 
     138            self.left_line.update(x=-1*self.right_line.x,mline= self.main_line,translation=True) 
    139139            #self.left_line.update(xmin= self.right_line.x ,xmax=-1*self.right_line.x) 
    140140            self.top_line.update( xmin= self.left_line.x ,xmax= self.right_line.x, 
     
    219219    def get_params(self): 
    220220        params = {} 
    221         params["x_min"] = self.left_line.x  
    222         params["x_max"] = self.right_line.x  
     221        params["x_min"] = self.left_line.xmin  
     222        params["x_max"] = self.right_line.xmax  
    223223        params["y_min"] = self.bottom_line.y 
    224224        params["y_max"] = self.top_line.y 
     
    264264        self.axes = axes 
    265265         
    266         self.y = y 
     266        self.y= y 
    267267        self.save_y = y  
    268268         
     
    271271        self.xmax = xmax 
    272272        self.save_xmax = xmax 
     273         
    273274        self.theta2 = theta2 
    274         self.radius1 = math.sqrt(math.pow(self.xmin, 2)+ math.pow(self.y, 2)) 
    275         self.radius2 = math.sqrt(math.pow(self.xmax, 2)+ math.pow(self.y, 2)) 
    276          
    277         
    278         #print "phi and theta2", math.degrees(math.atan2(self.y, self.xmax)) 
    279          
    280         self.theta_right= math.atan2(self.y,self.xmin) 
    281         self.theta_left= math.atan2(self.y,self.xmax) 
    282          
    283         self.phi_left= self.theta_left - self.theta2 
    284         self.phi_right=  self.theta_right -  self.theta2  
    285         print "phi left right", math.degrees(self.phi_left),math.degrees(self.phi_right) 
    286         #print "theta left right ", math.degrees(self.theta_left),math.degrees(self.theta_right) 
    287          
    288         self.line = self.axes.plot([self.xmin,self.xmax],[self.y,self.y], 
     275 
     276         
     277        x1= self.xmin*math.cos(self.theta2)- self.y*math.sin(self.theta2) 
     278        y1= self.xmin*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 
     279         
     280        x2= self.xmax*math.cos(self.theta2)- self.y*math.sin(self.theta2) 
     281        y2= self.xmax*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 
     282        print "x1, y1", x1, y1, x2,y2 
     283        self.line = self.axes.plot([x1,x2],[y1,y2], 
    289284                                      linestyle='-', marker='', 
    290285                                      color=self.color, 
     
    329324            self.theta2= mline.theta 
    330325            delta = mline.get_delta_angle() 
    331             # rotation 
    332             x1 = self.radius1 * math.cos(self.phi_left +  delta) 
    333             y1= self.radius1 * math.sin(self.phi_left + delta) 
    334                  
    335             x2= -1*self.radius2 * math.cos( self.phi_right + delta) 
    336             y2= -1*self.radius2 * math.sin(self.phi_right + delta) 
     326             
     327            x1= self.xmin*math.cos(self.theta2)- self.y*math.sin(self.theta2) 
     328            y1= 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            y2= self.xmax*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 
    337332             
    338333            self.line.set(xdata=[x1,x2], ydata=[y1,y2])  
     
    373368        """ 
    374369        self.y=y 
    375         #self.radius1= math.sqrt(math.pow(self.xmin, 2)+ math.pow(self.y, 2)) 
    376         #self.radius2= math.sqrt(math.pow(self.xmax, 2)+ math.pow(self.y, 2)) 
    377          
    378         #self.theta_right= math.atan2(self.y,self.xmin) 
    379         #self.theta_left= math.atan2(self.y,self.xmax) 
    380          
    381         #self.phi_left= self.theta_left - self.theta2 
    382         #self.phi_right=  self.theta_right -  self.theta2  
     370         
    383371         
    384372        self.has_move=True 
     
    409397    """ 
    410398    def __init__(self,base,axes,color='black', zorder=5, ymin=0.0,  
    411                  ymax=0.5,x= 0.5, 
     399                 ymax=0.5,xmin= 0.5,xmax=0.5, 
    412400                 theta2= math.pi/3 ): 
    413401         
     
    416404        self.axes = axes 
    417405        # x coordinate of the vertical line 
    418         self.x = x 
    419         self.save_x = x 
     406        self.xmin = xmin 
     407        self.save_xmin = xmin 
     408        self.xmax = xmax 
     409        self.save_xmax = xmax 
    420410        # minimum value of y coordinate of the vertical line  
    421411        self.ymin = ymin 
     
    425415        self.save_ymax=ymax 
    426416        #insure rotation 
    427         self.radius1= math.sqrt(math.pow(self.x, 2)+ math.pow(self.ymin, 2)) 
    428         self.radius2= math.sqrt(math.pow(self.x, 2)+ math.pow(self.ymax, 2)) 
    429          
    430          
    431         self.theta_down = math.atan2(self.ymin, self.x) 
    432         self.theta_up = math.atan2(self.ymax, self.x) 
     417        self.radius1= math.sqrt(math.pow(self.xmin, 2)+ math.pow(self.ymin, 2)) 
     418        self.radius2= math.sqrt(math.pow(self.xmax, 2)+ math.pow(self.ymax, 2)) 
     419         
     420         
     421        self.theta_down = math.atan2(self.ymin, self.xmin) 
     422        self.theta_up = math.atan2(self.ymax, self.xmax) 
    433423        self.theta2= theta2 
    434424         
     
    438428        #print "theta up down ", math.degrees(self.theta_up),math.degrees(self.theta_down) 
    439429        # Draw vertical line 
    440         self.line = self.axes.plot([self.x,self.x],[self.ymin,self.ymax], 
     430        self.xmin= self.xmin* math.cos(self.theta2)-self.ymin *math.sin(self.theta2) 
     431        self.xmax= self.xmax* math.cos(self.theta2)-self.ymax *math.sin(self.theta2) 
     432         
     433        self.ymin= self.xmin* math.sin(self.theta2)+self.ymin *math.cos(self.theta2) 
     434        self.ymax= self.xmax* math.sin(self.theta2)+self.ymax *math.cos(self.theta2) 
     435         
     436        self.line = self.axes.plot([self.xmin,self.xmax],[self.ymin,self.ymax], 
    441437                                      linestyle='-', marker='', 
    442438                                      color=self.color, 
     
    488484            x2= -1*self.radius2 * math.cos( self.phi_up + delta) 
    489485            y2= -1*self.radius2 * math.sin(self.phi_up + delta) 
    490              
    491             self.line.set(xdata=[x1,x2], ydata=[y1,y2])   
     486            self.xmin= x1 
     487            self.xmax=x2 
     488            self.ymin= y1 
     489            self.ymax= y2 
     490            self.line.set(xdata=[self.xmin,self.xmax], ydata=[self.ymin,self.ymax])   
    492491            
    493492        #else: 
     
    501500        can restore on Esc. 
    502501        """ 
    503         self.save_x= self.x 
     502        #self.save_x= self.x 
     503        self.save_xmin= self.xmin 
     504        self.save_xmax= self.xmax 
    504505        self.save_ymin= self.ymin 
    505506        self.save_ymax= self.ymax 
     
    516517        Restore the roughness for this layer. 
    517518        """ 
    518         self.x = self.save_x 
    519          
     519        self.xmin = self.save_xmin 
     520        self.xmax = self.save_xmax 
    520521        self.ymin=self.save_ymin 
    521522        self.ymax=self.save_ymax 
     523         
     524         
    522525    def move(self, x, y, ev): 
    523526        """ 
    524527        Process move to a new position, making sure that the move is allowed. 
    525528        """ 
    526         self.x = x 
    527         self.radius1= math.sqrt(math.pow(self.x, 2)+ math.pow(self.ymin, 2)) 
    528         self.radius2= math.sqrt(math.pow(self.x, 2)+ math.pow(self.ymax, 2)) 
    529          
    530          
    531         self.theta_down = math.atan2(self.ymin, self.x) 
    532         self.theta_up = math.atan2(self.ymax, self.x) 
    533          
    534          
    535         self.phi_down= self.theta_down - self.theta2 
    536         self.phi_up= self.theta_up - self.theta2 
    537         
     529        delta_xmin = x- self.save_xmin 
     530        delta_xmax = x- self.save_xmax 
     531        delta_ymin = y- self.save_ymin 
     532        delta_ymax = y- self.save_ymax 
     533         
     534        self.xmin= self.xmin + delta_xmin 
     535        self.xmax= self.xmax + delta_xmax 
     536         
     537        self.ymin= self.ymin +delta_ymin 
     538        self.ymax= self.ymax +delta_ymax 
     539         
     540         
    538541        self.has_move=True 
    539542        self.base.base.update() 
Note: See TracChangeset for help on using the changeset viewer.