Index: sansview/perspectives/fitting/fitpage1D.py
===================================================================
--- sansview/perspectives/fitting/fitpage1D.py	(revision 6e659ae81af46547dea900c85dc6596a8f0565ab)
+++ sansview/perspectives/fitting/fitpage1D.py	(revision 51d47b5b86b892ab660da7cca3522ab438d9158d)
@@ -41,5 +41,5 @@
         #panel interface
         self.vbox  = wx.BoxSizer(wx.VERTICAL)
-        self.sizer10 = wx.GridBagSizer(5,5)
+        #self.sizer10 = wx.GridBagSizer(5,5)
         self.sizer9 = wx.GridBagSizer(5,5)
         self.sizer8 = wx.GridBagSizer(5,5)
@@ -73,7 +73,5 @@
         self.vbox.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
         self.vbox.Add(self.sizer9)
-        #close layer
-        self.vbox.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
-        self.vbox.Add(self.sizer10)
+       
         
         #---------sizer 1 draw--------------------------------
@@ -243,8 +241,18 @@
         ix += 1
         self.sizer9.Add(self.btFit,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        
+        id = wx.NewId()
+        self.btStopFit =wx.Button(self,id,'Stop')
+        self.btStopFit.Bind(wx.EVT_BUTTON, self.onStopFit,id=id)
+        self.btStopFit.SetToolTipString("Stop the current fitting job.")
+        self.btStopFit.Hide()
+        ix += 1
+        self.sizer9.Add(self.btStopFit,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        
         ix =0
         iy+=1 
         self.sizer9.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
         #----------sizer 10 draw------------------------------------------------------
+        """
         id = wx.NewId()
         self.btClose =wx.Button(self,id,'Close')
@@ -260,5 +268,5 @@
         iy+=1
         self.sizer10.Add((20,20),(iy,ix),(1,1),wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-       
+       """
         # contains link between  model ,all its parameters, and panel organization
         self.parameters=[]
@@ -325,5 +333,12 @@
                             "Chisqr cannot be compute: %s"% sys.exc_value))
         
- 
+    def onStopFit(self, event):
+        
+        self.manager.stop_fit()
+        self.btStopFit.Hide()
+        self.vbox.Layout()
+        self.SetScrollbars(20,20,55,40)
+        self.Layout()
+        self.parent.GetSizer().Layout()
     def compute_chisqr(self):
         """ @param fn: function that return model value
@@ -419,8 +434,12 @@
                                             ymin=self.data.ymin, ymax=self.data.ymax,
                                             xmin=self.data.xmin,xmax=self.data.xmax)
-                #self.manager._on_single_fit(qmin=self.qmin_x,qmax=self.qmax_x,
-                                            #ymin=self.data.ymin, ymax=self.data.ymax)
+                self.btStopFit.Show()
             else:
                  self.manager._on_single_fit(qmin=self.qmin_x,qmax=self.qmax_x)
+                 self.btStopFit.Show()
+            self.vbox.Layout()
+            self.SetScrollbars(20,20,55,40)
+            self.Layout()
+            self.parent.GetSizer().Layout()
         else:
               wx.PostEvent(self.parent.parent, StatusEvent(status=\
Index: sansview/perspectives/fitting/fitpanel.py
===================================================================
--- sansview/perspectives/fitting/fitpanel.py	(revision 6e659ae81af46547dea900c85dc6596a8f0565ab)
+++ sansview/perspectives/fitting/fitpanel.py	(revision 51d47b5b86b892ab660da7cca3522ab438d9158d)
@@ -23,6 +23,6 @@
     def __init__(self, parent, *args, **kwargs):
         
-        wx.aui.AuiNotebook.__init__(self,parent,-1, style=wx.aui.AUI_NB_SCROLL_BUTTONS )
-        #wx.aui.AuiNotebook.__init__(self,parent,-1, style=wx.aui.AUI_NB_DEFAULT_STYLE  )
+        #wx.aui.AuiNotebook.__init__(self,parent,-1, style=wx.aui.AUI_NB_SCROLL_BUTTONS )
+        wx.aui.AuiNotebook.__init__(self,parent,-1, style=wx.aui.AUI_NB_DEFAULT_STYLE  )
         
         
@@ -34,4 +34,5 @@
         self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.onClosePage)
         #Creating the default page --welcomed page
+        self.about_page=None
         from sans.guiframe.welcome_panel import PanelAbout
         self.about_page = PanelAbout(self, -1)
@@ -39,7 +40,5 @@
         #self.about_page.Disable()
         #Creating a page for simultaneous fitting
-        from simfitpage import SimultaneousFitPage
-        self.sim_page = SimultaneousFitPage(self, id=-1)
-        self.AddPage(self.sim_page,"Simultaneous Fit")
+       
         
         self._mgr = self.GetAuiManager()
@@ -55,4 +54,5 @@
        
         self.model_page=None
+        self.sim_page=None
         # increment number for model name
         self.count=0
@@ -63,4 +63,5 @@
         
     def onClosePage(self, event):
+        """
         self.ToggleWindowStyle(wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB)
         #print "went here",self.get_current_page(), self.GetPage(0)
