Index: guiframe/dataFitting.py
===================================================================
--- guiframe/dataFitting.py	(revision 1abcb049704ee303e0b32bdf82d7ac27976dab8b)
+++ guiframe/dataFitting.py	(revision ff3f900b45d2f0824d9871b811c47d536f87bc4c)
@@ -1,36 +1,63 @@
 """
-    A Data1D class compatible with guiframe from the output of DataLoader. 
+    Adapters for fitting module
 """
-from danse.common.plottools.plottables import Data1D as plotData1D
-from danse.common.plottools.plottables import Theory1D as plotTheory1D
+from danse.common.plottools.plottables import Data1D as PlotData1D
+from danse.common.plottools.plottables import Data2D as PlotData2D
 
-from DataLoader.data_info import Data1D as loader_data_1D
+from DataLoader.data_info import Data1D as LoadData1D
+from DataLoader.data_info import Data2D as LoadData2D
 
-class Data1D(plotData1D, loader_data_1D):
-    """
-        A Data1D class compatible with guiframe from 
-        the output of DataLoader. The new class inherits 
-        from DataLoader.data_info.Data1D
-    """
-    def __init__(self,x=[],y=[],dx=None,dy=None,dxl=None, dxw=None):
-        plotData1D.__init__(self, x, y, dx, dy)
-        loader_data_1D.__init__(self, x=x, y=y, dx=dx, dy=dy)
-        self.smearer=None
-       
-        self.dxl = dxl
-        self.dxw = dxw
- 
-class Theory1D(plotTheory1D, loader_data_1D):
-    """
-        A Theory1D class compatible with guiframe from 
-        the output of DataLoader. The new class inherits 
-        from DataLoader.data_info.Data1D
-    """
-    def __init__(self,x=[],y=[],dy=None,dxl=None, dxw=None):
-        plotTheory1D.__init__(self, x, y)
-        loader_data_1D.__init__(self, x=x, y=y, dx=dx, dy=dy)
-        self.smearer=None
+import copy
+
+class Data1D(PlotData1D,LoadData1D):
+    
+    def __init__(self,x=[],y=[],dx=None,dy=None):
+        PlotData1D.__init__(self, x, y, dx, dy)
+        LoadData1D.__init__(self, x, y, dx, dy)
+        self.id= None
+        self.group_id =None
+        self.is_data = True
+    
+    def copy_from_datainfo(self, data1d):
+        """
+            copy values of Data1D of type DataLaoder.Data_info
+        """
+        self.x  = copy.deepcopy(data1d.x)
+        self.dx = copy.deepcopy(data1d.dx)
+        self.y  = copy.deepcopy(data1d.y)
+        self.dy = copy.deepcopy(data1d.dy)
+        dxl = copy.deepcopy(data1d.dxl)
+        dxw = copy.deepcopy(data1d.dxw)
+    
+        self.xaxis(data1d._xaxis,data1d._xunit)
+        self.yaxis(data1d._yaxis,data1d._yunit)
+    
+    
+      
+class Data2D(PlotData2D,LoadData2D):
+    def __init__(self,image=None,err_image=None,xmin=None,xmax=None,ymin=None,ymax=None,zmin=None,zmax=None):
         
-        self.dxl = dxl
-        self.dxw = dxw
- 
+        PlotData2D.__init__(self, image=image, err_image=err_image,xmin=xmin, xmax=xmax,
+                            ymin=ymin, ymax=ymax)
+        
+        LoadData2D.__init__(self,data=image, err_data=err_image)
+        
+    def copy_from_datainfo(self, data2d):
+        """
+            copy value of Data2D of type DataLoader.data_info
+        """
+        self.data     =  copy.deepcopy(data2d.data)
+        self.err_data =  copy.deepcopy(data2d.err_data)
+        self.x_bins     = copy.deepcopy(data2d.x_bins)
+        self.y_bins     = copy.deepcopy(data2d.y_bins)
+        
+        self.xmin       = data2d.xmin
+        self.xmax       = data2d.xmax
+        self.ymin       = data2d.ymin
+        self.ymax       = data2d.ymax
+        
+        self.xaxis(data2d._xaxis,data2d._xunit)
+        self.yaxis(data2d._yaxis,data2d._yunit)
+        
+        
+        
Index: guiframe/data_loader.py
===================================================================
--- guiframe/data_loader.py	(revision 675e0abbb7babe88f28b713cd827fdb8f8546cf2)
+++ guiframe/data_loader.py	(revision ff3f900b45d2f0824d9871b811c47d536f87bc4c)
@@ -1,6 +1,6 @@
 import os, sys,numpy
 import wx
-from dataFitting import Data1D, Theory1D
-from danse.common.plottools.plottables import Data2D
+from dataFitting import Data1D
+from dataFitting import Data2D
 from DataLoader.loader import Loader
 
@@ -74,13 +74,4 @@
     """
         Use the DataLoader loader to created data to plot.
-        
-        TODO: this method needs a major cleanup. 
-        It's a complete mess. It needs:
-          - to be cleaned of code duplication
-          - to be cleaned of data duplication: we should not
-            need to reference all the Data1D data members.
-            It should be sufficient to use the Data1D class
-            defined in dataFitting (which btw needs a better name).
-        
         @param path: the path of the data to load
     """
