Index: guitools/PlotPanel.py
===================================================================
--- guitools/PlotPanel.py	(revision 08b9e5866d389fac2cb0c63fae5353ffbffb969f)
+++ guitools/PlotPanel.py	(revision c87d55a45e57622985ea41022323206eae4cd3da)
@@ -382,6 +382,12 @@
             when clicking on linear Fit on context menu , display Fitting Dialog
         """
-        list =[]
-        list = self.graph.returnPlottable()
+        list = {}
+        plotlist = self.graph.returnPlottable()
+        if self.graph.selected_plottable is not None:
+            for item in plotlist:
+                if item.name==self.graph.selected_plottable:
+                    list[item] = plotlist[item]
+        else:
+            list = plotlist
         from fitDialog import LinearFit
         
Index: guitools/test_panel.py
===================================================================
--- guitools/test_panel.py	(revision 057210c6ea19572fef82f93aab447415c671aaa2)
+++ guitools/test_panel.py	(revision c87d55a45e57622985ea41022323206eae4cd3da)
@@ -1,9 +1,75 @@
 import wx
 from PlotPanel import PlotPanel
-from plottables import Plottable, Graph, Data1D
+from plottables import Plottable, Graph, Data1D, Theory1D
 import  sys
 import numpy
-import pylab
+import random, math
 
+class SANSplotpanel(PlotPanel):
+    
+    def __init__(self, parent, id = -1, color = None,\
+        dpi = None, **kwargs):
+        PlotPanel.__init__(self, parent, id=id, color=color, dpi=dpi, **kwargs)
+        
+        # Keep track of the parent Frame
+        self.parent = parent
+        
+        # Internal list of plottable names (because graph 
+        # doesn't have a dictionary of handles for the plottables)
+        self.plots = {}
+        
+    def add_plottable(self, plot):
+        self.plots[plot.name] = plot
+        
+        self.graph.add(plot)
+        self.graph.xaxis('\\rm{q} ', 'A^{-1}')
+        self.graph.yaxis("\\rm{Intensity} ","cm^{-1}")
+        self.onResetGraph(None)
+                
+    def plottable_selected(self, id):
+        PlotPanel.plottable_selected(self, id)
+        if id is not None:
+            self.parent.SetStatusText("Hovering over %s" % self.graph.selected_plottable)
+        else:
+            self.parent.SetStatusText("")
+   
+                
+    def onContextMenu(self, event):
+        """
+            Default context menu for a plot panel
+        """
+        # Slicer plot popup menu
+        id = wx.NewId()
+        slicerpop = wx.Menu()
+        slicerpop.Append(id,'&Save image', 'Save image as PNG')
+        wx.EVT_MENU(self, id, self.onSaveImage)
+        
+        slicerpop.AppendSeparator()
+        id = wx.NewId()
+        slicerpop.Append(id, '&Change scale')
+        wx.EVT_MENU(self, id, self._onProperties)
+        
+        id = wx.NewId()
+        slicerpop.Append(id, '&Reset Graph')
+        wx.EVT_MENU(self, id, self.onResetGraph)
+ 
+        if self.graph.selected_plottable in self.plots:
+            # Careful here: Message to status bar
+            self.parent.SetStatusText("Fit a line to %s" % self.graph.selected_plottable)
+            id = wx.NewId()
+            slicerpop.AppendSeparator()
+            slicerpop.Append(id, '&Linear Fit to %s' % self.graph.selected_plottable )
+            wx.EVT_MENU(self, id, self.onFitting)
+       
+        pos = event.GetPosition()
+        pos = self.ScreenToClient(pos)
+        self.PopupMenu(slicerpop, pos)
+       
+    def onFitting(self, event):
+        if self.graph.selected_plottable is not None:
+            if self.plots[self.graph.selected_plottable].__class__.__name__ == 'Data1D':
+                PlotPanel.onFitting(self, event)     
+            else:
+                self.parent.SetStatusText("Can't fit a theory curve")
 
 class ViewerFrame(wx.Frame):
@@ -20,19 +86,5 @@
         
         # Panel for 1D plot
-        self.plotpanel    = PlotPanel(self, -1, style=wx.RAISED_BORDER)
-
-        x  = pylab.arange(0, 25, 1)
-        dx = numpy.zeros(len(x))
-        y  = x/2.0
-        dy = y*0.1
-
-        self.data = Data1D(x=x, y=y, dx=None, dy=dy)
-
-        # Graph        
-        self.graph = Graph()
-        self.graph.xaxis('\\rm{q} ', 'A^{-1}')
-        self.graph.yaxis("\\rm{Intensity} ","cm^{-1}")
-        self.graph.add(self.data)
-        self.graph.render(self.plotpanel)
+        self.plotpanel    = SANSplotpanel(self, -1, style=wx.RAISED_BORDER)
 
         # Set up the menu
@@ -63,6 +115,4 @@
         self.SetSizer(sizer)
         self.Centre()
-        
-        
                 
     def _setup_menus(self):
@@ -75,5 +125,14 @@
         # File menu
         filemenu = wx.Menu()
-        filemenu.Append(101,'&Quit', 'Exit')
+        
+        # Quit
+        id = wx.NewId()
+        filemenu.Append(id,'&Quit', 'Exit')
+        wx.EVT_MENU(self, id, self.Close)
+        
+        # New plot
+        id = wx.NewId()
+        filemenu.Append(id,'&Add data', 'Add a new curve to the plot')
+        wx.EVT_MENU(self, id, self._add_data)
  
         # Add sub menus
@@ -81,8 +140,5 @@
          
         self.SetMenuBar(menubar)
-        
-        # Bind handlers
-        wx.EVT_MENU(self, 101, self.Close)
-               
+
     def _onClose(self, event):
         """
@@ -90,13 +146,37 @@
         wx.Exit()
         sys.exit()
-                   
-    def Close(self, event=None):
-        """
-            Quit the application
-        """
-        wx.Frame.Close(self)
-        wx.Exit()
-        sys.exit()
-   
+           
+    def _add_data(self, event):
+        data_len = 25
+        x  = numpy.zeros(data_len)
+        y  = numpy.zeros(data_len)
+        x2  = numpy.zeros(data_len)
+        y2  = numpy.zeros(data_len)
+        dy2  = numpy.zeros(data_len)
+        x3  = numpy.zeros(data_len)
+        y3  = numpy.zeros(data_len)
+        dy3  = numpy.zeros(data_len)
+        for i in range(len(x)):
+            x[i] = i
+            x2[i] = i-0.1+0.2*random.random()
+            x3[i] = i-0.1+0.2*random.random()
+            y[i] = 0.5*(i+random.random())
+            y2[i] = i+random.random()
+            dy2[i] = math.sqrt(y2[i]) 
+            y3[i] = 0.3*(i+random.random())
+            dy3[i] = math.sqrt(y3[i]) 
+            
+        newplot = Theory1D(x=x, y=y)
+        newplot.name = "Theory curve"
+        self.plotpanel.add_plottable(newplot)
+        
+        newplot = Data1D(x=x2, y=y2, dy=dy2)
+        newplot.name = "Data set 1"
+        self.plotpanel.add_plottable(newplot)
+        
+        newplot = Data1D(x=x3, y=y3, dy=dy3)
+        newplot.name = "Data set 2"
+        self.plotpanel.add_plottable(newplot)
+            
   
 class ViewApp(wx.App):
