Index: guiframe/local_perspectives/plotting/Arc.py
===================================================================
--- guiframe/local_perspectives/plotting/Arc.py	(revision 2d107b883288e417fcd3b30f942cda5fd43b54c7)
+++ guiframe/local_perspectives/plotting/Arc.py	(revision 356aea7851c1dda619149e40e61be7ef49e0fe97)
@@ -72,4 +72,8 @@
         while self.theta2 < self.theta1: self.theta2 += 2*math.pi
         npts = int((self.theta2 - self.theta1)/(math.pi/120))
+        
+        
+            
+            
         for i in range(self.npts):
             
@@ -89,11 +93,9 @@
         self.inner_circle.set_data(x, y) 
         
-       
-        if self._inner_mouse_x <0:
-            self._inner_mouse_x= 0
-            self._inner_mouse_y= 0
+        """
         r=  math.sqrt(math.pow(self._inner_mouse_x, 2)+math.pow(self._inner_mouse_y, 2))
         x1=  r*math.cos(self.theta1)
         y1= r*math.sin(self.theta1)
+        """
         #x1= self._inner_mouse_x*math.cos(self.theta1)
         #y1= self._inner_mouse_x*math.sin(self.theta1)
@@ -101,6 +103,5 @@
         #y2= r2*math.sin(self.theta1)
        
-            
-       
+   
     def save(self, ev):
         """
@@ -110,6 +111,7 @@
         #self._inner_save_x = self._inner_mouse_x
         #self._inner_save_y = self._inner_mouse_y
-        self._inner_save_x = self._inner_mouse_x
-        self._inner_save_y = self._inner_mouse_y
+        self._inner_save_x = ev.xdata
+        self._inner_save_y = ev.ydata
+        print "save value",self._inner_save_x ,self._inner_save_y
         self.base.freeze_axes()
 
@@ -129,5 +131,5 @@
         Process move to a new position, making sure that the move is allowed.
         """
-        #print "ring move x, y", x,y
+        print "ring move x, y", x,y
         self._inner_mouse_x = x
         self._inner_mouse_y = y
Index: guiframe/local_perspectives/plotting/DataPanel.py
===================================================================
--- guiframe/local_perspectives/plotting/DataPanel.py	(revision 2d107b883288e417fcd3b30f942cda5fd43b54c7)
+++ guiframe/local_perspectives/plotting/DataPanel.py	(revision 356aea7851c1dda619149e40e61be7ef49e0fe97)
@@ -104,8 +104,8 @@
         
         is_new = True
-        print "model panel name",event.plot.name
+        #print "model panel name",event.plot.name
         if event.plot.name in self.plots.keys():
             # Check whether the class of plottable changed
-            print "model panel",event.plot.name,event.plot.__class__
+            #print "model panel",event.plot.name,event.plot.__class__
             if not event.plot.__class__==self.plots[event.plot.name].__class__:
                 self.graph.delete(self.plots[event.plot.name])
@@ -346,4 +346,5 @@
     group_id = None
     
+    
     def __init__(self, parent, id = -1,data2d=None, color = None,\
         dpi = None, style = wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs):
@@ -369,10 +370,16 @@
         self.beamstop_radius = DEFAULT_BEAM
         # Slicer
+        if data2d.xmax==None:
+            data2d.xmax=DEFAULT_QMAX
         
         self.qmax = data2d.xmax
-        self.imax= data2d.ymax
+        if data2d.ymax==None:
+            data2d.ymax=DEFAULT_QMAX
+        self.imax = data2d.ymax
+      
         self.qstep = DEFAULT_QSTEP
-        self.x = pylab.arange(-self.qmax, self.qmax+self.qstep*0.01, self.qstep)
-        self.y = pylab.arange(-self.imax, self.imax+self.qstep*0.01, self.qstep)
+        print "panel2D qmax",self.qmax,
+        self.x = pylab.arange(-1*self.qmax, self.qmax+self.qstep*0.01, self.qstep)
+        self.y = pylab.arange(-1*self.imax, self.imax+self.qstep*0.01, self.qstep)
 
         self.slicer_z = 5
@@ -380,4 +387,6 @@
         self.parent.Bind(EVT_INTERNAL, self._onEVT_INTERNAL)
         self.axes_frozen = False