@@ -94,55 +85,31 @@
     try:
         output=L.load(path)
-        
+        if output==None:
+            msg="Could not open this page"
+            wx.PostEvent(parent, StatusEvent(status=msg))
+            return
     except:
         wx.PostEvent(parent, StatusEvent(status="Problem loading file: %s" % sys.exc_value))
         return
-    if output==None:
-        msg="Could not open this page"
-        wx.PostEvent(parent, StatusEvent(status=msg))
-        return
+    
+  
     filename = os.path.basename(path)
     
     if not  output.__class__.__name__=="list":
-        ## smearing info
-        try:
-            dxl = output.dxl
-            dxw = output.dxw
-        except:
-            dxl = None
-            dxw = None
-       
-            
         ## Creating a Data2D with output
         if hasattr(output,'data'):
-            
-            new_plot = Data2D(image=output.data,err_image=output.err_data,
-                              xmin=output.xmin,xmax=output.xmax,
-                              ymin=output.ymin,ymax=output.ymax)
-            new_plot.x_bins=output.x_bins
-            new_plot.y_bins=output.y_bins
-            
-        ##Creating Data1D with output
+            new_plot = Data2D(image=None,err_image=None)
+      
         else:
-            ##dy values checked
-            dy= output.dy
-            if dy ==None:
-                dy= numpy.zeros(len(output.y))
-            
             msg="Loading 1D data: "
             wx.PostEvent(parent, StatusEvent(status= "%s %s"%(msg, output.filename)))
-            new_plot = Data1D(x=output.x, y=output.y, dx=output.dx,
-                              dy= dy, dxl=dxl, dxw=dxw)
-            # Copy all the data to the new object so that the 
-            # new_plot object properly behaves as a data_info.Data1D.
-            # This also means that we should not have to copy all
-            # the data below...
-            output.clone_without_data(clone=new_plot)
-                
-        ## source will request in dataLoader .manipulation module
-        new_plot.source=output.source
+            new_plot = Data1D(x=[], y=[], dx=None,dy= None)
+            
+        new_plot.copy_from_datainfo(output) 
+        output.clone_without_data(clone=new_plot)      
+      
         ## data 's name
-        if output.filename==None:
-            output.filename=str(filename)
+        if output.filename==None or output.filename=="":
+            output.filename = str(filename)
         ## name of the data allow to differentiate data when plotted
         name= output.filename
@@ -152,6 +119,6 @@
             ## create a copy of the loaded data
             parent.indice_load_data[name]+=1
-            name = name +"(copy %i)"%parent.indice_load_data[name]
-            
+            name = name +"[%i]"%parent.indice_load_data[name]
+       
         new_plot.name = name
         ## allow to highlight data when plotted
@@ -162,19 +129,15 @@
         ## to save  data 1D as cansas xml file
         new_plot.info= output
-        ## detector used by dataLoader.manipulation module
-        new_plot.detector =output.detector
-        ## If the data file does not tell us what the axes are, just assume...
-        new_plot.xaxis(output._xaxis,output._xunit)
-        new_plot.yaxis(output._yaxis,output._yunit)
         ##group_id specify on which panel to plot this data
         new_plot.group_id = name
         new_plot.is_data =True
         ##post data to plot
-        wx.PostEvent(parent, NewPlotEvent(plot=new_plot, title=str(name)))
+        if hasattr(new_plot,"title"):
+            title= str(new_plot.title)
+        else:
+            title = str(name)
+        wx.PostEvent(parent, NewPlotEvent(plot=new_plot, title= title ))
         
     ## the output of the loader is a list , some xml files contain more than one data
-    #TODO: refactor this so that there is no duplication of code.
-    # There is no reason why the code above shouldn't be put in 
-    # a private method to be used within the loop below.
     else:
         i=1
@@ -188,13 +151,11 @@
                 dxl=None
                 dxw=None
-            dy = item.dy  
-            if dy ==None:
-                dy= numpy.zeros(len(item.y))
-               
-            new_plot = Data1D(x=item.x,y=item.y,dx=dx,dy=item.dy,dxl=dxl,dxw=dxw)
-            # Copy all the data to the new object
+
+            new_plot = Data1D(x=item.x,y=item.y,dx=dx,dy=item.dy)
+            new_plot.copy_from_datainfo(item)
             item.clone_without_data(clone=new_plot)
-            new_plot.source=item.source
-            
+            new_plot.dxl = dxl
+            new_plot.dxw = dxw
+           
             name= str(item.run[0])
             if not name in parent.indice_load_data.keys():
@@ -213,8 +174,5 @@
             new_plot.name = name
             new_plot.interactive = True
-            new_plot.detector =item.detector
-            # If the data file does not tell us what the axes are, just assume...
-            new_plot.xaxis(item._xaxis,item._xunit)
-            new_plot.yaxis(item._yaxis,item._yunit)
+         
             new_plot.group_id = name
             new_plot.id = name
