Index: sansview/perspectives/fitting/basepage.py
===================================================================
--- sansview/perspectives/fitting/basepage.py	(revision fe496eeb67fc41232a4f7c04808dbb1c5eae5b13)
+++ sansview/perspectives/fitting/basepage.py	(revision 240b99667ef276450071f502cdb1331ccb27714e)
@@ -78,4 +78,6 @@
         ## Create memento to save the current state
         self.state= PageState(parent= self.parent,model=self.model, data=self.data)
+        ## flag to determine if state has change
+        self.state_change= False
         ## save customized array
         self.values=[]
@@ -403,6 +405,6 @@
         self.state.model = self.model.clone()
         #if not hasattr(self.model, "_persistency_dict"):
-        self.model._persistency_dict = {}
-        self.state.model._persistency_dict= copy.deepcopy(self.model._persistency_dict)
+        #self.model._persistency_dict = {}
+        #self.state.model._persistency_dict= copy.deepcopy(self.model._persistency_dict)
                         
         new_state = self.state.clone()
@@ -515,5 +517,5 @@
         self.state.weights = copy.deepcopy( self.weights)
         ## save data    
-        self.state.save_data(self.data)
+        self.state.data= copy.deepcopy(self.data)
        
         try:
@@ -570,11 +572,7 @@
         self._copy_parameters_state(self.fittable_param, self.state.fittable_param)
         self._copy_parameters_state(self.fixed_param, self.state.fixed_param)
