Index: sansview/perspectives/fitting/fitting.py
===================================================================
--- sansview/perspectives/fitting/fitting.py	(revision 3fef0a86cb57e82bef69a068c169760ae742bbdc)
+++ sansview/perspectives/fitting/fitting.py	(revision 6ed82c726014b9f3a1007b11164aa514cebece85)
@@ -7,6 +7,7 @@
 from sans.guicomm.events import NewPlotEvent, StatusEvent  
 from sans.guicomm.events import EVT_SLICER_PANEL,ERR_DATA
-
+from sans.guiframe import dataFitting
 from sans.fit.AbstractFitEngine import Model,FitData1D,FitData2D
+
 from fitproblem import FitProblem
 from fitpanel import FitPanel
@@ -14,4 +15,5 @@
 import models
 import fitpage
+
 
 DEFAULT_BEAM = 0.005
@@ -254,8 +256,7 @@
             
         from sans.guiframe import dataFitting 
-        if item.__class__.__name__=="Data1D":
-            data= dataFitting.Data1D(x=item.x, y=item.y, dy=dy, dxl=dxl, dxw=dxw)
-        else:
-            data= dataFitting.Theory1D(x=item.x, y=item.y, dxl=dxl, dxw=dxw)
+        
+        data= dataFitting.Data1D(x=item.x, y=item.y, dy=dy, dxl=dxl, dxw=dxw)
+        
         data.name = item.name
         data.detector = detector
@@ -268,4 +269,8 @@
         ## to save  data 1D as cansas xml file
         data.info= info
+        is_data=False
+        if hasattr(item, "is_data"):
+            is_data= item.is_data
+        data.is_data = is_data
         ## If the data file does not tell us what the axes are, just assume...
         data.xaxis(copy.deepcopy(item._xaxis),copy.deepcopy(item._xunit))
@@ -561,7 +566,20 @@
         """
         self.panel = event.GetEventObject()
-        for item in self.panel.graph.plottables:
-            
-            if item.name == self.panel.graph.selected_plottable:
+        for plottable in self.panel.graph.plottables:
+            
+            if plottable.name == self.panel.graph.selected_plottable:
+                if not hasattr(plottable, "is_data")or \
+                    plottable.__class__.__name__=="Theory1D":
+                    dy=numpy.zeros(len(plottable.y))
+                    if hasattr(plottable, "dy"):
+                        dy= copy.deepcopy(plottable.dy)
+                    item= self.copy_data(plottable, dy)
+                    item.group_id += "data1D"
+                    item.id +="data1D"
+                    item.is_data= False
+                    title = item.name
+                    wx.PostEvent(self.parent, NewPlotEvent(plot=item, title=str(title)))
+                else:
+                    item= copy.deepcopy(plottable)  
                 ## put the errors values back to the model if the errors were hiden
                 ## before sending them to the fit engine
@@ -579,5 +597,17 @@
                         data= copy.deepcopy(item)
             else:
-                data= copy.deepcopy(item)
+                ## Data2D case
+                if not hasattr(plottable, "is_data"):
+                    item= copy.deepcopy(plottable)
+                    item.group_id += "data2D"
+                    item.id +="data2D"
+                    item.is_data= False
+                    title = item.name
+                    title += " Fit"
+                    data = item
+                    wx.PostEvent(self.parent, NewPlotEvent(plot=item, title=str(title)))
+                else:
+                    item= copy.deepcopy(plottable )
+                    data= copy.deepcopy(plottable )
             ## create anew page                   
             if item.name == self.panel.graph.selected_plottable or\
@@ -588,5 +618,6 @@
                     if page !=None:   
                         #create a fitproblem storing all link to data,model,page creation
-                        self.page_finder[page]= FitProblem()
+                        if not page in self.page_finder.keys():
+                            self.page_finder[page]= FitProblem()
                         ## item is almost the same as data but contains
                         ## axis info for plotting 
@@ -930,5 +961,5 @@
             title= my_info.title
             if title== None:
-                title="Analytical model 1D "
+                title = "Analytical model 1D "
                 wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot,
                              title= str(title), reset=True ))
@@ -984,4 +1015,5 @@
             theory.xmin= data.xmin
             theory.xmax= data.xmax
+        print "model comptele plot",theory.xmin,theory.xmax,theory.ymin,theory.ymin
        
         ## plot
