Index: sansview/perspectives/fitting/basepage.py
===================================================================
--- sansview/perspectives/fitting/basepage.py	(revision 1b69256054476c92effbefde954de5e503d2b9b0)
+++ sansview/perspectives/fitting/basepage.py	(revision 330573d11b080c2302da8ab85d9ba8a153765f1f)
@@ -10,4 +10,6 @@
 from pagestate import PageState
 (PageInfoEvent, EVT_PAGE_INFO)   = wx.lib.newevent.NewEvent()
+(PreviousStateEvent, EVT_PREVIOUS_STATE)   = wx.lib.newevent.NewEvent()
+(NextStateEvent, EVT_NEXT_STATE)   = wx.lib.newevent.NewEvent()
 _BOX_WIDTH = 80
 
@@ -46,4 +48,5 @@
         ## smearer object
         self.smearer = None
+        
         ##list of model parameters. each item must have same length
         ## each item related to a given parameters
@@ -81,5 +84,5 @@
         self.number_saved_state= 0
         ## dictionary of saved state
-        self.saved_states={}
+        self.saved_states={} 
         
         ## Create context menu for page
@@ -125,5 +128,4 @@
       
         
-        
     def onUndo(self, event):
         """
@@ -131,4 +133,7 @@
         """
         print "enable undo"
+        event = PreviousStateEvent(page = self)
+        wx.PostEvent(self.parent, event)
+        
         
     def onRedo(self, event):
@@ -137,4 +142,7 @@
         """
         print "enable redo"
+        event = NextStateEvent(page= sent)
+        wx.PostEvent(self.parent, event)
+        
         
     def define_page_structure(self):
@@ -361,6 +369,6 @@
                 
                 self.state.disp_cb_dict[p]=  self.disp_cb_dict[p].GetValue()
-                event = PageInfoEvent(page = self)
-                wx.PostEvent(self.parent, event)
+                #event = PageInfoEvent(page = self)
+                #wx.PostEvent(self.parent, event)
         return
     
@@ -564,6 +572,6 @@
         
         ## post state to fit panel
-        event = PageInfoEvent(page = self)
-        wx.PostEvent(self.parent, event)
+        #event = PageInfoEvent(page = self)
+        #wx.PostEvent(self.parent, event)
     
     
@@ -575,4 +583,7 @@
             state of the graphic interface
         """
+        if state ==None:
+            self._undo.Enable(False)
+            return 
         self.model= state.model
         self.data = state.data
@@ -592,4 +603,5 @@
         if hasattr(self, "cb1"):   
             self.cb1.SetValue(state.cb1)