+        
+       
         ## Graph        
         self.graph = Graph()
@@ -604,13 +613,8 @@
             Perform sector averaging on Q
         """
+        
         from SectorSlicer import SectorInteractorQ
-              
-        self.slicer_z += 1
-        self.slicer = SectorInteractorQ(self, self.subplot, zorder=self.slicer_z)
-        self.subplot.set_ylim(-self.qmax, self.qmax)
-        self.subplot.set_xlim(-self.qmax, self.qmax)
-        self.update()
-        self.slicer.update()
-        
+        self.onClearSlicer(event)
+        wx.PostEvent(self.parent, InternalEvent(slicer= SectorInteractorQ))
         
     def onSectorPhi(self, event):
@@ -618,12 +622,7 @@
             Perform sector averaging on Phi
         """
-        from SectorSlicer import SectorInteractor
-              
-        self.slicer_z += 1
-        self.slicer = SectorInteractor(self, self.subplot, zorder=self.slicer_z)
-        self.subplot.set_ylim(-self.qmax, self.qmax)
-        self.subplot.set_xlim(-self.qmax, self.qmax)
-        self.update()
-        self.slicer.update()
+        from SectorSlicer import SectorInteractorPhi
+        self.onClearSlicer(event)
+        wx.PostEvent(self.parent, InternalEvent(slicer= SectorInteractorPhi))
         
        
@@ -700,4 +699,6 @@
         self.graph.yaxis("\\rm{Intensity} ","cm^{-1}")
         self.graph.render(self)
+        
+        
     def onContextMenu(self, event):
         # Slicer plot popup menu
Index: guiframe/local_perspectives/plotting/Edge.py
===================================================================
--- guiframe/local_perspectives/plotting/Edge.py	(revision 2d107b883288e417fcd3b30f942cda5fd43b54c7)
+++ guiframe/local_perspectives/plotting/Edge.py	(revision 356aea7851c1dda619149e40e61be7ef49e0fe97)
@@ -27,5 +27,7 @@
         self.save_theta= theta
         #self.scale = 10.0
-        
+        self.move_stop=False
+        self.theta_left=None
+        self.theta_right=None
         self.arc1= arc1
         self.arc2=arc2
@@ -39,5 +41,5 @@
                                       color=self.color,
                                       visible=True)[0]
-       
+        self.phi= theta
         self.npts = 20
         self.has_move= False
@@ -65,16 +67,27 @@
         return self.theta
         
-    def update(self,r1=None, r2=None):
+    def update(self,r1=None, r2=None, theta_right=None, theta_left=None):
         """
         Draw the new roughness on the graph.
         """
-        # Plot inner circle
+        self.theta_left=theta_left
+        self.theta_right=theta_right
         if r1 !=None:
             self.r1=r1
         if r2!=None:
             self.r2=r2
-        #print "update line ",self.r1,self.r2
-        #if self.theta <0:
-        #    self.theta= 2*math.pi + self.theta
+        if theta_right!=None:
+            if theta_right < self.theta:
+                self.move_stop=True
+            else:
+                self.move_stop=False
+        if theta_left !=None:
+            if theta_left > self.theta:
+                self.move_stop=True
+            else:
+                self.move_stop=False
+        if theta_left ==None and theta_right==None:
+            self.move_stop=True
+        print "in the edge theta_right theta_left",theta_right,theta_left,self.theta
         x1= self.r1*math.cos(self.theta)
         y1= self.r1*math.sin(self.theta)
@@ -83,5 +96,5 @@
              
         self.line.set(xdata=[x1,x2], ydata=[y1,y2])
-        return 1
+        
  
     def save(self, ev):
