Changeset 24ea33c in sasview for sansview


Ignore:
Timestamp:
Jan 10, 2009 10:08:54 AM (15 years ago)
Author:
Mathieu Doucet <doucetm@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
20be946
Parents:
4b91fd1
Message:

Fixed 1D and 2D model update problem. 2D models will no longer be recalculated when the "View 2D" button is clicked twice in a row and no parameter has changed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansview/perspectives/fitting/modelpage.py

    r86c1832 r24ea33c  
    8080        self.sizer4.Add(wx.StaticText(self, -1, 'x range'),(iy, ix),(1,1),\ 
    8181                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    82         
    83         qmin= 0.001 
    84         qmax= 1.0 
     82        ## Q range 
     83        self.qmin= 0.001 
     84        self.qmax= 0.1 
     85         
    8586        ix += 1 
    8687        self.xmin    = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) 
    87         self.xmin.SetValue(format_number(qmin)) 
     88        self.xmin.SetValue(format_number(self.qmin)) 
    8889        self.xmin.SetToolTipString("Minimun value of x in linear scale.") 
    8990        self.xmin.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 
     
    9495        ix += 2 
    9596        self.xmax    = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) 
    96         self.xmax.SetValue(format_number(qmax)) 
     97        self.xmax.SetValue(format_number(self.qmax)) 
    9798        self.xmax.SetToolTipString("Maximum value of x in linear scale.") 
    9899        self.xmax.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 
     
    174175         call manager to plot model in 2D 
    175176        """ 
    176         self.enable2D=True 
    177         print "modelpage name", self.prevmodel_name 
    178         self.manager.draw_model(model=self.model,name=self.prevmodel_name, 
     177        # If the 2D display is not currently enabled, plot the model in 2D  
     178        # and set the enable2D flag. 
     179        if self.enable2D==False: 
     180            self.enable2D=True 
     181            self.manager.draw_model(model=self.model,name=self.prevmodel_name, 
    179182                                    description=None, 
    180183                                     enable2D=self.enable2D, 
    181                                      qmin=float(self.xmin.GetValue()), 
    182                                     qmax=float(self.xmax.GetValue())) 
     184                                     qmin=float(self.qmin), 
     185                                    qmax=float(self.qmax)) 
     186             
    183187    def populate_box(self, dict): 
    184188        """ 
     
    358362    def set_model_parameter(self): 
    359363        if len(self.parameters) !=0 and self.model !=None: 
     364            # Flag to register when a parameter has changed. 
     365            is_modified = False 
    360366            for item in self.parameters: 
    361367                try: 
    362368                     name=str(item[0].GetLabelText()) 
    363369                     value= float(item[1].GetValue()) 
    364                      self.model.setParam(name,value) 
     370                     # If the value of the parameter has changed, 
     371                     # update the model and set the is_modified flag 
     372                     if value != self.model.getParam(name): 
     373                         self.model.setParam(name,value) 
     374                         is_modified = True 
    365375                except: 
    366376                     wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\ 
    367377                            "Model Drawing  Error:wrong value entered : %s"% sys.exc_value)) 
    368378             
    369             print self.enable2D 
    370             self.manager.draw_model(self.model,qmin=float(self.xmin.GetValue()), 
    371                                     qmax=float(self.xmax.GetValue()), 
    372                                     enable2D=self.enable2D) 
     379            # Here we should check whether the boundaries have been modified. 
     380            # If qmin and qmax have been modified, update qmin and qmax and  
     381            # set the is_modified flag to True 
     382            if float(self.xmin.GetValue()) != self.qmin: 
     383                self.qmin = float(self.xmin.GetValue()) 
     384                is_modified = True 
     385            if float(self.xmax.GetValue()) != self.qmax: 
     386                self.qmax = float(self.xmax.GetValue()) 
     387                is_modified = True 
     388             
     389            if is_modified: 
     390                self.manager.draw_model(self.model, self.model.name,  
     391                                        qmin=self.qmin, qmax=self.qmax, 
     392                                        enable2D=self.enable2D) 
    373393            #self.manager.draw_model(self,model,description=None, 
    374394            # enable1D=True,qmin=None,qmax=None, qstep=None) 
Note: See TracChangeset for help on using the changeset viewer.