Ignore:
Timestamp:
Jul 5, 2017 5:28:55 PM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
1386b2f
Parents:
251ef684
Message:

clean up plugin-model handling code; preserve active parameter values when plugin is updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/fitting/basepage.py

    r65f3930 r277257f  
    504504        self.state.manager = manager 
    505505 
    506     def populate_box(self, model_dict): 
     506    def populate_box(self, model_list_box): 
    507507        """ 
    508508        Store list of model 
    509509 
    510         :param model_dict: dictionary containing list of models 
    511  
    512         """ 
    513         self.model_list_box = model_dict 
    514         self.state.model_list_box = self.model_list_box 
     510        :param model_list_box: dictionary containing categorized models 
     511        """ 
     512        self.model_list_box = model_list_box 
    515513        self.initialize_combox() 
    516514 
    517     def set_model_dictionary(self, model_dict): 
     515    def set_model_dictionary(self, model_dictionary): 
    518516        """ 
    519517        Store a dictionary linking model name -> model object 
    520518 
    521         :param model_dict: dictionary containing list of models 
    522         """ 
    523         self.model_dict = model_dict 
     519        :param model_dictionary: dictionary containing all models 
     520        """ 
     521        self.model_dictionary = model_dictionary 
    524522 
    525523    def initialize_combox(self): 
     
    527525        put default value in the combo box 
    528526        """ 
    529         if self.model_list_box is not None and len(self.model_list_box) > 0: 
     527        if self.model_list_box: 
    530528            self._populate_box(self.structurebox, 
    531529                               self.model_list_box["Structure Factors"]) 
     
    12181216        self.categorybox.Select(category_pos) 
    12191217        self._show_combox(None) 
    1220         if self.categorybox.GetValue() == CUSTOM_MODEL \ 
    1221                 and PLUGIN_NAME_BASE not in state.formfactorcombobox: 
     1218        if (self.categorybox.GetValue() == CUSTOM_MODEL 
     1219                and PLUGIN_NAME_BASE not in state.formfactorcombobox): 
    12221220            state.formfactorcombobox = \ 
    12231221                PLUGIN_NAME_BASE + state.formfactorcombobox 
    12241222        formfactor_pos = 0 
    12251223        for ind_form in range(self.formfactorbox.GetCount()): 
    1226             if self.formfactorbox.GetString(ind_form) == \ 
    1227                                                 (state.formfactorcombobox): 
     1224            if (self.formfactorbox.GetString(ind_form) 
     1225                    == state.formfactorcombobox): 
    12281226                formfactor_pos = int(ind_form) 
    12291227                break 
     
    12351233            state.structurecombobox = unicode(state.structurecombobox) 
    12361234            for ind_struct in range(self.structurebox.GetCount()): 
    1237                 if self.structurebox.GetString(ind_struct) == \ 
    1238                                                 (state.structurecombobox): 
     1235                if (self.structurebox.GetString(ind_struct) 
     1236                        == state.structurecombobox): 
    12391237                    structfactor_pos = int(ind_struct) 
    12401238                    break 
     
    18401838            if mod_cat == CUSTOM_MODEL: 
    18411839                for model in self.model_list_box[mod_cat]: 
    1842                     m_list.append(self.model_dict[model.name]) 
     1840                    m_list.append(self.model_dictionary[model.name]) 
    18431841            else: 
    18441842                cat_dic = self.master_category_dict[mod_cat] 
    1845                 for (model, enabled) in cat_dic: 
     1843                for model, enabled in cat_dic: 
    18461844                    if enabled: 
    1847                         m_list.append(self.model_dict[model]) 
     1845                        m_list.append(self.model_dictionary[model]) 
    18481846        except Exception: 
    18491847            msg = traceback.format_exc() 
     
    34973495        self.model_box.Clear() 
    34983496 
    3499         if category == 'Plugin Models': 
     3497        if category == CUSTOM_MODEL: 
    35003498            for model in self.model_list_box[category]: 
    35013499                str_m = str(model).split(".")[0] 
Note: See TracChangeset for help on using the changeset viewer.