Index: guitools/fitDialog.py
===================================================================
--- guitools/fitDialog.py	(revision 57896544f08828746f936a04451449e4a91450e1)
+++ guitools/fitDialog.py	(revision f52bea1de61984ae151243e2fed0972a4c7d83d5)
@@ -9,5 +9,5 @@
 class LinearFit(wx.Dialog):
     #def __init__(self, parent, id, title):
-    def __init__(self, parent, plottable, push_data, id, title):
+    def __init__(self, parent, plottable, push_data,transform, id, title):
         wx.Dialog.__init__(self, parent, id, title, size=(550, 300))
         """
@@ -15,8 +15,10 @@
         """
         self.parent = parent
+        self.transform = transform
         #dialog panel self call function to plot the fitting function
         self.push_data = push_data
         #dialog self plottable
         self.plottable = plottable
+        
         
         #Dialog interface
@@ -75,8 +77,9 @@
         sizer.Add(self.tcXmax, (iy, ix))
         iy += 1
-        ix = 1
+        ix = 3
         sizer.Add(self.btFit, (iy, ix))
         self.btFit.Bind(wx.EVT_BUTTON, self._onFit)
-        ix += 2
+        iy +=1
+        ix = 3
         sizer.Add(btClose, (iy, ix))
        
@@ -92,7 +95,13 @@
         
     def _onFit(self ,event):
-       
-        print "we are on fit"
+        """
+            Performs the fit. Receive an event when clicking on the button Fit.Computes chisqr ,
+            A and B parameters of the best linear fit y=Ax +B
+            Push a plottable to 
+        """
+       
         temp =[]
+        tempx=[]
+        tempy=[]
         xmin = self._checkVal(self.tcXmin.GetValue())
         xmax = self._checkVal(self.tcXmax.GetValue())
@@ -100,73 +109,78 @@
         #store the values of View in x,y, dx,dy
         x,y,dx,dy=self.plottable.returnValuesOfView()
-       
+        self.xtrans,self.ytrans= self.transform()
+        #Display the fittings values
+        default_A = self.model.getParam('A') 
+        default_B = self.model.getParam('B') 
+        cstA = fittings.Parameter(self.model, 'A', default_A)
+        cstB  = fittings.Parameter(self.model, 'B', default_B)
+        if  self.ytrans == "Log(y)":
+            for y_i in y:
+                tempy.append(log(y_i))       
+            chisqr, out, cov = fittings.sansfit(self.model, 
+                            [cstA, cstB],x, tempy,dy,min(x),max(x))
+        else :
+            chisqr, out, cov = fittings.sansfit(self.model, 
+                            [cstA, cstB],x, y,dy,min(x),max(x))
+        #Check that cov and out are iterable before displaying them
+        if cov ==None:
+            errA =0.0
+            errB =0.0
+        else:
+            errA= math.sqrt(cov[0][0])
+            errB= math.sqrt(cov[1][1])
+        if out==None:
+            cstA=0.0
+            cstB=0.0
+        else:
+            cstA=out[0]
+            cstB=out[1]
+        self.model.setParam('A', float(cstA))
+        self.model.setParam('B', float(cstB))
+        
         if x != []:
             if xmin !=None  and xmax != None:
                 for j in range(len(x)):
-                    if x[j]>xmin and x[j]<xmax:
+                    if x[j] > xmin and x[j] < xmax:
                         temp.append(self.model.run(x[j]))
-                    
-                        for y_i in temp:
-                            tempdy.append(math.sqrt(y_i)) 
             else:
                 # x has a default value in case the user doesn't load data
                 for x_i in x:
                     temp.append(self.model.run(x_i))
-        
-                    self.tcXmin.SetValue(str(min(x)))
-                    self.tcXmax.SetValue(str(max(x)))
-                    xmin = self._checkVal(self.tcXmin.GetValue())
-                    xmax = self._checkVal(self.tcXmax.GetValue())
+                self.tcXmin.SetValue(str(min(x)))
+                self.tcXmax.SetValue(str(max(x)))
+                xmin = self._checkVal(self.tcXmin.GetValue())
+                xmax = self._checkVal(self.tcXmax.GetValue())
                 
             self.file_data1.x =x
-            self.file_data1.y =temp
-          
+            # Create new data plottable with result
+            self.file_data1.y =[]
+            self.xtrans, self.ytrans= self.transform()
+            
+            if self.ytrans == "Log(y)":
+                for x_i in x:
+                    self.file_data1.y.append(exp(self.model.run(x_i)))
+            else:
+                self.file_data1.y =temp     
             self.file_data1.dx=None
             self.file_data1.dy=None
+            
             self.file_data1.reset_view()
-        
-            # Display the fittings values
-            default_A = self.model.getParam('A') 
-            default_B = self.model.getParam('B') 
-            cstA = fittings.Parameter(self.model, 'A', default_A)
-            cstB  = fittings.Parameter(self.model, 'B', default_B)        
-            chisqr, out, cov = fittings.sansfit(self.model, 
-               [cstA, cstB],x, y,dy,min(x),max(x))
             
-           
-            #Check that cov and out are iterable before displaying them
-            if cov ==None:
-                errA =str(0.0)
-                errB =str(0.0)
-            else:
-                errA= str(math.sqrt(cov[0][0]))
-                errB= str(math.sqrt(cov[1][1]))
-            if out==None:
-                cstA=str(0.0)
-                cstB=str(0.0)
-            else:
-                cstA=str(out[0])
-                cstB=str(out[1])
-           
-            self.model.setParam('A', float(cstA))
-            self.model.setParam('B', float(cstB))
-             # Create new data plottable with result
-            self.file_data1.y = []
-           
-            for x_i in x:
-                self.file_data1.y.append(self.model.run(x_i))
             #Send the data to display to the PlotPanel
-            self.file_data1.reset_view()
+            #
             self.push_data(self.file_data1)
             # Display the fitting value on the Fit Dialog
-            self._onsetValues(cstA, cstB, errA,errB,str(chisqr))
+            self._onsetValues(cstA, cstB, errA,errB,chisqr)
        
     def _onsetValues(self,cstA,cstB,errA,errB,Chi):
-        
-         self.tcA.SetValue(cstA)
-         self.tcB.SetValue(cstB)
-         self.tcErrA.SetValue(errA)
-         self.tcErrB.SetValue(errB)
-         self.tcChi.SetValue(Chi)
+         """
+              Display  the value on fit Dialog 
+         """
+         self.tcA.SetValue(str(cstA))
+         self.tcB.SetValue(str(cstB))
+         self.tcErrA.SetValue(str(errA))
+         self.tcErrB.SetValue(str(errB))
+         self.tcChi.SetValue(str(Chi))
          
     def _returnPlottable(self):
@@ -175,6 +189,6 @@
     def _checkVal(self,value):
         """
-                Ensure that fields parameter contains a value 
-                before sending to fit in Plotter1D
+                Ensure that field parameter contains a value 
+                before sending to fit 
         """
         try:
