Index: sansview/perspectives/fitting/fitpage1D.py
===================================================================
--- sansview/perspectives/fitting/fitpage1D.py	(revision db709e4fbeac91ce621c73623d3d788bd09e2c2c)
+++ sansview/perspectives/fitting/fitpage1D.py	(revision d15c02022d76c57e7bc024e447f04fd9510dff8b)
@@ -181,5 +181,7 @@
         self.model_list_box={}
         self.data = data
-        
+        ## Q range
+        self.qmin= 0.001
+        self.qmax= 0.1
         """
         bs = wx.BoxSizer(wx.VERTICAL)
@@ -536,4 +538,6 @@
         print "went here",len(self.parameters) ,self.model
         if len(self.parameters) !=0 and self.model !=None:
+            # Flag to register when a parameter has changed.
+            is_modified = False
             for item in self.parameters:
                 try:
@@ -543,35 +547,28 @@
                     name=str(item[0].GetLabelText())
                     value= float(item[1].GetValue())
-                    self.model.setParam(name,value) 
+                    # If the value of the parameter has changed,
+                    # update the model and set the is_modified flag
+                    if value != self.model.getParam(name):
+                        self.model.setParam(name,value)
+                        is_modified = True 
                 except:
                      wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\
                             "Drawing  Error:wrong value entered : %s"% sys.exc_value))
-           
-                is_modified = False
-                if self.xmin.IsModified():
-                    is_modified = True
-                if self.xmax.IsModified():
-                    is_modified = True
-                
-                try: 
-                    
-                    if item[1].IsModified() or is_modified:
-                        print str(item[0].GetLabelText()),item[1].IsModified()
-                        item[1].SetModified(False)
-                        name=str(item[0].GetLabelText())
-                        value= float(item[1].GetValue())
-                        self.model.setParam(name,value)
-                        self.xmin.SetModified(False)
-                        self.xmax.SetModified(False)
-                        is_modified=False
-                        
-                        self.manager.redraw_model(
-                        float(self.xmin.GetValue()),
-                        float(self.xmax.GetValue())  )    
-            
-                except:
-                     wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\
-                            "Model Drawing  Error:wrong value entered : %s"% sys.exc_value))
-            
+            # Here we should check whether the boundaries have been modified.
+            # If qmin and qmax have been modified, update qmin and qmax and 
+            # set the is_modified flag to True
+            if float(self.xmin.GetValue()) != self.qmin:
+                self.qmin = float(self.xmin.GetValue())
+                is_modified = True
+            if float(self.xmax.GetValue()) != self.qmax:
+                self.qmax = float(self.xmax.GetValue())
+                is_modified = True
+            
+            if is_modified:
+                self.manager.redraw_model(
+                                        qmin=self.qmin, qmax=self.qmax,
+                                        )
+            #self.manager.draw_model(self,model,description=None,
+            # enable1D=True,qmin=None,qmax=None, qstep=None)
            
     def select_all_param(self,event): 
Index: sansview/perspectives/fitting/fitpage2D.py
===================================================================
--- sansview/perspectives/fitting/fitpage2D.py	(revision db709e4fbeac91ce621c73623d3d788bd09e2c2c)
+++ sansview/perspectives/fitting/fitpage2D.py	(revision d15c02022d76c57e7bc024e447f04fd9510dff8b)
@@ -72,4 +72,7 @@
         self.vbox.Add(self.sizer4)
         self.vbox.Add(self.sizer1)
+        ## Q range
+        self.qmin= 0.001
+        self.qmax= 0.1
         
         id = wx.NewId()
@@ -496,33 +499,40 @@
             and the reset model according to paramaters changes
         """
+        print "went here",len(self.parameters) ,self.model
         if len(self.parameters) !=0 and self.model !=None:
+            # Flag to register when a parameter has changed.
+            is_modified = False
             for item in self.parameters:
-                
-                is_modified = False
-                if self.xmin.IsModified():
-                    is_modified = True
-                if self.xmax.IsModified():
-                    is_modified = True
-                
-                try: 
-                    
-                    if item[1].IsModified() or is_modified:
-                        print str(item[0].GetLabelText()),item[1].IsModified()
-                        item[1].SetModified(False)
-                        name=str(item[0].GetLabelText())
-                        value= float(item[1].GetValue())
+                try:
+                    item[2].Hide()
+                    item[3].Clear()
+                    item[3].Hide()
+                    name=str(item[0].GetLabelText())
+                    value= float(item[1].GetValue())
+                    # If the value of the parameter has changed,
+                    # update the model and set the is_modified flag
+                    if value != self.model.getParam(name):
                         self.model.setParam(name,value)
-                        self.xmin.SetModified(False)
-                        self.xmax.SetModified(False)
-                        is_modified=False
-                        
-                        self.manager.redraw_model(
-                        float(self.xmin.GetValue()),
-                        float(self.xmax.GetValue())  )    
-            
+                        is_modified = True 
                 except:
                      wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\
-                            "Model Drawing  Error:wrong value entered : %s"% sys.exc_value))
+                            "Drawing  Error:wrong value entered : %s"% sys.exc_value))
+            # Here we should check whether the boundaries have been modified.
+            # If qmin and qmax have been modified, update qmin and qmax and 
+            # set the is_modified flag to True
+            if float(self.xmin.GetValue()) != self.qmin:
+                self.qmin = float(self.xmin.GetValue())
+                is_modified = True
+            if float(self.xmax.GetValue()) != self.qmax:
+                self.qmax = float(self.xmax.GetValue())
+                is_modified = True
             
+            if is_modified:
+                
+                self.manager.redraw_model( 
+                                        qmin=self.qmin, qmax=self.qmax,
+                                        )
+                #self.manager.draw_model(self,model,description=None,
+                # enable1D=True,qmin=None,qmax=None, qstep=None)
            
     def select_all_param(self,event): 
Index: sansview/perspectives/fitting/fitpanel.py
===================================================================
--- sansview/perspectives/fitting/fitpanel.py	(revision 86c1832466ddab5c573aec133a29d224902b0e03)
+++ sansview/perspectives/fitting/fitpanel.py	(revision d15c02022d76c57e7bc024e447f04fd9510dff8b)
@@ -122,5 +122,5 @@
             @param page_title: the name of the page
         """
-        print "page_title fitpanel", page_title
+        #print "page_title fitpanel", page_title
         if  self.draw_model_name ==None:
             
Index: sansview/perspectives/fitting/fitting.py
===================================================================
--- sansview/perspectives/fitting/fitting.py	(revision db709e4fbeac91ce621c73623d3d788bd09e2c2c)
+++ sansview/perspectives/fitting/fitting.py	(revision d15c02022d76c57e7bc024e447f04fd9510dff8b)
@@ -611,8 +611,13 @@
                 qmax= 1.0
             if qstep ==None:
-                qstep =0.001
+                qstep =100
            
             #print "x in data1D",qmin,qmax
-            x = numpy.arange(qmin, qmax, qstep)        
+            #x = numpy.arange(qmin, qmax, qstep)  
+            x=  numpy.linspace(start= qmin,
+                               stop= qmax,
+                               num= qstep,
+                               endpoint=True
+                               )      
             xlen= len(x)
             y = numpy.zeros(xlen)
@@ -620,5 +625,5 @@
                 for i in range(xlen):
                     y[i] = model.run(x[i])
-        
+                
                 try:
                     new_plot = Theory1D(x, y)
@@ -635,5 +640,5 @@
                 for i in range(xlen):
                     y[i] = model.run(x[i])
-                    
+                #print x, y   
                 try:
                     new_plot = Theory1D(x, y)
@@ -655,15 +660,31 @@
         wx.PostEvent(self.parent, StatusEvent(status="Calc \
         complete in %g sec" % elapsed))
-                           
-        print "complete",output, model,qmin, qmax
+        #print "complete",output, model,qmin, qmax
         data = output
         theory= Data2D(data)
+        #print data.detector
+        #theory.detector= data.detector
+        from DataLoader.data_info import Detector, Source
+        
+        detector = Detector()
+        theory.detector=[]
+        theory.detector.append(detector)
+            
+        theory.detector[0].pixel_size.x= 5.0
+        theory.detector[0].pixel_size.y= 5.0
+        theory.source= Source()
+        theory.source.wavelength= 8.4
+        theory.detector[0].beam_center.x= 0
+        theory.detector[0].beam_center.y= 0
+        theory.detector[0].distance= 13705.0
+        
         theory.name= model.name
         theory.group_id ="Model"
         theory.id ="Model"
-        theory.xmin= qmin
+        theory.xmin= -qmax
         theory.xmax= qmax
-        theory.ymin= qmin
+        theory.ymin= -qmax
         theory.ymax= qmax
+        print "model draw comptele xmax",theory.xmax
         wx.PostEvent(self.parent, NewPlotEvent(plot=theory,
                          title="Analytical model 2D %s" %str(model.name)))
@@ -673,11 +694,19 @@
     def _draw_model2D(self,model,description=None, enable2D=False,qmin=None,qmax=None, qstep=None):
         if qmin==None:
-            qmin= -0.05
+            qmin= 0.0
         if qmax==None:
             qmax= 0.05
         if qstep ==None:
-            qstep =0.001
-        x = numpy.arange(qmin,qmax, qstep)
-        y = numpy.arange(qmin,qmax,qstep)
+            qstep =100
+       
+        x=  numpy.linspace(start= -1*qmax,
+                               stop= qmax,
+                               num= qstep,
+                               endpoint=True )  
+        y = numpy.linspace(start= -1*qmax,
+                               stop= qmax,
+                               num= qstep,
+                               endpoint=True )
+       
         lx = len(x)
         #print x
@@ -686,5 +715,8 @@
         if enable2D:
             from model_thread import Calc2D
-            self.calc_thread = Calc2D(parent =self.parent,x=x, y=y,model= self.model, qmin=qmin,qmax=qmax,
+            self.calc_thread = Calc2D(parent =self.parent,x=x,
+                                       y=y,model= self.model, 
+                                       qmin=qmin,
+                                       qmax=qmax,
                             completefn=self.complete,
                             updatefn=self.update)
Index: sansview/perspectives/fitting/model_thread.py
===================================================================
--- sansview/perspectives/fitting/model_thread.py	(revision db709e4fbeac91ce621c73623d3d788bd09e2c2c)
+++ sansview/perspectives/fitting/model_thread.py	(revision d15c02022d76c57e7bc024e447f04fd9510dff8b)
@@ -125,4 +125,5 @@
         y = self.y
         output = numpy.zeros((len(x),len(y)))
+        """
         if self.qmin *self.qmax >=0:
             print "same signe plotting"
