Index: sansview/perspectives/fitting/fitpage.py
===================================================================
--- sansview/perspectives/fitting/fitpage.py	(revision 442895f8f6b7b30ca7be518812051dcdd0204d83)
+++ sansview/perspectives/fitting/fitpage.py	(revision 0056173917543f1d2329e6d57462f61b0b92d261)
@@ -211,4 +211,5 @@
         
     def onClose(self,event):
+        """ close the page associated with this panel"""
         self.GrandParent.onClose()
         
@@ -233,6 +234,7 @@
             sum=0
             for item in res:
-                sum +=item
-        self.tcChi.SetValue(format_number(math.fabs(sum)))
+                if numpy.isfinite(item):
+                    sum +=item
+            self.tcChi.SetValue(format_number(math.fabs(sum)))
             
             
@@ -259,8 +261,7 @@
         list_name=[]
         for item in  self.model_list_box.itervalues():
+            name = item.__name__
             if hasattr(item, "name"):
                 name = item.name
-            else:
-                name = item.__name__
             list_name.append(name)
         list_name.sort()   
@@ -277,17 +278,17 @@
             post an event to its owner to draw an appropriate theory
         """
+        
         for item in self.model_list_box.itervalues():
-            model=item()
-            if hasattr(model, "name"):
-                name = model.name
-            else:
-                name = model.__class__.__name__
-            try:
-                if name ==event.GetString():
-                    evt = ModelEventbox(model=model,name=name)
+            name = item.__name__
+            if hasattr(item, "name"):
+                name = item.name
+            #print "fitpage: _on_select_model model name",name ,event.GetString()
+            if name ==event.GetString():
+                try:
+                    evt = ModelEventbox(model=item(),name=name)
                     wx.PostEvent(self.event_owner, evt)
-            except:
-                raise #ValueError,"model.name is not equal to model class name"
-
+                except:
+                    raise #ValueError,"model.name is not equal to model class name"
+                break
     
     def _onTextEnter(self,event):
Index: sansview/perspectives/fitting/fitproblem.py
===================================================================
--- sansview/perspectives/fitting/fitproblem.py	(revision 3b19ac900df88b5cbef968f2497d314a8a59c333)
+++ sansview/perspectives/fitting/fitproblem.py	(revision 0056173917543f1d2329e6d57462f61b0b92d261)
@@ -20,4 +20,6 @@
         self.model_list=[]
         self.schedule='False'
+        self.param_name= None
+        self.param_value=None
         
     def set_model(self,model,name):
@@ -39,4 +41,5 @@
     def get_model(self):
         """ @return: saved model """
+        print "fitproblem",self.model_list
         return self.model_list
      
@@ -65,7 +68,17 @@
             @param value: value of that parameter
         """
-        
-        self.model_list[0].setParam(name,value)
-       
+        print "fitproblem",name,value
+        #self.model_list[0].setParam(name,value)
+        self.param_name = name
+        self.param_value= value
+    def get_model_param(self):
+        """ 
+            set the value of a given parameter of this model
+            @param name: name of the given parameter
+            @param value: value of that parameter
+        """
+        print self.param_name, self.param_value
+        #self.model_list[0].setParam(name,value)
+        return self.param_name, self.param_value
         
     def reset_model(self,model):
Index: sansview/perspectives/fitting/fitting.py
===================================================================
--- sansview/perspectives/fitting/fitting.py	(revision 442895f8f6b7b30ca7be518812051dcdd0204d83)
+++ sansview/perspectives/fitting/fitting.py	(revision 0056173917543f1d2329e6d57462f61b0b92d261)
@@ -14,44 +14,4 @@
 import fitpage
 import park
