Index: prview/perspectives/pr/inversion_state.py
===================================================================
--- prview/perspectives/pr/inversion_state.py	(revision 229da98c3eef5aedd1335551f0f9046c902df65f)
+++ prview/perspectives/pr/inversion_state.py	(revision a07e72f8fb8281178797bf691b36e56274d8580b)
@@ -17,5 +17,5 @@
 from xml.dom.minidom import parse
 from lxml import etree
-import DataLoader
+from sans.guiframe.dataFitting import Data1D
 from DataLoader.readers.cansas_reader import Reader as CansasReader
 from DataLoader.readers.cansas_reader import get_content
@@ -519,6 +519,6 @@
         """
         if datainfo is None:
-            datainfo = DataLoader.data_info.Data1D(x=[], y=[])    
-        elif not issubclass(datainfo.__class__, DataLoader.data_info.Data1D):
+            datainfo = Data1D(x=[], y=[])    
+        elif not issubclass(datainfo.__class__, Data1D):
             msg = "The cansas writer expects a Data1D "
             msg += "instance: %s" % str(datainfo.__class__.__name__)
Index: prview/perspectives/pr/pr.py
===================================================================
--- prview/perspectives/pr/pr.py	(revision 229da98c3eef5aedd1335551f0f9046c902df65f)
+++ prview/perspectives/pr/pr.py	(revision a07e72f8fb8281178797bf691b36e56274d8580b)
@@ -24,12 +24,10 @@
 import pylab
 from sans.guiframe.dataFitting import Data1D
-from sans.guiframe.dataFitting import Theory1D
 from sans.guiframe.events import NewPlotEvent
-from sans.guiframe.events import StatusEvent    
-
+from sans.guiframe.events import StatusEvent 
+from sans.guiframe.gui_style import GUIFRAME_ID   
 from sans.pr.invertor import Invertor
 from DataLoader.loader import Loader
-from DataLoader.data_info import Data1D as LoaderData1D
-import DataLoader
+
 from pr_widgets import load_error 
 from sans.guiframe.plugin_base import PluginBase
@@ -41,8 +39,4 @@
 IQ_FIT_LABEL       = r"$I_{fit}(q)$"
 IQ_SMEARED_LABEL   = r"$I_{smeared}(q)$"
-
-#import wx.lib
-#(NewPrFileEvent, EVT_PR_FILE) = wx.lib.newevent.NewEvent()
-
 
 
@@ -103,5 +97,4 @@
         
         # Associate the inversion state reader with .prv files
-        from DataLoader.loader import Loader
         from inversion_state import Reader
          
@@ -166,6 +159,5 @@
             self.control_panel.set_state(state)
         except:
-            raise
-            #logging.error("prview.set_state: %s" % sys.exc_value)
+            logging.error("prview.set_state: %s" % sys.exc_value)
 
   
@@ -188,8 +180,4 @@
         """
         from sans.pr.invertor import Invertor
-            
-        from danse.common.plottools import Data1D as PlotData1D
-        from danse.common.plottools import Theory1D as Theory1D
-        
         # Generate P(r) for sphere
         radius = 60.0
@@ -220,12 +208,17 @@
         for i in range(len(out)):
             print "%g +- %g" % (out[i], math.sqrt(cov[i][i]))
-
+        
         # Show input P(r)
-        new_plot = PlotData1D(pr.x, pr.y, dy=pr.err)
+        title = "Pr"
+        new_plot = Data1D(pr.x, pr.y, dy=pr.err)
         new_plot.name = "P_{obs}(r)"
         new_plot.xaxis("\\rm{r}", 'A')
         new_plot.yaxis("\\rm{P(r)} ","cm^{-3}")
-        print "_fit_pr"
-        wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="Pr"))
+        group_id = "P_{obs}(r)"
+        if group_id not in new_plot.group_id:
+            new_plot.group_id.append(group_id)
+        new_plot.id = "P_{obs}(r)"
+        new_plot.title = title
+        wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=title))
 
         # Show P(r) fit
