Index: sansview/perspectives/fitting/basepage.py
===================================================================
--- sansview/perspectives/fitting/basepage.py	(revision 918fcb1599b60d19f2caebb0813fc91f0eac70ca)
+++ sansview/perspectives/fitting/basepage.py	(revision 484faf7a3c6b0aab49f1aa6b612e0ff0a7c03010)
@@ -1229,7 +1229,9 @@
                 if self.enable_smearer.GetValue():
                     temp_smear= self.smearer
+            
             self.manager.draw_model(self.model, data=self.data,
                                     smearer= temp_smear,
-                                    qmin=float(self.qmin_x), qmax=float(self.qmax_x),
+                                    qmin=float(self.qmin_x), 
+                                    qmax=float(self.qmax_x),
                                     qstep= float(self.num_points),
                                     enable2D=self.enable2D) 
@@ -1442,5 +1444,5 @@
 
                 # If qmin and qmax have been modified, update qmin and qmax
-                if check_value( self.qmin, self.qmax):
+                if self._validate_qrange( self.qmin, self.qmax):
                     tempmin = float(self.qmin.GetValue())
                     if tempmin != self.qmin_x:
@@ -1481,5 +1483,6 @@
         wx.PostEvent(self.parent, event)
         self.state_change= False
-  
+        #Draw the model for a different range
+        self._draw_model()
                    
     def _on_select_model_helper(self): 
@@ -2012,5 +2015,5 @@
         #On 'More details' button
         """
-        from helpPanel import  HelpWindow
+        from help_panel import  HelpWindow
         
         if self.model == None:
Index: sansview/perspectives/fitting/fitting.py
===================================================================
--- sansview/perspectives/fitting/fitting.py	(revision 7975f2b5849c8557ad3c09b4c5dc65a79b45a88a)
+++ sansview/perspectives/fitting/fitting.py	(revision 484faf7a3c6b0aab49f1aa6b612e0ff0a7c03010)
@@ -102,5 +102,5 @@
         self.sim_page=None
         #dictionary containing data name and error on dy of that data 
-        self.err_dy={}
+        self.err_dy = {}
         
    
@@ -136,10 +136,10 @@
         wx.EVT_MENU(owner, id1, self.on_add_sim_page)
         #menu for SLD Calculator
-        self.tool_menu = wx.Menu()
-        id_tool_menu = wx.NewId()
-        sld_id = wx.NewId()
-        sld_help= "Compute the scattering length density of molecules"
-        self.tool_menu.Append(sld_id, "SLD Calculator",sld_help)
-        wx.EVT_MENU(owner,sld_id,  self.onCalculateSld)
+        #self.tool_menu = wx.Menu()
+        #id_tool_menu = wx.NewId()
+        #sld_id = wx.NewId()
+        #sld_help= "Compute the scattering length density of molecules"
+        #self.tool_menu.Append(sld_id, "SLD Calculator",sld_help)
+        #wx.EVT_MENU(owner,sld_id,  self.onCalculateSld)
     
         #menu for model
@@ -154,7 +154,7 @@
       
         #create  menubar items
-        return [(id, self.menu1, "Fitting"),
-                (id_tool_menu, self.tool_menu,"Tools" ),
-                (id2, menu2, "Model")]
+        return [(id, self.menu1, "Fitting")]
+                #(id_tool_menu, self.tool_menu,"Tools" ),
+                #(id2, menu2, "Model")]
        
     
@@ -178,5 +178,6 @@
             TODO: replace the text with a nice image
         """
-        from helpPanel import  HelpWindow
+        
+        from help_panel import  HelpWindow
         frame = HelpWindow(None, -1, 'HelpWindow')    
         frame.Show(True)
@@ -194,7 +195,8 @@
         """
         self.graph = graph
-        fitOption = "Select data for fitting"
-        fitOpenHint =  "Dialog with fitting parameters "
-               
+        fit_option = "Select data for fitting"
+        fit_hint =  "Dialog with fitting parameters "
+        invariant_option = "Compute Invariant"
+        invariant_hint =  "A dialog will appears for further computation"
         for item in graph.plottables:
             if item.__class__.__name__ is "Data2D":
@@ -202,8 +204,8 @@
                 if hasattr(item,"is_data"):
                     if item.is_data:
-                        return [[fitOption, fitOpenHint, self._onSelect]]
+                        return [[fit_option, fit_hint, self._onSelect]]
                     else:
                         return [] 
-                return [[fitOption, fitOpenHint, self._onSelect]]
+                return [[fit_option, fit_hint, self._onSelect]]
             else:
                 if item.name==graph.selected_plottable :
@@ -214,9 +216,14 @@
                             if hasattr(item,"is_data"):
                                 if item.is_data:
-                                    return [[fitOption, fitOpenHint, self._onSelect]]
+                                    return [[fit_option, fit_hint,
+                                              self._onSelect],
+                                            [invariant_option, 
+                                    invariant_hint, self._compute_invariant]]
                                 else:
                                     return [] 
                             else:
-                               return [[fitOption, fitOpenHint, self._onSelect]] 
+                               return [[fit_option, fit_hint, self._onSelect],
+                                       [invariant_option, 
+                                        invariant_hint, self._compute_invariant]]
         return []   
 
@@ -548,5 +555,10 @@
                
             
-            
+    def _compute_invariant(self, event):    
+        """
+            Open the invariant panel to invariant computation
+        """
+        
+        
     def _closed_fitpage(self, event):   
         """
@@ -848,4 +860,5 @@
             set engine to park
         """
+        Plugin.on_perspective(self,event=event)
         self._on_change_engine('park')
        
@@ -908,4 +921,5 @@
             @param engine: the key work of the engine
         """
+       
         ## saving fit engine name
         self._fit_engine = engine
@@ -1090,5 +1104,5 @@
            
             title= new_plot.name
-            
+            new_plot. perspective = self.get_perspective()
             # Pass the reset flag to let the plotting event handler
             # know that we are replacing the whole plot