@@ -71,6 +72,42 @@
             # Prevent last tab from being closed
             self.ToggleWindowStyle(~wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB)
-            
-
+        """
+        selected_page = self.GetPage(self.GetSelection())
+        page_number = self.GetSelection()
+        if self.sim_page != selected_page and selected_page!=self.about_page:
+            print "sim_page ",sim_page ,selected_page
+            # remove the check box link to the model name of this page (selected_page)
+            self.sim_page.remove_model(selected_page)
+            #remove that page from page_finder of fitting module
+            page_finder=self.manager.get_page_finder() 
+            for page, value in page_finder.iteritems():
+                if page==selected_page:
+                    del page_finder[page]
+                    break
+            #Delete the page from notebook
+           
+            #print "on close",selected_page.name,self.GetPageText(page_number),self.draw_model_name
+            
+            if selected_page.name in self.fit_page_name:
+                self.fit_page_name.remove(selected_page.name)
+                
+            if selected_page.name== self.draw_model_name:
+                print "went here"
+                self.draw_model_name=None
+                self.model_page=None
+            if  page_number == 1:
+                self.model_page=None
+                self.draw_model_name=None
+            #selected_page.Destroy()
+            #self.RemovePage(page_number)
+            #i=self.DeletePage(page_number)
+        elif selected_page==self.about_page:
+            #selected_page.Destroy()
+            #self.DeletePage(page_number)
+            self.about_page=None
+        else:
+            
+            self.manager.sim_page=None  
+            #self.DeletePage(page_number)
    
 
@@ -83,5 +120,5 @@
         """
         self.manager = manager
-        self.sim_page.set_manager(manager)
+        #self.sim_page.set_manager(manager)
         
     def set_owner(self,owner):
@@ -91,5 +128,11 @@
         """
         self.event_owner=owner
-      
+        
+    def add_sim_page(self):
+        from simfitpage import SimultaneousFitPage
+        self.sim_page = SimultaneousFitPage(self, id=-1)
+        self.AddPage(self.sim_page,caption="Simultaneous Fit",select=True)
+        self.sim_page.set_manager(self.manager)
+        return self.sim_page
         
     def add_fit_page( self,data ):
Index: sansview/perspectives/fitting/fitting.py
===================================================================
--- sansview/perspectives/fitting/fitting.py	(revision 6e659ae81af46547dea900c85dc6596a8f0565ab)
+++ sansview/perspectives/fitting/fitting.py	(revision 51d47b5b86b892ab660da7cca3522ab438d9158d)
@@ -55,4 +55,5 @@
         # model 2D view
         self.model2D_id=None
+        self.sim_page=None
         self.err_dy={}
         
@@ -70,7 +71,7 @@
         #Menu for fitting
         self.menu1 = wx.Menu()
-        #id1 = wx.NewId()
-        #self.menu1.Append(id1, '&fit panel')
-        #wx.EVT_MENU(owner, id1, self.on_perspective)
+        id1 = wx.NewId()
+        self.menu1.Append(id1, '&Simultaneous')
+        wx.EVT_MENU(owner, id1, self.on_add_sim_page)
         #Set park engine
         id3 = wx.NewId()
@@ -84,13 +85,17 @@
         id2 = wx.NewId()
         owner.Bind(models.EVT_MODEL,self._on_model_menu)
-        #owner.Bind(modelpage.EVT_MODEL,self._on_model_menu)
+      
         self.fit_panel.set_owner(owner)
         self.fit_panel.set_model_list(self.menu_mng.get_model_list())
         owner.Bind(fitpage1D.EVT_MODEL_BOX,self._on_model_panel)
-        #owner.Bind(fitpage2D.EVT_MODEL_BOX,self._on_model_panel)
+        
         #create  menubar items
         return [(id, self.menu1, "Fitting"),(id2, menu2, "Model")]
     
-    
+    def on_add_sim_page(self, event):
+        self.sim_page= self.fit_panel.add_sim_page()
+        self.sim_page.add_model(self.page_finder)
+        
+        
     def help(self, evt):
         """