+      
         ## reset state of checkbox,textcrtl  and  regular parameters value
         self._reset_parameters_state(self.orientation_params_disp,
@@ -674,6 +686,6 @@
         self.state = state.clone() 
         ## post state to fit panel
-        event = PageInfoEvent(page = self)
-        wx.PostEvent(self.parent, event)
+        #event = PageInfoEvent(page = self)
+        #wx.PostEvent(self.parent, event)
         
     def _selectDlg(self):
@@ -732,7 +744,5 @@
         if self.model !=None:
             
-            ## save current state
-            self.save_current_state()
-            
+           
             # Flag to register when a parameter has changed.
             is_modified = False
@@ -1183,8 +1193,4 @@
         self.state.disp_list = self.disp_list
         
-        ## post state to fit panel
-        event = PageInfoEvent(page = self)
-        wx.PostEvent(self.parent, event)
-        
         self.sizer4_4.Layout()
         self.sizer4.Layout()
@@ -1200,6 +1206,12 @@
         """
         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()
         else:
@@ -1396,6 +1408,6 @@
         self.state.disp_box= n
         ## post state to fit panel
-        event = PageInfoEvent(page = self)
-        wx.PostEvent(self.parent, event)
+        #event = PageInfoEvent(page = self)
+        #wx.PostEvent(self.parent, event)
         
         self.sizer4_4.Layout()
Index: sansview/perspectives/fitting/fitpage.py
===================================================================
--- sansview/perspectives/fitting/fitpage.py	(revision 7437880dff0233ffbc079256a9247d1ec30991eb)
+++ sansview/perspectives/fitting/fitpage.py	(revision 330573d11b080c2302da8ab85d9ba8a153765f1f)
@@ -169,6 +169,5 @@
                
         #Set sizer for Fitting section
-        self._set_range_sizer( title="Fitting",
-                               object1=sizer_smearer, object= sizer_fit)
+        self._set_range_sizer( title="Fitting",object1=sizer_smearer, object= sizer_fit)
   
        
@@ -543,4 +542,8 @@
             wx.PostEvent(self.event_owner, evt)   
         self.btFit.SetFocus() 
+        ## post state to fit panel
+        event = PageInfoEvent(page = self)
+        wx.PostEvent(self.parent, event) 
+     
    
     def _onparamRangeEnter(self, event):
@@ -577,4 +580,10 @@
         """
         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()
@@ -751,5 +760,7 @@
         self.compute_chisqr(smearer= temp_smearer)  
         ## save the state enable smearing
-        self.save_current_state() 
+        self.state.smearer= temp_smearer
+        #self.save_current_state() 
+   
    
     def complete_chisqr(self, output, elapsed=None):  
@@ -765,6 +776,6 @@
             ## post state to fit panel
             self.state.tcChi =output
-            event = PageInfoEvent(page = self)
-            wx.PostEvent(self.parent, event)
+            #event = PageInfoEvent(page = self)
+            #wx.PostEvent(self.parent, event)
         except:
             pass
@@ -901,6 +912,13 @@
                     item[0].SetValue(False)
                 self.param_toFit=[]
-                
-        self.save_current_state()  
+        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)
+           
+        #self.save_current_state()  
         
                 
@@ -936,5 +954,13 @@
             self.cb1.SetValue(False)
         ## save current state of the page
-        self.save_current_state()
+        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)
+        
+        #self.save_current_state()
         
     
@@ -1011,4 +1037,5 @@
         for item in keys:
             if not item in self.disp_list and not item in self.model.orientation_params:
+               
                 iy += 1
                 ix = 0
@@ -1198,7 +1225,8 @@
         self.sizer3.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10)
         self.sizer3.Layout()
+        self.Layout()
+        self.Refresh()
         self.SetScrollbars(20,20,200,100)
-        
-    
+       
             
         
Index: sansview/perspectives/fitting/fitpanel.py
===================================================================
--- sansview/perspectives/fitting/fitpanel.py	(revision 1b69256054476c92effbefde954de5e503d2b9b0)
+++ sansview/perspectives/fitting/fitpanel.py	(revision 330573d11b080c2302da8ab85d9ba8a153765f1f)
@@ -3,24 +3,90 @@
 import wx.lib
 import numpy
-import string ,re
-#import models
+import string 
+
+
+import basepage
+
 _BOX_WIDTH = 80