@@ -134,6 +135,7 @@
                 center_y= (self.qmax -self.qmin)/2
         else:
-            center_x=0
-            center_y=0
+        """
+        center_x=0
+        center_y=0
         #print "center_x , center_y",center_x , center_y
         #print "x ",len(x)
@@ -143,23 +145,23 @@
         lx = len(self.x)
        
-        for i_x in range(int(len(self.x)/2)+1):
-           
-            # Check whether we need to bail out
-            self.update(output=output)
-            self.isquit()
-            
-            for i_y in range(int(len(self.y)/2)+1):
+        for i_x in range(len(self.x)):
+           
+            # Check whether we need to bail out
+            self.update(output=output)
+            self.isquit()
+            
+            for i_y in range(int(len(self.y))):
                 try:
-                    value1 = self.model.runXY([self.x[i_x]-center_x, self.y[i_y]-center_y])
-                    value2 = self.model.runXY([self.x[i_x]-center_x, self.y[lx-i_y-1]-center_y])
-                    value3 = self.model.runXY([self.x[lx-i_x-1]-center_x, self.y[i_y]-center_y])
-                    value4 = self.model.runXY([self.x[lx-i_x-1]-center_x, self.y[lx-i_y-1]-center_y])
+                    if (self.x[i_x]*self.x[i_x]+self.y[i_y]*self.y[i_y]) \
+                    < self.qmin * self.qmin:
+                        output[i_x] [i_y]=0
+                         
+                    else:
+                        value1 = self.model.runXY([self.x[i_x]-center_x, self.y[i_y]-center_y])
+                       
+                        
+                        output[i_x] [i_y]=value1 
+                       
                     
-                    output[i_x] [i_y]=value1 
-                    output[lx-i_x-1][lx-i_y-1] =value4 
-                    output[i_x] [lx-i_y-1]= value2 
-                    output[lx-i_x-1][i_y] = value3 
-                    
-                  
                 except:
                      wx.PostEvent(self.parent, StatusEvent(status=\
Index: sansview/perspectives/fitting/modelpage.py
===================================================================
--- sansview/perspectives/fitting/modelpage.py	(revision a5aaec9d9b4fec84f7f7300fcf626a98224a87eb)
+++ sansview/perspectives/fitting/modelpage.py	(revision d15c02022d76c57e7bc024e447f04fd9510dff8b)
@@ -73,6 +73,9 @@
         self.sizer4.Add(wx.StaticText(self, -1, 'Min'),(iy, ix),(1,1),\
                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix += 2
+        ix += 1
         self.sizer4.Add(wx.StaticText(self, -1, 'Max'),(iy, ix),(1,1),\
+                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        ix += 1
+        self.sizer4.Add(wx.StaticText(self, -1, 'Npts'),(iy, ix),(1,1),\
                             wx.EXPAND|wx.ADJUST_MINSIZE, 0)
         ix = 0
@@ -83,4 +86,5 @@
         self.qmin= 0.001
         self.qmax= 0.1
+        self.num_points= 100
         
         ix += 1
@@ -93,5 +97,5 @@
         
        
-        ix += 2
+        ix += 1
         self.xmax    = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20))
         self.xmax.SetValue(format_number(self.qmax))
@@ -99,6 +103,13 @@
         self.xmax.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)
         self.xmax.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter)
+        self.sizer4.Add(self.xmax,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        ix += 1
+        self.npts    = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20))
+        self.npts.SetValue(format_number(self.num_points))
+        self.npts.SetToolTipString("Number of point to plot.")
+        self.npts.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)
+        self.npts.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter)
        
-        self.sizer4.Add(self.xmax,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        self.sizer4.Add(self.npts,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
         ix = 0
         iy += 1
@@ -134,5 +145,5 @@
         # preview selected model name
         self.prevmodel_name=name
-        print "model view prev_model",name
+        #print "model view prev_model",name
         self.modelbox.SetValue(self.prevmodel_name)
         # flag to check if the user has selected a new model in the combox box
@@ -388,8 +399,12 @@
                 self.qmax = float(self.xmax.GetValue())
                 is_modified = True
+            if float(self.npts.GetValue()) !=  self.num_points:
+                self.qmax = float(self.npts.GetValue())
+                is_modified = True
             
             if is_modified:
                 self.manager.draw_model(self.model, self.model.name, 
                                         qmin=self.qmin, qmax=self.qmax,
+                                        qstep= self.num_points,
                                         enable2D=self.enable2D)
             #self.manager.draw_model(self,model,description=None,