-class PlottableDatas(Data,Data1D):
-    """ class plottable data: class allowing to plot Data type on panel"""
-    
-    def __init__(self,data=None,data1d=None):
-        Data.__init__(self,sans_data=data1d)
-        Data1D.__init__(self,x=data1d.x,y = data1d.y,dx = data1d.dx,dy = data1d.dy)
-        #self.x = data1d.x
-        #self.y = data1d.y
-        #self.dx = data1d.dx
-        #self.dy = data1d.dy
-        #self.data=data
-        self.group_id = data1d.group_id
-        #x_name, x_units = data1d.get_xaxis() 
-        #y_name, y_units = data1d.get_yaxis() 
-        #self.xaxis( x_name, x_units)
-        #self.yaxis( y_name, y_units )
-        #self.qmin = data.qmin
-        #self.qmax = data.qmax
-       
-
-class PlottableData(Data,Data1D):
-    """ class plottable data: class allowing to plot Data type on panel"""
-    
-    def __init__(self,data=None,data1d=None):
-        #Data.__init__(self,*args)
-        #Data1D.__init__(self,**kw)
-        self.x = data1d.x
-        self.y = data1d.y
-        self.dx = data1d.dx
-        self.dy = data1d.dy
-        self.data=data
-        self.group_id = data1d.group_id
-        x_name, x_units = data1d.get_xaxis() 
-        y_name, y_units = data1d.get_yaxis() 
-        self.xaxis( x_name, x_units)
-        self.yaxis( y_name, y_units )
-        self.qmin = data.qmin
-        self.qmax = data.qmax
-        def residuals(self, fn):
-            return self.data.residuals(fn)
 
 class Plugin:
@@ -218,4 +178,5 @@
                 list=value.get_model()
                 model=list[0]
+                print "fitting",model.name,modelname
                 if model.name== modelname:
                     value.set_model_param(names,values)
@@ -400,5 +361,9 @@
                             wx.PostEvent(self.parent, StatusEvent(status="Fitting error: %s" % sys.exc_value))
                             return
-                    self.fitter.set_model(Model(model), self.id, pars) 
+                    new_model=Model(model)
+                    param_name,param_value=value.get_model_param()
+                    print "fitting ",param_name
+                    new_model.set( param_name =str(param_value))
+                    #self.fitter.set_model(new_model, self.id, pars) 
                     self.fitter.set_data(Data(sans_data=data),self.id,qmin,qmax)
                 
@@ -492,7 +457,4 @@
                 theory.xaxis(x_name, x_units)
                 theory.yaxis(y_name, y_units)
-                #print"fitting : redraw data.x",data.x
-                #print"fitting : redraw data.y",data.y
-                #print"fitting : redraw data.dy",data.dy
                 if qmin == None :
                    qmin = min(data.x)
@@ -524,17 +486,9 @@
                     theory.x.append(tempx)
                     theory.y.append(tempy)
-                except:
-                        wx.PostEvent(self.parent, StatusEvent(status="fitting \
-                        skipping point x %g %s" %(qmax, sys.exc_value)))
-                try:
-                    #print "fitting redraw for plot thoery .x",theory.x
-                    #print "fitting redraw for plot thoery .y",theory.y
-                    #print "fitting redraw for plot thoery .dy",theory.dy
-                    #rom sans.guicomm.events import NewPlotEvent
                     wx.PostEvent(self.parent, NewPlotEvent(plot=theory, title="Analytical model"))
                 except:
-                    raise
-                    print "SimView.complete1D: could not import sans.guicomm.events"
-            
+                    wx.PostEvent(self.parent, StatusEvent(status="fitting \
+                        skipping point x %g %s" %(qmax, sys.exc_value)))
+               
             
     def _on_model_menu(self, evt):
@@ -567,9 +521,8 @@
             new_plot.yaxis("\\rm{Intensity} ","cm^{-1}")
             new_plot.group_id ="Fitness"
-         
             wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="Analytical model"))
         except:
-            print "SimView.complete1D: could not import sans.guicomm.events\n %s" % sys.exc_value
-            logging.error("SimView.complete1D: could not import sans.guicomm.events\n %s" % sys.exc_value)
+            wx.PostEvent(self.parent, StatusEvent(status="fitting \
+                        skipping point x %g %s" %(qmax, sys.exc_value)))
 
 if __name__ == "__main__":