-        
-        ## post state to fit panel
-        #event = PageInfoEvent(page = self)
-        #wx.PostEvent(self.parent, event)
-    
-    
-    def reset_page_helper(self, state, forward=False):
+    
+    
+    def reset_page_helper(self, state):
         """
             Use page_state and change the state of existing page
@@ -590,8 +588,16 @@
         self.smearer= state.smearer
         self.enable2D= state.enable2D
-        
+        ## set the state of the radio box
+        self.shape_rbutton.SetValue(state.shape_rbutton )
+        self.shape_indep_rbutton.SetValue(state.shape_indep_rbutton)
+        self.struct_rbutton.SetValue(state.struct_rbutton )
+        self.plugin_rbutton.SetValue(state.plugin_rbutton)
         ##draw sizer containing model parameters value for the current model
         self._set_model_sizer_selection( self.model )
         self.set_model_param_sizer(self.model)
+        
+        ## reset value of combox box
+        self.structurebox.SetSelection(state.structurecombobox )
+        self.formfactorbox.SetSelection(state.formfactorcombobox)
         ## enable the view 2d button if this is a modelpage type
         if hasattr(self,"model_view"):
@@ -617,47 +623,15 @@
         if hasattr(self, "disp_box"):
             self.disp_box.SetSelection(state.disp_box)  
-            n = self.disp_box.GetCurrentSelection()
-            dispersity= self.disp_box.GetClientData(n)
-            
-            self._set_dipers_Param(event=None)
-            name= dispersity.__name__
-            if name == "GaussianDispersion":
-                self.disp_cb_dict = {}
+           
+            self.disp_cb_dict = {}
+            for k,v in self.state.disp_cb_dict.iteritems():
                 self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 
-               
-                self._disp_obj_dict={}
-                for k , v in state._disp_obj_dict.iteritems():
-                    self._disp_obj_dict[k]=v
-          
-            if  name=="ArrayDispersion":
-                self.model_disp.Show(True)
-                self.disp_box.Show(True)
-                self._set_sizer_arraydispersion()
+                self.state.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 
                 
-                for k,v in state.disp_cb_dict.iteritems():
-                    self.disp_cb_dict[k].SetValue(v) 
-                    
-                    if self.disp_cb_dict[k].GetValue():
-                        # Create the dispersion objects
-                        from sans.models.dispersion_models import ArrayDispersion
-                        disp_model = ArrayDispersion()
-                        
-                        disp_model.set_weights(state.values, state.weights)
-                       
-                        # Store the object to make it persist outside the scope of this method
-                        #TODO: refactor model to clean this up?
-                        self._disp_obj_dict[k] = disp_model
-                      
-                        self.values=[]
-                        self.weights = []
-                        self.values= state.values
-                        self.weights = state.weights
-                    
-                        # Set the new model as the dispersion object for the selected parameter
-                        #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)
-                        
+            self._disp_obj_dict={}
+            for k , v in self.state._disp_obj_dict.iteritems():
+                self._disp_obj_dict[k]=v
+      
+        self._set_dipers_Param(event=None)
         ##plotting range restore    
         self._reset_plotting_range(state)
@@ -677,15 +651,15 @@
         self._reset_parameters_state(self.fixed_param,state.fixed_param)
         
-      
+        
         ## 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):
@@ -724,4 +698,16 @@
             self.npts.SetValue(str(state.npts)) 
             
+    def _save_typeOfmodel(self):
+        """
+            save radiobutton containing the type model that can be selected
+        """
+        self.state.shape_rbutton = self.shape_rbutton.GetValue()
+        self.state.shape_indep_rbutton = self.shape_indep_rbutton.GetValue()
+        self.state.struct_rbutton = self.struct_rbutton.GetValue()
+        self.state.plugin_rbutton = self.plugin_rbutton.GetValue()
+        ## post state to fit panel
+        event = PageInfoEvent(page = self)
+        wx.PostEvent(self.parent, event)
+        self._undo.Enable(True)
         
     def _save_plotting_range(self ):
@@ -780,5 +766,5 @@
             ## if any value is modify draw model with new value
             if is_modified:
-               
+                self.state_change= True
                 self._draw_model() 
                 self.save_current_state()
@@ -871,8 +857,11 @@
                 max_value = item[6].GetValue()
                 max_state = item[6].IsShown()
+            unit=None
+            if item[7]!=None:
+                unit = item[7].GetLabel()
                
             statelist.append([checkbox_state, parameter_name, parameter_value,
                               static_text ,[error_state,error_value],
-                                [min_state,min_value],[max_state , max_value],None])
+                                [min_state,min_value],[max_state , max_value],unit])
            
         
@@ -982,4 +971,6 @@
                             break
                     break
+        ## save state and post
+        
                     
         
@@ -1132,5 +1123,5 @@
             self._populate_box( self.formfactorbox,
                                 self.model_list_box["Customized Models"])
-        
+        self._save_typeOfmodel()
         self._on_select_model(event=None)
         self.sizer4_4.Layout()
@@ -1192,5 +1183,6 @@
         self.disp_list =self.model.getDispParamList()
         self.state.disp_list = self.disp_list
-        
+        self.state.structurecombobox =self.structurebox.GetCurrentSelection()
+        self.state.formfactorcombobox = self.formfactorbox.GetCurrentSelection()
         self.sizer4_4.Layout()
         self.sizer4.Layout()
@@ -1290,6 +1282,6 @@
             self.disp_box.Hide()
             self.sizer4_4.Clear(True)
-            ## post state to fit panel
-            self.save_current_state()
+            ## save the state of the dispersity
+            #self.save_current_state()
             return
             
@@ -1309,8 +1301,11 @@
             self.disp_box.SetSelection(0) 
             self.sizer4_4.Clear(True)
-            #self._reset_dispersity()
-            
-        ## post state to fit panel
+        
+        ## post state to fit panel 
         self.save_current_state()
+        if event !=None:
+            event = PageInfoEvent(page = self)
+            wx.PostEvent(self.parent, event)
+        
         self.sizer4_4.Layout()
         self.sizer4.Layout()
@@ -1382,5 +1377,6 @@
            
             self._draw_model()
-            
+        ## save state into
+        self.save_current_state()
         self.sizer4_4.Layout()
         self.sizer4.Layout()
@@ -1407,7 +1403,4 @@
             
         self.state.disp_box= n
-        ## post state to fit panel
-        #event = PageInfoEvent(page = self)
-        #wx.PostEvent(self.parent, event)
         
         self.sizer4_4.Layout()
@@ -1457,5 +1450,10 @@
         self.sizer4.Layout()
         self.SetScrollbars(20,20,200,100)
-       
+        ## save state into
+        self._copy_parameters_state(self.orientation_params_disp,
+                                     self.state.orientation_params_disp)
+        self._copy_parameters_state(self.fittable_param, self.state.fittable_param)
+        self._copy_parameters_state(self.fixed_param, self.state.fixed_param)
+
 
     def _set_range_sizer(self, title, object1=None,object=None):
Index: sansview/perspectives/fitting/fitpage.py
===================================================================
--- sansview/perspectives/fitting/fitpage.py	(revision 330573d11b080c2302da8ab85d9ba8a153765f1f)
+++ sansview/perspectives/fitting/fitpage.py	(revision 240b99667ef276450071f502cdb1331ccb27714e)
@@ -453,4 +453,9 @@
         self.state.disp_cb_dict = copy.deepcopy(self.disp_cb_dict)      
         self.state.model = self.model.clone()  
+         ## save state into
+        self._copy_parameters_state(self.orientation_params_disp,
+                                     self.state.orientation_params_disp)
+        self._copy_parameters_state(self.fittable_param, self.state.fittable_param)
+        self._copy_parameters_state(self.fixed_param, self.state.fixed_param)
                          
         wx.PostEvent(self.parent, StatusEvent(status=\
@@ -542,4 +547,6 @@
             wx.PostEvent(self.event_owner, evt)   
         self.btFit.SetFocus() 
+        self.state.enable_disp = self.enable_disp.GetValue()
+        self.state.disable_disp = self.disable_disp.GetValue()
         ## post state to fit panel
         event = PageInfoEvent(page = self)
@@ -573,4 +580,9 @@
          ##Calculate chi2
         self.compute_chisqr(smearer= temp_smearer)  
+        ## new state posted
+        if self.state_change:
+            event = PageInfoEvent(page = self)
+            wx.PostEvent(self.parent, event)
+            self.state_change= False
         
         
@@ -580,10 +592,5 @@
         """
         tcrtl= event.GetEventObject()