Index: nsview/perspectives/fitting/helpPanel.py
===================================================================
--- sansview/perspectives/fitting/helpPanel.py	(revision f8b79d64270b5f4e7e032f97dca930cc6f95dda1)
+++ 	(revision )
@@ -1,168 +1,0 @@
-#!/usr/bin/python
-import wx
-import wx.html as html
-from wx.lib.splitter import MultiSplitterWindow
-import os
-def help():
-    """
-        Provide general online help text
-        Future work: extend this function to allow topic selection
-    """
-    info_txt  = "The inversion approach is based on Moore, J. Appl. Cryst. (1980) 13, 168-175.\n\n"
-    info_txt += "P(r) is set to be equal to an expansion of base functions of the type "
-    info_txt += "phi_n(r) = 2*r*sin(pi*n*r/D_max). The coefficient of each base functions "
-    info_txt += "in the expansion is found by performing a least square fit with the "
-    info_txt += "following fit function:\n\n"
-    info_txt += "chi**2 = sum_i[ I_meas(q_i) - I_th(q_i) ]**2/error**2 + Reg_term\n\n"
-    info_txt += "where I_meas(q) is the measured scattering intensity and I_th(q) is "
-    info_txt += "the prediction from the Fourier transform of the P(r) expansion. "
-    info_txt += "The Reg_term term is a regularization term set to the second derivative "
-    info_txt += "d**2P(r)/dr**2 integrated over r. It is used to produce a smooth P(r) output.\n\n"
-    info_txt += "The following are user inputs:\n\n"
-    info_txt += "   - Number of terms: the number of base functions in the P(r) expansion.\n\n"
-    info_txt += "   - Regularization constant: a multiplicative constant to set the size of "
-    info_txt += "the regularization term.\n\n"
-    info_txt += "   - Maximum distance: the maximum distance between any two points in the system.\n"
-     
-    return info_txt
-    
-class HelpDialog(wx.Dialog):
-    def __init__(self, parent, id):
-      
-        wx.Dialog.__init__(self, parent, id, size=(400, 420))
-        self.SetTitle("P(r) help") 
-        
-
-        vbox = wx.BoxSizer(wx.VERTICAL)
-
-        explanation = help()
-           
-        label_explain = wx.StaticText(self, -1, explanation, size=(350,320))
-            
-        vbox.Add(label_explain, 0, wx.ALL|wx.EXPAND, 15)
-
-
-        static_line = wx.StaticLine(self, -1)
-        vbox.Add(static_line, 0, wx.EXPAND, 0)
-        
-        button_OK = wx.Button(self, wx.ID_OK, "OK")
-
-        sizer_button = wx.BoxSizer(wx.HORIZONTAL)
-        sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        sizer_button.Add(button_OK, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)       
-        vbox.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
-
-        self.SetSizer(vbox)
-        self.SetAutoLayout(True)
-        
-        self.Layout()
-        self.Centre()
-
-class HelpWindow(wx.Frame):
-    def __init__(self, parent, id, title= 'HelpWindow', pageToOpen=None):
-        wx.Frame.__init__(self, parent, id, title, size=(700, 450))
-        """
-             contains help info
-        """
-      
-        splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE)
-        rpanel = wx.Panel(splitter, -1)
-        lpanel = wx.Panel(splitter, -1,style=wx.BORDER_SUNKEN)
-        
-        vbox = wx.BoxSizer(wx.VERTICAL)
-        header = wx.Panel(rpanel, -1)
-        header.SetBackgroundColour('#6666FF')
-        header.SetForegroundColour('WHITE')
-        hbox = wx.BoxSizer(wx.HORIZONTAL)
-        st = wx.StaticText(header, -1, 'Contents', (5, 5))
-        font = st.GetFont()
-        font.SetPointSize(10)
-        st.SetFont(font)
-        hbox.Add(st, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5)
-        header.SetSizer(hbox)
-        vbox.Add(header, 0, wx.EXPAND)
-       
-        vboxl= wx.BoxSizer(wx.VERTICAL)
-        headerl = wx.Panel(lpanel, -1, size=(-1, 20))
-       
-        headerl.SetBackgroundColour('#6666FF')
-        headerl.SetForegroundColour('WHITE')
-        hboxl = wx.BoxSizer(wx.HORIZONTAL)
-        lst = wx.StaticText(headerl, -1, 'Menu', (5, 5))
-        fontl = lst.GetFont()
-        fontl.SetPointSize(10)
-        lst.SetFont(fontl)
-        hboxl.Add(lst, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5)
-        headerl.SetSizer(hboxl)
-        vboxl.Add(headerl, 0, wx.EXPAND)
-        self.lhelp = html.HtmlWindow(lpanel, -1, style=wx.NO_BORDER)
-        self.rhelp = html.HtmlWindow(rpanel, -1, style=wx.NO_BORDER, size=(500,-1))
-        page1="""<html>
-            <body>
-             <p>Select topic on Menu</p>
-            </body>
-            </html>"""
-        page="""<html>
-            <body>
-            <ul>
-            <li><a href ="doc/change_scale_help.html" target ="showframe">Change scale</a><br></li>
-            <li><a href ="doc/reset_Graph_help.html" target ="showframe">Graph Help</a><br></li>
-            <li><a href ="doc/load_data_help.html" target ="showframe">Load a File</a><br></li>
-            <li><a href ="doc/simultaneous_fit_help.html" target ="showframe">Simultaneous Fit</a><br></li>
-            <li><a href ="doc/single_fit_help.html" target ="showframe">Single Fit</a><br></li>
-            <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>
-            </body>
-            </html>"""
-        self.rhelp.SetPage(page1)
-        self.lhelp.SetPage(page)
-        self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED,self.OnLinkClicked )
-        
-        #open the help frame a the current page
-        if  pageToOpen!= None:
-            self.rhelp.LoadPage(str( pageToOpen))
-            
-        vbox.Add(self.rhelp,1, wx.EXPAND)
-        vboxl.Add(self.lhelp, 1, wx.EXPAND)
-        rpanel.SetSizer(vbox)
-        lpanel.SetSizer(vboxl)
-        lpanel.SetFocus()
-        
-        vbox1 = wx.BoxSizer(wx.HORIZONTAL)
-        vbox1.Add(splitter,1,wx.EXPAND)
-        splitter.AppendWindow(lpanel, 200)
-        splitter.AppendWindow(rpanel)
-        self.SetSizer(vbox1)
-       
-        self.Centre()
-        self.Show(True)
-        
-    def OnButtonClicked(self, event):
-        """
-            Function to diplay html page related to the hyperlinktext selected
-        """
-        #link= "doc/modelfunction.html"
-        self.rhelp.LoadPage("doc/modelfunction.html")
-        
-    def OnLinkClicked(self, event):
-        """
-            Function to diplay html page related to the hyperlinktext selected
-        """
-        link= event.GetLinkInfo().GetHref()
-        self.rhelp.LoadPage(link)
-
-class ViewApp(wx.App):
-    def OnInit(self):
-        frame = HelpWindow(None, -1, 'HelpWindow')    
-        frame.Show(True)
-        self.SetTopWindow(frame)
-        
-        return True
-        
-
-if __name__ == "__main__": 
-    app = ViewApp(0)
-    app.MainLoop()     
Index: sansview/perspectives/fitting/help_panel.py
===================================================================
--- sansview/perspectives/fitting/help_panel.py	(revision 484faf7a3c6b0aab49f1aa6b612e0ff0a7c03010)
+++ sansview/perspectives/fitting/help_panel.py	(revision 484faf7a3c6b0aab49f1aa6b612e0ff0a7c03010)
@@ -0,0 +1,168 @@
+#!/usr/bin/python
+import wx
+import wx.html as html
+from wx.lib.splitter import MultiSplitterWindow
+import os
+def help():
+    """
+        Provide general online help text
+        Future work: extend this function to allow topic selection
+    """
+    info_txt  = "The inversion approach is based on Moore, J. Appl. Cryst. (1980) 13, 168-175.\n\n"
+    info_txt += "P(r) is set to be equal to an expansion of base functions of the type "
+    info_txt += "phi_n(r) = 2*r*sin(pi*n*r/D_max). The coefficient of each base functions "
+    info_txt += "in the expansion is found by performing a least square fit with the "
+    info_txt += "following fit function:\n\n"
+    info_txt += "chi**2 = sum_i[ I_meas(q_i) - I_th(q_i) ]**2/error**2 + Reg_term\n\n"
+    info_txt += "where I_meas(q) is the measured scattering intensity and I_th(q) is "
+    info_txt += "the prediction from the Fourier transform of the P(r) expansion. "
+    info_txt += "The Reg_term term is a regularization term set to the second derivative "
+    info_txt += "d**2P(r)/dr**2 integrated over r. It is used to produce a smooth P(r) output.\n\n"
+    info_txt += "The following are user inputs:\n\n"
+    info_txt += "   - Number of terms: the number of base functions in the P(r) expansion.\n\n"
+    info_txt += "   - Regularization constant: a multiplicative constant to set the size of "
+    info_txt += "the regularization term.\n\n"
+    info_txt += "   - Maximum distance: the maximum distance between any two points in the system.\n"
+     
+    return info_txt
+    
+class HelpDialog(wx.Dialog):
+    def __init__(self, parent, id):
+      
+        wx.Dialog.__init__(self, parent, id, size=(400, 420))
+        self.SetTitle("P(r) help") 
+        
+
+        vbox = wx.BoxSizer(wx.VERTICAL)
+
+        explanation = help()
+           
+        label_explain = wx.StaticText(self, -1, explanation, size=(350,320))
+            
+        vbox.Add(label_explain, 0, wx.ALL|wx.EXPAND, 15)
+
+
+        static_line = wx.StaticLine(self, -1)
+        vbox.Add(static_line, 0, wx.EXPAND, 0)
+        
+        button_OK = wx.Button(self, wx.ID_OK, "OK")
+
+        sizer_button = wx.BoxSizer(wx.HORIZONTAL)
+        sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        sizer_button.Add(button_OK, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)       
+        vbox.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
+
+        self.SetSizer(vbox)
+        self.SetAutoLayout(True)
+        
+        self.Layout()
+        self.Centre()
+
+class HelpWindow(wx.Frame):
+    def __init__(self, parent, id, title= 'HelpWindow', pageToOpen=None):
+        wx.Frame.__init__(self, parent, id, title, size=(700, 450))
+        """
+             contains help info
+        """
+      
+        splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE)
+        rpanel = wx.Panel(splitter, -1)
+        lpanel = wx.Panel(splitter, -1,style=wx.BORDER_SUNKEN)
+        
+        vbox = wx.BoxSizer(wx.VERTICAL)
+        header = wx.Panel(rpanel, -1)
+        header.SetBackgroundColour('#6666FF')
+        header.SetForegroundColour('WHITE')
+        hbox = wx.BoxSizer(wx.HORIZONTAL)
+        st = wx.StaticText(header, -1, 'Contents', (5, 5))
+        font = st.GetFont()
+        font.SetPointSize(10)
+        st.SetFont(font)
+        hbox.Add(st, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5)
+        header.SetSizer(hbox)
+        vbox.Add(header, 0, wx.EXPAND)
+       
+        vboxl= wx.BoxSizer(wx.VERTICAL)
+        headerl = wx.Panel(lpanel, -1, size=(-1, 20))
+       
+        headerl.SetBackgroundColour('#6666FF')
+        headerl.SetForegroundColour('WHITE')
+        hboxl = wx.BoxSizer(wx.HORIZONTAL)
+        lst = wx.StaticText(headerl, -1, 'Menu', (5, 5))
+        fontl = lst.GetFont()
+        fontl.SetPointSize(10)
+        lst.SetFont(fontl)
+        hboxl.Add(lst, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5)
+        headerl.SetSizer(hboxl)
+        vboxl.Add(headerl, 0, wx.EXPAND)
+        self.lhelp = html.HtmlWindow(lpanel, -1, style=wx.NO_BORDER)
+        self.rhelp = html.HtmlWindow(rpanel, -1, style=wx.NO_BORDER, size=(500,-1))
+        page1="""<html>
+            <body>
+             <p>Select topic on Menu</p>
+            </body>
+            </html>"""
+        page="""<html>
+            <body>
+            <ul>
+            <li><a href ="doc/change_scale_help.html" target ="showframe">Change scale</a><br></li>
+            <li><a href ="doc/reset_Graph_help.html" target ="showframe">Graph Help</a><br></li>
+            <li><a href ="doc/load_data_help.html" target ="showframe">Load a File</a><br></li>
+            <li><a href ="doc/simultaneous_fit_help.html" target ="showframe">Simultaneous Fit</a><br></li>
+            <li><a href ="doc/single_fit_help.html" target ="showframe">Single Fit</a><br></li>
+            <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>
+            </body>
+            </html>"""
+        self.rhelp.SetPage(page1)
+        self.lhelp.SetPage(page)
+        self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED,self.OnLinkClicked )
+        
+        #open the help frame a the current page
+        if  pageToOpen!= None:
+            self.rhelp.LoadPage(str( pageToOpen))
+            
+        vbox.Add(self.rhelp,1, wx.EXPAND)
+        vboxl.Add(self.lhelp, 1, wx.EXPAND)
+        rpanel.SetSizer(vbox)
+        lpanel.SetSizer(vboxl)
+        lpanel.SetFocus()
+        
+        vbox1 = wx.BoxSizer(wx.HORIZONTAL)
+        vbox1.Add(splitter,1,wx.EXPAND)
+        splitter.AppendWindow(lpanel, 200)
+        splitter.AppendWindow(rpanel)
+        self.SetSizer(vbox1)
+       
+        self.Centre()
+        self.Show(True)
+        
+    def OnButtonClicked(self, event):
+        """
+            Function to diplay html page related to the hyperlinktext selected
+        """
+        #link= "doc/modelfunction.html"
+        self.rhelp.LoadPage("doc/modelfunction.html")
+        
+    def OnLinkClicked(self, event):
+        """
+            Function to diplay html page related to the hyperlinktext selected
+        """
+        link= event.GetLinkInfo().GetHref()
+        self.rhelp.LoadPage(link)
+
+class ViewApp(wx.App):
+    def OnInit(self):
+        frame = HelpWindow(None, -1, 'HelpWindow')    
+        frame.Show(True)
+        self.SetTopWindow(frame)
+        
+        return True
+        
+
+if __name__ == "__main__": 
+    app = ViewApp(0)
+    app.MainLoop()     
Index: sansview/perspectives/fitting/invariant_panel.py
===================================================================
--- sansview/perspectives/fitting/invariant_panel.py	(revision 484faf7a3c6b0aab49f1aa6b612e0ff0a7c03010)
+++ sansview/perspectives/fitting/invariant_panel.py	(revision 484faf7a3c6b0aab49f1aa6b612e0ff0a7c03010)
@@ -0,0 +1,368 @@
+"""
+    This module provide GUI for the neutron scattering length density calculator
+    @author: Gervaise B. Alina
+"""
+
+import wx
+import sys
+
+from sans.guiframe.utils import format_number, check_float
+from sans.guicomm.events import StatusEvent  
+
+
+_BOX_WIDTH = 76
+_STATICBOX_WIDTH = 350
+_SCALE = 1e-6
+
+#SLD panel size 
+if sys.platform.count("win32")>0:
+    _STATICBOX_WIDTH = 350
+    PANEL_WIDTH = 500
+    PANEL_HEIGHT = 600
+    FONT_VARIANT = 0
+else:
+    _STATICBOX_WIDTH = 380
+    PANEL_WIDTH = 530
+    PANEL_HEIGHT = 600
+    FONT_VARIANT = 1
+    
+class InvariantPanel(wx.Panel):
+    """
+        Provides the SLD calculator GUI.
+    """
+    ## Internal nickname for the window, used by the AUI manager
+    window_name = "SLD Calculator"
+    ## Name to appear on the window title bar
+    window_caption = "SLD Calculator"
+    ## Flag to tell the AUI manager to put this panel in the center pane
+    CENTER_PANE = True
+    def __init__(self, parent, base=None):
+        wx.Panel.__init__(self, parent)
+        #Font size 
+        self.SetWindowVariant(variant=FONT_VARIANT)
+        #Object that receive status event
+        self.base = base
+        self._do_layout()
+        self.SetAutoLayout(True)
+        self.Layout()
+       
+    def _do_layout(self):
+        """
+            Draw window content
+        """
+        unit_invariant = '[1/cm][1/A]'
+        unit_volume = ''
+        unit_surface = ''
+        uncertainty = "+/-"
+        sizer_input = wx.GridBagSizer(5,5)
+        sizer_output = wx.GridBagSizer(5,5)
+        sizer_button = wx.BoxSizer(wx.HORIZONTAL)
+        sizer1 = wx.BoxSizer(wx.HORIZONTAL)
+        sizer2 = wx.BoxSizer(wx.HORIZONTAL)
+        sizer3 = wx.BoxSizer(wx.HORIZONTAL)
+       
+        #---------inputs----------------
+        background_txt = wx.StaticText(self, -1, 'Background')
+        self.background_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
+        self.background_ctl.SetToolTipString("Background to subtract to data.")
+        scale_txt = wx.StaticText(self, -1, 'Scale')
+        self.scale_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
+        self.scale_ctl.SetToolTipString("Scale to apply to data.")
+        contrast_txt = wx.StaticText(self, -1, 'Contrast')
+        self.contrast_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
+        self.contrast_ctl.SetToolTipString("Contrast in q range.")
+        porod_const_txt = wx.StaticText(self, -1, 'Porod Constant')
+        self.porod_const_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
+        self.porod_const_ctl.SetToolTipString("Invariant in q range.")
+       
+        iy = 0
+        ix = 0
+        sizer_input.Add(background_txt,(iy, ix),(1,1),\
+                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+        ix +=1
+        sizer_input.Add(self.background_ctl,(iy, ix),(1,1),\
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+        iy += 1
+        ix = 0
+        sizer_input.Add(scale_txt,(iy, ix),(1,1),\
+                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+        ix += 1
+        sizer_input.Add(self.scale_ctl, (iy, ix), (1,1),\
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+        iy += 1
+        ix = 0
+        sizer_input.Add(contrast_txt, (iy, ix),(1,1),\
+                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+        ix += 1
+        sizer_input.Add(self.contrast_ctl,(iy, ix),(1,1),\
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+        iy += 1
+        ix = 0
+        sizer_input.Add(porod_const_txt, (iy, ix),(1,1),\
+                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+        ix += 1
+        sizer_input.Add(self.porod_const_ctl,(iy, ix),(1,1),\
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+        
+        sizer_low_q = wx.GridBagSizer(5,5)
+        self.guinier = wx.RadioButton(self, -1, 'Guinier',
+                                         (10, 10), style=wx.RB_GROUP)
+        self.power_law_low = wx.RadioButton(self, -1, 'Power_law', (10, 10))
+        #self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param,
+        #           id=self.guinier.GetId())
+        #self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param,
+        #           id=self.power_law_law.GetId())
+        #MAC needs SetValue
+        self.guinier.SetValue(True)
+        power_low_txt = wx.StaticText(self, -1, 'Power')
+        self.power_low_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
+        self.power_low_ctl.SetToolTipString("Power to apply to the\
+                                         Power_law function.")
+        iy = 0
+        ix = 0
+        sizer_low_q.Add(self.power_law_low,(iy, ix),(1,1),
+                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+        iy += 1
+        ix = 0
+        sizer_low_q.Add(power_low_txt,(iy, ix),(1,1),
+                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+        ix += 1
+        sizer_low_q.Add(self.power_low_ctl, (iy, ix), (1,1),
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        iy += 1
+        ix = 0
+        sizer_low_q.Add(self.guinier,(iy, ix),(1,1),
+                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+      
+        sizer_high_q = wx.GridBagSizer(5,5)
+        self.power_law_high = wx.RadioButton(self, -1, 'Power_law', (10, 10))
+        #self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param,
+        #           id=self.power_law_high.GetId())
+        #MAC needs SetValue
+        self.power_law_high.SetValue(True)
+        power_high_txt = wx.StaticText(self, -1, 'Power')
+        self.power_high_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
+        self.power_high_ctl.SetToolTipString("Power to apply to the\
+                                         Power_law function.")
+        iy = 0
+        ix = 0
+        sizer_high_q.Add(self.power_law_high,(iy, ix),(1,1),
+                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+        iy += 1
+        ix = 0
+        sizer_high_q.Add(power_high_txt,(iy, ix),(1,1),
+                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+        ix += 1
+        sizer_high_q.Add(self.power_high_ctl, (iy, ix), (1,1),
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        
+        high_q_box = wx.StaticBox(self, -1, "High Q")
+        boxsizer_high_q = wx.StaticBoxSizer(high_q_box, wx.VERTICAL)
+        boxsizer_high_q.Add(sizer_high_q)
+        
+        low_q_box = wx.StaticBox(self, -1, "Low Q")
+        boxsizer_low_q = wx.StaticBoxSizer(low_q_box, wx.VERTICAL)
+        boxsizer_low_q.Add(sizer_low_q)
+        
+        sizer_extrapolation = wx.BoxSizer(wx.HORIZONTAL)
+        extrapolation_box = wx.StaticBox(self, -1, "Extrapolation")
+        boxsizer_extra = wx.StaticBoxSizer(extrapolation_box, wx.HORIZONTAL)
+        boxsizer_extra.Add(boxsizer_low_q)
+        boxsizer_extra.Add((10,10))
+        boxsizer_extra.Add(boxsizer_high_q)
+    
+        inputbox = wx.StaticBox(self, -1, "Input")
+        boxsizer1 = wx.StaticBoxSizer(inputbox, wx.VERTICAL)
+        boxsizer1.SetMinSize((_STATICBOX_WIDTH,-1))
+        boxsizer1.Add(sizer_input)
+        boxsizer1.Add(boxsizer_extra)
+        
+        sizer1.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10)
+        #---------Outputs sizer--------
+        invariant_txt = wx.StaticText(self, -1, 'Invariant')
+        self.invariant_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
+        self.invariant_ctl.SetEditable(False)
+        self.invariant_ctl.SetToolTipString("Invariant in q range.")
+        self.invariant_err_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
+        self.invariant_err_ctl.SetEditable(False)
+        self.invariant_err_ctl.SetToolTipString("Uncertainty on invariant.")
+        invariant_units_txt = wx.StaticText(self, -1, unit_invariant)
+        
+        invariant_total_txt = wx.StaticText(self, -1, 'Invariant Total')
+        self.invariant_total_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
+        self.invariant_total_ctl.SetEditable(False)
+        self.invariant_total_ctl.SetToolTipString("Invariant in q range and extra\
+                   polated range.")
+        self.invariant_total_err_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
+        self.invariant_total_err_ctl.SetEditable(False)
+        self.invariant_total_err_ctl.SetToolTipString("Uncertainty on invariant.")
+        invariant_total_units_txt = wx.StaticText(self, -1, unit_invariant)
+        
+        volume_txt = wx.StaticText(self, -1, 'Volume Fraction')
+        self.volume_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
+        self.volume_ctl.SetEditable(False)
+        self.volume_ctl.SetToolTipString("volume fraction.")
+        self.volume_err_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
+        self.volume_err_ctl.SetEditable(False)
+        self.volume_err_ctl.SetToolTipString("Uncertainty of volume fraction.")
+        volume_units_txt = wx.StaticText(self, -1, unit_volume)
+        
+        surface_txt = wx.StaticText(self, -1, 'Surface')
+        self.surface_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
+        self.surface_ctl.SetEditable(False)
+        self.surface_ctl.SetToolTipString("Surface.")
+        self.surface_err_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
+        self.surface_err_ctl.SetEditable(False)
+        self.surface_err_ctl.SetToolTipString("Uncertainty of surface.")
+        surface_units_txt = wx.StaticText(self, -1, unit_surface)
+        
+        invariant_low_txt = wx.StaticText(self, -1, 'Invariant in low Q')
+        self.invariant_low_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
+        self.invariant_low_ctl.SetEditable(False)
+        self.invariant_low_ctl.SetToolTipString("Invariant compute in low Q")
+        invariant_low_units_txt = wx.StaticText(self, -1,  unit_invariant)
+        
+        invariant_high_txt = wx.StaticText(self, -1, 'Invariant in high Q')
+        self.invariant_high_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
+        self.invariant_high_ctl.SetEditable(False)
+        self.invariant_high_ctl.SetToolTipString("Invariant compute in high Q")
+        invariant_high_units_txt = wx.StaticText(self, -1,  unit_invariant)
+       
+        iy = 0
+        ix = 0
+        sizer_output.Add(invariant_low_txt, (iy, ix), (1,1),
+                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+        ix +=1
+        sizer_output.Add(self.invariant_low_ctl, (iy, ix), (1,1),
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        ix += 2
+        sizer_output.Add(invariant_low_units_txt, (iy, ix), (1,1),
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+        iy += 1
+        ix = 0 
+        sizer_output.Add(invariant_high_txt, (iy, ix), (1,1),
+                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+        ix +=1
+        sizer_output.Add(self.invariant_high_ctl, (iy, ix), (1,1),
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        ix += 2
+        sizer_output.Add(invariant_high_units_txt, (iy, ix), (1,1),
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+        iy += 1
+        ix = 0
+        sizer_output.Add(invariant_txt,(iy, ix),(1,1),
+                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+        ix += 1
+        sizer_output.Add(self.invariant_ctl,(iy, ix),(1,1),
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+        ix += 1
+        sizer_output.Add( wx.StaticText(self, -1, uncertainty),
+                         (iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+        ix +=1
+        sizer_output.Add(self.invariant_err_ctl
+                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+        ix +=1
+        sizer_output.Add(invariant_units_txt
+                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+        iy += 1
+        ix = 0
+        sizer_output.Add(invariant_total_txt,(iy, ix),(1,1),
+                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+        ix += 1
+        sizer_output.Add(self.invariant_total_ctl,(iy, ix),(1,1),
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+        ix += 1
+        sizer_output.Add( wx.StaticText(self, -1, uncertainty),
+                         (iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+        ix +=1
+        sizer_output.Add(self.invariant_total_err_ctl
+                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+        ix +=1
+        sizer_output.Add(invariant_total_units_txt
+                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+        iy += 1
+        ix = 0
+        sizer_output.Add(volume_txt,(iy, ix),(1,1),
+                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+        ix +=1
+        sizer_output.Add(self.volume_ctl,(iy, ix),(1,1),
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+        ix +=1
+        sizer_output.Add(wx.StaticText(self, -1, uncertainty)
+                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        ix += 1
+        sizer_output.Add(self.volume_err_ctl
+                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
+        ix += 1
+        sizer_output.Add(volume_units_txt
+                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+        iy += 1
+        ix = 0
+        sizer_output.Add(surface_txt,(iy, ix),(1,1),
+                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+        ix +=1
+        sizer_output.Add(self.surface_ctl,(iy, ix),(1,1),
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+        ix +=1
+        sizer_output.Add(wx.StaticText(self, -1, uncertainty)
+                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        ix += 1
+        sizer_output.Add(self.surface_err_ctl
+                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
+        ix +=1
+        sizer_output.Add(surface_units_txt
+                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        
+        outputbox = wx.StaticBox(self, -1, "Output")
+        boxsizer2 = wx.StaticBoxSizer(outputbox, wx.VERTICAL)
+        boxsizer2.SetMinSize((_STATICBOX_WIDTH,-1))
+        boxsizer2.Add( sizer_output )
+        sizer2.Add(boxsizer2,0, wx.EXPAND|wx.ALL, 10)
+        #-----Button  sizer------------
+    
+        id = wx.NewId()
+        button_calculate = wx.Button(self, id, "Compute")
+        button_calculate.SetToolTipString("Compute SlD of neutrons.")
+        self.Bind(wx.EVT_BUTTON, self.compute_invariant, id = id)   
+        
+        sizer_button.Add((250, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        sizer_button.Add(button_calculate, 0, wx.RIGHT|wx.ADJUST_MINSIZE,20)
+        sizer3.Add(sizer_button)
+        #---------layout----------------
+        vbox  = wx.BoxSizer(wx.VERTICAL)
+        vbox.Add(sizer1)
+        vbox.Add(sizer2)
+        vbox.Add(sizer3)
+        vbox.Fit(self) 
+        self.SetSizer(vbox)
+    
+    def compute_invariant(self, event):
+        """
+            compute invariant
+        """
+         
+class InvariantDialog(wx.Dialog):
+    def __init__(self, parent=None, id=1, title="Invariant",base=None):
+        wx.Dialog.__init__(self, parent, id, title, size=( PANEL_WIDTH,
+                                                             PANEL_HEIGHT))
+        
+        self.panel = InvariantPanel(self, base=base)
+        self.Centre()
+        self.Show(True)
+        
+class MyApp(wx.App):
+    def OnInit(self):
+        wx.InitAllImageHandlers()
+       
+        dialog = InvariantDialog(None)
+        if dialog.ShowModal() == wx.ID_OK:
+            pass
+        dialog.Destroy()
+        
+        return 1
+   
+# end of class MyApp
+
+if __name__ == "__main__":
+    app = MyApp(0)
+    app.MainLoop()
Index: nsview/perspectives/fitting/modelpage.py
===================================================================
--- sansview/perspectives/fitting/modelpage.py	(revision 7975f2b5849c8557ad3c09b4c5dc65a79b45a88a)
+++ 	(revision )
@@ -1,675 +1,0 @@
-
-import wx
-import wx.lib.newevent
-import numpy
-import copy
-import math
-from sans.models.dispersion_models import ArrayDispersion, GaussianDispersion
-
-from sans.guicomm.events import StatusEvent   
-from sans.guiframe.utils import format_number
-(ModelEventbox, EVT_MODEL_BOX) = wx.lib.newevent.NewEvent()
-_BOX_WIDTH = 76
-
-import basepage
-from basepage import BasicPage
-from basepage import PageInfoEvent
-
-class ModelPage(BasicPage):
-    """
-        FitPanel class contains fields allowing to display results when
-        fitting  a model and one data
-        @note: For Fit to be performed the user should check at least one parameter
-        on fit Panel window.
-  
-    """
-
-    def __init__(self,parent, page_info):
-        BasicPage.__init__(self, parent, page_info)
-        """ 
-            Initialization of the Panel
-        """
-        self._fill_model_sizer( self.sizer1)  
-        self._fill_range_sizer()
-        self.engine_type = None 
-         
-        description=""
-        if self.model!=None:
-            
-            description = self.model.description
-            
-            self.select_model(self.model)
-            self.set_model_description(description,self.sizer2)
-            
-     
-        
-        
-    def _on_display_description(self, event):
-        """
-            Show or Hide description
-            @param event: wx.EVT_RADIOBUTTON
-        """
-        self._on_display_description_helper()
-        
-        self.SetScrollbars(20,20,25,65)
-        self.Refresh()
-
-        
-        
-    def _on_display_description_helper(self):
-        """
-            Show or Hide description
-            @param event: wx.EVT_RADIOBUTTON
-        """
-        
-        ## Show description
-        if self.description_hide.GetValue():
-            self.sizer_description.Clear(True)
-            
-        else:
-            description="Model contains no description"
-            if self.model!=None:
-                description = self.model.description
-            if description.lstrip().rstrip() =="": 
-                description="Model contains no description"
-            self.description = wx.StaticText( self,-1,str(description) )
-            self.sizer_description.Add( self.description, 1, wx.EXPAND | wx.ALL, 10 )
-           
-        self.Layout()
-    
-    
-    def _fill_range_sizer(self):
-        """
-            Fill the sizer containing the plotting range
-            add  access to npts
-        """
-        ##The following 3 lines are for Mac. Let JHC know before modifying..
-        title = "Plotted Q Range"
-        box_description= wx.StaticBox(self, -1,str(title))
-        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
-
-        sizer_npts= wx.GridSizer(1, 1,5, 5)    
-        self.npts    = self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER)
-        self.npts.SetValue(format_number(self.num_points))
-        self.npts.SetToolTipString("Number of point to plot.")
-        
-        sizer_npts.Add(wx.StaticText(self, -1, 'Npts'),1, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 13)        
-
-        sizer_npts.Add(self.npts,1,wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
-        self._set_range_sizer( title=title, box_sizer=boxsizer1, object= sizer_npts)
-       
-       
-    def _on_select_model(self, event): 
-        """
-             call back for model selection
-        """    
-        self._on_select_model_helper() 
-        #Reset dispersity that was not done in _on_select_model_helper() 
-        self._reset_dispersity()
-        self.select_model(self.model)
-        
-       
-    def _fill_model_sizer(self, sizer):
-        """
-            fill sizer containing model info
-        """
-        ##The following 3 lines are for Mac. Let JHC know before modifying..
-        title = "Model"
-        box_description= wx.StaticBox(self, -1,str(title))
-        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
-        
-        id = wx.NewId()
-        self.model_view =wx.Button(self,id,'View 2D', size=(80,23))
-        self.model_view.Bind(wx.EVT_BUTTON, self._onModel2D,id=id)
-        self.model_view.SetToolTipString("View model in 2D")
-        
-        ## class base method  to add view 2d button   
-        self._set_model_sizer(sizer=sizer,box_sizer=boxsizer1, title=title,object= self.model_view )    
-    
-  
-    #def _set_sizer_gaussian(self):
-    def _set_sizer_dispersion(self, dispersity):
-        """
-            draw sizer with gaussian, log or schulz dispersity parameters
-        """
-        self.fittable_param=[]
-        self.fixed_param=[]
-        self.orientation_params_disp=[]
-        #self.temp=[]
-       
-        self.sizer4_4.Clear(True)
-        if self.model==None:
-            ##no model is selected
-            return
-        if not self.enable_disp.GetValue():
-            ## the user didn't select dispersity display
-            return 
-        self._reset_dispersity()
-        # Create the dispersion objects
-        for item in self.model.dispersion.keys():
-            #disp_model =  GaussianDispersion()
-            disp_model = dispersity()
-            self._disp_obj_dict[item] = disp_model
-            self.model.set_dispersion(item, disp_model)
-            self.state._disp_obj_dict[item]= disp_model
-            
-            
-        ix=0
-        iy=1
-        disp = wx.StaticText(self, -1, 'Names')
-        self.sizer4_4.Add(disp,( iy, ix),(1,1), 
-                           wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix += 1 
-        values = wx.StaticText(self, -1, 'Sigmas (STD)')
-        self.sizer4_4.Add(values,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-       
-        ix += 1 
-        npts = wx.StaticText(self, -1, 'Npts')
-        self.sizer4_4.Add(npts,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        ix += 1 
-        nsigmas = wx.StaticText(self, -1, 'Nsigmas')
-        self.sizer4_4.Add(nsigmas,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        
-        for item in self.model.dispersion.keys():
-            if not item in self.model.orientation_params:
-                self.disp_cb_dict[item]= None
-                name1=item+".width"
-                name2=item+".npts"
-                name3=item+".nsigmas"
-                iy += 1
-                for p in self.model.dispersion[item].keys():
-                    if p=="width":
-                        ix = 0
-                        name = wx.StaticText(self, -1,  name1)
-                        self.sizer4_4.Add( name,( iy, ix),(1,1),  
-                                           wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-                        ix = 1
-                        value= self.model.getParam(name1)
-                        ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),
-                                            style=wx.TE_PROCESS_ENTER)
-                        ctl1.SetValue(str (format_number(value)))
-                        self.sizer4_4.Add(ctl1, (iy,ix),(1,1), wx.EXPAND)
-                        self.fittable_param.append([None,name1,ctl1,None,
-                                                    None, None, None,None])
-                    elif p=="npts":
-                            ix =2
-                            value= self.model.getParam(name2)
-                            Tctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20),
-                                                style=wx.TE_PROCESS_ENTER)
-                            Tctl1.SetValue(str (format_number(value)))
-                            self.sizer4_4.Add(Tctl1, (iy,ix),(1,1),
-                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-                            self.fixed_param.append([None,name2, Tctl1,None,None,
-                                                      None, None,None])
-                    elif p=="nsigmas":
-                            ix =3 
-                            value= self.model.getParam(name3)
-                            Tctl2 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20),
-                                                style=wx.TE_PROCESS_ENTER)
-                            Tctl2.SetValue(str (format_number(value)))
-                            self.sizer4_4.Add(Tctl2, (iy,ix),(1,1),
-                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-                            ix +=1
-                            self.sizer4_4.Add((20,20), (iy,ix),(1,1),
-                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-                            self.fixed_param.append([None,name3, Tctl2,
-                                                     None,None, None, None,None])
-        for item in self.model.dispersion.keys():
-            if item in self.model.orientation_params:
-                self.disp_cb_dict[item]= None
-                name1=item+".width"
-                name2=item+".npts"
-                name3=item+".nsigmas"
-                iy += 1
-                for p in self.model.dispersion[item].keys():
-                    if p=="width":
-                        ix = 0
-                        name = wx.StaticText(self, -1,  name1)
-                        self.sizer4_4.Add( name,( iy, ix),(1,1),  
-                                           wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-                        if not self.enable2D:
-                            name.Hide()
-                        else:
-                            name.Show(True)
-                        ix = 1
-                        value= self.model.getParam(name1)
-                        ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),
-                                            style=wx.TE_PROCESS_ENTER)
-                        ctl1.SetValue(str (format_number(value)))
-                        if not self.enable2D:
-                            ctl1.Hide()
-                            ctl1.Disable()
-                        else:
-                            ctl1.Show(True)
-                            ctl1.Enable()
-                        self.sizer4_4.Add(ctl1, (iy,ix),(1,1), wx.EXPAND)
-                        self.fittable_param.append([None,name1,ctl1,None,
-                                                    None, None, None,None])
-                        self.orientation_params_disp.append([None,name1,ctl1,None,
-                                                    None, None, None,None])
-                    elif p=="npts":
-                            ix =2
-                            value= self.model.getParam(name2)
-                            Tctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20),
-                                                style=wx.TE_PROCESS_ENTER)
-                            Tctl1.SetValue(str (format_number(value)))
-                            if not self.enable2D:
-                                Tctl1.Hide()
-                                Tctl1.Disable()
-                            else:
-                                Tctl1.Show(True)
-                                Tctl1.Enable()
-                            self.sizer4_4.Add(Tctl1, (iy,ix),(1,1),
-                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-                            self.fixed_param.append([None,name2, Tctl1,None,None,
-                                                      None, None,None])
-                            self.orientation_params_disp.append([None,name2, Tctl1,None,None,
-                                                      None, None,None])
-                    elif p=="nsigmas":
-                            ix =3 
-                            value= self.model.getParam(name3)
-                            Tctl2 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20),
-                                                style=wx.TE_PROCESS_ENTER)
-                            Tctl2.SetValue(str (format_number(value)))
-                            if not self.enable2D:
-                                Tctl2.Hide()
-                                Tctl2.Disable()
-                            else:
-                                Tctl2.Show(True)
-                                Tctl2.Enable()
-                            self.sizer4_4.Add(Tctl2, (iy,ix),(1,1),
-                                               wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-                            ix +=1
-                            #self.sizer4_4.Add((20,20), (iy,ix),(1,1),
-                                               #wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-                            self.fixed_param.append([None,name3, Tctl2,
-                                                     None,None, None, None,None])
-                            self.orientation_params_disp.append([None,name3, Tctl2,
-                                                     None,None, None, None,None])
-            
-        msg = " Selected Distribution: Gaussian"        
-        wx.PostEvent(self.parent.parent, StatusEvent( status= msg )) 
-        self.state.disp_cb_dict = copy.deepcopy(self.disp_cb_dict)   
-        ix =0
-        iy +=1 
-        #self.sizer4_4.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)   
-        self.sizer4_4.Layout()
-        self.sizer4.Layout()
-        self.SetScrollbars(20,20,25,65)
-             
- 
-    def _onModel2D(self, event):
-        """
-         call manager to plot model in 2D
-        """
-        # If the 2D display is not currently enabled, plot the model in 2D 
-        # and set the enable2D flag.
-
-        if self.fitrange:
-            self.enable2D = True
- 
-        if self.enable2D:
-            self._draw_model()
-            self.model_view.Disable()
-           
-            n = self.disp_box.GetCurrentSelection()
-            dispersity= self.disp_box.GetClientData(n)
-            #TODO:Find a better way to reinitialize the parameters containers 
-            # when resetting the page and 2D view is enable
-            #self.set_model_param_sizer(self.model): called here is using a lot
-            #of for loops and redraw the sizer again .How to avoid it?
-            self.set_model_param_sizer(self.model)
-            
-            if len(self.orientation_params)>0:
-                for item in self.orientation_params:
-                    if item[2]!=None:      
-                        item[2].Enable()
-            # same as above why do we have to redraw the sizer of dispersity to get
-            # the appropriate value of parameters containers on reset page?
-            # Reset containers of dispersity parameters for the appropriate dispersity
-            #and model
-            if  self.disp_name.lower()in ["array","arraydispersion"]:                
-                self._set_sizer_arraydispersion()  
-            else:
-                self._set_sizer_dispersion(dispersity)
-                if len(self.orientation_params_disp)>0:
-                   
-                    for item in self.orientation_params_disp:
-                        if item[2]!=None:
-                            item[2].Enable()
-                            
-        self.state.enable2D =  copy.deepcopy(self.enable2D)
-        self.Layout()
-        ## post state to fit panel
-        #self._undo.Enable(True)
-        event = PageInfoEvent(page = self)
-        wx.PostEvent(self.parent, event)
-              
-                
-    def reset_page(self, state):
-        """
-            reset the state
-        """
-        self.reset_page_helper(state)
-        
-        
-    def select_model(self, model):
-        """
-            Select a new model
-            @param model: model object 
-        """
-        self.model = model
-        if self.model !=None:
-            self.disp_list= self.model.getDispParamList()
-        self.set_model_param_sizer(self.model)
-        ## keep the sizer view consistent with the model menu selecting
-        self._set_model_sizer_selection( self.model )
-        self.enable_disp.SetValue(False)
-        self.disable_disp.SetValue(True)
-        self.set_dispers_sizer()
-        
-        self.model_view.SetFocus()
-        if self.model !=None:
-            self._draw_model()
-        self.state.structurecombobox = self.structurebox.GetCurrentSelection()
-        self.state.formfactorcombobox = self.formfactorbox.GetCurrentSelection()
-       
-        ## post state to fit panel
-        #self._undo.Enable(True)
-        event = PageInfoEvent(page = self)
-        wx.PostEvent(self.parent, event)               
-    
-    
-    def set_model_description(self,description,sizer):
-        """
-            fill a sizer with description
-            @param description: of type string
-            @param sizer: wx.BoxSizer()
-        """
-    
-        sizer.Clear(True)
-        box_description= wx.StaticBox(self, -1, 'Model Description')
-        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
-
-        sizer_selection=wx.BoxSizer(wx.HORIZONTAL)
-        self.description_hide = wx.RadioButton(self, -1, 'Hide', style=wx.RB_GROUP)
-        self.description_show = wx.RadioButton(self, -1, 'Show')
-       
-        
-        if description=="":
-            self.description_hide.SetValue(True)
-            description=" Description unavailable. Click for details"
-            
-        self.description = wx.StaticText( self,-1,str(description) )
-        
-        self.Bind( wx.EVT_RADIOBUTTON, self._on_display_description,
-                   id=self.description_hide.GetId() )
-        
-        self.Bind( wx.EVT_RADIOBUTTON, self._on_display_description,
-                   id=self.description_show.GetId() )
-        #MAC needs SetValue
-        self.description_hide.SetValue(True)
-        
-        self.model_description = wx.Button(self,-1, label="Details", size=(80,23))
-        
-        self.model_description.Bind(wx.EVT_BUTTON,self.on_button_clicked)
-        self.model_description.SetToolTipString("Click Model Functions in HelpWindow...")
-        self.model_description.SetFocus()
-        sizer_selection.Add( self.description_show )
-        sizer_selection.Add( (20,20)) 
-        sizer_selection.Add( self.description_hide )
-        sizer_selection.Add((20,20),0, wx.LEFT|wx.RIGHT|wx.EXPAND,75)
-        sizer_selection.Add( self.model_description )
-                     
-         
-        self.sizer_description=wx.BoxSizer(wx.HORIZONTAL)
-        self.sizer_description.Add( self.description, 1, wx.EXPAND | wx.ALL, 10 )
-        boxsizer1.Add( sizer_selection) 
-        boxsizer1.Add( (20,20)) 
-        boxsizer1.Add( self.sizer_description) 
-    
-        self._on_display_description(event=None)
-        sizer.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10)
-        sizer.Layout()
-   
-    def on_button_clicked(self,event):
-        """
-        #On 'More details' button
-        """
-        from helpPanel import  HelpWindow
-        
-        if self.model == None:
-            name = 'FuncHelp'
-        else:
-            name = self.model.name
-        frame = HelpWindow(None, -1,  pageToOpen="doc/model_functions.html")    
-        frame.Show(True)
-        if frame.rhelp.HasAnchor(name):
-            frame.rhelp.ScrollToAnchor(name)
-        else:
-           msg= "Model does not contains an available description "
-           msg +="Please.Search in the Help window"
-           wx.PostEvent(self.parent.parent, StatusEvent(status = msg ))
-                     
-            
-            
-    def set_range(self, qmin_x, qmax_x, npts):
-        """
-            Set the range for the plotted models
-            @param qmin: minimum Q
-            @param qmax: maximum Q
-            @param npts: number of Q bins
-        """
-        # Set the data members
-        self.qmin_x = qmin_x
-        self.qmax_x = qmax_x
-        self.num_points = npts
-        
-        # Set the controls
-        #For qmin and qmax, do not use format_number.(If do, qmin and max could be different from what is in the data.)
-       
-        self.qmin.SetValue(str(self.qmin_x))
-        self.qmax.SetValue(str(self.qmax_x))
-        self.npts.SetValue(format_number(self.num_points))
-        
-        
-    def set_model_param_sizer(self, model):
-        """
-            Build the panel from the model content
-            @param model: the model selected in combo box for fitting purpose
-        """
-        self.sizer3.Clear(True)
-        self.parameters = []
-        self.param_toFit=[]
-        self.fixed_param=[]
-        self.orientation_params=[]
-        self.orientation_params_disp=[]
-        #self.temp=[]
-        if model ==None:
-            ##no model avaiable to draw sizer 
-            self.sizer3.Layout()
-            self.SetScrollbars(20,20,25,65)
-            return
-        box_description= wx.StaticBox(self, -1,str("Model Parameters"))
-        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
-        sizer = wx.GridBagSizer(5,5)
-        
-        self.model = model
-        self.set_model_description(self.model.description,self.sizer2)
-       
-        keys = self.model.getParamList()
-        ##list of dispersion parameters
-        self.disp_list=self.model.getDispParamList()
-       
-        keys.sort()
-    
-        iy = 0
-        ix = 0
-        self.text1_2 = wx.StaticText(self, -1, 'Names')
-        sizer.Add(self.text1_2,(iy, ix),(1,1),\
-                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix +=1
-        self.text2_2 = wx.StaticText(self, -1, 'Values')
-        sizer.Add(self.text2_2,(iy, ix),(1,1),\
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-        ix +=1
-        self.text2_4 = wx.StaticText(self, -1, '[Units]')
-        sizer.Add(self.text2_4,(iy, ix),(1,1),\
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-        self.text2_4.Hide()
-        
-        for item in keys:
-            if not item in self.disp_list and not item in self.model.orientation_params:
-                iy += 1
-                ix = 0
-                name = wx.StaticText(self, -1,item)
-                sizer.Add( name,( iy, ix),(1,1),
-                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-
-                ix += 1
-                value= self.model.getParam(item)
-                ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),
-                    style=wx.TE_PROCESS_ENTER)
-                
-                ctl1.SetValue(str (format_number(value)))
-                
-                sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND)
-                ix +=1
-                # Units
-                if self.model.details.has_key(item):
-                    units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT)
-                else:
-                    units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT)
-                sizer.Add(units, (iy,ix),(1,1),  wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-                ##[cb state, name, value, "+/-", error of fit, min, max , units]
-                self.parameters.append([None,item, ctl1,
-                                        None,None, None, None,None])
-        iy+=1
-        sizer.Add((10,10),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        iy += 1
-        ix = 0
-        
-        #Add tile for orientational angle parameters
-        for item in keys:
-            if item in self.model.orientation_params:        
-                orient_angle = wx.StaticText(self, -1, '[For 2D only]:')
-                sizer.Add(orient_angle,(iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
-                if not self.enable2D:
-                    orient_angle.Hide()
-                else:
-                    orient_angle.Show(True)
-                break
-                                          
-        for item  in self.model.orientation_params:
-            if not item in self.disp_list and item in keys:
-                iy += 1
-                ix = 0
-                name = wx.StaticText(self, -1,item)
-                sizer.Add( name,( iy, ix),(1,1),
-                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-                if not self.enable2D:
-                    name.Hide()
-                else:
-                    name.Show(True)
-
-                ix += 1
-                value= self.model.getParam(item)
-                ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),
-                    style=wx.TE_PROCESS_ENTER)
-                
-                ctl1.SetValue(str (format_number(value)))
-                if not self.enable2D:
-                    ctl1.Hide()
-                    ctl1.Disable()
-                else:
-                    ctl1.Show(True)
-                    ctl1.Enable()
-                
-                sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND)
-                ix +=1
-                # Units
-                if self.model.details.has_key(item):
-                    units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT)
-                else:
-                    units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT)
-                if not self.enable2D:
-                    units.Hide()
-                else:
-                    units.Show(True)
-   
-                sizer.Add(units, (iy,ix),(1,1),  wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-                #Save 2D orient. params
-                #self.temp.append([name,ctl1,units,orient_angle])
-                
-                               
-                ##[cb state, name, value, "+/-", error of fit, min, max , units]
-                self.parameters.append([None,item, ctl1,
-                                        None,None, None, None,None])
-                self.orientation_params.append([None,item, ctl1,
-                                        None,None, None, None,None])
-                    
-        iy+=1
-        
-        #Display units text on panel
-        for item in keys:   
-            self.text2_4.Show()
-
-      
-        boxsizer1.Add(sizer)
-        self.sizer3.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10)
-        self.sizer3.Layout()
-        self.SetScrollbars(20,20,25,65)
-    
- 
-
-                
-        
-class HelpWindow(wx.Frame):
-    def __init__(self, parent, id, title):
-        wx.Frame.__init__(self, parent, id, title, size=(570, 400))
-       
-        from sans.models.CylinderModel import CylinderModel
-        model = CylinderModel()
-        #from sans.models.LineModel import LineModel
-        #model = LineModel()
-        from fitpanel import PageInfo
-        myinfo = PageInfo(self,model)
-        from models import ModelList
-        mylist= ModelList()
-        
-        from sans.models.SphereModel import SphereModel
-        from sans.models.SquareWellStructure import SquareWellStructure
-        from sans.models.DebyeModel import DebyeModel
-        from sans.models.LineModel import LineModel
-        name= "shapes"
-        list1= [SphereModel]
-        mylist.set_list( name, list1)
-        
-        name= "Shape-independent"
-        list1= [DebyeModel]
-        mylist.set_list( name, list1)
-        
-        name= "Structure Factors"
-        list1= [SquareWellStructure]
-        mylist.set_list( name, list1)
-        
-        name= "Added models"
-        list1= [LineModel]
-        mylist.set_list( name, list1)
-        
-        myinfo.model_list_box = mylist.get_list()
-        
-        self.page = ModelPage(self, myinfo) 
-        
-        
-        
-        self.Centre()
-        self.Show(True)
-
-
-   
-if __name__=="__main__":
-    app = wx.App()
-    HelpWindow(None, -1, 'HelpWindow')
-    app.MainLoop()
-                
Index: nsview/perspectives/fitting/sldCalculator.py
===================================================================
--- sansview/perspectives/fitting/sldCalculator.py	(revision 6c5239c5a17df3882490924782e95ac4b192b7fc)
+++ 	(revision )
@@ -1,104 +1,0 @@
-"""
-    This module intends to compute the neutron scattering length density of molecule
-    @author: Gervaise B. Alina
-"""
-
-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 
-
-class SldCalculator(object):
-    """
-        compute neutron SLD and related parameters
-    """
-    def __init__(self):
-        self.wavelength  = 6.0
-        self.coherence   = 0.0
-        self.absorption  = 0.0
-        self.incoherence = 0.0
-        self.sld_formula = None
-        self.volume = 0.0
-        self.density = None
-        self.length= 0.0
-        
-        
-    def setValue(self,user_formula, density, wavelength=6.0):
-        """
-            Store values of density and wavelength into the calculator 
-            and compute the volume
-        """
-        self.wavelength = wavelength
-        self.density    = float(density)
-        self.sld_formula = formula(str(user_formula), density= self.density)
-        if self.density==0:
-            raise ZeroDivisionError,"integer division or modulo by zero for density"
-            return 
-        self.volume = (self.sld_formula.mass /self.density)/avogadro_number*1.0e24   
-        
-        
-    def calculateXRaySld(self, element):
-        """
-            Get an element and compute the corresponding SLD for a given formula
-            @param element:  elementis a string of existing atom
-        """
-        myformula = formula(str (element))
-        if len(myformula.atoms)!=1:
-            return 
-        element= myformula.atoms.keys()[0] 
-        energy = xray_energy(element.K_alpha)
-        atom = self.sld_formula.atoms
-        atom_reel, atom_im = xray_sld_from_atoms( atom,
-                                              density= self.density,
-                                              energy= energy )
-        return atom_reel, atom_im
-      
-        
-    def calculateNSld(self):
-        """
-            Compute the neutron SLD for a given molecule
-            @return absorp: absorption
-            @return coh: coherence cross section
-            @return inc: incoherence cross section
-        """
-        if self.density ==0:
-            raise ZeroDivisionError,"integer division or modulo by zero for density"
-            return 
-        atom = self.sld_formula.atoms
-        coh,absorp,inc = neutron_sld_from_atoms(atom,self.density,self.wavelength)
-        #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
-        self.incoherence = inc*1/10
-        #Doesn't match result of Alan calculator for absorption factor of 2
-        #multiplication of 100 is going around
-        self.absorption = absorp*2*100
-        self.coherence  = coh
-        return self.coherence, self.absorption, self.incoherence
-    
-    
-    def calculateLength(self):
-        """
-            Compute the neutron 1/e length
-        """
-        self.length= (self.coherence+ self.absorption+ self.incoherence)/self.volume
-        return self.length
-        
-        
-    def calculateAbsorptionIm(self):
-        """
-            Compute imaginary part of the absorption 
-        """
-        atom = self.sld_formula.atoms 
-        #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 
-        if self.volume !=0:
-            im = im/self.volume
-        else:
-            raise ZeroDivisionError,"integer division or modulo by zero for volume"
-        return im
-        
Index: nsview/perspectives/fitting/sldPanel.py
===================================================================
--- sansview/perspectives/fitting/sldPanel.py	(revision 6e9976be3c6ad17c4ee1e455860ae747e46fc9af)
+++ 	(revision )
@@ -1,381 +1,0 @@
-"""
-    This module provide GUI for the neutron scattering length density calculator
-    @author: Gervaise B. Alina
-"""
-
-import wx
-import sys
-
-from sans.guiframe.utils import format_number, check_float
-from sans.guicomm.events import StatusEvent  
-from sldCalculator import SldCalculator
-
-_BOX_WIDTH = 76
-_STATICBOX_WIDTH = 350
-_SCALE = 1e-6
-
-#SLD panel size 
-if sys.platform.count("darwin")==0:
-    _STATICBOX_WIDTH = 350
-    PANEL_SIZE = 400
-    FONT_VARIANT = 0
-else:
-    _STATICBOX_WIDTH = 380
-    PANEL_SIZE = 430
-    FONT_VARIANT = 1
-    
-class SldPanel(wx.Panel):
-    """
-        Provides the SLD calculator GUI.
-    """
-    def __init__(self, parent,base=None, id = -1):
-        wx.Panel.__init__(self, parent, id = id)
-        #Font size 
-        self.SetWindowVariant(variant=FONT_VARIANT)
-        
-        # Object that receive status event
-        self.base= base
-        self.calculator = SldCalculator()
-        self.wavelength = self.calculator.wavelength
-        
-        self._do_layout()
-        self.SetAutoLayout(True)
-        self.Layout()
-       
-
-    def _do_layout(self):
-        """
-            Draw window content
-        """
-        unit_a = '[A]'
-        unit_density = '[g/cm^(3)]'
-        unit_sld= '[1/A^(2)]'
-        unit_cm1='[1/cm]'
-        unit_cm='[cm]'
-        sizer_input = wx.GridBagSizer(5,5)
-        sizer_output = wx.GridBagSizer(5,5)
-        sizer_button = wx.BoxSizer(wx.HORIZONTAL)
-        sizer1 = wx.BoxSizer(wx.HORIZONTAL)
-        sizer2 = wx.BoxSizer(wx.HORIZONTAL)
-        sizer3 = wx.BoxSizer(wx.HORIZONTAL)
-        #---------inputs----------------
-        inputbox = wx.StaticBox(self, -1, "Input")
-        boxsizer1 = wx.StaticBoxSizer(inputbox, wx.VERTICAL)
-        boxsizer1.SetMinSize((_STATICBOX_WIDTH,-1))
-        
-        compound_txt = wx.StaticText(self, -1, 'Compound ')
-        self.compound_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
-        density_txt = wx.StaticText(self, -1, 'Density ')
-        self.density_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
-        unit_density_txt = wx.StaticText(self, -1, unit_density)
-        wavelength_txt = wx.StaticText(self, -1, 'Wavelength ')
-        self.wavelength_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
-        self.wavelength_ctl.SetValue(str(self.wavelength))
-        unit_a_txt = wx.StaticText(self, -1, unit_a)
-        iy = 0
-        ix = 0
-        sizer_input.Add(compound_txt,(iy, ix),(1,1),\
-                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix +=1
-        sizer_input.Add(self.compound_ctl,(iy, ix),(1,1),\
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-        iy += 1
-        ix = 0
-        sizer_input.Add(density_txt,(iy, ix),(1,1),\
-                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix +=1
-        sizer_input.Add(self.density_ctl,(iy, ix),(1,1),\
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-        ix +=1
-        sizer_input.Add(unit_density_txt,(iy, ix),(1,1),\
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-        iy += 1
-        ix = 0
-        sizer_input.Add(wavelength_txt,(iy, ix),(1,1),\
-                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix +=1
-        sizer_input.Add(self.wavelength_ctl,(iy, ix),(1,1),\
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-        ix +=1
-        sizer_input.Add(unit_a_txt,(iy, ix),(1,1),\
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-        boxsizer1.Add( sizer_input )
-        sizer1.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10)
-        #---------Outputs sizer--------
-        outputbox = wx.StaticBox(self, -1, "Output")
-        boxsizer2 = wx.StaticBoxSizer(outputbox, wx.VERTICAL)
-        boxsizer2.SetMinSize((_STATICBOX_WIDTH,-1))
-        
-        i_complex= '+ i'
-        neutron_sld_txt = wx.StaticText(self, -1, 'Neutron SLD')
-        self.neutron_sld_reel_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
-        self.neutron_sld_reel_ctl.SetEditable(False)
-        self.neutron_sld_reel_ctl.SetToolTipString("Neutron SLD reel.")
-        self.neutron_sld_im_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
-        self.neutron_sld_im_ctl.SetEditable(False)
-        self.neutron_sld_im_ctl.SetToolTipString("Neutron SLD imaginary.")
-        neutron_sld_units_txt = wx.StaticText(self, -1, unit_sld)
-        
-        cu_ka_sld_txt = wx.StaticText(self, -1, 'Cu Ka SLD')
-        self.cu_ka_sld_reel_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
-        self.cu_ka_sld_reel_ctl.SetEditable(False)
-        self.cu_ka_sld_reel_ctl.SetToolTipString("Cu Ka SLD reel.")
-        self.cu_ka_sld_im_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
-        self.cu_ka_sld_im_ctl.SetEditable(False)
-        self.cu_ka_sld_im_ctl.SetToolTipString("Cu Ka SLD imaginary.")
-        cu_ka_sld_units_txt = wx.StaticText(self, -1, unit_sld)
-        
-        mo_ka_sld_txt = wx.StaticText(self, -1, 'Mo Ka SLD')
-        self.mo_ka_sld_reel_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
-        self.mo_ka_sld_reel_ctl.SetEditable(False)
-        self.mo_ka_sld_reel_ctl.SetToolTipString("Mo Ka SLD reel.")
-        self.mo_ka_sld_im_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
-        self.mo_ka_sld_im_ctl.SetEditable(False)
-        self.mo_ka_sld_im_ctl.SetToolTipString("Mo Ka SLD reel.")
-        mo_ka_sld_units_txt = wx.StaticText(self, -1, unit_sld)
-        
-        neutron_inc_txt = wx.StaticText(self, -1, 'Neutron Inc. Xs')
-        self.neutron_inc_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
-        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')
-        self.neutron_abs_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
-        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')
-        self.neutron_length_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1))
-        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
-        sizer_output.Add(neutron_sld_txt,(iy, ix),(1,1),
-                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix +=1
-        sizer_output.Add(self.neutron_sld_reel_ctl,(iy, ix),(1,1),
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-        ix +=1
-        sizer_output.Add(wx.StaticText(self, -1, i_complex)
-                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-        ix +=1
-        sizer_output.Add(self.neutron_sld_im_ctl
-                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-        ix +=1
-        sizer_output.Add(neutron_sld_units_txt
-                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-        iy += 1
-        ix = 0
-        sizer_output.Add(cu_ka_sld_txt,(iy, ix),(1,1),
-                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix +=1
-        sizer_output.Add(self.cu_ka_sld_reel_ctl,(iy, ix),(1,1),
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-        ix +=1
-        sizer_output.Add(wx.StaticText(self, -1, i_complex)
-                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        ix +=1
-        sizer_output.Add(self.cu_ka_sld_im_ctl
-                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
-        ix +=1
-        sizer_output.Add(cu_ka_sld_units_txt
-                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-        iy += 1
-        ix = 0
-        sizer_output.Add(mo_ka_sld_txt,(iy, ix),(1,1),
-                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix +=1
-        sizer_output.Add(self.mo_ka_sld_reel_ctl,(iy, ix),(1,1),
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-        ix +=1
-        sizer_output.Add(wx.StaticText(self, -1, i_complex)
-                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        ix +=1
-        sizer_output.Add(self.mo_ka_sld_im_ctl
-                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
-        ix +=1
-        sizer_output.Add(mo_ka_sld_units_txt
-                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        iy += 1
-        ix = 0
-        sizer_output.Add(neutron_inc_txt,(iy, ix),(1,1),
-                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix +=1
-        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
-        sizer_output.Add(neutron_abs_txt,(iy, ix),(1,1),
-                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix +=1
-        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
-        sizer_output.Add(neutron_length_txt,(iy, ix),(1,1),
-                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix +=1
-        sizer_output.Add(self.neutron_length_ctl,(iy, ix),(1,1),
-                            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((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----------------
-        vbox  = wx.BoxSizer(wx.VERTICAL)
-        vbox.Add(sizer1)
-        vbox.Add(sizer2)
-        vbox.Add(sizer3)
-        vbox.Fit(self) 
-        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 = self.calculator.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.calculator.setValue(self.formulata_text,self.density,self.wavelength)
-                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.calculator.calculateXRaySld( "Cu")
-                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.calculator.calculateXRaySld( "Mo")
-                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.calculator.calculateNSld()
-                im = self.calculator.calculateAbsorptionIm()
-                length = self.calculator.calculateLength()
-                # Neutron SLD
-                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))
-                # Neutron length
-                self.neutron_length_ctl.SetValue(format_number(length))
-                # display wavelength
-                self.wavelength_ctl.SetValue(str(self.wavelength))
-        except:
-            if self.base !=None:
-                  msg= "SLD Calculator: %s" % (sys.exc_value)
-                  wx.PostEvent(self.base, StatusEvent(status= msg ))
-            else:
-                raise
-            return   
-
-   
-        
-  
-    
-   
- 
-        
-               
-class SldWindow(wx.Frame):
-    def __init__(self, parent=None, id=1, title="SLD Calculator",base=None):
-        wx.Frame.__init__(self, parent, id, title, size=( PANEL_SIZE,  PANEL_SIZE))
-        
-        self.panel = SldPanel(self, base=base)
-        self.Centre()
-        self.Show(True)
-        
-class ViewApp(wx.App):
-    def OnInit(self):
-        frame = SldWindow(None, -1, 'SLD Calculator')    
-        frame.Show(True)
-        self.SetTopWindow(frame)
-        
-        return True
-        
-
-if __name__ == "__main__": 
-    app = ViewApp(0)
-    app.MainLoop()     