@@ -300,5 +305,6 @@
              @note: expecting park used for fit.
         """  
-        sim_page=self.fit_panel.GetPage(1) 
+        #sim_page=self.fit_panel.GetPage(1) 
+        sim_page= self.sim_page
         for page, value in self.page_finder.iteritems():
             if page != sim_page:
@@ -419,5 +425,11 @@
                 wx.PostEvent(self.parent, StatusEvent(status="Simultaneous Fitting error: %s" % sys.exc_value))
                 return
-  
+    def stop_fit(self):
+        if self.calc_thread != None and self.calc_thread.isrunning():
+                    
+                    self.calc_thread.interrupt()
+                    self.calc_thread.stop()
+                    wx.PostEvent(self.parent, StatusEvent(status="Fitting  \
+        is cancelled" , type="stop"))
     def _on_single_fit(self,id=None,qmin=None, qmax=None,ymin=None, ymax=None,xmin=None,xmax=None):
         """ 
@@ -442,5 +454,6 @@
         #with the fit will be perform
         current_pg=self.fit_panel.get_current_page() 
-        simul_pg=self.fit_panel.GetPage(1 )
+        #simul_pg=self.fit_panel.GetPage(1 )
+        simul_pg=self.sim_page
         pars=[]   
         #for page, value in self.page_finder.iteritems():
@@ -465,4 +478,7 @@
                 #Do the single fit
                 self.fitter.set_model(Model(model), self.fit_id, pars) 
+                if self._fit_engine=="scipy":
+                    wx.PostEvent(self.parent, StatusEvent(status="Parameters range will\
+                     be ignored for %s fitting engine"%str(self._fit_engine)))
                 #print "args...:",metadata,self.fit_id,smearer,qmin,qmax,ymin,ymax
                 dy=[]
@@ -565,9 +581,5 @@
                             param_value = item[1]
                             param_name = item[0]
-                            #print "fitting ", param,param_name, param_value
-                           
-                            #new_model.set( model.getParam(param_name[0])= param_value)
-                            #new_model.set( exec"%s=%s"%(param_name[0], param_value))
-                            #new_model.set( exec "%s"%(param_nam) = param_value)
+    
                             new_model.parameterset[ param_name].set( param_value )
                         
@@ -659,5 +671,6 @@
         
         print "name fitting", name
-        sim_page=self.fit_panel.GetPage(1)
+        #sim_page=self.fit_panel.GetPage(1)
+        sim_page=self.sim_page
         current_pg = self.fit_panel.get_current_page() 
         if current_pg != sim_page:
@@ -679,5 +692,6 @@
             self.page_finder[current_pg].set_model(model,M_name)
             self.plot_helper(currpage= current_pg,qmin= None,qmax= None)
-            sim_page.add_model(self.page_finder)
+            if self.sim_page!=None:
+                self.sim_page.add_model(self.page_finder)
         
     def  set_smearer(self,smearer):     
Index: sansview/perspectives/fitting/modelpage.py
===================================================================
--- sansview/perspectives/fitting/modelpage.py	(revision 50c769e196ac2dc7a25d505d6413eb2e95426bd1)
+++ sansview/perspectives/fitting/modelpage.py	(revision 51d47b5b86b892ab660da7cca3522ab438d9158d)
@@ -34,4 +34,5 @@
         # model on which the fit would be performed
         self.model=model
+        self.back_up_model= model.clone()
         #list of dispersion paramaters
         self.disp_list=[]
@@ -49,5 +50,5 @@
         self.vbox  = wx.BoxSizer(wx.VERTICAL)
         self.sizer11 = wx.BoxSizer(wx.HORIZONTAL)