Index: sansview/perspectives/fitting/modelpage.py
===================================================================
--- sansview/perspectives/fitting/modelpage.py	(revision 442895f8f6b7b30ca7be518812051dcdd0204d83)
+++ sansview/perspectives/fitting/modelpage.py	(revision 0056173917543f1d2329e6d57462f61b0b92d261)
@@ -52,4 +52,5 @@
         self.sizer1 = wx.GridBagSizer(5,5)
         self.sizer2 = wx.GridBagSizer(5,5)
+        self.sizer4 = wx.GridBagSizer(5,5)
         self.modelbox = wx.ComboBox(self, -1)
         id = wx.NewId()
@@ -57,7 +58,16 @@
         self.vbox.Add(self.sizer1)
         self.vbox.Add(self.sizer2)
+        self.vbox.Add(self.sizer4)
+        
+        id = wx.NewId()
+        self.btClose =wx.Button(self,id,'Close')
+        self.btClose.Bind(wx.EVT_BUTTON, self.onClose,id=id)
+        self.btClose.SetToolTipString("Close page.")
+        
+        ix = 12
+        iy = 1
+        self.sizer4.Add( self.btClose,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
         ix = 0
         iy = 1
-       
         self.sizer3.Add(wx.StaticText(self,-1,'Model'),(iy,ix),(1,1)\
                   , wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
@@ -87,4 +97,8 @@
         
         
+    def onClose(self,event):
+        """ close the page associated with this panel"""
+        self.GrandParent.onClose()
+        
     def set_owner(self,owner):
         """ 
@@ -122,5 +136,5 @@
    
     def set_page(self, model,description):
-        print " modelpage: set_page was called",model
+        #print " modelpage: set_page was called",model
         self.model=model
         self.description=description
@@ -137,8 +151,8 @@
             post an event to its owner to draw an appropriate theory
         """
-        print "modelpage: self.model_list_box ",self.model_list_box
+        #print "modelpage: self.model_list_box ",self.model_list_box
         for item in self.model_list_box.itervalues():
             model=item()
-            print "modelpage:model",model
+            #print "modelpage:model",model
             if hasattr(model, "name"):
                 name = model.name
Index: sansview/perspectives/fitting/models.py
===================================================================
--- sansview/perspectives/fitting/models.py	(revision 442895f8f6b7b30ca7be518812051dcdd0204d83)
+++ sansview/perspectives/fitting/models.py	(revision 0056173917543f1d2329e6d57462f61b0b92d261)
@@ -5,12 +5,20 @@
 
 (ModelEvent, EVT_MODEL) = wx.lib.newevent.NewEvent()
+
 class ModelInfo(object):
+    """
+         this class contains description for a given model
+    """
     def __init__(self,model,description=None):
         self.model=model
         self.description=description
+        
     def set_description(self, descrition):
         self.description =str(description)
+        
     def get_description(self):
         return self.description
+    
+    
 def log(message):
     print message
@@ -179,15 +187,14 @@
         if len(self.indep_model_list) == 0:
             for item in self.indep_model:
-                if item not in self.indep_model_list.values():
-                    self.indep_model_list[str(id)] = item
-                    self.model_list[str(id)]=item
-                    if hasattr(item, "name"):
-                        name = item.model.name
-                    else:
-                        name = item.model.__name__
-                    indep_submenu.Append(id,name, name)
-                    self.model_list_box[name] =item.model
-                    wx.EVT_MENU(event_owner, int(id), self._on_model)
-                    id = wx.NewId()         
+                #if item not in self.indep_model_list.values():
+                    #self.indep_model_list[str(id)] = item
+                self.model_list[str(id)]=item
+                name = item.model.__name__
+                if hasattr(item, "name"):
+                    name = item.model.name
+                indep_submenu.Append(id,name, name)
+                self.model_list_box[name] =item.model
+                wx.EVT_MENU(event_owner, int(id), self._on_model)
+                id = wx.NewId()         
         modelmenu.AppendMenu(wx.NewId(), "Shape-independent...", indep_submenu, "List of shape-independent models")
         
@@ -198,16 +205,14 @@
         if len(self.custom_models) == 0:
             for item in self.plugins:
-                if item not in self.custom_models.values():
-                    self.custom_models[str(id)] = item
-                    
-                    self.model_list[str(id)]=ModelInfo(item,model_info)
-                    if hasattr(item, "name"):
-                        name = item.name
-                    else:
-                        name = item.__name__
-                    added_models.Append(id, name, name)
-                    self.model_list_box[name] =item
-                    wx.EVT_MENU(event_owner, int(id), self._on_model)
-                    id = wx.NewId()
+                #if item not in self.custom_models.values():
+                    #self.custom_models[str(id)] = item
+                self.model_list[str(id)]=ModelInfo(item,model_info)
+                name = item.__name__
+                if hasattr(item, "name"):
+                    name = item.name
+                added_models.Append(id, name, name)
+                self.model_list_box[name] =item
+                wx.EVT_MENU(event_owner, int(id), self._on_model)
+                id = wx.NewId()
         modelmenu.AppendMenu(wx.NewId(),"Added models...", added_models, "List of additional models")
         return 0
Index: sansview/perspectives/fitting/simfitpage.py
===================================================================
--- sansview/perspectives/fitting/simfitpage.py	(revision 442895f8f6b7b30ca7be518812051dcdd0204d83)
+++ sansview/perspectives/fitting/simfitpage.py	(revision 0056173917543f1d2329e6d57462f61b0b92d261)
@@ -44,6 +44,6 @@
 
         self.ctl2 = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE)
-        self.ctl2.Bind(wx.EVT_KILL_FOCUS, self._onTextEnter)
-        self.ctl2.Bind(wx.EVT_TEXT_ENTER, self._onTextEnter)
+        #self.ctl2.Bind(wx.EVT_KILL_FOCUS, self._onTextEnter)
+        #self.ctl2.Bind(wx.EVT_TEXT_ENTER, self._onTextEnter)
         self.sizer2.Add(self.ctl2, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
        
@@ -65,4 +65,5 @@
     def onFit(self,event):
         """ signal for fitting"""
+        self._onTextEnter()
         if len(self.model_toFit) >0 :
             if len(self.params)>0:
@@ -75,4 +76,6 @@
             wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\
                             "Select at least on model to fit "))