-        ## save current state
-        self.save_current_state()
-        
-        event = PageInfoEvent(page = self)
-        wx.PostEvent(self.parent, event)
-        
+       
         if check_float(tcrtl):
             self._onparamEnter_helper()
@@ -592,4 +599,9 @@
                 temp_smearer= self.smearer
             self.compute_chisqr(smearer= temp_smearer)
+            ## new state posted
+            if self.state_change:
+                 event = PageInfoEvent(page = self)
+                 wx.PostEvent(self.parent, event)
+                 self.state_change= False
         else:
             msg= "Cannot Plot :Must enter a number!!!  "
@@ -610,8 +622,11 @@
         self.Layout()   
         
-    def reset_page(self, state):
+    def reset_page(self, state,first=False):
         """
             reset the state
         """
+        if first:
+            self._undo.Enable(False)
+           
         self.reset_page_helper(state)
         evt = ModelEventbox(model=self.model)
@@ -1108,5 +1123,5 @@
                 ##[cb state, name, value, "+/-", error of fit, min, max , units]
                 self.parameters.append([cb,item, ctl1,
-                                        text2,ctl2, ctl3, ctl4,None])
+                                        text2,ctl2, ctl3, ctl4,units])
               
         iy+=1
@@ -1206,7 +1221,7 @@
                 ##[cb state, name, value, "+/-", error of fit, min, max , units]
                 self.parameters.append([cb,item, ctl1,
-                                        text2,ctl2, ctl3, ctl4,None])
+                                        text2,ctl2, ctl3, ctl4,units])
                 self.orientation_params.append([cb,item, ctl1,
-                                        text2,ctl2, ctl3, ctl4,None])
+                                        text2,ctl2, ctl3, ctl4,units])
               
         iy+=1
@@ -1220,7 +1235,14 @@
             else:
                 self.text2_4.Hide()
-    
+                
+        self._copy_parameters_state(self.orientation_params,
+                                     self.state.orientation_params)
+        self._copy_parameters_state(self.orientation_params_disp,
+                                     self.state.orientation_params_disp)
+        self._copy_parameters_state(self.parameters, self.state.parameters)
+        self._copy_parameters_state(self.fittable_param, self.state.fittable_param)
+        self._copy_parameters_state(self.fixed_param, self.state.fixed_param)
+        
         boxsizer1.Add(sizer)
-        
         self.sizer3.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10)
         self.sizer3.Layout()
Index: sansview/perspectives/fitting/fitpanel.py
===================================================================
--- sansview/perspectives/fitting/fitpanel.py	(revision fe496eeb67fc41232a4f7c04808dbb1c5eae5b13)
+++ sansview/perspectives/fitting/fitpanel.py	(revision 240b99667ef276450071f502cdb1331ccb27714e)
@@ -311,4 +311,5 @@
             else:
                 self.fit_page_name[name]=ListOfState()
+                
                 #self.fit_page_name[name].appendItem(panel.createMemento())
             #GetPage(self, page_idx) 
@@ -355,5 +356,6 @@
             else:
                 self.model_page.select_model(model)
-                self.fit_page_name[page_title].insert(0,self.model_page.createMemento())
+                self.fit_page_name[name]=ListOfState()
+                #self.fit_page_name[page_title].insert(0,self.model_page.createMemento())
       
       
@@ -397,4 +399,6 @@
             self.fit_page_name[page.window_name].appendItem(page.createMemento()) 
             
