Index: sansview/perspectives/fitting/basepage.py
===================================================================
--- sansview/perspectives/fitting/basepage.py	(revision 71f03737f44ec12a86e74f08ab8a1dc96640bc08)
+++ sansview/perspectives/fitting/basepage.py	(revision 0aeabc66516f98ba46a16b35e8b2328b40a35433)
@@ -71,5 +71,5 @@
         self.qmin_x= 0.0001
         self.qmax_x= 0.13
-        self.num_points= 100
+        self.num_points= 50
         ## Create memento to save the current state
         
@@ -321,6 +321,6 @@
                     #TODO: total hack - fix this
                     self.state.model= self.model.clone()
-                    if not hasattr(self.model, "_persistency_dict"):
-                        self.model._persistency_dict = {}
+                    #if not hasattr(self.model, "_persistency_dict"):
+                    self.model._persistency_dict = {}
                     self.model._persistency_dict[p] = [self.values, self.weights]
                     self.state.model._persistency_dict[p] = [self.values, self.weights]
@@ -330,5 +330,5 @@
               
                 ## Redraw the model
-                print "select angle => draw"
+               
                 self._draw_model()
                 ## post state to fit panel
@@ -368,6 +368,6 @@
         
         self.state.model = self.model.clone()
-        if not hasattr(self.model, "_persistency_dict"):
-                            self.model._persistency_dict = {}
+        #if not hasattr(self.model, "_persistency_dict"):
+        self.model._persistency_dict = {}
         self.state.model._persistency_dict= copy.deepcopy(self.model._persistency_dict)
                         
@@ -471,13 +471,16 @@
             Store current state
         """
+        ## save model option
         if self.model!= None:
             self.disp_list= self.model.getDispParamList()
             self.state.disp_list= copy.deepcopy(self.disp_list)
             self.state.model = self.model.clone()
-        self.state.save_data(self.data)
-        self.state.disp_list = self.disp_list
+            
         self.state.enable2D = copy.deepcopy(self.enable2D)
         self.state.values= copy.deepcopy(self.values)
         self.state.weights = copy.deepcopy( self.weights)
+        ## save data    
+        self.state.save_data(self.data)
+       
         try:
             n = self.disp_box.GetCurrentSelection()
@@ -516,4 +519,5 @@
             self.state.values = copy.deepcopy(self.values)
             self.state.weights = copy.deepcopy(self.weights)
+        ## save plotting range
         self._save_plotting_range()
         
@@ -545,10 +549,7 @@
             state of the graphic interface
         """
-        ## set the value of the current state to the state given as parameter
-        self.state = state.clone() 
-        
-        self.model= self.state.model
-        self.data = self.state.data
-        self.smearer= self.state.smearer
+        self.model= state.model
+        self.data = state.data
+        self.smearer= state.smearer
         self.enable2D= state.enable2D
         
@@ -573,9 +574,9 @@
             
         ## display dispersion info layer
-        self.enable_disp.SetValue(self.state.enable_disp)
-        self.disable_disp.SetValue(self.state.disable_disp)
+        self.enable_disp.SetValue(state.enable_disp)
+        self.disable_disp.SetValue(state.disable_disp)
         
         if hasattr(self, "disp_box"):
-            self.disp_box.SetSelection(self.state.disp_box)  
+            self.disp_box.SetSelection(state.disp_box)  
             n = self.disp_box.GetCurrentSelection()
             dispersity= self.disp_box.GetClientData(n)
@@ -586,8 +587,7 @@
                 self.disp_cb_dict = {}
                 self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 
-                self.state.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 
                
                 self._disp_obj_dict={}
-                for k , v in self.state._disp_obj_dict.iteritems():
+                for k , v in state._disp_obj_dict.iteritems():
                     self._disp_obj_dict[k]=v
           
@@ -599,5 +599,5 @@
                 for k,v in state.disp_cb_dict.iteritems():
                     self.disp_cb_dict[k].SetValue(v) 
-                    self.state.disp_cb_dict[k]=v 
+                    
                     if self.disp_cb_dict[k].GetValue():
                         # Create the dispersion objects
@@ -610,9 +610,5 @@
                         #TODO: refactor model to clean this up?
                         self._disp_obj_dict[k] = disp_model
