Changeset 356aea78 in sasview


Ignore:
Timestamp:
Dec 12, 2008 4:39:35 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:
b98db8c
Parents:
3aae6b6
Message:

working on sector slicer

Location:
guiframe/local_perspectives/plotting
Files:
4 edited

Legend:

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

    r2d107b8 r356aea78  
    7272        while self.theta2 < self.theta1: self.theta2 += 2*math.pi 
    7373        npts = int((self.theta2 - self.theta1)/(math.pi/120)) 
     74         
     75         
     76             
     77             
    7478        for i in range(self.npts): 
    7579             
     
    8993        self.inner_circle.set_data(x, y)  
    9094         
    91         
    92         if self._inner_mouse_x <0: 
    93             self._inner_mouse_x= 0 
    94             self._inner_mouse_y= 0 
     95        """ 
    9596        r=  math.sqrt(math.pow(self._inner_mouse_x, 2)+math.pow(self._inner_mouse_y, 2)) 
    9697        x1=  r*math.cos(self.theta1) 
    9798        y1= r*math.sin(self.theta1) 
     99        """ 
    98100        #x1= self._inner_mouse_x*math.cos(self.theta1) 
    99101        #y1= self._inner_mouse_x*math.sin(self.theta1) 
     
    101103        #y2= r2*math.sin(self.theta1) 
    102104        
    103              
    104         
     105    
    105106    def save(self, ev): 
    106107        """ 
     
    110111        #self._inner_save_x = self._inner_mouse_x 
    111112        #self._inner_save_y = self._inner_mouse_y 
    112         self._inner_save_x = self._inner_mouse_x 
    113         self._inner_save_y = self._inner_mouse_y 
     113        self._inner_save_x = ev.xdata 
     114        self._inner_save_y = ev.ydata 
     115        print "save value",self._inner_save_x ,self._inner_save_y 
    114116        self.base.freeze_axes() 
    115117 
     
    129131        Process move to a new position, making sure that the move is allowed. 
    130132        """ 
    131         #print "ring move x, y", x,y 
     133        print "ring move x, y", x,y 
    132134        self._inner_mouse_x = x 
    133135        self._inner_mouse_y = y 
  • guiframe/local_perspectives/plotting/DataPanel.py

    r2d107b8 r356aea78  
    104104         
    105105        is_new = True 
    106         print "model panel name",event.plot.name 
     106        #print "model panel name",event.plot.name 
    107107        if event.plot.name in self.plots.keys(): 
    108108            # Check whether the class of plottable changed 
    109             print "model panel",event.plot.name,event.plot.__class__ 
     109            #print "model panel",event.plot.name,event.plot.__class__ 
    110110            if not event.plot.__class__==self.plots[event.plot.name].__class__: 
    111111                self.graph.delete(self.plots[event.plot.name]) 
     
    346346    group_id = None 
    347347     
     348     
    348349    def __init__(self, parent, id = -1,data2d=None, color = None,\ 
    349350        dpi = None, style = wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs): 
     
    369370        self.beamstop_radius = DEFAULT_BEAM 
    370371        # Slicer 
     372        if data2d.xmax==None: 
     373            data2d.xmax=DEFAULT_QMAX 
    371374         
    372375        self.qmax = data2d.xmax 
    373         self.imax= data2d.ymax 
     376        if data2d.ymax==None: 
     377            data2d.ymax=DEFAULT_QMAX 
     378        self.imax = data2d.ymax 
     379       
    374380        self.qstep = DEFAULT_QSTEP 
    375         self.x = pylab.arange(-self.qmax, self.qmax+self.qstep*0.01, self.qstep) 
    376         self.y = pylab.arange(-self.imax, self.imax+self.qstep*0.01, self.qstep) 
     381        print "panel2D qmax",self.qmax, 
     382        self.x = pylab.arange(-1*self.qmax, self.qmax+self.qstep*0.01, self.qstep) 
     383        self.y = pylab.arange(-1*self.imax, self.imax+self.qstep*0.01, self.qstep) 
    377384 
    378385        self.slicer_z = 5 
     
    380387        self.parent.Bind(EVT_INTERNAL, self._onEVT_INTERNAL) 
    381388        self.axes_frozen = False 
     389         
     390        
    382391        ## Graph         
    383392        self.graph = Graph() 
     
    604613            Perform sector averaging on Q 
    605614        """ 
     615         
    606616        from SectorSlicer import SectorInteractorQ 
    607                
    608         self.slicer_z += 1 
    609         self.slicer = SectorInteractorQ(self, self.subplot, zorder=self.slicer_z) 
    610         self.subplot.set_ylim(-self.qmax, self.qmax) 
    611         self.subplot.set_xlim(-self.qmax, self.qmax) 
    612         self.update() 
    613         self.slicer.update() 
    614          
     617        self.onClearSlicer(event) 
     618        wx.PostEvent(self.parent, InternalEvent(slicer= SectorInteractorQ)) 
    615619         
    616620    def onSectorPhi(self, event): 
     
    618622            Perform sector averaging on Phi 
    619623        """ 
    620         from SectorSlicer import SectorInteractor 
    621                
    622         self.slicer_z += 1 
    623         self.slicer = SectorInteractor(self, self.subplot, zorder=self.slicer_z) 
    624         self.subplot.set_ylim(-self.qmax, self.qmax) 
    625         self.subplot.set_xlim(-self.qmax, self.qmax) 
    626         self.update() 
    627         self.slicer.update() 
     624        from SectorSlicer import SectorInteractorPhi 
     625        self.onClearSlicer(event) 
     626        wx.PostEvent(self.parent, InternalEvent(slicer= SectorInteractorPhi)) 
    628627         
    629628        
     
    700699        self.graph.yaxis("\\rm{Intensity} ","cm^{-1}") 
    701700        self.graph.render(self) 
     701         
     702         
    702703    def onContextMenu(self, event): 
    703704        # Slicer plot popup menu 
  • guiframe/local_perspectives/plotting/Edge.py

    r2d107b8 r356aea78  
    2727        self.save_theta= theta 
    2828        #self.scale = 10.0 
    29          
     29        self.move_stop=False 
     30        self.theta_left=None 
     31        self.theta_right=None 
    3032        self.arc1= arc1 
    3133        self.arc2=arc2 
     
    3941                                      color=self.color, 
    4042                                      visible=True)[0] 
    41         
     43        self.phi= theta 
    4244        self.npts = 20 
    4345        self.has_move= False 
     
    6567        return self.theta 
    6668         
    67     def update(self,r1=None, r2=None): 
     69    def update(self,r1=None, r2=None, theta_right=None, theta_left=None): 
    6870        """ 
    6971        Draw the new roughness on the graph. 
    7072        """ 
    71         # Plot inner circle 
     73        self.theta_left=theta_left 
     74        self.theta_right=theta_right 
    7275        if r1 !=None: 
    7376            self.r1=r1 
    7477        if r2!=None: 
    7578            self.r2=r2 
    76         #print "update line ",self.r1,self.r2 
    77         #if self.theta <0: 
    78         #    self.theta= 2*math.pi + self.theta 
     79        if theta_right!=None: 
     80            if theta_right < self.theta: 
     81                self.move_stop=True 
     82            else: 
     83                self.move_stop=False 
     84        if theta_left !=None: 
     85            if theta_left > self.theta: 
     86                self.move_stop=True 
     87            else: 
     88                self.move_stop=False 
     89        if theta_left ==None and theta_right==None: 
     90            self.move_stop=True 
     91        print "in the edge theta_right theta_left",theta_right,theta_left,self.theta 
    7992        x1= self.r1*math.cos(self.theta) 
    8093        y1= self.r1*math.sin(self.theta) 
     
    8396              
    8497        self.line.set(xdata=[x1,x2], ydata=[y1,y2]) 
    85         return 1 
     98         
    8699  
    87100    def save(self, ev): 
     
    107120        Process move to a new position, making sure that the move is allowed. 
    108121        """ 
    109         self.theta= math.atan2(y,x) 
    110          
    111         self.has_move= True 
     122        #print "on move theta left , theta right",self.theta_left,self.theta_right 
     123        theta= math.atan2(y,x) 
     124        print "on move theta left , theta right",self.theta_left,self.theta_right,theta 
     125        if self.theta_left !=None: 
     126            if self.theta_left >= theta: 
     127                print "went hier" 
     128                self.move_stop= True 
     129        if self.theta_right !=None: 
     130            if self.theta_right <= theta: 
     131                self.move_stop= True 
     132 
     133        if self.move_stop: 
     134            self.theta= math.atan2(y,x) 
     135            self.has_move= True 
     136             
    112137        self.base.base.update() 
    113138         
  • guiframe/local_perspectives/plotting/SectorSlicer.py

    r2d107b8 r356aea78  
    117117        if self.inner_radius.has_move: 
    118118            print "inner radius has moved" 
    119             self.inner_radius.update() 
     119            self.inner_radius.update(theta_left=self.outer_radius.get_radius()) 
    120120            self.inner_circle.update(theta1=self.inner_radius.get_radius(), theta2=None) 
    121121            self.outer_circle.update(theta1=self.inner_radius.get_radius(), theta2=None) 
    122122        if  self.outer_radius.has_move: 
    123123             print "outer radius has moved" 
    124              self.outer_radius.update() 
     124             self.outer_radius.update(theta_right=self.inner_radius.get_radius()) 
    125125             self.inner_circle.update(theta1=None, theta2=self.outer_radius.get_radius()) 
    126126             self.outer_circle.update(theta1=None, theta2=self.outer_radius.get_radius()) 
     
    139139    def post_data(self,new_sector ): 
    140140        """ post data averaging in Q""" 
    141         rmin=self.inner_circle.get_radius() 
    142         rmax=self.outer_circle.get_radius() 
    143         phimin=self.inner_radius.get_radius() 
    144         phimax=self.outer_radius.get_radius() 
     141        if self.inner_circle.get_radius() < self.outer_circle.get_radius(): 
     142            rmin=self.inner_circle.get_radius() 
     143            rmax=self.outer_circle.get_radius() 
     144        else: 
     145            rmin=self.outer_circle.get_radius() 
     146            rmax=self.inner_circle.get_radius() 
     147        if self.inner_radius.get_radius() < self.outer_radius.get_radius(): 
     148            phimin=self.inner_radius.get_radius() 
     149            phimax=self.outer_radius.get_radius() 
     150        else: 
     151            phimin=self.outer_radius.get_radius() 
     152            phimax=self.inner_radius.get_radius() 
     153             
     154        print "phimin, phimax, rmin ,rmax",math.degrees(phimin), math.degrees(phimax), rmin ,rmax 
    145155        #from DataLoader.manipulations import SectorQ 
     156         
    146157        sect = new_sector(r_min=rmin, r_max=rmax, phi_min=phimin, phi_max=phimax) 
    147158        sector = sect(self.base.data2D) 
     
    156167        else: 
    157168            dxw= None 
    158              
     169        
    159170        new_plot = Data1D(x=sector.x,y=sector.y,dy=sector.dy,dxl=dxl,dxw=dxw) 
    160171        new_plot.name = str(new_sector.__name__) +"("+ self.base.data2D.name+")" 
     
    168179        new_plot.detector =self.base.data2D.detector 
    169180        # If the data file does not tell us what the axes are, just assume... 
    170         new_plot.xaxis(self.base.data2D._xaxis,self.base.data2D._xunit) 
    171         new_plot.yaxis(self.base.data2D._yaxis,self.base.data2D._yunit) 
    172         new_plot.group_id = "sector"+self.base.data2D.name 
     181        new_plot.xaxis("\\rm{Q}", 'rad') 
     182        new_plot.yaxis("\\rm{Intensity} ","cm^{-1}") 
     183        new_plot.group_id = str(new_sector.__name__)+self.base.data2D.name 
    173184        wx.PostEvent(self.base.parent, NewPlotEvent(plot=new_plot, 
    174185                                                 title=str(new_sector.__name__) )) 
     
    243254        from DataLoader.manipulations import SectorQ 
    244255        self.post_data(SectorQ )    
     256         
     257 
     258class SectorInteractorPhi(SectorInteractor): 
     259    def __init__(self,base,axes,color='black', zorder=3): 
     260        SectorInteractor.__init__(self, base, axes, color=color) 
     261        self.base=base 
     262        self._post_data() 
     263    def _post_data(self): 
     264        from DataLoader.manipulations import SectorPhi 
     265        self.post_data(SectorPhi )    
     266         
     267         
Note: See TracChangeset for help on using the changeset viewer.