@@ -239,5 +232,4 @@
         """
         """
-        from danse.common.plottools import Theory1D as PlotTheory1D
         # Show P(r)
         y_true = numpy.zeros(len(x))
@@ -251,5 +243,6 @@
         
         # Show the theory P(r)
-        new_plot = PlotTheory1D(x, y_true)
+        new_plot = Data1D(x, y_true)
+        new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM
         new_plot.name = "P_{true}(r)"
         new_plot.xaxis("\\rm{r}", 'A')
@@ -272,6 +265,4 @@
         """
         """  
-        from danse.common.plottools import Theory1D as PlotTheory1D
-
         qtemp = pr.x
         if not q==None:
@@ -304,15 +295,19 @@
                 print "Error getting error", value, x[i]
                 
-        new_plot = PlotTheory1D(x, y)
+        new_plot = Data1D(x, y)
+        new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM
         new_plot.name = IQ_FIT_LABEL
         new_plot.xaxis("\\rm{Q}", 'A^{-1}')
         new_plot.yaxis("\\rm{Intensity} ","cm^{-1}")
-        
         title = "I(q)"
+        new_plot.title = title
+        
         # If we have a group ID, use it
         if pr.info.has_key("plot_group_id"):
-            new_plot.group_id = pr.info["plot_group_id"]
-            title = pr.info["plot_group_id"]
-            
+            if len( pr.info["plot_group_id"]) > 0:
+                index =  len( pr.info["plot_group_id"]) - 1
+                new_plot.group_id.append( pr.info["plot_group_id"][index])
+        new_plot.id = IQ_FIT_LABEL
+        #new_plot.group_id.append(2)
         wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=title))
         
@@ -331,5 +326,6 @@
                     print "Error getting error", value, x[i]
                     
-            new_plot = Theory1D(x, y)
+            new_plot = Data1D(x, y)
+            new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM
             new_plot.name = IQ_SMEARED_LABEL
             new_plot.xaxis("\\rm{Q}", 'A^{-1}')
@@ -337,5 +333,11 @@
             # If we have a group ID, use it
             if pr.info.has_key("plot_group_id"):
-                new_plot.group_id = pr.info["plot_group_id"]
+                if len( pr.info["plot_group_id"]) > 0:
+                    index =  len( pr.info["plot_group_id"]) - 1
+                    new_plot.group_id.append( pr.info["plot_group_id"][index])
+           
+            new_plot.id = IQ_SMEARED_LABEL
+            new_plot.title = title
+            #new_plot.group_id.append(2)
             wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=title))
         
@@ -359,7 +361,4 @@
         """
         """     
-        from danse.common.plottools import Data1D as PlotData1D 
-        from danse.common.plottools import Theory1D as PlotTheory1D
-        
         # Show P(r)
         x = pylab.arange(0.0, pr.d_max, pr.d_max/self._pr_npts)
@@ -394,11 +393,13 @@
         
         if cov2==None:
-            new_plot = PlotTheory1D(x, y)
+            new_plot = Data1D(x, y)
+            new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM
         else:
-            new_plot = PlotData1D(x, y, dy=dy)
+            new_plot = Data1D(x, y, dy=dy)
         new_plot.name = PR_FIT_LABEL
         new_plot.xaxis("\\rm{r}", 'A')
         new_plot.yaxis("\\rm{P(r)} ","cm^{-3}")
         new_plot.title = "P(r) fit"
+        new_plot.id = PR_FIT_LABEL
         # Make sure that the plot is linear
         new_plot.xtransform = "x"
@@ -563,5 +564,5 @@
             return 0.0
 
-    def get_context_menu(self, graph=None):
+    def get_context_menu(self, plotpanel=None):
         """
         Get the context menu items available for P(r)
@@ -572,42 +573,38 @@
         
         """
+        graph = plotpanel.graph
         # Look whether this Graph contains P(r) data