+            print " current added state: ",len(self.fit_page_name[page.window_name])
+            
     def _onUndo(self, event ):
         """
@@ -456,5 +460,6 @@
                 panel.reset_page(memento)
         else:
-            self.fit_page_name[page_title]=[]
+            self.fit_page_name[page_title]=ListOfState()
+            #self.fit_page_name[page_title]=[]
             self.fit_page_name[page_title].insert(0,panel.createMemento())
        
Index: sansview/perspectives/fitting/pagestate.py
===================================================================
--- sansview/perspectives/fitting/pagestate.py	(revision 0aeabc66516f98ba46a16b35e8b2328b40a35433)
+++ sansview/perspectives/fitting/pagestate.py	(revision 240b99667ef276450071f502cdb1331ccb27714e)
@@ -64,7 +64,12 @@
         ## save the state of the context menu
         self.saved_states={}
-        ## save  current value of combobox
+        ## save selection of combobox
         self.formfactorcombobox = ""
         self.structurecombobox  = ""
+        ## radio box to select type of model
+        self.shape_rbutton = False
+        self.shape_indep_rbutton = False
+        self.struct_rbutton = False
+        self.plugin_rbutton = False
         ## the indice of the current selection
         self.disp_box = 0
@@ -74,4 +79,5 @@
         self.qmax= 0.1
         self.npts = None
+        self.name=""
         ## enable smearering state
         self.enable_smearer = False
@@ -86,13 +92,5 @@
         ## store value of chisqr
         self.tcChi= None
-       
-   
-    def save_data(self, data):
-        """
-            Save data
-        """
-        self.data = copy.deepcopy(data)
-
-        
+    
     def clone(self):
         model=None
@@ -103,5 +101,13 @@
         obj.data = copy.deepcopy(self.data)
         obj.model_list_box = copy.deepcopy(self.model_list_box)
-      
+        
+        obj.formfactorcombobox= self.formfactorcombobox
+        obj.structurecombobox  =self.structurecombobox  
+        
+        obj.shape_rbutton = self.shape_rbutton 
+        obj.shape_indep_rbutton = self.shape_indep_rbutton
+        obj.struct_rbutton = self.struct_rbutton
+        obj.plugin_rbutton = self.plugin_rbutton
+        
         obj.manager = self.manager
         obj.event_owner = self.event_owner
@@ -143,27 +149,54 @@
         return obj
 
-
-class PageMemento(object):
-    """
-        Store the state of a fitpage or model page of fitpanel
-    """
-    def __init__(self, state):
-        """ Initialization"""
-        self.state = state
-       
-    def setState(self,state):
-        """
-            set current state
-            @param state: new state
-        """
-        self.state = state
-        
-    def getState(self):
-        """
-            @return state
-        """
-        return self.state
+      
+    def old__repr__(self):
+        """ output string for printing"""
+        rep = "\n\nState name: %s\n"%self.name
+        rep +="data : %s\n"% str(self.data)
+        rep += "Plotting Range: min: %s, max: %s, steps: %s\n"%(str(self.qmin),
+                                                str(self.qmax),str(self.npts))
+        rep +="model  : %s\n\n"% str(self.model)
+        rep +="number parameters(self.parameters): %s\n"%len(self.parameters)
+        for item in self.parameters:
+            rep += "parameter name: %s \n"%str(item[1])
+            rep += "value: %s\n"%str(item[2])
+            rep += "selected: %s\n"%str(item[0])
+            rep += "error displayed : %s \n"%str(item[4][0])
+            rep += "error value:%s \n"%str(item[4][1])
+            rep += "minimum displayed : %s \n"%str(item[5][0])
+            rep += "minimum value : %s \n"%str(item[5][1])
+            rep += "maximum displayed : %s \n"%str(item[6][0])
+            rep += "maximum value : %s \n"%str(item[6][1])
+            rep += "parameter unit: %s\n\n"%str(item[7])
+        rep +="number orientation parameters"
+        rep +="(self.orientation_params): %s\n"%len(self.orientation_params)
+        for item in self.orientation_params:
+            rep += "parameter name: %s \n"%str(item[1])
+            rep += "value: %s\n"%str(item[2])
+            rep += "selected: %s\n"%str(item[0])
+            rep += "error displayed : %s \n"%str(item[4][0])
+            rep += "error value:%s \n"%str(item[4][1])
+            rep += "minimum displayed : %s \n"%str(item[5][0])
+            rep += "minimum value : %s \n"%str(item[5][1])
+            rep += "maximum displayed : %s \n"%str(item[6][0])
+            rep += "maximum value : %s \n"%str(item[6][1])
+            rep += "parameter unit: %s\n\n"%str(item[7])
+        rep +="number dispersity parameters"
+        rep +="(self.orientation_params_disp): %s\n"%len(self.orientation_params_disp)
+        for item in self.orientation_params_disp:
+            rep += "parameter name: %s \n"%str(item[1])
+            rep += "value: %s\n"%str(item[2])
+            rep += "selected: %s\n"%str(item[0])
+            rep += "error displayed : %s \n"%str(item[4][0])
+            rep += "error value:%s \n"%str(item[4][1])
+            rep += "minimum displayed : %s \n"%str(item[5][0])
+            rep += "minimum value : %s \n"%str(item[5][1])
+            rep += "maximum displayed : %s \n"%str(item[6][0])
+            rep += "maximum value : %s \n"%str(item[6][1])
+            rep += "parameter unit: %s\n\n"%str(item[7])
+        
+        return rep
+
+        
        
        
-       
-       