@@ -107,7 +120,19 @@
         Process move to a new position, making sure that the move is allowed.
         """
-        self.theta= math.atan2(y,x)
-        
-        self.has_move= True
+        #print "on move theta left , theta right",self.theta_left,self.theta_right
+        theta= math.atan2(y,x)
+        print "on move theta left , theta right",self.theta_left,self.theta_right,theta
+        if self.theta_left !=None:
+            if self.theta_left >= theta:
+                print "went hier"
+                self.move_stop= True
+        if self.theta_right !=None:
+            if self.theta_right <= theta:
+                self.move_stop= True
+
+        if self.move_stop:
+            self.theta= math.atan2(y,x)
+            self.has_move= True
+            
         self.base.base.update()
         
Index: guiframe/local_perspectives/plotting/SectorSlicer.py
===================================================================
--- guiframe/local_perspectives/plotting/SectorSlicer.py	(revision 2d107b883288e417fcd3b30f942cda5fd43b54c7)
+++ guiframe/local_perspectives/plotting/SectorSlicer.py	(revision 356aea7851c1dda619149e40e61be7ef49e0fe97)
@@ -117,10 +117,10 @@
         if self.inner_radius.has_move:
             print "inner radius has moved"
-            self.inner_radius.update()
+            self.inner_radius.update(theta_left=self.outer_radius.get_radius())
             self.inner_circle.update(theta1=self.inner_radius.get_radius(), theta2=None)
             self.outer_circle.update(theta1=self.inner_radius.get_radius(), theta2=None)
         if  self.outer_radius.has_move:
              print "outer radius has moved"
-             self.outer_radius.update()
+             self.outer_radius.update(theta_right=self.inner_radius.get_radius())
              self.inner_circle.update(theta1=None, theta2=self.outer_radius.get_radius())
              self.outer_circle.update(theta1=None, theta2=self.outer_radius.get_radius())
@@ -139,9 +139,20 @@
     def post_data(self,new_sector ):
         """ post data averaging in Q"""
-        rmin=self.inner_circle.get_radius()
-        rmax=self.outer_circle.get_radius()
-        phimin=self.inner_radius.get_radius()
-        phimax=self.outer_radius.get_radius()
+        if self.inner_circle.get_radius() < self.outer_circle.get_radius():
+            rmin=self.inner_circle.get_radius()
+            rmax=self.outer_circle.get_radius()
+        else:
+            rmin=self.outer_circle.get_radius()
+            rmax=self.inner_circle.get_radius()
+        if self.inner_radius.get_radius() < self.outer_radius.get_radius():
+            phimin=self.inner_radius.get_radius()
+            phimax=self.outer_radius.get_radius()
+        else:
+            phimin=self.outer_radius.get_radius()
+            phimax=self.inner_radius.get_radius()
+            
+        print "phimin, phimax, rmin ,rmax",math.degrees(phimin), math.degrees(phimax), rmin ,rmax
         #from DataLoader.manipulations import SectorQ
+        
         sect = new_sector(r_min=rmin, r_max=rmax, phi_min=phimin, phi_max=phimax)
         sector = sect(self.base.data2D)
@@ -156,5 +167,5 @@
         else:
             dxw= None
-            
+       
         new_plot = Data1D(x=sector.x,y=sector.y,dy=sector.dy,dxl=dxl,dxw=dxw)
         new_plot.name = str(new_sector.__name__) +"("+ self.base.data2D.name+")"
@@ -168,7 +179,7 @@
         new_plot.detector =self.base.data2D.detector
         # If the data file does not tell us what the axes are, just assume...
-        new_plot.xaxis(self.base.data2D._xaxis,self.base.data2D._xunit)
-        new_plot.yaxis(self.base.data2D._yaxis,self.base.data2D._yunit)
-        new_plot.group_id = "sector"+self.base.data2D.name
+        new_plot.xaxis("\\rm{Q}", 'rad')
+        new_plot.yaxis("\\rm{Intensity} ","cm^{-1}")
+        new_plot.group_id = str(new_sector.__name__)+self.base.data2D.name
         wx.PostEvent(self.base.parent, NewPlotEvent(plot=new_plot,
                                                  title=str(new_sector.__name__) ))
@@ -243,2 +254,14 @@
         from DataLoader.manipulations import SectorQ
         self.post_data(SectorQ )   
+        
+
+class SectorInteractorPhi(SectorInteractor):
+    def __init__(self,base,axes,color='black', zorder=3):
+        SectorInteractor.__init__(self, base, axes, color=color)
+        self.base=base
+        self._post_data()
+    def _post_data(self):
+        from DataLoader.manipulations import SectorPhi
+        self.post_data(SectorPhi )   
+        
+        
