Index: guiframe/local_perspectives/plotting/DataPanel.py
===================================================================
--- guiframe/local_perspectives/plotting/DataPanel.py	(revision 768656ee3fc923f226cb348145fb3cfb09f09903)
+++ guiframe/local_perspectives/plotting/DataPanel.py	(revision 2d107b883288e417fcd3b30f942cda5fd43b54c7)
@@ -18,5 +18,8 @@
 from sans.guicomm.events import StatusEvent ,NewPlotEvent
 
+
+from SlicerParameters import SlicerEvent
 from binder import BindArtist
+(InternalEvent, EVT_INTERNAL)   = wx.lib.newevent.NewEvent()
 #from SlicerParameters import SlicerEvent
 #(InternalEvent, EVT_INTERNAL)   = wx.lib.newevent.NewEvent()
@@ -375,5 +378,5 @@
         self.slicer_z = 5
         self.slicer = None
-        #self.parent.Bind(EVT_INTERNAL, self._onEVT_INTERNAL)
+        self.parent.Bind(EVT_INTERNAL, self._onEVT_INTERNAL)
         self.axes_frozen = False
         ## Graph        
@@ -457,8 +460,10 @@
         
         id = wx.NewId()
-        slicerpop.Append(id, '&Sector')
-        wx.EVT_MENU(self, id, self.onSector) 
-        
-        
+        slicerpop.Append(id, '&Sector Q')
+        wx.EVT_MENU(self, id, self.onSectorQ) 
+        
+        id = wx.NewId()
+        slicerpop.Append(id, '&Sector Phi')
+        wx.EVT_MENU(self, id, self.onSectorPhi) 
       
         
@@ -524,12 +529,92 @@
         #self.slicer.update()
         self.draw()
+        
+        
+    def _getEmptySlicerEvent(self):
+        return SlicerEvent(type=None,
+                           params=None,
+                           obj_class=None)
+    def _onEVT_INTERNAL(self, event):
+        """
+            I don't understand why Unbind followed by a Bind
+            using a modified self.slicer doesn't work.
+            For now, I post a clear event followed by
+            a new slicer event...
+        """
+        self._setSlicer(event.slicer)
+            
+    def _setSlicer(self, slicer):
+        # Clear current slicer
+        #printEVT("Plotter2D._setSlicer %s" % slicer)
+        
+        if not self.slicer == None:  
+            self.slicer.clear()            
+            
+        self.slicer_z += 1
+        self.slicer = slicer(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()
+        
+        # Post slicer event
+        event = self._getEmptySlicerEvent()
+        event.type = self.slicer.__class__.__name__
+        event.obj_class = self.slicer.__class__
+        event.params = self.slicer.get_params()
+        wx.PostEvent(self.parent, event)
+
     def onCircular(self, event):
         """
-            perform circular averaging
-        """
+            perform circular averaging on Data2D
+        """
+        
         from DataLoader.manipulations import CircularAverage
-    def onSector(self, event):
-        """
-            Perform sector averaging
+        Circle = CircularAverage( r_min= -self.qmax, r_max= self.qmax, bin_width=0.001)
+        circ = Circle(self.data2D)
+        from sans.guiframe.dataFitting import Data1D
+        if hasattr(circ,"dxl"):
+            dxl= circ.dxl
+        else:
+            dxl= None
+        if hasattr(circ,"dxw"):
+            dxw= circ.dxw
+        else:
+            dxw= None
+            
+        new_plot = Data1D(x=circ.x,y=circ.y,dy=circ.dy,dxl=dxl,dxw=dxw)
+        new_plot.name = "Circ avg "+ self.data2D.name
+        new_plot.source=self.data2D.source
+        new_plot.info=self.data2D.info
+        new_plot.interactive = True
+        #print "loader output.detector",output.source
+        new_plot.detector =self.data2D.detector
+        
+        # If the data file does not tell us what the axes are, just assume...
+        new_plot.xaxis("\\rm{q}","A^{-1}")
+        new_plot.yaxis("\\rm{Intensity} ","cm^{-1}")
+        new_plot.group_id = "Circ avg "+ self.data2D.name
+        self.scale = 'log'
+        wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=new_plot.name))
+        
+        
+        
+    def onSectorQ(self, event):
+        """
+            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()
+        
+        
+    def onSectorPhi(self, event):
+        """
+            Perform sector averaging on Phi
         """
         from SectorSlicer import SectorInteractor
@@ -544,6 +629,15 @@
        
     def onClearSlicer(self, event):
-        print "on clear"  
-        
+        """
+            Clear the slicer on the plot
+        """
+        if not self.slicer==None:
+            self.slicer.clear()
+            self.subplot.figure.canvas.draw()
+            self.slicer = None
+        
+            # Post slicer None event
+            event = self._getEmptySlicerEvent()
+            wx.PostEvent(self.parent, event)
           
     def _onEditDetector(self, event):
@@ -553,5 +647,5 @@
     def _onToggleScale(self, event):
         """
-            toggle axis and replot image
+            toggle pixel scale and replot image
         """
         if self.scale == 'log':
@@ -562,4 +656,9 @@
                    self.ymax_2D,self.zmin_2D ,self.zmax_2D )
         wx.PostEvent(self.parent, StatusEvent(status="Image is in %s scale"%self.scale))
+        
+        
+        
+        
+        
         
 class View1DModelPanel2D( View1DPanel2D):
