Index: src/sas/sasgui/guiframe/local_perspectives/plotting/SectorSlicer.py
===================================================================
--- src/sas/sasgui/guiframe/local_perspectives/plotting/SectorSlicer.py	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sasgui/guiframe/local_perspectives/plotting/SectorSlicer.py	(revision 3bdbfcc5cdff8a3a11a9bb19c1cc8c3660a9c2e2)
@@ -3,80 +3,64 @@
 """
 import math
-import wx
+from PyQt4 import QtGui
+from PyQt4 import QtCore
+
 from BaseInteractor import _BaseInteractor
-from sas.sasgui.guiframe.events import NewPlotEvent
-from sas.sasgui.guiframe.events import StatusEvent
-from sas.sasgui.guiframe.events import SlicerParameterEvent
-from sas.sasgui.guiframe.events import EVT_SLICER_PARS
 from sas.sasgui.guiframe.dataFitting import Data1D
-
-
-class SectorInteractor(_BaseInteractor):
+import sas.qtgui.GuiUtils as GuiUtils
+from sas.qtgui.SlicerModel import SlicerModel
+
+
+class SectorInteractor(_BaseInteractor, SlicerModel):
     """
     Draw a sector slicer.Allow to performQ averaging on data 2D
     """
-    def __init__(self, base, axes, color='black', zorder=3):
+    def __init__(self, base, axes, item=None, color='black', zorder=3):
 
         _BaseInteractor.__init__(self, base, axes, color=color)
-        ## Class initialization
+        SlicerModel.__init__(self)
+        # Class initialization
         self.markers = []
         self.axes = axes
-        ## connect the plot to event
+        self._item = item
+        # Connect the plot to event
         self.connect = self.base.connect
 
-        ## compute qmax limit to reset the graph
-        x = math.pow(max(self.base.data2D.xmax,
-                         math.fabs(self.base.data2D.xmin)), 2)
-        y = math.pow(max(self.base.data2D.ymax,
-                         math.fabs(self.base.data2D.ymin)), 2)
+        # Compute qmax limit to reset the graph
+        x = math.pow(max(self.base.data.xmax,
+                         math.fabs(self.base.data.xmin)), 2)
+        y = math.pow(max(self.base.data.ymax,
+                         math.fabs(self.base.data.ymin)), 2)
         self.qmax = math.sqrt(x + y)
-        ## Number of points on the plot
+        # Number of points on the plot
         self.nbins = 20
-        ## Angle of the middle line
+        # Angle of the middle line
         self.theta2 = math.pi / 3
-        ## Absolute value of the Angle between the middle line and any side line
+        # Absolute value of the Angle between the middle line and any side line
         self.phi = math.pi / 12
-        ## Middle line
-        self.main_line = LineInteractor(self, self.base.subplot, color='blue',
+        # Middle line
+        self.main_line = LineInteractor(self, self.axes, color='blue',
                                         zorder=zorder, r=self.qmax,
                                         theta=self.theta2)
         self.main_line.qmax = self.qmax
-        ## Right Side line
-        self.right_line = SideInteractor(self, self.base.subplot, color='black',
+        # Right Side line
+        self.right_line = SideInteractor(self, self.axes, color='black',
                                          zorder=zorder, r=self.qmax,
                                          phi=-1 * self.phi, theta2=self.theta2)
         self.right_line.qmax = self.qmax
-        ## Left Side line
-        self.left_line = SideInteractor(self, self.base.subplot, color='black',
+        # Left Side line
+        self.left_line = SideInteractor(self, self.axes, color='black',
                                         zorder=zorder, r=self.qmax,
                                         phi=self.phi, theta2=self.theta2)
         self.left_line.qmax = self.qmax
-        ## draw the sector
+        # draw the sector
         self.update()
         self._post_data()
-        ## Bind to slice parameter events
-        self.base.Bind(EVT_SLICER_PARS, self._onEVT_SLICER_PARS)
-
-    def _onEVT_SLICER_PARS(self, event):
-        """
-        receive an event containing parameters values to reset the slicer
-
-        :param event: event of type SlicerParameterEvent with params as
-        attribute
-
-        """
-        wx.PostEvent(self.base.parent,
-                     StatusEvent(status="SectorSlicer._onEVT_SLICER_PARS"))
-        event.Skip()
-        if event.type == self.__class__.__name__:
-            self.set_params(event.params)
-            self.base.update()
+        self.setModelFromParams()
 
     def set_layer(self, n):
         """
          Allow adding plot to the same panel
-
         :param n: the number of layer