-                        self.state._disp_obj_dict [k]= disp_model
-                        self.state.values=[]
-                        self.state.weights=[]
-                        self.state.values = self.values
-                        self.state.weights = self.weights
+                      
                         self.values=[]
                         self.weights = []
@@ -621,17 +617,21 @@
                     
                         # Set the new model as the dispersion object for the selected parameter
-                        if not hasattr(self.model, "_persistency_dict"):
-                            self.model._persistency_dict = {}
+                        #if not hasattr(self.model, "_persistency_dict"):
+                        self.model._persistency_dict = {}
                         self.model._persistency_dict[k] = [state.values, state.weights]
                         self.model.set_dispersion(k, disp_model)
                         
         ##plotting range restore    
-        self._reset_plotting_range()
+        self._reset_plotting_range(state)
         ## smearing info  restore
         if hasattr(self,"enable_smearer"):
             ## set smearing value whether or not the data contain the smearing info
-            self.enable_smearer.SetValue(self.state.enable_smearer)
-            self.disable_smearer.SetValue(self.state.disable_smearer)
-            self.compute_chisqr(smearer= self.smearer)  
+            self.enable_smearer.SetValue(state.enable_smearer)
+            self.disable_smearer.SetValue(state.disable_smearer)
+            self.tcChi.SetLabel(str( state.tcChi))
+            self.sizer5.Layout()
+            self.Layout()
+            self.Refresh()
+            #self.compute_chisqr(smearer= self.smearer)  
             
         ## reset state of checkbox,textcrtl  and dispersity parameters value
@@ -642,9 +642,12 @@
         ## draw the model with previous parameters value
         self._onparamEnter_helper()
-      
+       
         ## reset context menu items
         self._reset_context_menu()
-        
-
+        ## set the value of the current state to the state given as parameter
+        self.state = state.clone() 
+        ## post state to fit panel
+        event = PageInfoEvent(page = self)
+        wx.PostEvent(self.parent, event)
         
     def _selectDlg(self):
@@ -674,18 +677,13 @@
     
     
-    def _reset_plotting_range(self):
+    def _reset_plotting_range(self, state):
         """
             Reset the plotting range to a given state
         """
-       
-        self.qmin.SetValue(str(self.state.qmin))
-        self.qmax.SetValue(str(self.state.qmax)) 
+        self.qmin.SetValue(str(state.qmin))
+        self.qmax.SetValue(str(state.qmax)) 
         if self.state.npts!=None:
-            self.npts.SetValue(format_number(self.state.npts)) 
-            self.num_points = float(self.state.npts)
-            
-        self.qmin_x = float(self.qmin.GetValue())
-        self.qmax_x = float(self.qmax.GetValue())
-        
+            self.npts.SetValue(str(state.npts)) 
+            
         
     def _save_plotting_range(self ):
@@ -743,5 +741,5 @@
             ## if any value is modify draw model with new value
             if is_modified:
-                print "is_modified--->",is_modified
+               
                 self._draw_model() 
                 self.save_current_state()
@@ -960,5 +958,5 @@
                 if self.enable_smearer.GetValue():
                     temp_smear= self.smearer
