Index: sansview/perspectives/fitting/fitting.py
===================================================================
--- sansview/perspectives/fitting/fitting.py	(revision 1b001a7ae233233602a7834bd523a959896ec2ff)
+++ sansview/perspectives/fitting/fitting.py	(revision 4faf4bad9d37a08d61abda7e341aad4fc88b1042)
@@ -26,4 +26,5 @@
 from sans.fit.AbstractFitEngine import Model
 from sans.fit.AbstractFitEngine import FitAbort
+
 
 from fitproblem import FitProblem
@@ -126,13 +127,18 @@
             
         self.menu1.AppendSeparator()
-        
         id1 = wx.NewId()
         simul_help = "Allow to edit fit engine with multiple model and data"
         self.menu1.Append(id1, '&Simultaneous Page',simul_help)
         wx.EVT_MENU(owner, id1, self.on_add_sim_page)
+        #menu for SLD Calculator
+        self.menu1.AppendSeparator()
+        sld_menu = wx.Menu()
+        sld_id = wx.NewId()
+        sld_help= "Compute the scattering length density of molecules"
+        self.menu1.Append(sld_id, "SLD Calculator",sld_help)
+        wx.EVT_MENU(owner,sld_id,  self.onCalculateSld)
     
         #menu for model
         menu2 = wx.Menu()
-    
         self.menu_mng.populate_menu(menu2, owner)
         id2 = wx.NewId()
@@ -516,6 +522,13 @@
             return 
            
-           
-           
+    def onCalculateSld(self, event):
+        """
+            Compute the scattering length density of molecula
+        """  
+        from sldPanel import SldWindow
+        frame = SldWindow(base=self.parent)
+        frame.Show(True) 
+      
+          
     def _onEVT_SLICER_PANEL(self, event):
         """
Index: sansview/perspectives/fitting/helpPanel.py
===================================================================
--- sansview/perspectives/fitting/helpPanel.py	(revision 6fb01b6018e1362284f713be5cb6ab1ab51bc47a)
+++ sansview/perspectives/fitting/helpPanel.py	(revision 4faf4bad9d37a08d61abda7e341aad4fc88b1042)
@@ -59,5 +59,5 @@
 
 class HelpWindow(wx.Frame):
-    def __init__(self, parent, id, title):
+    def __init__(self, parent, id, title= 'HelpWindow', pageToOpen=None):
         wx.Frame.__init__(self, parent, id, title, size=(700, 450))
         """
@@ -118,4 +118,5 @@
             <li><a href ="doc/model_use_help.html" target ="showframe">Visualize Model</a><br></li>
             <li><a href ="doc/averaging_help.html" target ="showframe">Data Averaging</a><br></li>
+            <li><a href ="doc/sld_calculator_help.html" target ="showframe">SLD Calculator</a><br></li>
             <li><a href ="doc/model_functions.html" target ="showframe">Model Functions</a><br></li>
             </ul>
@@ -126,7 +127,7 @@
         self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED,self.OnLinkClicked )
         
-        #'HelpWindow' from menu bar, title=model name from 'More Details' button in model penal
-        if title != 'HelpWindow':
-            self.rhelp.LoadPage("doc/model_functions.html")
+        #open the help frame a the current page
+        if  pageToOpen!= None:
+            self.rhelp.LoadPage(str( pageToOpen))
             
         vbox.Add(self.rhelp,1, wx.EXPAND)
Index: sansview/perspectives/fitting/model_thread.py
===================================================================
--- sansview/perspectives/fitting/model_thread.py	(revision cad821b4320fd56917a37ed3c875215b5d8fafca)
+++ sansview/perspectives/fitting/model_thread.py	(revision 4faf4bad9d37a08d61abda7e341aad4fc88b1042)
@@ -122,6 +122,6 @@
         
         ######Temp. FIX for Qrange w/ smear. #ToDo: Should not pass all the data to 'run' or 'smear'...