-        #if graph.selected_plottable==IQ_DATA_LABEL:
-        for item in graph.plottables:
-            if item.name == PR_FIT_LABEL:
-                #add_data_hint = "Load a data file and display it on this plot"
-                #["Add P(r) data",add_data_hint , self._on_add_data],
-                change_n_hint = "Change the number of"
-                change_n_hint += " points on the P(r) output"
-                change_n_label = "Change number of P(r) points"
-                m_list = [[change_n_label, change_n_hint , self._on_pr_npts]]
-
-                if self._scale_output_unity or self._normalize_output:
-                    hint = "Let the output P(r) keep the scale of the data"
-                    m_list.append(["Disable P(r) scaling", hint, 
-                                   self._on_disable_scaling])
-                if not self._scale_output_unity:
-                    m_list.append(["Scale P_max(r) to unity", 
-                                   "Scale P(r) so that its maximum is 1", 
-                                   self._on_scale_unity])
-                if not self._normalize_output:
-                    m_list.append(["Normalize P(r) to unity", 
-                                   "Normalize the integral of P(r) to 1", 
-                                   self._on_normalize])
-                    
-                return m_list
-                #return [["Add P(r) data", 
-                #"Load a data file and display it on this plot",
-                # self._on_add_data],
-                #       ["Change number of P(r) points",
-                # "Change the number of points on the P(r) output",
-                # self._on_pr_npts]]
-
-            elif item.name == graph.selected_plottable:
-	            #TODO: we might want to check that the units are 
-	            #     consistent with I(q) before allowing this menu item
-                if not self.standalone and \
-                issubclass(item.__class__, DataLoader.data_info.Data1D):
-                    return [["Compute P(r)", 
+        if graph.selected_plottable not in plotpanel.plots:
+            return []
+        item = plotpanel.plots[graph.selected_plottable]
+        if item.id == PR_FIT_LABEL:
+            #add_data_hint = "Load a data file and display it on this plot"
+            #["Add P(r) data",add_data_hint , self._on_add_data],
+            change_n_hint = "Change the number of"
+            change_n_hint += " points on the P(r) output"
+            change_n_label = "Change number of P(r) points"
+            m_list = [[change_n_label, change_n_hint , self._on_pr_npts]]
+
+            if self._scale_output_unity or self._normalize_output:
+                hint = "Let the output P(r) keep the scale of the data"
+                m_list.append(["Disable P(r) scaling", hint, 
+                               self._on_disable_scaling])
+            if not self._scale_output_unity:
+                m_list.append(["Scale P_max(r) to unity", 
+                               "Scale P(r) so that its maximum is 1", 
+                               self._on_scale_unity])
+            if not self._normalize_output:
+                m_list.append(["Normalize P(r) to unity", 
+                               "Normalize the integral of P(r) to 1", 
+                               self._on_normalize])
+                
+            return m_list
+             
+        elif item.id in [PR_LOADED_LABEL, IQ_DATA_LABEL, IQ_FIT_LABEL,
+                          IQ_SMEARED_LABEL]:
+            return []
+        elif item.id == graph.selected_plottable:
+	       if not self.standalone and issubclass(item.__class__, Data1D):
+                return [["Compute P(r)", 
                              "Compute P(r) from distribution", 
                              self._on_context_inversion]]      
@@ -657,5 +654,11 @@
             y = self._added_plots[plot].y/sum
             
-            new_plot = Theory1D(self._added_plots[plot].x, y)
+            new_plot = Data1D(self._added_plots[plot].x, y)
+            new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM
+            index  = len(self._added_plots[plot].group_id) - 1
+            if group_id not in new_plot.group_id:
+                new_plot.group_id.append(group_id)
+            new_plot.id = self._added_plots[plot].id
+            new_plot.title = self._added_plots[plot].title
             new_plot.name = self._added_plots[plot].name
             new_plot.xaxis("\\rm{r}", 'A')
@@ -686,5 +689,6 @@
             y = self._added_plots[plot].y/_max
             
-            new_plot = Theory1D(self._added_plots[plot].x, y)
+            new_plot = Data1D(self._added_plots[plot].x, y)
+            new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM
             new_plot.name = self._added_plots[plot].name
             new_plot.xaxis("\\rm{r}", 'A')
@@ -736,7 +740,7 @@
         
         filename = os.path.basename(path)
-        
-        #new_plot = Data1D(x, y, dy=err)
-        new_plot = Theory1D(x, y)
+
+        new_plot = Data1D(x, y)
+        new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM
         new_plot.name = filename
         new_plot.xaxis("\\rm{r}", 'A')
@@ -863,5 +867,7 @@
             new_plot.xaxis("\\rm{Q}", 'A^{-1}')
             new_plot.yaxis("\\rm{Intensity} ","cm^{-1}")
-            #new_plot.group_id = "test group"
+            if pr.info.has_key("plot_group_id"):
+                new_plot.group_id.append(pr.info["plot_group_id"])
+            new_plot.id = IQ_DATA_LABEL
             wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="Iq"))
                 