-        self.sizer10 = wx.GridBagSizer(5,5)
+        #self.sizer10 = wx.GridBagSizer(5,5)
         self.sizer9 = wx.GridBagSizer(5,5)
         self.sizer8 = wx.GridBagSizer(5,5)
@@ -74,7 +75,6 @@
         self.vbox.Add(self.sizer9)
         #close layer
-        self.vbox.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
-        self.vbox.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
-        self.vbox.Add(self.sizer10)
+        #self.vbox.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
+        #self.vbox.Add(self.sizer10)
         
       
@@ -186,4 +186,5 @@
         self.sizer9.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
         #----------sizer 10 draw------------------------------------------------------
+        """
         id = wx.NewId()
         self.btClose =wx.Button(self,id,'Close')
@@ -199,5 +200,5 @@
         iy+=1
         self.sizer10.Add((20,20),(iy,ix),(1,1),wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-       
+        """
         # contains link between  model ,all its parameters, and panel organization
         self.parameters=[]
@@ -214,5 +215,5 @@
         if self.model!=None:
             self.set_panel(self.model)
-        
+        self.theta_cb=None
        
        
@@ -291,5 +292,6 @@
             else:
                 if self.data !=None and self.model !=None: # allow to recognize data panel from model panel
-                #if self.data !=None and self.model !=None:
+                    
+                
                     self.cb1.SetValue(False)
                     self.select_all_param_helper()
@@ -302,4 +304,15 @@
                 if self.cb1.GetValue():
                     self.select_all_param_helper()
+            
+            if self.back_up_model!=None:
+                keys = self.back_up_model.getDispParamList()
+                keys.sort()
+                #disperse param into the initial state
+                for item in keys:
+                    value= self.back_up_model.getParam(item)
+                    self.model.setParam(item, value)
+                self._draw_model() 
+            
+                
             self.fittable_param=[]        
             self.fixed_param=[]
@@ -326,5 +339,13 @@
             self.disp_box.SetValue("GaussianModel")
             for k,v in self.polydisp.iteritems():
-                self.disp_box.Insert(str(v),id)  
+                """
+                if str(v)=="MyModel":
+                    self.disp_box.Insert("Select customized Model",id)  
+                else:
+                    self.disp_box.Insert(str(v),id)
+                """
+                if str(v)!="MyModel":
+                    self.disp_box.Insert(str(v),id)  
+                    
                 id+=1
             wx.EVT_COMBOBOX(self.disp_box,-1, self._on_select_Disp) 
@@ -409,7 +430,5 @@
         self.parent.model_page.name = name
         self.parent.draw_model_name = name
-        self.model_view.Enable()
-        self.enable2D=False
-        print "select_model", self.name,model.__class__
+        
         self.set_panel(model)
         self._draw_model(name)
@@ -418,8 +437,7 @@
         items = self.modelbox.GetItems()
         for i in range(len(items)):
-            print "model name",items[i],model.name, model.__class__.__name__
             if items[i]==name:
                 self.modelbox.SetSelection(i)
-                
+                self.model_view.SetFocus()
                 
     def _on_select_Disp(self,event):
@@ -452,10 +470,8 @@
                 self.set_panel(model)
                 self.name= name
-                
+                self.model_view.SetFocus()
                 self.parent.model_page.name=name
                 self.parent.draw_model_name=name
-                #self.manager.draw_model(model, name)
-                #self.enable2D=False
-                #self.model_view.Enable()
+               
                 self._draw_model(name)
             
@@ -523,4 +539,12 @@
                             wx.EXPAND|wx.ADJUST_MINSIZE, 0)
         self.text2_3.Hide() 
+        ix +=1
+        self.text2_5 = wx.StaticText(self, -1, 'Min')
+        self.sizer5.Add(self.text2_5,(iy, ix),(1,1),\
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+        ix +=1
+        self.text2_6 = wx.StaticText(self, -1, 'Max')
+        self.sizer5.Add(self.text2_6,(iy, ix),(1,1),\
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
         ix +=1
         self.text2_4 = wx.StaticText(self, -1, 'Units')
@@ -559,4 +583,26 @@
                 self.sizer5.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
                 ctl2.Hide()
+                ix += 1
+                param_min= format_number(self.model.details[item][1])
+                ctl3 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER)
+                if float(param_min) ==0:
+                    ctl3.SetValue("-inf")
+                else:
+                    ctl3.SetValue(str (format_number(param_min)))
+                ctl3.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)
+                ctl3.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)
+                
+                self.sizer5.Add(ctl3, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+                ix += 1
+                param_max= format_number(self.model.details[item][2])
+                ctl4 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER)
+                if float(param_max)==0:
+                    ctl4.SetValue("+inf")
+                else:
+                    ctl4.SetValue(str (format_number(param_max)))
+                ctl4.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)
+                ctl4.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)
+                self.sizer5.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+                
                 ix +=1
                 # Units