+            
+            
     def set_manager(self, manager):
         """
@@ -105,5 +108,5 @@
             @param page_finder: the dictionary containing models information
         """
-        import copy 
+       
         self.model_list=[]
         self.model_toFit=[]
@@ -206,5 +209,6 @@
     
                 
-    def _onTextEnter(self,event):
+    #def _onTextEnter(self,event):
+    def _onTextEnter(self):
         """
             get values from the constrainst textcrtl ,parses them into model name
@@ -225,10 +229,10 @@
                         self.params.append(self.parser_helper(item))
                     except:
-                        wx.PostEvent(self.parent.GrandParent, StatusEvent(status="Loading Error: %s" % sys.exc_value))
+                        wx.PostEvent(self.parent.GrandParent, StatusEvent(status="Constraint Error: %s" % sys.exc_value))
             else:
                 try:
                     self.params.append(self.parser_helper(value))
                 except:
-                     wx.PostEvent(self.parent.GrandParent, StatusEvent(status="Loading Error: %s" % sys.exc_value))
+                     wx.PostEvent(self.parent.GrandParent, StatusEvent(status="Constraint Error: %s" % sys.exc_value))
         except:
             raise
@@ -253,5 +257,12 @@
                 model_name=param_names[0]
                 param_name=param_names[1]
-                param=[str(model_name),str(param_name),str(param_value)]
+                ##### just added
+                if string.find(param_name,".")!=-1:
+                ########
+                    param_new_name= re.split("\.",param_name)
+                else:  
+                    param_new_name=  param_name
+                print "simfitpage: param name",param_new_name
+                param=[str(model_name),str(param_new_name[1]),str(param_value)]
                 #print "simfitpage: param",param
                 return param