-        new_index = (self.qmin > self.x) |(self.x > self.qmax)
-        output[new_index] = None
+        #new_index = (self.qmin > self.x) |(self.x > self.qmax)
+        #output[new_index] = None
                 
         elapsed = time.time()-self.starttime
Index: sansview/perspectives/fitting/modelpage.py
===================================================================
--- sansview/perspectives/fitting/modelpage.py	(revision 58c6ba6fe2df1ff853cb54aaae283e16b4d6acc7)
+++ sansview/perspectives/fitting/modelpage.py	(revision 4faf4bad9d37a08d61abda7e341aad4fc88b1042)
@@ -433,5 +433,5 @@
         else:
             name = self.model.name
-        frame = HelpWindow(None, -1, name)    
+        frame = HelpWindow(None, -1,  pageToOpen="doc/model_functions.html")    
         frame.Show(True)
         if frame.rhelp.HasAnchor(name):
Index: sansview/perspectives/fitting/sldPanel.py
===================================================================
--- sansview/perspectives/fitting/sldPanel.py	(revision 785c823324aaba8461c3abed70e8f3dfe58f0d5b)
+++ sansview/perspectives/fitting/sldPanel.py	(revision 4faf4bad9d37a08d61abda7e341aad4fc88b1042)
@@ -1,10 +1,35 @@
+"""
+    This module intends to compute the neutron scattering length density of molecule
+    @author: Gervaise B. Alina
+"""
+
 import wx
+import sys
+
+import periodictable
+from periodictable import formula
+from periodictable.xsf import xray_energy, xray_sld_from_atoms
+from periodictable.constants import avogadro_number
+import periodictable.nsf
+neutron_sld_from_atoms= periodictable.nsf.neutron_sld_from_atoms 
+
+from sans.guiframe.utils import format_number, check_float
+from sans.guicomm.events import StatusEvent  
+
+
 _BOX_WIDTH = 76
 _STATICBOX_WIDTH = 350
+_SCALE = 1e-6
+_DEFAULT_WAVELENGTH = 1.798
+
 
 class SldPanel(wx.Panel):
-    def __init__(self, parent, id = -1):
+    """
+        Provides the SLD calculator GUI.
+    """
+    def __init__(self, parent,base=None, id = -1):
         wx.Panel.__init__(self, parent, id = id)
-        
+        # Object that receive status event
+        self.base= base
         self._do_layout()
         self.SetAutoLayout(True)
@@ -96,4 +121,5 @@
         self.neutron_inc_ctl.SetEditable(False)
         self.neutron_inc_ctl.SetToolTipString("Neutron Inc. Xs")
+        neutron_inc_units_txt = wx.StaticText(self, -1,  unit_cm1)
         
         neutron_abs_txt = wx.StaticText(self, -1, 'Neutron Abs. Xs')
@@ -101,4 +127,5 @@
         self.neutron_abs_ctl.SetEditable(False)
         self.neutron_abs_ctl.SetToolTipString("Neutron Abs. Xs")
+        neutron_abs_units_txt = wx.StaticText(self, -1,  unit_cm1)
         
         neutron_length_txt = wx.StaticText(self, -1, 'Neutron 1/e length')
@@ -106,4 +133,5 @@
         self.neutron_length_ctl.SetEditable(False)
         self.neutron_length_ctl.SetToolTipString("Neutron 1/e length")
+        neutron_length_units_txt = wx.StaticText(self, -1,  unit_cm)
         iy = 0
         ix = 0
