Index: src/sas/guiframe/local_perspectives/plotting/masking.py
===================================================================
--- src/sas/guiframe/local_perspectives/plotting/masking.py	(revision b5de88e13816ca80c8329096bc22edbab9a36123)
+++ src/sas/guiframe/local_perspectives/plotting/masking.py	(revision 7d56795669085f6578efe03fcbfb0a2068d2827e)
@@ -30,6 +30,11 @@
 from sas.guiframe.dataFitting import Data1D, Data2D
 from boxMask import BoxMask
+from sectorMask import SectorMask
+from AnnulusSlicer import CircularMask
+
 from sas.guiframe.events import SlicerEvent
 from sas.guiframe.events import StatusEvent
+from functools import partial
+
 (InternalEvent, EVT_INTERNAL) = wx.lib.newevent.NewEvent()
 
@@ -61,17 +66,12 @@
                  elapsed=0,
                  yieldtime=0.01,
-                 worktime=0.01
-                 ):
-        """
-        """
-        CalcThread.__init__(self, completefn,
-                 updatefn,
-                 yieldtime,
-                 worktime)
+                 worktime=0.01):
+        """
+        """
+        CalcThread.__init__(self, completefn, updatefn, yieldtime, worktime)
         self.starttime = 0
         self.id = id
         self.panel = panel
         self.image = image
-
 
     def compute(self):
@@ -158,34 +158,29 @@
         sizer.Add(shape_txt, (1, 1), flag=wx.TOP | wx.LEFT | wx.BOTTOM, border=5)
         self.innersector_rb = wx.RadioButton(self, -1, "Double Wings")
