Index: sansview/perspectives/fitting/basepage.py
===================================================================
--- sansview/perspectives/fitting/basepage.py	(revision 1467e1a676c0b3d34d59d4747eaad76d397f7ba0)
+++ sansview/perspectives/fitting/basepage.py	(revision f8395e329a6cf36a0fd3f024baf3708193c845be)
@@ -934,5 +934,4 @@
             @param statelist: list of state object to store the current state
         """
-        #statelist=[]
         if len(listtocopy)==0:
             return
Index: sansview/perspectives/fitting/invariant.py
===================================================================
--- sansview/perspectives/fitting/invariant.py	(revision f8395e329a6cf36a0fd3f024baf3708193c845be)
+++ sansview/perspectives/fitting/invariant.py	(revision f8395e329a6cf36a0fd3f024baf3708193c845be)
@@ -0,0 +1,131 @@
+"""
+    This module is responsible to compute invariant related computation.
+    @author: Gervaise B. Alina/UTK
+"""
+import numpy
+class InvariantCalculator(object):
+    """
+        Compute invariant 
+    """
+    def __init__(self):
+        """
+            Initialize variables
+        """
+        self.x =[]
+        self.y =[]
+        self.dxl = None
+        
+    def setData(self, x=[], y=[], dxl=None):
+        """
+            set the data 
+        """
+        tempx = numpy.array(x)
+        tempy = numpy.array(y)
+        #Make sure data is order before computing
+        ind = numpy.lexsort((tempy,tempx))
+        self.x = tempx[ind]
+        self.y = tempy[ind]
+        if dxl !=None:
+            tempdxl= numpy.array(dxl)
+            self.dxl= tempdxl[ind]
+        else:
+            self.dxl=dxl
+      
+    
+    def computeInvariant(self):
+        """
+            Compute invariant
+        """
+        if len(self.x)<=1 or len(self.y)<=1 or len(self.x)!=len(self.y):
+            msg=  "Length x and y must be equal"
+            msg +=" and greater than 1; got x=%s, y=%s"%(len(self.x),len(self.y))
+            raise ValueError,msg
+        elif len(self.x)==1 and len(self.y)==1:
+            return 0
+    
+        else:
+            n= len(self.x)-1
+            #compute the first delta
+            dx0= self.x[1]- self.x[0]
+            #compute the last delta
+            dxn= self.x[n]- self.x[n-1]
+            sum = 0
+            sum += self.x[0]* self.x[0]* self.y[0]*dx0
+            sum += self.x[n]* self.x[n]* self.y[n]*dxn
+            if len(self.x)==2:
+                return sum
+            else:
+                #iterate between for element different from the first and the last
+                for i in xrange(1, n-1):
+                    dxi = (self.x[i+1] - self.x[i-1])/2
+                    sum += self.x[i]*self.x[i]* self.y[i]* dxi
+                return sum
+            
+               
+    def computeSmearInvariant(self):
+        """
+            Compute invariant with smearing info
+        """
+        if self.dxl ==None:
+            msg = "Cannot compute Smear invariant dxl "
+            msg +="must be a list, got dx= %s"%str(self.dxl)
+            raise ValueError,msg
+
+        if len(self.x)<=1 or len(self.y)<=1 or len(self.x)!=len(self.y)\
+                or len(self.x)!= len(self.dxl):
+            msg=  "Length x and y must be equal"
+            msg +=" and greater than 1; got x=%s, y=%s"%(len(self.x),len(self.y))
+            raise ValueError,msg
+        else:
+            n= len(self.x)-1
+            #compute the first delta
+            dx0= self.x[1]- self.x[0]
+            #compute the last delta
+            dxn= self.x[n]- self.x[n-1]
+            sum = 0
+            sum += self.x[0]* self.dxl[0]* self.y[0]*dx0
+            sum += self.x[n]* self.dxl[n]* self.y[n]*dxn
+            if len(self.x)==2:
+                return sum
+            else:
+                #iterate between for element different from the first and the last
+                for i in xrange(1, n-1):
+                    dxi = (self.x[i+1] - self.x[i-1])/2
+                    sum += self.x[i]*self.dxl[i]* self.y[i]* dxi
+                return sum
+            
+if __name__=="__main__":
+    # test the module
+    x=[1,2,3,4,10]
+    y=[2,3,4,5,6]
+   
+    I= InvariantCalculator()
+    I.setData(x=x, y=y)
+    invariant = I.computeInvariant()
+    print "1-Invariant : ", invariant
+    
+    x=[0,1]
+    y=[0,2]
+    I.setData(x=x, y=y)
+    invariant = I.computeInvariant()
+    print "2-Invariant : ", invariant
+    
+    x=[1,3,4,10,2]
+    y=[2,4,5,6,3]
+    I.setData(x=x, y=y)
+    invariant = I.computeInvariant()
+    print "3-Invariant : ", invariant
+    
+    # compute invariant with smear information
+    from sans.guiframe.dataFitting import Data1D
+    data1= Data1D(x=x,y=y )
+    data1.dxl =[0.1,0.1,0.1,0.1,0.1]
+   
+    I.setData(x= data1.x, y= data1.y, dxl=data1.dxl)
+    invariant = I.computeSmearInvariant()
+    print "4-Smear Invariant:", invariant
+    I.setData(x= data1.x, y= data1.y)
+    try:
+        invariant = I.computeSmearInvariant()
+    except:
+        print "5-Smear Invariant error for dxl=None"
Index: sansview/perspectives/fitting/invariantDialog.py
===================================================================
--- sansview/perspectives/fitting/invariantDialog.py	(revision f8395e329a6cf36a0fd3f024baf3708193c845be)
+++ sansview/perspectives/fitting/invariantDialog.py	(revision f8395e329a6cf36a0fd3f024baf3708193c845be)
@@ -0,0 +1,72 @@
+"""
+    Provide GUI for invariant calculation
+"""
+import wx
+from invariant import InvariantCalculator
+_BOX_WIDTH = 76
+_STATICBOX_WIDTH = 200
+
+
+class InvariantDialog(wx.Dialog):
+    """
+        Panel displaying results of calculations
+    """
+    def __init__(self, parent,base=None, id = -1, *args, **kwds ):
+        wx.Dialog.__init__(self, parent, id = id, *args, **kwds)
+        #Object that receives status event
+        self.base= base
+        self.calculator = InvariantCalculator()
+    
+        self._do_layout()
+        self.SetAutoLayout(True)
+        self.Layout()
+       
+
+    def _do_layout(self):
+        """
+            Draw window content
+        """
+        sizer1 = wx.BoxSizer(wx.HORIZONTAL)
+        sizer2 = wx.BoxSizer(wx.VERTICAL)
+        
+        self.q_result_txt= wx.StaticText(self, -1, "Q*")
+        self.q_result_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH ,-1))
+        self.q_unit_txt= wx.StaticText(self, -1, "[A^(-3)cm^(-1)]")
+        
+        definitionbox = wx.StaticBox(self, -1, "Definitions")
+        boxsizer = wx.StaticBoxSizer(definitionbox, wx.VERTICAL)
+        boxsizer.SetMinSize((_STATICBOX_WIDTH,-1))
+        text= "this is the definition"
+        self.definition_txt= wx.StaticText(self, -1, text)
+        sizer_definition = wx.BoxSizer(wx.VERTICAL)
+        sizer_definition.Add(self.definition_txt)
+        boxsizer.Add( sizer_definition )
+        sizer2.Add(boxsizer,0, wx.EXPAND | wx.ALL, 20)
+       
+        sizer1.Add(self.q_result_txt,wx.LEFT , 100)
+        sizer1.Add(self.q_result_ctl)
+        sizer1.Add(self.q_unit_txt)
+        
+        self.button_OK = wx.Button(self, wx.ID_OK, "OK")
+        self.Bind(wx.EVT_BUTTON, self.checkValues, self.button_OK)
+        vbox  = wx.BoxSizer(wx.VERTICAL)
+        vbox.Add((20,20))
+        vbox.Add(sizer1)
+        vbox.Add(sizer2)
+        vbox.Fit(self) 
+        self.SetSizer(vbox)
+        
+        
+class ViewApp(wx.App):
+    def OnInit(self):
+        dlg = InvariantDialog(None, id=-1, title="Invariant Calculator")    
+        dlg.Show(True)
+        self.SetTopWindow(dlg)
+        
+        return True
+        
+
+if __name__ == "__main__": 
+    app = ViewApp(0)
+    app.MainLoop()     
+       