@@ -161,4 +189,7 @@
         sizer_output.Add(self.neutron_inc_ctl,(iy, ix),(1,1),
                             wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+        ix +=2
+        sizer_output.Add(neutron_inc_units_txt,(iy, ix),(1,1),
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
         iy += 1
         ix = 0
@@ -168,4 +199,7 @@
         sizer_output.Add(self.neutron_abs_ctl,(iy, ix),(1,1),
                             wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+        ix +=2
+        sizer_output.Add(neutron_abs_units_txt,(iy, ix),(1,1),
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
         iy += 1
         ix = 0
@@ -174,14 +208,24 @@
         ix +=1
         sizer_output.Add(self.neutron_length_ctl,(iy, ix),(1,1),
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        ix +=2
+        sizer_output.Add(neutron_length_units_txt,(iy, ix),(1,1),
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
         boxsizer2.Add( sizer_output )
         sizer2.Add(boxsizer2,0, wx.EXPAND | wx.ALL, 10)
         #-----Button  sizer------------
         id = wx.NewId()
+        button_help = wx.Button(self, id, "Help")
+        button_help.SetToolTipString("Help  SlD calculations and formula.")
+        self.Bind(wx.EVT_BUTTON, self.onHelp, id = id)  
+         
+        id = wx.NewId()
         button_calculate = wx.Button(self, id, "Calculate")
         button_calculate.SetToolTipString("Calculate SlD of neutrons.")
-        #self.Bind(wx.EVT_BUTTON, self._calculateSld, id = id)   
-        sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        sizer_button.Add(button_calculate, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 10)
+        self.Bind(wx.EVT_BUTTON, self.calculateSld, id = id)   
+        
+        sizer_button.Add((200, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        sizer_button.Add(button_help, 0, wx.RIGHT|wx.ADJUST_MINSIZE,10)
+        sizer_button.Add(button_calculate, 0, wx.RIGHT|wx.ADJUST_MINSIZE,20)
         sizer3.Add(sizer_button)
         #---------layout----------------
@@ -194,10 +238,162 @@
         self.SetSizer(vbox)
         
-        
+    def check_inputs(self):
+        """Check validity user inputs"""
+        flag= True
+       
+        if check_float(self.density_ctl):
+            self.density = float(self.density_ctl.GetValue())
+        else:
+            flag=False
+            raise ValueError,"Error for Density value :expect float"
+    
+        self.wavelength= self.wavelength_ctl.GetValue()
+        if self.wavelength.lstrip().rstrip()=="":
+            self.wavelength = _DEFAULT_WAVELENGTH
+        else:
+            if check_float(self.wavelength_ctl):
+                self.wavelength= float(self.wavelength)
+            else:
+                flag = False
+                raise ValueError,"Error for wavelenth value :expect float"
+                
+        self.formulata_text= self.compound_ctl.GetValue().lstrip().rstrip()
+        if self.formulata_text!="":
+            self.compound_ctl.SetBackgroundColour(wx.WHITE)
+            self.compound_ctl.Refresh()
+        else:
+            self.compound_ctl.SetBackgroundColour("pink")
+            self.compound_ctl.Refresh()
+            flag=False
+            raise ValueError, "Enter a formula"
+        return flag 
+        
+    def onHelp(self, event):
+        """
+            provide more hint on the SLD calculator
+        """
+        from helpPanel import  HelpWindow
+        frame = HelpWindow(None, -1, pageToOpen="doc/sld_calculator_help.html")    
+        frame.Show(True)
+        name = "SLD_calculator"
+        if frame.rhelp.HasAnchor(name):
+            frame.rhelp.ScrollToAnchor(name)
+        else:
+           msg= "Cannot find SLD Calculator description "
+           msg +="Please.Search in the Help window"
+           wx.PostEvent(self.base, StatusEvent(status = msg ))  
+           
+           
+    def calculateSld(self, event):
+        """
+            Calculate the neutron scattering density length of a molecule
+        """
+        try:
+            #Check validity user inputs
+            if self.check_inputs():
+                #get ready to compute
+                try:
+                    self.new_formula = formula(self.formulata_text, density= self.density)
+                    atom = self.new_formula.atoms
+                except:
+                    if self.base !=None:
+                        msg= "SLD Calculator: %s" % (sys.exc_value)
+                        wx.PostEvent(self.base, StatusEvent(status= msg ))
+                    else:
+                        raise
+                    return
+                # Compute the Cu SLD
+                Cu_reel, Cu_im = self.calculateXRaySld( "Cu", density= self.density,
+                                                        user_formula= self.new_formula)
+                self.cu_ka_sld_reel_ctl.SetValue(format_number(Cu_reel*_SCALE))
+                self.cu_ka_sld_im_ctl.SetValue(format_number(Cu_im*_SCALE))
+                # Compute the Mo SLD
+                Mo_reel, Mo_im = self.calculateXRaySld( "Mo", density= self.density,
+                                                        user_formula= self.new_formula)
+                self.mo_ka_sld_reel_ctl.SetValue(format_number(Mo_reel*_SCALE))
+                self.mo_ka_sld_im_ctl.SetValue(format_number(Mo_im*_SCALE))
+               
+                coh,absorp,inc= self.calculateNSld(self.density, wavelength= self.wavelength,
+                                                     user_formula= self.new_formula)
+                #Don't know if value is return in cm or  cm^(-1).assume return in cm
+                # to match result of neutron inc of Alan calculator
+                inc= inc*1/10
+                #Doesn't match result of Alan calculator for absorption factor of 2
+                #multiplication of 100 is going around
+                absorp= absorp *2*100
+                volume= (self.new_formula.mass /self.density)/avogadro_number*1.0e24
+                #im: imaginary part of neutron SLD
+                im=0
+                for el, count in atom.iteritems():
+                    if el.neutron.b_c_i !=None:
+                        im += el.neutron.b_c_i*count 
+                im = im/volume
+                
+                self.neutron_sld_reel_ctl.SetValue(format_number(coh*_SCALE))
+                self.neutron_sld_im_ctl.SetValue(format_number(im*_SCALE))
+                self.neutron_inc_ctl.SetValue(format_number(inc ))
+                self.neutron_abs_ctl.SetValue(format_number(absorp))
+                #Don't know if value is return in cm or  cm^(-1).assume return in cm
+                # to match result of neutron inc of Alan calculator
+                length= (coh+ absorp+ inc)/volume
+                self.neutron_length_ctl.SetValue(format_number(length))
+        except:
+            if self.base !=None:
+                  msg= "SLD Calculator: %s" % (sys.exc_value)
+                  wx.PostEvent(self.base, StatusEvent(status= msg ))
+            else:
+                raise
+            return   
+
+    def calculateXRaySld(self, element, density,user_formula):
+        """
+            Get an element and compute the corresponding SLD for a given formula
+            @param element:  elementis a string of existing atom
+            @param formula: molecule enters by the user
+        """
+        try:
+            myformula = formula(str (element))
+            if len(myformula.atoms)!=1:
+                return 
+            element= myformula.atoms.keys()[0] 
+            energy = xray_energy(element.K_alpha)
+            atom = user_formula.atoms
+            atom_reel, atom_im = xray_sld_from_atoms( atom,
+                                                  density=density,
+                                                  energy= energy )
+            return atom_reel, atom_im
+        except:
+            if self.base !=None:
+                  msg= "SLD Calculator: %s" % (sys.exc_value)
+                  wx.PostEvent(self.base, StatusEvent(status= msg ))
+            else:
+                raise
+            return   
+        
+    def calculateNSld(self,density,wavelength,user_formula ):
+        """
+            Compute the neutron SLD for a given molecule
+            @return absorp: absorption
+            @return coh: coherence cross section
+            @return inc: incoherence cross section
+          
+        """
+        if density ==0:
+            raise ZeroDivisionError,"integer division or modulo by zero for density"
+            return 
+        atom = user_formula.atoms
+        coh,absorp,inc = neutron_sld_from_atoms(atom,density,wavelength)
+
+        return coh,absorp,inc
+    
+   
+ 
+        
+               
 class SldWindow(wx.Frame):
-    def __init__(self, parent, id, title):
+    def __init__(self, parent=None, id=1, title="SLD Calculator",base=None):
         wx.Frame.__init__(self, parent, id, title, size=(400, 400))
         
-        self.panel = SldPanel(self)
+        self.panel = SldPanel(self, base=base)
         self.Centre()
         self.Show(True)