-            print "self.model.dispersion",self.model.dispersion
+           
             self.manager.draw_model(self.model, data=self.data,
                                     smearer= temp_smear,
@@ -1143,4 +1141,5 @@
             from sans.models.MultiplicationModel import MultiplicationModel
             self.model= MultiplicationModel(form_factor(),struct_factor())
+            
         else:
             if form_factor != None:
@@ -1339,5 +1338,5 @@
             self.model.set_dispersion(p, disp_model)
             # Redraw the model
-            print "reset dispersity=> draw"
+           
             self._draw_model()
             
Index: sansview/perspectives/fitting/fitpage.py
===================================================================
--- sansview/perspectives/fitting/fitpage.py	(revision 71f03737f44ec12a86e74f08ab8a1dc96640bc08)
+++ sansview/perspectives/fitting/fitpage.py	(revision 0aeabc66516f98ba46a16b35e8b2328b40a35433)
@@ -557,8 +557,18 @@
                 tcrtl.SetBackgroundColour("pink")
                 tcrtl.Refresh()
+                return
         else:
            tcrtl.SetBackgroundColour(wx.WHITE)
            tcrtl.Refresh()  
-        self._onparamEnter_helper()    
+        self._onparamEnter_helper() 
+        
+        ##compute chisqr for range change
+        temp_smearer = None
+        if self.enable_smearer.GetValue():
+            msg=""
+            temp_smearer= self.smearer   
+         ##Calculate chi2
+        self.compute_chisqr(smearer= temp_smearer)  
+        
         
     def _onparamEnter(self,event):
@@ -747,7 +757,15 @@
         """
         try:
-            self.tcChi.SetLabel(format_number(output))
+            self.tcChi.SetLabel(str(output))
+           
+            self.sizer5.Layout()
+            self.Layout()
+            self.Refresh
+            ## post state to fit panel
+            self.state.tcChi =output
+            event = PageInfoEvent(page = self)
+            wx.PostEvent(self.parent, event)
         except:
-            raise
+            pass
         
         
@@ -809,5 +827,5 @@
             if self.calc_Chisqr!= None and self.calc_Chisqr.isrunning():
                 self.calc_Chisqr.stop()
-                
+           
             self.calc_Chisqr= CalcChisqr2D( x_bins= self.data.x_bins,
                                             y_bins= self.data.y_bins,
Index: sansview/perspectives/fitting/fitpanel.py
===================================================================
--- sansview/perspectives/fitting/fitpanel.py	(revision 71f03737f44ec12a86e74f08ab8a1dc96640bc08)
+++ sansview/perspectives/fitting/fitpanel.py	(revision 0aeabc66516f98ba46a16b35e8b2328b40a35433)
@@ -332,6 +332,5 @@
         self.model_page_number=self.GetSelection()
         self.model_page=self.GetPage(self.GetSelection())
-        # Set the range used to plot models
-        self.model_page.set_range(qmin, qmax, npts)
+     
         ##  resetting page
         if reset:
@@ -339,11 +338,8 @@
 
                 memento= self.fit_page_name[page_title][0]
-                
                 panel.reset_page(memento)
         else:
             self.fit_page_name[page_title]=[]
             self.fit_page_name[page_title].insert(0,panel.createMemento())
-            ## We just created a model page, we are ready to plot the model
-            self.manager.draw_model(model, qmin=qmin, qmax=qmax)
+       
   
-  
Index: sansview/perspectives/fitting/gui_thread.py
===================================================================
--- sansview/perspectives/fitting/gui_thread.py	(revision 6dd2be32f30fdf89d70ef4cd925c5d6657ba9667)
+++ sansview/perspectives/fitting/gui_thread.py	(revision 0aeabc66516f98ba46a16b35e8b2328b40a35433)
@@ -149,4 +149,8 @@
         """
         self.starttime = time.time()
+        if self.model ==None:
+            return
+        if self.data==None:
+            return
         if self.err_data==None or self.err_data==[]:
             self.err_data= numpy.zeros(len(self.x_bins),len(self.y_bins))
Index: sansview/perspectives/fitting/pagestate.py
===================================================================
--- sansview/perspectives/fitting/pagestate.py	(revision 71f03737f44ec12a86e74f08ab8a1dc96640bc08)
+++ sansview/perspectives/fitting/pagestate.py	(revision 0aeabc66516f98ba46a16b35e8b2328b40a35433)
@@ -23,7 +23,7 @@
         # model on which the fit would be performed
         self.model = model
-        if not hasattr(self.model, "_persistency_dict"):
-            self.model._persistency_dict = {}
-        self.model._persistency_dict = copy.deepcopy(model._persistency_dict)
+        #if not hasattr(self.model, "_persistency_dict"):
+        #    self.model._persistency_dict = {}
+        #self.model._persistency_dict = copy.deepcopy(model._persistency_dict)
         #fit page manager 
         self.manager = None
@@ -84,4 +84,6 @@
         ## state of selected all check button
         self.cb1 = False
+        ## store value of chisqr
+        self.tcChi= None
        
    
@@ -115,7 +117,6 @@
         obj.enable_disp = copy.deepcopy(self.enable_disp)
         obj.disable_disp = copy.deepcopy(self.disable_disp)
-        if self.model !=None and len(self.model._persistency_dict)>0:
-            for k, v in self.model._persistency_dict.iteritems():
-                obj.model._persistency_dict[k] = copy.deepcopy(v)
+        obj.tcChi = self.tcChi
+  
         if len(self._disp_obj_dict)>0:
             for k , v in self._disp_obj_dict.iteritems():