-
         """
         self.layernum = n
@@ -92,5 +76,4 @@
         self.right_line.clear()
         self.base.connect.clearall()
-        self.base.Unbind(EVT_SLICER_PARS)
 
     def update(self):
@@ -100,6 +83,6 @@
         """
         # Update locations
-        ## Check if the middle line was dragged and
-        #update the picture accordingly
+        # Check if the middle line was dragged and
+        # update the picture accordingly
         if self.main_line.has_move:
             self.main_line.update()
@@ -108,5 +91,5 @@
             self.left_line.update(delta=self.left_line.phi / 2,
                                   mline=self.main_line.theta)
-        ## Check if the left side has moved and update the slicer accordingly
+        # Check if the left side has moved and update the slicer accordingly
         if self.left_line.has_move:
             self.main_line.update()
@@ -116,6 +99,5 @@
                                    mline=self.main_line, side=True,
                                    left=False, right=True)
-        ## Check if the right side line has moved and
-        #update the slicer accordingly
+        # Check if the right side line has moved and update the slicer accordingly
         if self.right_line.has_move:
             self.main_line.update()
@@ -130,5 +112,4 @@
         can restore on Esc.
         """
-        self.base.freeze_axes()
         self.main_line.save(ev)
         self.right_line.save(ev)
@@ -141,10 +122,10 @@
         :param nbins: the number of point to plot for the average 1D data
         """
-        ## get the data2D to average
-        data = self.base.data2D
+        # Get the data2D to average
+        data = self.base.data
         # If we have no data, just return
         if data == None:
             return
-        ## Averaging
+        # Averaging
         from sas.sascalc.dataloader.manipulations import SectorQ
         radius = self.qmax
@@ -157,6 +138,6 @@
                        phi_max=phimax + math.pi, nbins=nbins)
 
-        sector = sect(self.base.data2D)
-        ##Create 1D data resulting from average
+        sector = sect(self.base.data)
+        # Create 1D data resulting from average
 
         if hasattr(sector, "dxl"):
@@ -171,23 +152,26 @@
         new_plot.dxl = dxl
         new_plot.dxw = dxw
-        new_plot.name = "SectorQ" + "(" + self.base.data2D.name + ")"
-        new_plot.source = self.base.data2D.source
-        #new_plot.info=self.base.data2D.info
+        new_plot.name = "SectorQ" + "(" + self.base.data.name + ")"
+        new_plot.title = "SectorQ" + "(" + self.base.data.name + ")"
+        new_plot.source = self.base.data.source
         new_plot.interactive = True
-        new_plot.detector = self.base.data2D.detector
-        ## If the data file does not tell us what the axes are, just assume...
+        new_plot.detector = self.base.data.detector
+        # If the data file does not tell us what the axes are, just assume them.
         new_plot.xaxis("\\rm{Q}", "A^{-1}")
         new_plot.yaxis("\\rm{Intensity}", "cm^{-1}")
         if hasattr(data, "scale") and data.scale == 'linear' and \
-                self.base.data2D.name.count("Residuals") > 0:
+                self.base.data.name.count("Residuals") > 0:
             new_plot.ytransform = 'y'
             new_plot.yaxis("\\rm{Residuals} ", "/")
 
-        new_plot.group_id = "2daverage" + self.base.data2D.name
-        new_plot.id = "SectorQ" + self.base.data2D.name
+        new_plot.group_id = "2daverage" + self.base.data.name
+        new_plot.id = "SectorQ" + self.base.data.name
         new_plot.is_data = True
-        self.base.parent.update_theory(data_id=data.id, theory=new_plot)
-        wx.PostEvent(self.base.parent,
-                     NewPlotEvent(plot=new_plot, title="SectorQ" + self.base.data2D.name))
+        variant_plot = QtCore.QVariant(new_plot)
+        GuiUtils.updateModelItemWithPlot(self._item, variant_plot, new_plot.id)
+
+        if self.update_model:
+            self.setModelFromParams()
+        self.draw()
 
     def moveend(self, ev):
@@ -195,11 +179,6 @@
         Called a dragging motion ends.Get slicer event
         """
-        self.base.thaw_axes()
-        ## Post parameters
-        event = SlicerParameterEvent()
-        event.type = self.__class__.__name__
-        event.params = self.get_params()
-        ## Send slicer paramers to plotter2D
-        wx.PostEvent(self.base, event)
+        # Post parameters
+        self._post_data(self.nbins)
 
     def restore(self):
@@ -222,14 +201,12 @@
         pass
 
-    def get_params(self):
+    def getParams(self):
         """
         Store a copy of values of parameters of the slicer into a dictionary.
