Changeset 376916c in sasview


Ignore:
Timestamp:
Apr 1, 2009 2:37:27 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:
89ef796
Parents:
208de57
Message:

resettting gaussian dispersity —fixed
reducing access to molde multplication —-done as request

Location:
sansview/perspectives/fitting
Files:
4 edited

Legend:

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

    r1328e03 r376916c  
    471471             
    472472            for k, list in self.model_list_box.iteritems(): 
    473                 if k == "shapes": 
     473                if k in["P(Q)*S(Q)","Shapes" ] and class_name in self.model_list_box["Shapes"]: 
    474474                    self.shape_rbutton.SetValue(True) 
    475                 elif k == "Shape-independent": 
     475                    ## fill the form factor list with new model 
     476                    self._populate_box(self.formfactorbox,self.model_list_box["Shapes"]) 
     477                    items = self.formfactorbox.GetItems() 
     478                    ## set comboxbox to the selected item 
     479                    for i in range(len(items)): 
     480                        if items[i]== str(name): 
     481                            self.formfactorbox.SetSelection(i) 
     482                            break 
     483                    return 
     484                elif k == "Shape-Independent": 
    476485                    self.shape_indep_rbutton.SetValue(True) 
    477486                elif k == "Structure Factors": 
     
    479488                else: 
    480489                    self.plugin_rbutton.SetValue(True) 
    481                      
     490                
    482491                if class_name in list: 
    483492                    ## fill the form factor list with new model 
     
    491500                    break 
    492501        else: 
    493             ## Select the model from the combo box 
     502            ## Select the model from the combobox 
    494503            class_name = model.__class__ 
    495504            name = model.name 
    496505            self.formfactorbox.Clear() 
    497506            items = self.formfactorbox.GetItems() 
     507     
    498508            for k, list in self.model_list_box.iteritems(): 
    499                 if k == "shapes": 
     509                if k in["P(Q)*S(Q)","Shapes" ] and class_name in self.model_list_box["Shapes"]: 
    500510                    self.shape_rbutton.SetValue(True) 
    501                 elif k == "Shape-independent": 
     511                    ## fill the form factor list with new model 
     512                    self._populate_box(self.formfactorbox,self.model_list_box["Shapes"]) 
     513                    items = self.formfactorbox.GetItems() 
     514                    ## set comboxbox to the selected item 
     515                    for i in range(len(items)): 
     516                        if items[i]== str(name): 
     517                            self.formfactorbox.SetSelection(i) 
     518                            break 
     519                    return 
     520                elif k == "Shape-Independent": 
    502521                    self.shape_indep_rbutton.SetValue(True) 
    503522                elif k == "Structure Factors": 
     
    506525                    self.plugin_rbutton.SetValue(True) 
    507526                if class_name in list: 
    508                 ## fill the form factor list with new model 
     527                    ## fill the form factor list with new model 
    509528                    self._populate_box(self.formfactorbox, list) 
    510529                    items = self.formfactorbox.GetItems() 
     
    541560        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 
    542561        #-------------------------------------------------------- 
    543         self.shape_rbutton = wx.RadioButton(self, -1, 'Shape', style=wx.RB_GROUP) 
    544         self.shape_indep_rbutton = wx.RadioButton(self, -1, "Shape Independent") 
    545         self.struct_rbutton = wx.RadioButton(self, -1, "Structure ") 
    546         self.plugin_rbutton = wx.RadioButton(self, -1, "customized Model") 
     562        self.shape_rbutton = wx.RadioButton(self, -1, 'Shapes', style=wx.RB_GROUP) 
     563        self.shape_indep_rbutton = wx.RadioButton(self, -1, "Shape-Independent") 
     564        self.struct_rbutton = wx.RadioButton(self, -1, "Structure Factor ") 
     565        self.plugin_rbutton = wx.RadioButton(self, -1, "Customized Models") 
    547566        self.multip_cb = wx.CheckBox(self, -1,"P(Q)*S(Q)") 
    548567         
     
    591610        ## fill combox box 
    592611        if len(self.model_list_box)>0: 
    593             self._populate_box( self.formfactorbox,self.model_list_box["shapes"]) 
     612            self._populate_box( self.formfactorbox,self.model_list_box["Shapes"]) 
    594613        
    595614        if len(self.model_list_box)>0: 
     
    631650        self.page_info.save_radiobox_state( self.plugin_rbutton ) 
    632651         
    633          
    634          
    635         if self.shape_rbutton.GetValue(): 
    636             ##fill the comboxbox with form factor list 
     652        ## Don't want to populate combo box again if the event comes from check box 
     653        if self.shape_rbutton.GetValue()and\ 
     654             event.GetEventObject()==self.shape_rbutton: 
     655            ##fill the combobox with form factor list 
    637656            self.structurebox.Hide() 
    638657            self.text2.Hide() 
    639658            self.formfactorbox.Clear() 
    640             self._populate_box( self.formfactorbox,self.model_list_box["shapes"]) 
    641              
    642         if self.shape_indep_rbutton.GetValue(): 
    643             ##fill the comboxbox with shape independent  factor list 
     659            self._populate_box( self.formfactorbox,self.model_list_box["Shapes"]) 
     660             
     661        if self.shape_indep_rbutton.GetValue()and\ 
     662             event.GetEventObject()==self.shape_indep_rbutton: 
     663            ##fill the combobox with shape independent  factor list 
    644664            self.structurebox.Hide() 
    645665            self.text2.Hide() 
    646666            self.formfactorbox.Clear() 
    647667            self._populate_box( self.formfactorbox, 
    648                                 self.model_list_box["Shape-independent"]) 
    649              
    650         if self.struct_rbutton.GetValue(): 
    651             ##fill the comboxbox with structure factor list 
     668                                self.model_list_box["Shape-Independent"]) 
     669             
     670        if self.struct_rbutton.GetValue() and\ 
     671             event.GetEventObject()==self.struct_rbutton: 
     672            ##fill the combobox with structure factor list 
    652673            self.structurebox.Hide() 
    653674            self.text2.Hide() 
     
    656677                                self.model_list_box["Structure Factors"]) 
    657678            
    658         if self.plugin_rbutton.GetValue(): 
    659             ##fill the comboxbox with form factor list 
     679        if self.plugin_rbutton.GetValue()and\ 
     680             event.GetEventObject()==self.plugin_rbutton: 
     681            
     682            ##fill the combobox with form factor list 
    660683            self.structurebox.Hide() 
    661684            self.text2.Hide() 
    662685            self.formfactorbox.Clear() 
    663686            self._populate_box( self.formfactorbox, 
    664                                 self.model_list_box["Added models"]) 
     687                                self.model_list_box["Customized Models"]) 
     688         
    665689        if not self.multip_cb.GetValue():  
    666             model = self.formfactorbox.GetClientData(0) 
     690            self.structurebox.Hide() 
     691            self.text2.Hide() 
     692            n = self.formfactorbox.GetCurrentSelection() 
     693            model = self.formfactorbox.GetClientData(n) 
    667694            self.model = model() 
    668              
     695        ## user check multiplication option         
    669696        else: 
    670             ## multplication not available for structure factor 
    671             if self.struct_rbutton.GetValue(): 
     697            ##for this release  
     698            flag1= self.plugin_rbutton.GetValue()or self.struct_rbutton.GetValue()\ 
     699                    or self.shape_indep_rbutton.GetValue() 
     700            flag2= False    
     701              
     702            n = self.formfactorbox.GetCurrentSelection() 
     703            form_factor = self.formfactorbox.GetClientData(n)    
     704            ## selecting only multiplication model 
     705            if self.shape_rbutton.GetValue(): 
     706               if not form_factor in  self.model_list_box["multiplication"]: 
     707                   flag2 = True 
     708            ## multiplication not available for structure factor 
     709            if flag1 or  flag2: 
    672710                self.multip_cb.SetValue(False) 
    673711                self.structurebox.Hide() 
     712                self.text2.Hide() 
    674713                return 
    675             ##fill the comboxbox with form factor list 
     714            ## allow only some to have multiplication 
     715             
    676716            self.structurebox.Show(True) 
    677717            self.text2.Show(True) 
    678             ## draw multplication  model 
    679             form_factor = self.formfactorbox.GetClientData(0) 
    680             struct_factor = self.structurebox.GetClientData(0) 
     718            ## draw multiplication  model 
     719            n = self.structurebox.GetCurrentSelection() 
     720            struct_factor = self.structurebox.GetClientData(n) 
    681721             
    682722            from sans.models.MultiplicationModel import MultiplicationModel 
     
    707747                combobox.Append(name,models) 
    708748        try: 
     749 
    709750            combobox.SetSelection(0) 
    710751             
     
    719760             call back for model selection 
    720761        """ 
     762        ## reset dictionary containing reference to dispersion 
     763        self._disp_obj_dict = {} 
     764        self.disp_cb_dict ={} 
     765         
    721766        f_id = self.formfactorbox.GetCurrentSelection() 
    722767        s_id = self.structurebox.GetCurrentSelection() 
    723768        form_factor = self.formfactorbox.GetClientData( f_id ) 
    724769        struct_factor = self.structurebox.GetClientData( s_id ) 
    725         
     770         
     771        if not form_factor in  self.model_list_box["multiplication"]: 
     772            self.multip_cb.SetValue(False) 
     773            self.structurebox.Hide() 
     774            self.text2.Hide() 
     775            self.sizer4_4.Clear() 
     776            self.sizer4.Layout() 
     777             
    726778        if self.multip_cb.GetValue(): 
    727779            from sans.models.MultiplicationModel import MultiplicationModel 
     
    796848                self.sizer4_4.Clear(True) 
    797849                self._reset_dispersity() 
    798                 self._draw_model() 
    799850             
    800851            self.sizer4.Layout() 
     
    817868        model_disp = wx.StaticText(self, -1, 'No PolyDispersity for this model') 
    818869        self.sizer4_4.Add(model_disp,( iy, ix),(1,1),  wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    819         #self.sizer4_4.Layout() 
    820870        self.sizer4.Layout() 
    821871        self.SetScrollbars(20,20,200,100) 
    822872        return  
    823873     
    824     def _reset_gaussian_dispers(self): 
    825         """ 
    826             reset model paramaters to gaussian 
    827             TO IMPLEMENT 
    828         """ 
    829         return 
    830         if self.model==None: 
    831             return 
    832         from sans.models.dispersion_models import GaussianDispersion 
    833         list = self.model.dispersion.keys() 
    834          
    835         for key in list: 
    836             ## The parameter was un-selected. Go back to Gaussian model (with 0 pts) 
    837             disp_model = GaussianDispersion() 
    838             ## Set the new model as the dispersion object for the selected parameter 
    839             self.model.set_dispersion(key,disp_model) 
    840             self._draw_model() 
    841              
     874  
    842875             
    843876    def _reset_dispersity(self): 
     
    847880        self.fittable_param=[] 
    848881        self.fixed_param=[] 
     882         
    849883        from sans.models.dispersion_models import GaussianDispersion 
    850884        if len(self.disp_cb_dict)==0: 
     
    857891            #TODO: refactor model to clean this up? 
    858892            self._disp_obj_dict[p] = disp_model 
    859              
    860893            # Set the new model as the dispersion object for the selected parameter 
    861894            self.model.set_dispersion(p, disp_model) 
    862              
    863895            # Redraw the model 
    864              
     896            self._draw_model() 
    865897             
    866898             
     
    872904        dispersity  =event.GetClientData() 
    873905        name= dispersity.__name__ 
    874          
    875         if name == "GaussianModel": 
     906        if name == "GaussianDispersion": 
    876907            self._set_sizer_gaussian() 
    877908             
  • sansview/perspectives/fitting/fitpage.py

    r1328e03 r376916c  
    171171        self.qmax_x= data_max 
    172172         
     173         
    173174    def _fill_model_sizer(self, sizer): 
    174175        """ 
     
    201202        self.fittable_param=[] 
    202203        self.fixed_param=[] 
    203         ##reset model dispersity to gaussian 
    204         self._reset_gaussian_dispers() 
    205          
     204     
    206205        self.sizer4_4.Clear(True) 
    207206        
     
    212211            ## the user didn't select dispersity display 
    213212            return  
     213         
     214        self._reset_dispersity() 
     215        # Create the dispersion objects 
     216        for item in self.model.dispersion.keys(): 
     217            disp_model =  GaussianDispersion() 
     218            self._disp_obj_dict[item] = disp_model 
     219            self.model.set_dispersion(item, disp_model) 
     220 
    214221        ix=0 
    215222        iy=1 
     
    233240        
    234241        for item in self.model.dispersion.keys(): 
     242            self.disp_cb_dict[item]= None 
    235243            name1=item+".width" 
    236244            name2=item+".npts" 
  • sansview/perspectives/fitting/modelpage.py

    r1328e03 r376916c  
    125125        self.fittable_param=[] 
    126126        self.fixed_param=[] 
    127         ##reset model dispersity to gaussian 
    128         self._reset_gaussian_dispers() 
    129          
     127        
    130128        self.sizer4_4.Clear(True) 
    131129        if self.model==None: 
     
    135133            ## the user didn't select dispersity display 
    136134            return  
     135        self._reset_dispersity() 
     136        # Create the dispersion objects 
     137        for item in self.model.dispersion.keys(): 
     138            disp_model =  GaussianDispersion() 
     139            self._disp_obj_dict[item] = disp_model 
     140            self.model.set_dispersion(item, disp_model) 
     141 
     142         
    137143        ix=0 
    138144        iy=1 
     
    153159         
    154160        for item in self.model.dispersion.keys(): 
     161           
     162            self.disp_cb_dict[item]= None 
    155163            name1=item+".width" 
    156164            name2=item+".npts" 
     
    243251        self._draw_model() 
    244252        ## keep the sizer view consistent with the model menu selecting 
    245         ## 
    246         self.structurebox.Hide() 
    247         self.text2.Hide() 
    248         self.multip_cb.SetValue(False) 
    249          
    250         if hasattr( model,"model1"): 
    251             self._set_model_sizer_selection( model ) 
     253        self._set_model_sizer_selection( self.model ) 
    252254         
    253255        self.model_view.SetFocus() 
  • sansview/perspectives/fitting/models.py

    rc77d859 r376916c  
    103103    ##list of structure factors  
    104104    struct_list= [] 
     105    ##list of model allowing multiplication 
     106    multiplication_factor=[] 
    105107    ## list of added models 
    106108    plugins=[] 
     
    119121        from sans.models.SphereModel import SphereModel 
    120122        self.shape_list.append(SphereModel) 
     123        self.multiplication_factor.append(SphereModel) 
    121124         
    122125        from sans.models.CylinderModel import CylinderModel 
    123126        self.shape_list.append(CylinderModel) 
    124        
     127        self.multiplication_factor.append(CylinderModel) 
     128         
    125129        from sans.models.CoreShellModel import CoreShellModel 
    126130        self.shape_list.append(CoreShellModel) 
     
    134138        from sans.models.EllipsoidModel import EllipsoidModel 
    135139        self.shape_list.append(EllipsoidModel) 
     140        self.multiplication_factor.append(EllipsoidModel) 
    136141          
    137         from sans.models.LineModel import LineModel 
    138         self.shape_list.append(LineModel) 
     142         
    139143         
    140144        ## Structure factor  
    141         from sans.models.NoStructure import NoStructure 
    142         self.struct_list.append(NoStructure) 
    143          
     145       
    144146        from sans.models.SquareWellStructure import SquareWellStructure 
    145147        self.struct_list.append(SquareWellStructure) 
     
    170172        from sans.models.PorodModel import PorodModel 
    171173        self.shape_indep_list.append(PorodModel ) 
     174         
     175        from sans.models.LineModel import LineModel 
     176        self.shape_indep_list.append(LineModel) 
    172177         
    173178        from sans.models.FractalModel import FractalModel 
     
    218223        structure_factor = wx.Menu() 
    219224        added_models = wx.Menu() 
     225        multip_models = wx.Menu() 
    220226        ## create menu with shape 
    221         self._fill_menu( menuinfo = ["shapes",shape_submenu," simple shape"], 
    222                          list1 = self.shape_list, 
    223                          list2 = self.struct_list ) 
    224         self._fill_menu( menuinfo = ["Shape-independent",shape_indep_submenu, 
     227        self._fill_simple_menu( menuinfo = ["Shapes",shape_submenu," simple shape"], 
     228                         list1 = self.shape_list ) 
     229         
     230        self._fill_simple_menu( menuinfo = ["Shape-Independent",shape_indep_submenu, 
    225231                                    "List of shape-independent models"], 
    226                          list1 = self.shape_indep_list, 
    227                          list2 = self.struct_list ) 
    228         self._fill_menu( menuinfo = ["Added models", added_models, 
    229                                             "List of additional models"], 
    230                                  list1= self.plugins, 
    231                                  list2 = self.struct_list) 
     232                         list1 = self.shape_indep_list ) 
    232233         
    233234        self._fill_simple_menu( menuinfo= ["Structure Factors",structure_factor, 
    234235                                          "List of Structure factors models" ], 
    235236                                list1= self.struct_list ) 
     237         
     238        self._fill_simple_menu( menuinfo = ["Customized Models", added_models, 
     239                                            "List of additional models"], 
     240                                 list1= self.plugins ) 
     241         
     242        self._fill_menu(menuinfo=["P(Q)*S(Q)",multip_models, 
     243                                  "mulplication of 2 models"], 
     244                                   list1 = self.multiplication_factor , 
     245                                   list2 =  self.struct_list) 
    236246         
    237247         
     
    324334    def get_model_list(self):     
    325335        """ @ return dictionary of models for fitpanel use """ 
     336        self.model_combobox.set_list("multiplication", self.multiplication_factor) 
    326337        return self.model_combobox 
    327338     
    328      
    329     def get_form_struct(self): 
    330         """ retunr list of form structures""" 
    331         return self.struct_list 
    332          
    333      
    334      
    335339   
     340         
     341     
     342     
     343   
Note: See TracChangeset for help on using the changeset viewer.