Changeset ac11e40 in sasview


Ignore:
Timestamp:
Mar 25, 2009 3:37:30 PM (15 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
d0d2ab5
Parents:
2140e68
Message:

simfit page changed

File:
1 edited

Legend:

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

    r2140e68 rac11e40  
    1616        self.page = page 
    1717        self.fittable_param =[] 
    18         self.selected_params=[] 
    1918        self._set_fittableParam() 
    2019         
     
    5150        self.page_finder=page_finder 
    5251        ## list contaning info to set constraint  
    53         ## look like self.constraint_dict[page]=[ model_name, parameter_name, constraint(string)] 
     52        ## look like self.constraint_dict[page]=FitConstraint(model, page) 
    5453        self.constraint_dict={} 
    5554        ## item list  self.constraints_list=[combobox1, combobox2,=,textcrtl, button ] 
     
    5958        ## selected mdoel to fit 
    6059        self.model_toFit=[] 
    61          
    62          
    6360        ## draw 
    6461        self.define_page_structure() 
     
    9996        ## making sure all parameters content a constraint 
    10097        ## validity of the constraint expression is own by fit engine 
    101         self._set_constraint() 
     98        if self.show_constraint.GetValue(): 
     99            self._set_constraint() 
    102100        ## get the fit range of very fit problem         
    103101        for page, value in self.page_finder.iteritems(): 
     
    262260            return 
    263261        if self.show_constraint.GetValue(): 
    264             self.sizer_couples.Clear(True)  
     262            self._hide_constraint() 
    265263            self._show_constraint() 
    266264            return 
     
    274272            Show constraint fields 
    275273        """ 
    276         flag = False 
    277274        if len(self.constraints_list)!= 0: 
    278275            nb_fit_param = 0 
     
    281278            ##Don't add anymore 
    282279            if len(self.constraints_list) == nb_fit_param: 
    283                 flag = True 
    284         if len(self.model_toFit) < 2 or flag: 
     280                msg= "Cannot add another constraint .Maximum of number " 
     281                msg += "Parameters name reached %s"%str(nb_fit_param) 
     282                wx.PostEvent(self.parent.Parent, StatusEvent(status= msg )) 
     283                self.sizer_couples.Layout() 
     284                self.sizer2.Layout() 
     285                self.SetScrollbars(20,20,200,100) 
     286                return 
     287             
     288        if len(self.model_toFit) < 2 : 
    285289            msg= "Select at least 2 model to add constraint " 
    286290            wx.PostEvent(self.parent.Parent, StatusEvent(status= msg )) 
     
    300304         
    301305        ctl2 = wx.TextCtrl(self, -1) 
    302         ctl2.Bind(wx.EVT_TEXT_ENTER,self._onTextEnter) 
    303306        ctl2.Hide() 
    304307         
     
    310313            ## check if all parameters have been selected for constraint 
    311314            ## then do not allow add constraint on parameters 
    312             if len(value.fittable_param)!= len(value.selected_params): 
    313                     ## the user can apply constraint only on model select to fit 
    314                     model_cbox.Append( str(model.name), model) 
     315            model_cbox.Append( str(model.name), model) 
    315316             
    316317            
     
    337338        """ 
    338339            hide buttons related constraint  
    339         """ 
     340        """   
    340341        if len(self.constraint_dict)>0: 
    341             for value in self.constraint_dict.itervalues(): 
    342                 value.selected_params=[] 
    343                 param = value.fittable_param## list of parameter name 
    344                 ## reset the constraint to None on fitproblem 
    345                 for item in param: 
    346                     self.page_finder[value.page].set_model_param(item,None) 
    347                     
     342            for item in self.constraints_list: 
     343                model = item[0].GetClientData(0) 
     344                if model  in self.constraint_dict.keys(): 
     345                    page = self.constraint_dict[model].page 
     346                    self.page_finder[page].clear_model_param() 
     347                     
     348        self.constraint_dict={} 
     349        self._store_model() 
    348350        self.btAdd.Hide() 
    349351        self.constraints_list=[]          
     
    354356        self.AdjustScrollbars()     
    355357                 
    356          
     358     
    357359         
    358360    def _on_select_model(self, event): 
     
    370372        ## insert only fittable paramaters 
    371373        for param in param_list: 
    372             if not param in self.constraint_dict[model].selected_params: 
    373                 param_cbox.Append( str(param), model) 
     374            param_cbox.Append( str(param), model) 
     375             
    374376        param_cbox.Show(True) 
    375377        
     
    385387        model = event.GetClientData() 
    386388        param = event.GetString() 
    387         self.constraint_dict[model].selected_params.append(param) 
    388          
     389       
    389390        length = len(self.constraints_list) 
    390391        if length < 1: 
     
    423424            ctl2 = item[3] 
    424425            if ctl2.GetValue().lstrip().rstrip()=="": 
    425                  msg= " Enter a constraint for %s.%s! "%(model_cbox.GetString(0), 
     426                 msg= " Enter a constraint for %s.%s! "%(param_cbox.GetClientData(0).name, 
    426427                                              param_cbox.GetString(0))            
    427428                 wx.PostEvent(self.parent.Parent, StatusEvent(status= msg )) 
     
    458459        self.Bind(  wx.EVT_RADIOBUTTON, self._display_constraint, 
    459460                         id= self.show_constraint.GetId()    ) 
    460          
    461            
    462         
    463461         
    464462        sizer_title.Add( wx.StaticText(self,-1," Model") ) 
     
    472470        sizer_title.Add(( 10,10) ) 
    473471        
    474          
    475          
    476         ## Draw combobox box related to model name and model parameters 
    477         if self.show_constraint.GetValue(): 
    478             self._fill_sizer_constraint_helper(self.sizer_couples) 
    479         
    480472        self.btAdd =wx.Button(self,wx.NewId(),'Add') 
    481473        self.btAdd.Bind(wx.EVT_BUTTON, self._onAdd_constraint,id= self.btAdd.GetId()) 
     
    504496         
    505497         
    506     def _onTextEnter(self, event): 
    507         """ 
    508             callback function for textcrtl 
    509         """ 
    510         self.btAdd.Show(True) 
    511         self.sizer2.Layout() 
    512         self.SetScrollbars(20,20,200,100) 
    513         self._set_constraint() 
    514          
    515498    def _set_constraint(self): 
    516499        """ 
     
    521504        """ 
    522505        for item in self.constraints_list: 
    523             model = item[0].GetClientData(0) 
    524             param = item[1].GetString(0) 
     506             
     507            model = item[0].GetClientData(item[0].GetCurrentSelection()) 
     508            param = item[1].GetString(item[1].GetCurrentSelection()) 
    525509            constraint = item[3].GetValue().lstrip().rstrip() 
    526510            if model  in self.constraint_dict.keys(): 
    527511                page = self.constraint_dict[model].page 
    528                 if constraint != "": 
    529                     self.page_finder[page].set_model_param(param,constraint) 
     512                if constraint == "": 
     513                    constraint = None 
     514                
     515                self.page_finder[page].set_model_param(param,constraint) 
    530516         
    531517    
Note: See TracChangeset for help on using the changeset viewer.