@@ -884,9 +890,7 @@
         
         """
-        print "show_data", data.name
         #if path is not None:
         if data is not None:
             try:
-                #pr = self._create_file_pr(path)
                 pr = self._create_file_pr(data)
             except:
@@ -902,6 +906,7 @@
        
         # Make a plot of I(q) data
-        if self.pr.err==None:
-            new_plot = Theory1D(self.pr.x, self.pr.y)
+        if self.pr.err == None:
+            new_plot = Data1D(self.pr.x, self.pr.y)
+            new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM
         else:
             new_plot = Data1D(self.pr.x, self.pr.y, dy=self.pr.err)
@@ -910,12 +915,11 @@
         new_plot.yaxis("\\rm{Intensity} ","cm^{-1}")
         new_plot.interactive = True
-        #new_plot.group_id = "test group"
+        new_plot.group_id.append(IQ_DATA_LABEL)
+        new_plot.id = IQ_DATA_LABEL
+        new_plot.title = "I(q)"
         wx.PostEvent(self.parent, 
                      NewPlotEvent(plot=new_plot, title="I(q)", reset=reset))
         
         self.current_plottable = new_plot
-        self.current_plottable.group_id = IQ_DATA_LABEL
-        
-        
         # Get Q range
         self.control_panel.q_min = self.pr.x.min()
@@ -1021,5 +1025,7 @@
         # Keep track of the plot window title to ensure that
         # we can overlay the plots
-        if hasattr(self.current_plottable, "group_id"):
+        if self.current_plottable.group_id:
+            index = len(self.current_plottable.group_id) - 1
+            group_id = self.current_plottable.group_id[index]
             pr.info["plot_group_id"] = self.current_plottable.group_id
         
@@ -1329,5 +1335,5 @@
             if dlg.ShowModal() == wx.ID_OK:
                 data = dlg.get_data()
-                if issubclass(data.__class__, LoaderData1D):
+                if issubclass(data.__class__, Data1D):
                     self.control_panel._change_file(evt=None, data=data)
                 else:    
@@ -1337,5 +1343,5 @@
                              StatusEvent(status=msg, info='error'))
         elif len(data_list) == 1:
-            if issubclass(data_list[0].__class__, LoaderData1D):
+            if issubclass(data_list[0].__class__, Data1D):
                 self.control_panel._change_file(evt=None, data=data_list[0])
             else:
Index: prview/perspectives/pr/pr_widgets.py
===================================================================
--- prview/perspectives/pr/pr_widgets.py	(revision af91b687903ba4681033e2e0d336e931f2aa6835)
+++ prview/perspectives/pr/pr_widgets.py	(revision a07e72f8fb8281178797bf691b36e56274d8580b)
@@ -27,5 +27,5 @@
         
         ## Set to True when the mouse is clicked while the whole string is selected
-        full_selection = False
+        self.full_selection = False
         ## Call back for EVT_SET_FOCUS events
         _on_set_focus_callback = None