@@ -567,5 +613,5 @@
                 self.sizer5.Add(units, (iy,ix),(1,1),  wx.EXPAND|wx.ADJUST_MINSIZE, 0)
            
-            self.parameters.append([cb,ctl1,text2,ctl2])
+            self.parameters.append([cb,ctl1,text2,ctl2, ctl3, ctl4])
                 
         iy+=1
@@ -579,17 +625,12 @@
             else:
                 self.text2_4.Hide()
-        #Disable or enable fit button
-        """
-        if not (len(self.param_toFit ) >0):
-            self.qmin.Disable()
-            self.qmax.Disable()
-        else:
-            self.qmin.Enable()
-            self.qmax.Enable()
-        """  
+        
         self.vbox.Layout()
         self.SetScrollbars(20,20,55,40)
         self.Layout()
         self.parent.GetSizer().Layout()
+        
+        
+        
     def _selectDlg(self):
         import os
@@ -602,4 +643,8 @@
     def read_file(self, path):
         try:
+            if path==None:
+                wx.PostEvent(self.parent.parent, StatusEvent(status=\
+                            " Selected Distribution was not loaded: %s"%path))
+                return None, None
             input_f = open(path, 'r')
             buff = input_f.read()
@@ -621,36 +666,182 @@
             return numpy.array(angles), numpy.array(weights)
         except:
+            raise 
+        
+    def _draw_disp_theta(self): 
+        path = self._selectDlg()
+        dispersion=None
+       
+        for key, value in self.polydisp.iteritems():
+            if value =="MyModel":
+                disp_ph = key()
+                disp_th = key()
+                break
+        values,weights = self.read_file(path)
+        if values ==None and weights==None:
+            return 
+        import math
+        disp_ph.set_weights( values, weights)
+        disp_th.set_weights( values, weights)
+        
+        if self.theta_cb !=None:
+            angle= self.theta_cb.GetLabelText()
+        n=0
+        self.disp_list=self.model.getDispParamList()
+        if angle.lower().count("theta")>0:   
+            for param in self.model.getParamList():
+                if  not param in self.disp_list and  param.lower().count("theta")>0: 
+                    self.model.set_dispersion(param, disp_th)
+                    self.model.dispersion[param]['npts'] = len(values)
+                    n+=1
+           
+            if n ==0:
+              wx.PostEvent(self.parent.parent, StatusEvent(status=\
+                            " Model contains no theta distribution"))  
+            else:
+                self._draw_model() 
+    def _draw_disp_Phi(self): 
+        path = self._selectDlg()
+        dispersion=None
+       
+        for key, value in self.polydisp.iteritems():
+            if value =="MyModel":
+                disp_ph = key()
+                disp_th = key()
+                break
+        values,weights = self.read_file(path)
+        if values ==None and weights==None:
+            return 
+        import math
+        disp_ph.set_weights( values, weights)
+        disp_th.set_weights( values, weights)
+        
+        if self.theta_cb !=None:
+            angle= self.theta_cb.GetLabelText()
+        n=0
+        self.disp_list=self.model.getDispParamList()
+        if angle.lower().count("theta")>0:   
+            for param in self.model.getParamList():
+                if  not param in self.disp_list and  param.lower().count("theta")>0: 
+                    self.model.set_dispersion(param, disp_th)
+                    self.model.dispersion[param]['npts'] = len(values)
+                    n+=1
+           
+            if n ==0:
+              wx.PostEvent(self.parent.parent, StatusEvent(status=\
+                            " Model contains no theta distribution"))  
+            else:
+                self._draw_model() 
+          
+          
+    def select_disp_angle(self, event): 
+        if not self.phi_cb.GetValue():
+            return
+        path = self._selectDlg()
+        dispersion=None
+       
+        for key, value in self.polydisp.iteritems():
+            if value =="MyModel":
+                disp_ph = key()
+                disp_th = key()
+               
+                break
+        try:
+            values,weights = self.read_file(path)
+        except:
             raise