-
         :return params: the dictionary created
-
         """
         params = {}
-        ## Always make sure that the left and the right line are at phi
-        ## angle of the middle line
+        # Always make sure that the left and the right line are at phi
+        # angle of the middle line
         if math.fabs(self.left_line.phi) != math.fabs(self.right_line.phi):
             msg = "Phi left and phi right are different"
@@ -241,5 +218,5 @@
         return params
 
-    def set_params(self, params):
+    def setParams(self, params):
         """
         Receive a dictionary and reset the slicer with values contained
@@ -253,5 +230,5 @@
         self.nbins = int(params["nbins"])
         self.main_line.theta = main
-        ## Reset the slicer parameters
+        # Reset the slicer parameters
         self.main_line.update()
         self.right_line.update(phi=phi, delta=None, mline=self.main_line,
@@ -259,16 +236,6 @@
         self.left_line.update(phi=phi, delta=None,
                               mline=self.main_line, side=True)
-        ## post the new corresponding data
+        # Post the new corresponding data
         self._post_data(nbins=self.nbins)
-
-    def freeze_axes(self):
-        """
-        """
-        self.base.freeze_axes()
-
-    def thaw_axes(self):
-        """
-        """
-        self.base.thaw_axes()
 
     def draw(self):
@@ -291,23 +258,23 @@
         """
         _BaseInteractor.__init__(self, base, axes, color=color)
-        ## Initialize the class
+        # Initialize the class
         self.markers = []
         self.axes = axes
-        ## compute the value of the angle between the current line and
-        ## the x-axis
+        # compute the value of the angle between the current line and
+        # the x-axis
         self.save_theta = theta2 + phi
         self.theta = theta2 + phi
-        ## the value of the middle line angle with respect to the x-axis
+        # the value of the middle line angle with respect to the x-axis
         self.theta2 = theta2
-        ## Radius to find polar coordinates this line's endpoints
+        # Radius to find polar coordinates this line's endpoints
         self.radius = r
-        ## phi is the phase between the current line and the middle line
+        # phi is the phase between the current line and the middle line
         self.phi = phi
-        ## End points polar coordinates
+        # End points polar coordinates
         x1 = self.radius * math.cos(self.theta)
         y1 = self.radius * math.sin(self.theta)
         x2 = -1 * self.radius * math.cos(self.theta)
         y2 = -1 * self.radius * math.sin(self.theta)
-        ## defining a new marker
+        # Defining a new marker
         self.inner_marker = self.axes.plot([x1 / 2.5], [y1 / 2.5], linestyle='',
                                            marker='s', markersize=10,
@@ -316,13 +283,13 @@
                                            zorder=zorder, visible=True)[0]
 
-        ## Defining the current line
+        # Defining the current line
         self.line = self.axes.plot([x1, x2], [y1, y2],
                                    linestyle='-', marker='',
                                    color=self.color, visible=True)[0]
-        ## Flag to differentiate the left line from the right line motion
+        # Flag to differentiate the left line from the right line motion
         self.left_moving = False
-        ## Flag to define a motion
+        # Flag to define a motion
         self.has_move = False
-        ## connecting markers and draw the picture
+        # connecting markers and draw the picture
         self.connect_markers([self.inner_marker, self.line])
 
@@ -330,7 +297,5 @@
         """
         Allow adding plot to the same panel
-
         :param n: the number of layer
-
         """
         self.layernum = n
@@ -359,5 +324,4 @@
 
         """
-        #print "update left or right ", self.has_move
         self.left_moving = left
         theta3 = 0
@@ -396,5 +360,4 @@
         """
         self.save_theta = self.theta
-        self.base.freeze_axes()
 
     def moveend(self, ev):
@@ -416,5 +379,4 @@
         self.theta = math.atan2(y, x)
         self.has_move = True
-        #ToDo: Simplify below
         if not self.left_moving:
             if  self.theta2 - self.theta <= 0 and self.theta2 > 0:
@@ -464,5 +426,5 @@
         self.update()
 
-    def get_params(self):
+    def getParams(self):
         """
         """
@@ -472,5 +434,5 @@
         return params
 
-    def set_params(self, params):
+    def setParams(self, params):
         """
         """
@@ -554,5 +516,4 @@
         """
         self.save_theta = self.theta
-        self.base.freeze_axes()
 
     def moveend(self, ev):
@@ -582,5 +543,5 @@
         self.update()
 
-    def get_params(self):
+    def getParams(self):
         """
         """
@@ -590,5 +551,5 @@
         return params
 
-    def set_params(self, params):
+    def setParams(self, params):
         """
         """
