Changeset b6b1669 in sasview


Ignore:
Timestamp:
Jan 7, 2009 12:13:13 AM (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:
c73d871
Parents:
86c1832
Message:

working on boxslicer

File:
1 edited

Legend:

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

    r78ed1ad rb6b1669  
    3030        self.xmin= -1* x_min 
    3131        self.ymin= -1* y_min 
     32         
    3233        self.xmax= x_max 
    3334        self.ymax=  y_max 
    3435         
    35         self.theta2= math.pi/2 
     36        self.theta2= math.pi/4 
    3637        ## Number of points on the plot 
    3738        self.nbins = 20 
     
    4445        self.left_line = VerticalLine(self, self.base.subplot,color='blue', zorder=zorder,  
    4546                                        ymin= self.ymin, ymax= self.ymax, 
    46                                         xmin= self.xmin,xmax= self.xmin, 
     47                                        x=self.xmin, 
    4748                                        theta2= self.theta2) 
    4849        self.left_line.qmax = self.base.qmax 
     
    5051        self.right_line= VerticalLine(self, self.base.subplot,color='black', zorder=zorder, 
    5152                                     ymin= self.ymin, ymax= self.ymax, 
    52                                      xmin=self.xmax,xmax=self.xmax, 
     53                                     x=self.xmax, 
    5354                                      theta2= self.theta2) 
    5455        self.right_line.qmax = self.base.qmax 
     
    126127        if self.left_line.has_move: 
    127128            print "left has moved" 
    128             self.left_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) 
    130             #self.right_line.update(xmin= self.left_line.x ,xmax=-1*self.left_line.x) 
    131             self.top_line.update( xmin= self.left_line.x ,xmax= self.right_line.x, 
    132                                   mline= self.main_line,translation=True) 
    133             self.bottom_line.update(xmin= self.left_line.x ,xmax= self.right_line.x, 
    134                                     mline= self.main_line,translation=True) 
     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, 
     134                                   translation=True) 
     135            self.top_line.update( xmin= self.left_line.xmax ,xmax= self.right_line.xmax, 
     136                                  translation=True) 
     137            self.bottom_line.update(xmin= self.left_line.xmin ,xmax= self.right_line.xmin, 
     138                                    translation=True) 
    135139        if self.right_line.has_move: 
    136140            print "right has moved" 
    137             self.right_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) 
    139             #self.left_line.update(xmin= self.right_line.x ,xmax=-1*self.right_line.x) 
    140             self.top_line.update( xmin= self.left_line.x ,xmax= self.right_line.x, 
    141                                   mline= self.main_line,translation=True) 
    142             self.bottom_line.update(xmin= self.left_line.x ,xmax= self.right_line.x, 
    143                                     mline= self.main_line,translation=True) 
     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, 
     144                                  translation=True) 
     145            self.top_line.update( xmin= self.left_line.xmax ,xmax= self.right_line.xmax, 
     146                                  translation=True) 
     147            self.bottom_line.update(xmin= self.left_line.xmin ,xmax= self.right_line.xmin, 
     148                                    translation=True) 
    144149             
    145150             
    146151        if self.bottom_line.has_move: 
    147152            print "bottom has moved" 
    148             self.bottom_line.update(mline= self.main_line,translation=True) 
    149             self.top_line.update(y= -1*self.top_line.y,translation=True) 
    150             self.left_line.update( ymin= self.bottom_line.y ,ymax= self.top_line.y, 
    151                                    mline= self.main_line,translation=True) 
    152             self.right_line.update(ymin= self.bottom_line.y ,ymax= self.top_line.y, 
    153                                    mline= self.main_line,translation=True) 
     153            self.bottom_line.update(translation=True) 
     154            self.top_line.update(ymin= -1*self.bottom_line.ymin, 
     155                                 ymax =-1*self.bottom_line.ymax, 
     156                                 translation=True) 
     157            self.left_line.update( ymin= self.bottom_line.ymin ,ymax= self.top_line.ymax, 
     158                                   translation=True) 
     159            self.right_line.update(ymin= self.bottom_line.ymin,ymax= self.top_line.ymax, 
     160                                   translation=True) 
    154161             
    155162        if self.top_line.has_move: 
    156163            print "top has moved" 
    157164            self.top_line.update(mline= self.main_line,translation=True) 
    158             #self.bottom_line.update()xmin=None, xmax=None,y=None, mline=None): 
    159             self.bottom_line.update(y= -1*self.top_line.y,mline= self.main_line, 
     165            self.bottom_line.update(ymin= -1*self.top_line.ymin, 
     166                                    ymax=-1*self.top_line.ymax, 
    160167                                    translation=True ) 
    161             self.left_line.update(ymin= self.bottom_line.y ,ymax= self.top_line.y, 
    162                                   mline= self.main_line,translation=True) 
    163             self.right_line.update(ymin= self.bottom_line.y ,ymax= self.top_line.y, 
    164                                    mline= self.main_line,translation=True) 
     168            self.left_line.update(ymin= self.bottom_line.ymin ,ymax= self.top_line.ymax, 
     169                                  translation=True) 
     170            self.right_line.update(ymin= self.bottom_line.ymin ,ymax= self.top_line.ymax, 
     171                                   translation=True) 
    165172             
    166173     
     
    273280         
    274281        self.theta2 = theta2 
    275  
    276          
     282         
     283        self.clickx=self.xmin 
     284        self.clicky=self.y 
     285        self.clickxf=self.xmin 
     286        self.clickyf=self.y 
     287        self.deltax=0 
     288        self.deltay=0 
    277289        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) 
     290        self.ymin= self.xmin*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 
    279291         
    280292        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], 
     293        self.ymax= self.xmax*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 
     294        #print "x1, y1", x1, y1, x2,y2 
     295        self.line = self.axes.plot([x1,x2],[self.ymin,self.ymax], 
    284296                                      linestyle='-', marker='', 
    285297                                      color=self.color, 
     
    305317            for item in range(len(self.axes.lines)): 
    306318                del self.axes.lines[0] 
    307          
     319    def onClick(self, ev): 
     320        """ 
     321        Prepare to move the artist.  Calls save() to preserve the state for 
     322        later restore(). 
     323        """ 
     324        self.clickx,self.clicky = ev.xdata,ev.ydata 
     325        print "onclick",self.clickx,self.clicky 
     326        #self.save(ev) 
     327        return True    
    308328    def get_radius(self): 
    309329         
    310330        return 0 
    311331    
    312     def update(self,xmin=None, xmax=None,y=None, mline=None,translation=False): 
     332    def update(self,xmin=None, xmax=None,ymin=None,ymax=None, mline=None,translation=False): 
    313333        """ 
    314334        Draw the new roughness on the graph. 
    315335        """ 
    316336        #print "update main line", self.has_move 
    317         if xmin !=None: 
    318             self.xmin=xmin 
    319         if xmax !=None: 
    320             self.xmax=xmax 
    321         if y !=None: 
    322             self.y = y 
     337         
     338        if translation : 
     339            self.deltax = self.clickxf- self.clickx 
     340            self.deltay = self.clickyf-self.clicky 
     341             
     342            self.xmin= self.xmin +self.deltax 
     343            self.xmax=self.xmax+self.deltax 
     344            self.ymin= self.ymin +self.deltay 
     345            self.ymax=self.ymax+self.deltay 
     346             
     347            if xmin !=None: 
     348                self.xmin=xmin 
     349            if xmax !=None: 
     350                self.xmax=xmax 
     351            if ymin !=None: 
     352                self.ymin = ymin 
     353            if ymax !=None: 
     354                self.ymax = ymax 
     355            self.line.set(xdata=[self.xmin, self.xmax], 
     356                          ydata=[self.ymin, self.ymax]) 
    323357        if mline !=None: 
    324358            self.theta2= mline.theta 
    325             delta = mline.get_delta_angle() 
    326359             
    327360            x1= self.xmin*math.cos(self.theta2)- self.y*math.sin(self.theta2) 
     
    332365             
    333366            self.line.set(xdata=[x1,x2], ydata=[y1,y2])  
    334             print "Horizontal: update ",math.degrees(self.phi_left +delta),math.degrees(self.phi_right+delta) 
    335367            print x1,x2,y1,y2 
    336368            
     
    352384 
    353385    def moveend(self, ev): 
    354          
     386        self.clickxf,self.clickyf = ev.xdata,ev.ydata 
     387        print "move end ",self.clickxf,self.clickyf 
    355388        self.has_move=False 
    356389        self.base.moveend(ev) 
     
    367400        Process move to a new position, making sure that the move is allowed. 
    368401        """ 
    369         self.y=y 
    370          
    371402         
    372403        self.has_move=True 
     
    397428    """ 
    398429    def __init__(self,base,axes,color='black', zorder=5, ymin=0.0,  
    399                  ymax=0.5,xmin= 0.5,xmax=0.5, 
     430                 ymax=0.5,x=0.5, 
    400431                 theta2= math.pi/3 ): 
    401432         
     
    404435        self.axes = axes 
    405436        # x coordinate of the vertical line 
    406         self.xmin = xmin 
    407         self.save_xmin = xmin 
    408         self.xmax = xmax 
    409         self.save_xmax = xmax 
     437        self.x= x 
     438        self.save_x = x 
     439         
    410440        # minimum value of y coordinate of the vertical line  
    411441        self.ymin = ymin 
     
    415445        self.save_ymax=ymax 
    416446        #insure rotation 
    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) 
    423447        self.theta2= theta2 
    424448         
    425         self.phi_down= self.theta_down - self.theta2 
    426         self.phi_up= self.theta_up - self.theta2 
    427         print "phi up down", math.degrees(self.phi_up),math.degrees(self.phi_down) 
    428         #print "theta up down ", math.degrees(self.theta_up),math.degrees(self.theta_down) 
    429449        # Draw vertical line 
    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          
     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 
     461        self.deltay=0 
    436462        self.line = self.axes.plot([self.xmin,self.xmax],[self.ymin,self.ymax], 
    437463                                      linestyle='-', marker='', 
     
    458484            for item in range(len(self.axes.lines)): 
    459485                del self.axes.lines[0] 
    460          
     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 
    461496    def get_radius(self): 
    462497        return 0 
    463498     
    464     def update(self,x=None,ymin=None, ymax=None, mline=None,translation=False): 
     499    def update(self,xmin=None,xmax=None,ymin=None, ymax=None, mline=None,translation=False): 
    465500        """ 
    466501        Draw the new roughness on the graph. 
    467502        """ 
    468         if x!=None: 
    469             self.x = x 
    470         if ymin !=None: 
    471             self.ymin = ymin 
    472         if ymax !=None: 
    473             self.ymax = ymax 
     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]) 
    474522        if mline !=None: 
    475523             
     
    478526            if translation: 
    479527                delta= 0 
    480             # rotation 
    481             x1 = self.radius1 * math.cos(self.phi_down +  delta) 
    482             y1= self.radius1 * math.sin(self.phi_down + delta) 
    483                  
    484             x2= -1*self.radius2 * math.cos( self.phi_up + delta) 
    485             y2= -1*self.radius2 * math.sin(self.phi_up + delta) 
    486             self.xmin= x1 
    487             self.xmax=x2 
    488             self.ymin= y1 
    489             self.ymax= y2 
     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 
    490535            self.line.set(xdata=[self.xmin,self.xmax], ydata=[self.ymin,self.ymax])   
    491536            
    492         #else: 
    493         #   self.line.set(xdata=[self.x,self.x], ydata=[self.ymin,self.ymax]) 
    494       
    495          
     537              
    496538         
    497539    def save(self, ev): 
     
    509551 
    510552    def moveend(self, ev): 
    511          
     553        self.clickxf,self.clickyf = ev.xdata,ev.ydata 
     554        print "move end ",self.clickxf,self.clickyf 
    512555        self.has_move=False 
    513556        self.base.moveend(ev) 
     
    527570        Process move to a new position, making sure that the move is allowed. 
    528571        """ 
    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          
    540572         
    541573        self.has_move=True 
Note: See TracChangeset for help on using the changeset viewer.