-                   
-    def  set_panel_dispers(self, disp_list, type="GaussianModel" ):
+        
+        if values ==None and weights==None:
+            return 
+        import math
+        wx.PostEvent(self.parent.parent, StatusEvent(status=\
+                            " Costumized Distribution: %s"% path))
+       
+        disp_ph.set_weights( values, weights)
+        disp_th.set_weights( values, weights)
+        
+       
+        
+        if self.theta_cb !=None:
+            angle= self.phi_cb.GetLabelText()
+        n=0
+        print "hello1",self.model.runXY([0.01,0.01]) 
+        self.disp_list=self.model.getDispParamList()
+        name= "phi"
+        if angle.lower().count(name)>0:   
+            for param in self.model.getParamList():
+                if  not param in self.disp_list and  param.lower().count(name)>0: 
+                    self.model.set_dispersion(param, disp_th)
+                    print "para, th",param, disp_th
+                    #self.model.dispersion[param]['npts'] = len(values)
+                    n+=1
+            print "model dispers list",self.model.getDispParamList()
+            if n ==0:
+              wx.PostEvent(self.parent.parent, StatusEvent(status=\
+                            " Model contains no %s distribution"%name))  
+            else:
+                print "hello2",self.model.runXY([0.01,0.01]) 
+                #self._draw_model()
+                qmin=self.qmin_x
+                qmax=self.qmax_x
+                qstep= self.num_points
+                x=  numpy.linspace(start= -1*qmax,
+                               stop= qmax,
+                               num= qstep,
+                               endpoint=True )  
+                y = numpy.linspace(start= -1*qmax,
+                               stop= qmax,
+                               num= qstep,
+                               endpoint=True )
+                output= numpy.zeros([len(x),len(y)])
+                for i_x in range(int(len(x))):
+                    for i_y in range(int(len(y))):
+                        if (x[i_x]*x[i_x]+y[i_y]*y[i_y]) \
+                        < qmin * qmin:
+                            output[i_x] [i_y]=0   
+                        else:
+                            value = self.model.runXY([x[i_x], y[i_y]])
+                            output[i_x] [i_y]=value 
+                print"modelpage", output
+                self.manager.complete( output=output, elapsed=None, model=self.model, qmin=qmin, qmax=qmax,qstep=qstep)
+                #self._draw_model()
+                      
+                      
+                      
+    def set_panel_dispers(self, disp_list, type="GaussianModel" ):
         
         self.fittable_param=[]
         self.fixed_param=[]
-                
+        
         ix=0
         iy=1
                 ### this will become a separate method