-import basepage
-
-class StateContainer(object):
+
+
+class StateIterator(object):
     """
         Contains all saved state of a given page.
         Provide position of the current state of a page, the first save state
         and the last state for a given page. 
-        Allow easy unoding or redo for a given page  
-    """
-    def __init__(self, page=None):
-        """
-            Initialize variable
-        """
-        self.page = page
-        self.begin =0
-        self.current=0
-        self.end=0
+        Allow easy undo or redo for a given page  
+    """
+    def __init__(self):
+        self._current=0
+       
+    
+    def __iter__(self):
+        return self
+    
+    
+    def first(self):
+        self._current =0
+        return self._current
+    
+    def next(self, max ):
+        if self._current < max:
+            self._current += 1
+        return self._current
+    
+    def previous(self):
+        if self._current > 0:
+            self._current = self._current -1
+        return self._current
+    
+    def currentPosition(self):
+        return self._current
+    
+    def setPosition(self, value):
+        if value >=0:
+            self._current = int(value)
+        
+        
+    
+  
+class ListOfState(list):     
+    def __init__(self, *args, **kw):
+        list.__init__(self, *args, **kw)
+        self.iterator = StateIterator()
+        
+    def appendItem(self, x):
+        self.append(x)
+        self.iterator.setPosition(value= len(self)-1)
+        
+    def removeItem(self, x):
+        self.iterator.previous()
+        self.remove(x)
+        
+    def getPreviousItem(self):
+        position = self.iterator.previous()
+        
+        if position < 0:
+            return None
+        else:
+            return self[position]
+        
+    def getNextItem(self):
+        position = self.iterator.next()
+        if position >= len(self):
+            return None
+        else:
+            return self[position]
+        
+    def getCurrentItem(self):
+        postion = self.iterator.currentPosition()
+        if postion >= 0 and position < len(self):
+            return self[postion]
+        else:
+            return None
+        
+    def getCurrentPosition(self):
+        return self.iterator.currentPosition()
+        
+
         
         
@@ -37,5 +103,5 @@
     model_list_box = None
     name=None
-     ## Internal name for the AUI manager
+    ## Internal name for the AUI manager
     window_name = "Page"
     ## Title to appear on top of the window
@@ -105,4 +171,6 @@
         ## get the state of a page
         self.Bind(basepage.EVT_PAGE_INFO, self._onGetstate)
+        self.Bind(basepage.EVT_PREVIOUS_STATE, self._onUndo)
+        #(NextStateEvent, EVT_NEXT_STATE)   = wx.lib.neweve
         # increment number for model name
         self.count=0
@@ -241,6 +309,6 @@
                     panel.reset_page(memento)
             else:
-                self.fit_page_name[name]=[]
-                self.fit_page_name[name].insert(0,panel.createMemento())
+                self.fit_page_name[name]=ListOfState()
+                #self.fit_page_name[name].appendItem(panel.createMemento())
             #GetPage(self, page_idx) 
             return panel 
@@ -248,6 +316,8 @@
             if self.fit_page1D_number!=None:
                 panel =self.GetPage(self.fit_page1D_number) 
-                self.fit_page_name[name]=[]
-                self.fit_page_name[name].insert(0,panel.createMemento())
+                #self.fit_page_name[name]=[]
+                self.fit_page_name[name]= ListOfState()
+                #self.fit_page_name[name].insert(0,panel.createMemento())
+                #self.fit_page_name[name].append(panel.createMemento())
                 return panel
             return None
@@ -255,6 +325,6 @@
             if self.fit_page2D_number!=None:
                 panel =self.GetPage(self.fit_page2D_number) 
-                self.fit_page_name[name]=[]
-                self.fit_page_name[name].insert(0,panel.createMemento())
+                self.fit_page_name[name]=ListOfState()
+                #self.fit_page_name[name].append(panel.createMemento())
                 return panel
             return None
@@ -324,6 +394,19 @@
         page= event.page
         if page.window_name in self.fit_page_name:
-            self.fit_page_name[page.window_name].insert(0,page.createMemento()) 
+            self.fit_page_name[page.window_name].appendItem(page.createMemento()) 
             
+    def _onUndo(self, event ):
+        """
+            return the previous state of a given page is available
+        """
+        page = event.page 
+        if page.window_name in self.fit_page_name:
+            if self.fit_page_name[page.window_name].getCurrentPosition()==0:
+                state = None
+            else:
+                state = self.fit_page_name[page.window_name].getPreviousItem()
+            page.reset_page(state)
+                
+          
                 
     def _help_add_model_page(self,model,page_title="Model", qmin=0.0001, 
Index: sansview/perspectives/fitting/modelpage.py
===================================================================
--- sansview/perspectives/fitting/modelpage.py	(revision 71f03737f44ec12a86e74f08ab8a1dc96640bc08)
+++ sansview/perspectives/fitting/modelpage.py	(revision 330573d11b080c2302da8ab85d9ba8a153765f1f)
@@ -347,5 +347,8 @@
         if self.model !=None:
             self._draw_model()
-                         
+        ## post state to fit panel
+        event = PageInfoEvent(page = self)
+        wx.PostEvent(self.parent, event)               
+    
     
     def set_model_description(self,description,sizer):