-        self.Bind(wx.EVT_RADIOBUTTON, self.onInnerSectorMask,
+        self.Bind(wx.EVT_RADIOBUTTON, partial(self._on_mask, slicer=SectorMask, inside=True),
                   id=self.innersector_rb.GetId())
         sizer.Add(self.innersector_rb, (2, 1),
                   flag=wx.RIGHT | wx.BOTTOM, border=5)
         self.innercircle_rb = wx.RadioButton(self, -1, "Circular Disk")
-        self.Bind(wx.EVT_RADIOBUTTON, self.onInnerRingMask,
+        self.Bind(wx.EVT_RADIOBUTTON, partial(self._on_mask, slicer=CircularMask, inside=True),
                   id=self.innercircle_rb.GetId())
         sizer.Add(self.innercircle_rb, (3, 1),
-                   flag=wx.RIGHT | wx.BOTTOM, border=5)
-
+                  flag=wx.RIGHT | wx.BOTTOM, border=5)
         self.innerbox_rb = wx.RadioButton(self, -1, "Rectangular Disk")
-        self.Bind(wx.EVT_RADIOBUTTON, self.onInnerBoxMask,
+        self.Bind(wx.EVT_RADIOBUTTON, partial(self._on_mask, slicer=BoxMask, inside=True),
                   id=self.innerbox_rb.GetId())
         sizer.Add(self.innerbox_rb, (4, 1), flag=wx.RIGHT | wx.BOTTOM, border=5)
-
         self.outersector_rb = wx.RadioButton(self, -1, "Double Wing Window")
-        self.Bind(wx.EVT_RADIOBUTTON, self.onOuterSectorMask,
+        self.Bind(wx.EVT_RADIOBUTTON, partial(self._on_mask, slicer=SectorMask, inside=False),
                   id=self.outersector_rb.GetId())
         sizer.Add(self.outersector_rb, (5, 1),
                   flag=wx.RIGHT | wx.BOTTOM, border=5)
-
-        # outersector_y_txt = wx.StaticText(self, -1, 'Outer Sector')
         self.outercircle_rb = wx.RadioButton(self, -1, "Circular Window")
-        self.Bind(wx.EVT_RADIOBUTTON, self.onOuterRingMask,
+        self.Bind(wx.EVT_RADIOBUTTON, partial(self._on_mask, slicer=CircularMask, inside=False),
                   id=self.outercircle_rb.GetId())
         sizer.Add(self.outercircle_rb, (6, 1),
                   flag=wx.RIGHT | wx.BOTTOM, border=5)
-        # outerbox_txt = wx.StaticText(self, -1, 'Outer Box')
         self.outerbox_rb = wx.RadioButton(self, -1, "Rectangular Window")
-        self.Bind(wx.EVT_RADIOBUTTON, self.onOuterBoxMask,
+        self.Bind(wx.EVT_RADIOBUTTON, partial(self._on_mask, slicer=BoxMask, inside=False),
                   id=self.outerbox_rb.GetId())
         sizer.Add(self.outerbox_rb, (7, 1), flag=wx.RIGHT | wx.BOTTOM, border=5)
@@ -204,10 +199,10 @@
         button_add = wx.Button(self, id_button, "Add")
         button_add.SetToolTipString("Add the mask drawn.")
-        button_add.Bind(wx.EVT_BUTTON, self.onAddMask, id=button_add.GetId())
+        button_add.Bind(wx.EVT_BUTTON, self._on_add_mask, id=button_add.GetId())
         sizer.Add(button_add, (13, 7))
         id_button = wx.NewId()
         button_erase = wx.Button(self, id_button, "Erase")
         button_erase.SetToolTipString("Erase the mask drawn.")
-        button_erase.Bind(wx.EVT_BUTTON, self.onEraseMask,
+        button_erase.Bind(wx.EVT_BUTTON, self._on_erase_mask,
                           id=button_erase.GetId())
         sizer.Add(button_erase, (13, 8))
@@ -215,5 +210,5 @@
         button_reset = wx.Button(self, id_button, "Reset")
         button_reset.SetToolTipString("Reset the mask.")
-        button_reset.Bind(wx.EVT_BUTTON, self.onResetMask,
+        button_reset.Bind(wx.EVT_BUTTON, self._on_reset_mask,
                           id=button_reset.GetId())
         sizer.Add(button_reset, (13, 9), flag=wx.RIGHT | wx.BOTTOM, border=15)
@@ -221,5 +216,5 @@
         button_reset = wx.Button(self, id_button, "Clear")
         button_reset.SetToolTipString("Clear all mask.")
-        button_reset.Bind(wx.EVT_BUTTON, self.onClearMask,
+        button_reset.Bind(wx.EVT_BUTTON, self._on_clear_mask,
                           id=button_reset.GetId())
         sizer.Add(button_reset, (13, 10), flag=wx.RIGHT | wx.BOTTOM, border=15)
@@ -230,7 +225,10 @@
         self.Show(True)
 
-    def onInnerBoxMask(self, event=None):
-        """
-        Call Draw Box Slicer and get mask inside of the box
+    def _on_mask(self, event=None, slicer=BoxMask, inside=True):
+        """
+            Draw a slicer and use it as mask
+            :param event: wx event
+            :param slicer: Slicer class to use
+            :param inside: whether we mask what's inside or outside the slicer
         """
         # get ready for next evt
@@ -238,8 +236,8 @@
         # from boxMask import BoxMask
         if event != None:
-            self.onClearSlicer(event)
+            self._on_clear_slicer(event)
         self.slicer_z += 1
-        self.slicer = BoxMask(self, self.subplot,
-                               zorder=self.slicer_z, side=True)
+        self.slicer = slicer(self, self.subplot,
+                             zorder=self.slicer_z, side=inside)
         self.subplot.set_ylim(self.data.ymin, self.data.ymax)
         self.subplot.set_xlim(self.data.xmin, self.data.xmax)
@@ -247,85 +245,5 @@
         self.slicer_mask = self.slicer.update()
 
-    def onOuterBoxMask(self, event=None):
-        """
-        Call Draw Box Slicer and get mask outside of the box
-        """
-        event.Skip()
-        # from boxMask import BoxMask
-        if event != None:
-            self.onClearSlicer(event)
-        self.slicer_z += 1
-        self.slicer = BoxMask(self, self.subplot,
-                               zorder=self.slicer_z, side=False)
-        self.subplot.set_ylim(self.data.ymin, self.data.ymax)
-        self.subplot.set_xlim(self.data.xmin, self.data.xmax)
-        self.update()
-        self.slicer_mask = self.slicer.update()
-
-    def onInnerSectorMask(self, event=None):
-        """
-        Call Draw Sector Slicer and get mask inside of the sector
-        """
-        event.Skip()
-        from sectorMask import SectorMask
-        if event != None:
-            self.onClearSlicer(event)
-        self.slicer_z += 1
-        self.slicer = SectorMask(self, self.subplot,
-                                  zorder=self.slicer_z, side=True)
-        self.subplot.set_ylim(self.data.ymin, self.data.ymax)
-        self.subplot.set_xlim(self.data.xmin, self.data.xmax)
-        self.update()
-        self.slicer_mask = self.slicer.update()
-
-    def onOuterSectorMask(self, event=None):
-        """
-        Call Draw Sector Slicer and get mask outside of the sector
-        """
-        event.Skip()
-        from sectorMask import SectorMask
-        if event != None:
-            self.onClearSlicer(event)
-        self.slicer_z += 1
-        self.slicer = SectorMask(self, self.subplot,
-                                  zorder=self.slicer_z, side=False)
-        self.subplot.set_ylim(self.data.ymin, self.data.ymax)
-        self.subplot.set_xlim(self.data.xmin, self.data.xmax)
-        self.update()
-        self.slicer_mask = self.slicer.update()
-
-    def onInnerRingMask(self, event=None):
-        """
-        Perform inner circular cut on Phi and draw circular slicer
-        """
-        event.Skip()
-        from AnnulusSlicer import CircularMask
-        if event != None:
-            self.onClearSlicer(event)
-        self.slicer_z += 1
-        self.slicer = CircularMask(self, self.subplot,
-                                   zorder=self.slicer_z, side=True)
-        self.subplot.set_ylim(self.data.ymin, self.data.ymax)
-        self.subplot.set_xlim(self.data.xmin, self.data.xmax)
-        self.update()
-        self.slicer_mask = self.slicer.update()
-
-    def onOuterRingMask(self, event=None):
-        """
-        Perform outer circular cut on Phi and draw circular slicer
-        """
-        event.Skip()
-        from AnnulusSlicer import CircularMask
-        if event != None:
-            self.onClearSlicer(event)
-        self.slicer_z += 1
-        self.slicer = CircularMask(self, self.subplot,
-                                   zorder=self.slicer_z, side=False)
-        self.subplot.set_ylim(self.data.ymin, self.data.ymax)
-        self.subplot.set_xlim(self.data.xmin, self.data.xmax)
-        self.update()
-        self.slicer_mask = self.slicer.update()
-
-    def onAddMask(self, event):
+    def _on_add_mask(self, event):
         """
         Add new mask to old mask
@@ -347,5 +265,5 @@
         self._update_mask(mask)
 
-    def onEraseMask(self, event):
+    def _on_erase_mask(self, event):
         """
         Erase new mask from old mask
@@ -357,5 +275,5 @@
             self._check_display_mask(mask, event)
 
-    def onResetMask(self, event):
+    def _on_reset_mask(self, event):
         """
         Reset mask to the original mask
@@ -363,5 +281,5 @@
         self.slicer_z += 1
         self.slicer = BoxMask(self, self.subplot,
-                               zorder=self.slicer_z, side=True)
+                              zorder=self.slicer_z, side=True)
         self.subplot.set_ylim(self.data.ymin, self.data.ymax)
         self.subplot.set_xlim(self.data.xmin, self.data.xmax)
@@ -371,5 +289,5 @@
         self._check_display_mask(mask, event)
 
-    def onClearMask(self, event):
+    def _on_clear_mask(self, event):
         """
         Clear mask
@@ -377,8 +295,7 @@
         self.slicer_z += 1
         self.slicer = BoxMask(self, self.subplot,
-                               zorder=self.slicer_z, side=True)
+                              zorder=self.slicer_z, side=True)
         self.subplot.set_ylim(self.data.ymin, self.data.ymax)
         self.subplot.set_xlim(self.data.xmin, self.data.xmax)
-        # mask = copy.deepcopy(self.default_mask)
         mask = numpy.ones(len(self.data.mask), dtype=bool)
         self.data.mask = mask
@@ -386,5 +303,5 @@
         self._check_display_mask(mask, event)
 
-    def onClearSlicer(self, event):
+    def _on_clear_slicer(self, event):
         """
         Clear the slicer on the plot
@@ -419,5 +336,5 @@
         """
         # the case of liitle numbers of True points
-        if (len(mask[mask]) < 10 and self.data != None):
+        if len(mask[mask]) < 10 and self.data != None:
             self.ShowMessage()
             mask = copy.deepcopy(self.mask)
@@ -454,15 +371,15 @@
             zmin = min(self.data.data[self.data.data > 0])
         # plot
-        plot = self.plotpanel.image(data=temp_mask,
-                       qx_data=self.data.qx_data,
-                       qy_data=self.data.qy_data,
-                       xmin=self.data.xmin,
-                       xmax=self.data.xmax,
-                       ymin=self.data.ymin,
-                       ymax=self.data.ymax,
-                       zmin=zmin,
-                       zmax=zmax,
-                       cmap=self.cmap,
-                       color=0, symbol=0, label=self.data.name)
+        self.plotpanel.image(data=temp_mask,
+                             qx_data=self.data.qx_data,
+                             qy_data=self.data.qy_data,
+                             xmin=self.data.xmin,
+                             xmax=self.data.xmax,
+                             ymin=self.data.ymin,
+                             ymax=self.data.ymax,
+                             zmin=zmin,
+                             zmax=zmax,
+                             cmap=self.cmap,
+                             color=0, symbol=0, label=self.data.name)
         # axis labels
         self.plotpanel.axes[0].set_xlabel('$\\rm{Q}_{x}(A^{-1})$')
@@ -583,6 +500,6 @@
         """
         cal_plot = CalcPlot(panel=self.plotpanel,
-                                   image=self.newplot,
-                                   completefn=self.complete)
+                            image=self.newplot,
+                            completefn=self.complete)
         cal_plot.queue()
 
@@ -625,5 +542,4 @@
         pass
 
-
     def _draw_model(self, event):
         """
@@ -655,11 +571,9 @@
             pass
 
-
 class Maskplotpanel(PlotPanel):
     """
     PlotPanel for Quick plot and masking plot
     """
-    def __init__(self, parent, id=-1, dimension=2, color=None,
-                                            dpi=None, **kwargs):
+    def __init__(self, parent, id=-1, dimension=2, color=None, dpi=None, **kwargs):
         """
         """
@@ -757,7 +671,5 @@
         status_type = 'stop'
 
-        if self.dimension == 3:
-            pass
-        else:
+        if not self.dimension == 3:
             self.subplot.figure.canvas.draw_idle()
 
@@ -798,13 +710,7 @@
         Status msg
         """
-        if type == "stop":
-            label = "Plotting..."
-            able = True
-        else:
-            label = "Wait..."
-            able = False
         if self.parent.parent.parent != None:
-                wx.PostEvent(self.parent.parent.parent,
-                             StatusEvent(status=msg, type=type))
+            wx.PostEvent(self.parent.parent.parent,
+                         StatusEvent(status=msg, type=type))
 
 class ViewerFrame(wx.Frame):