-        if type== "MyModel":
-            
-            self.sizer8.Clear(True)
-            path = self._selectDlg()
-            dispersion=None
-            for key, value in self.polydisp.iteritems():
-                if value =="MyModel":
-                    dispersion= key()
-                    break
-            values,weights = self.read_file(path)
-            dispersion.set_weights( values, weights)
-            print "sipersion model", dispersion.value
-            for param in self.model.dispersion.keys():
-                print 
-                print "on MyModel disp",dispersion,param, self.model.set_dispersion(param, dispersion)
-
-            wx.PostEvent(self.parent.parent, StatusEvent(status=\
-                            " Selected Distribution: %s"%path))
-                
+        if type== "Select customized Model":
+            ix=0
+            iy=1
+            self.sizer8.Clear(True)        
+            disp1 = wx.StaticText(self, -1, 'Array Dispersion')
+            self.sizer8.Add(disp1,( iy, ix),(1,1),  wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+            
+            ix+=1 
+            self.theta_cb = wx.CheckBox(self, -1,"Theta ", (10, 10))
+            wx.EVT_CHECKBOX(self, self.theta_cb.GetId(), self.select_disp_angle)
+            self.sizer8.Add(self.theta_cb,(iy, ix),(1,1),\
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+            ix+=1
+            self.phi_cb = wx.CheckBox(self, -1,"Phi", (10, 10))
+            wx.EVT_CHECKBOX(self, self.phi_cb.GetId(), self.select_disp_angle)
+            self.sizer8.Add(self.phi_cb,(iy, ix),(1,1),\
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+            
+            ix =0
+            iy +=1 
+            self.sizer8.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)        
+            self.vbox.Layout()
+            self.SetScrollbars(20,20,55,40)
+            self.Layout()
+            self.parent.GetSizer().Layout()  
+           
         if type== "GaussianModel" :
-            print "went here"
-           
+
             self.sizer8.Clear(True)
             disp = wx.StaticText(self, -1, 'Dispersion')
@@ -738,5 +929,51 @@
             self.parent.GetSizer().Layout()  
           
-         
+    def checkFitValues(self,val_min, val_max):
+        """
+            Check the validity of input values
+        """
+        flag = True
+        min_value = val_min.GetValue()
+        max_value = val_max.GetValue()
+        # Check for possible values entered
+        if min_value.lstrip().rstrip() =="-inf":
+            min_value= -numpy.inf
+        if max_value.lstrip().rstrip() =="+inf":
+            max_value= numpy.inf
+        if  min_value==-numpy.inf and max_value== numpy.inf:
+            val_min.SetBackgroundColour(wx.WHITE)
+            val_min.Refresh()
+            val_max.SetBackgroundColour(wx.WHITE)
+            val_max.Refresh()
+            return flag
+        elif max_value== numpy.inf:
+            try:
+                float(min_value)
+                val_min.SetBackgroundColour(wx.WHITE)
+                val_min.Refresh()
+            except:
+                flag = False
+                val_min.SetBackgroundColour("pink")
+                val_min.Refresh()
+            return flag
+        elif min_value==-numpy.inf:
+            try:
+                float(max_value)
+                val_max.SetBackgroundColour(wx.WHITE)
+                val_max.Refresh()
+            except:
+                flag = False
+                val_max.SetBackgroundColour("pink")
+                val_max.Refresh()
+            return flag
+        else:    
+            if (float(min_value)< float(max_value)):
+                val_min.SetBackgroundColour(wx.WHITE)
+                val_min.Refresh()
+            else:
+                flag = False
+                val_min.SetBackgroundColour("pink")
+                val_min.Refresh()
+            return flag   
            
         
@@ -755,4 +992,5 @@
                      name=str(item[0].GetLabelText())
                      value= float(item[1].GetValue())
+                   
                      #print "model para", name,value
                      # If the value of the parameter has changed,
@@ -789,4 +1027,6 @@
                      name=str(item[0].GetLabelText())
                      value= float(item[1].GetValue())
+                     param_min= item[4].GetValue()
+                     param_max= item[5].GetValue()
                      #print " fittable model para", name,value
                      # If the value of the parameter has changed,
@@ -796,7 +1036,25 @@
                          self.model.setParam(name,value)
                          is_modified = True
+                     if self.checkFitValues(item[4], item[5]):
+                         if param_min.lstrip().rstrip()== "-inf":
+                             param_min=None
+                         else:
+                             param_min=float(param_min)
+                         if param_max.lstrip().rstrip() =="+inf":
+                             param_max=None
+                         else:
+                             param_max=float(param_max)
+                         if  param_min !=  self.model.details[name][1]:
+                             self.model.details[name][1]= param_min
+                             is_modified = True
+                         if  param_max !=  self.model.details[name][2]:
+                             self.model.details[name][2]= param_max
+                             is_modified = True
+                         
                 except:
-                     wx.PostEvent(self.parent.parent, StatusEvent(status=\
-                            "Model Drawing  Error:wrong value entered : %s"% sys.exc_value))
+                    print item[4].GetValue(),item[5].GetValue()
+                    raise 
+                    #wx.PostEvent(self.parent.parent, StatusEvent(status=\
+                    #       "Model Drawing  Error:wrong value entered : %s"% sys.exc_value))
             
             # Here we should check whether the boundaries have been modified.
@@ -847,5 +1105,5 @@
                 for item in self.parameters:
                     item[0].SetValue(True)
-                    list= [item[0],item[1],item[2],item[3]]
+                    list= [item[0],item[1],item[2],item[3],item[4],item[5]]
                     self.param_toFit.append(list )
                 if len(self.fittable_param)>0:
Index: sansview/perspectives/fitting/simfitpage.py
===================================================================
--- sansview/perspectives/fitting/simfitpage.py	(revision 2fe03d5dd3e01e076095ac9ce7a16f5d3acce015)
+++ sansview/perspectives/fitting/simfitpage.py	(revision 51d47b5b86b892ab660da7cca3522ab438d9158d)
@@ -21,4 +21,6 @@
         """
         self.parent = parent
+        #self.page_finder = page_finder
+        self.page_finder={}
         self.sizer3 = wx.GridBagSizer(5,5)
         self.sizer1 = wx.GridBagSizer(5,5)
@@ -51,6 +53,6 @@
         self.model_list=[]
         self.model_toFit=[]
-        self.page_finder={}
-       
+        
+        #self.add_model(self.page_finder)
         self.vbox.Layout()
         self.vbox.Fit(self) 
@@ -64,8 +66,4 @@
         for page in self.page_finder.iterkeys():
             page.set_model_parameter()
-            
-        #if len(self.model_toFit) ==1 :
-        #    self.manager._on_single_fit()
-           # print "simfitpage: when here"
         if len(self.model_toFit) >= 1 :
             self._onTextEnter()
@@ -84,5 +82,5 @@
         """
         self.manager = manager
-        
+        self.add_model( self.manager.page_finder)
         
     def select_all_model_name(self,event):
@@ -125,4 +123,5 @@
         iy = 1 
         list=[]
+       # if len(self.page_finder)>0:
         for page, value in page_finder.iteritems():
             try:
@@ -254,9 +253,54 @@
                     self.params.append(self.parser_helper(value))  
             except:
-                raise
+                #raise
                 wx.PostEvent(self.parent.Parent, StatusEvent(status="Constraint Error: %s" % sys.exc_value))
         #print "simfitpage: self.params",self.params
-        
-        
+    def new_parser_helper(self,value):
+        """
+             @return  param:a list containing the name of a model ,its parameters 
+             value and name extracted from the constrainst controlbox
+        """
+        from sans.guiframe import utils
+        mylist=["=","<",">","<=", ">="]
+        for item in mylist:
+            if utils.look_for_tag( value,str(item))[0]:
+                print "went here"
+                model_param = utils.split_text(str(item), value,1)
+                param_name = model_param[0]
+                param_value = model_param[1]
+                print "simpage",utils.look_for_tag(param_name,"\.")[0]
+                if utils.look_for_tag(param_name,"\.")[0]:
+                    param_names = utils.split_text("\.",param_name,1)
+                    model_name = param_names[0]
+                    param_name = param_names[1]
+                    ##### just added
+                    print "simfitpage: param name",model_name,param_name
+                
+                    param=[str(model_name),param_name,str(param_value),"="]
+                    #print "simfitpage: param",param
+                    return param
+                else:
+                    #raise ValueError,"cannot evaluate this expression"
+                    wx.PostEvent(self.parent.Parent,
+                                  StatusEvent(status="cannot evaluate this expression"))
+                    return
+            elif utils.look_for_tag( value,"<")[0]:
+                model_param = utils.split_text("<", value,2)
+                if len(model_param)== 2:
+                    try:
+                        param_name = str(model_param[0])
+                        param_value = float(model_param[1])
+                        param=[str(model_name),param_name,param_value,"<"]
+                        #print "simfitpage: param",param
+                        return param
+                    except:
+                        wx.PostEvent(self.parent.Parent, StatusEvent(status="\
+                        could read this expression%s" % sys.exc_value))
+                        return
+            else:
+                #raise ValueError,"Missing '=' in expression"
+                wx.PostEvent(self.parent.Parent, StatusEvent(status="Missing '=' in expression"))
+                
+            
         
     def parser_helper(self,value):
@@ -283,8 +327,11 @@
                 return param
             else:
-                raise ValueError,"cannot evaluate this expression"
+                #raise ValueError,"cannot evaluate this expression"
+                wx.PostEvent(self.parent.Parent,
+                              StatusEvent(status="cannot evaluate this expression"))
                 return
         else:
-            raise ValueError,"Missing '=' in expression"
+            #raise ValueError,"Missing '=' in expression"
+            wx.PostEvent(self.parent.Parent, StatusEvent(status="Missing '=' in expression"))
         
    
