Ignore:
File:
1 edited

Legend:

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

    r9e0aa69a re92a352  
    5353    ON_MAC = True 
    5454 
    55  
    5655class BasicPage(ScrolledPanel, PanelBase): 
    5756    """ 
    58     This class provide general structure of fitpanel page 
     57    This class provide general structure of the fitpanel page 
    5958    """ 
    6059    # Internal name for the AUI manager 
     
    678677    def _copy_info(self, flag): 
    679678        """ 
    680         Send event dpemding on flag 
    681  
    682         : Param flag: flag that distinguish event 
     679        Send event depending on flag 
     680 
     681        : Param flag: flag that distinguishes the event 
    683682        """ 
    684683        # messages depending on the flag 
     
    10421041                        disp_model = POLYDISPERSITY_MODELS['array']() 
    10431042                        if hasattr(state, "values") and \ 
    1044                                  self.disp_cb_dict[item].GetValue() is True: 
     1043                                 self.disp_cb_dict[item].GetValue(): 
    10451044                            if len(state.values) > 0: 
    10461045                                self.values = state.values 
     
    11061105        """ 
    11071106        for key, value in self.master_category_dict.iteritems(): 
    1108             formfactor = state.formfactorcombobox.split(":") 
    1109             if isinstance(formfactor, list): 
    1110                 formfactor = formfactor[0] 
    11111107            for list_item in value: 
    1112                 if formfactor in list_item: 
     1108                if state.formfactorcombobox in list_item: 
    11131109                    return self.categorybox.Items.index(key) 
    11141110        return 0 
     
    11201116        :precondition: the page is already drawn or created 
    11211117 
    1122         :postcondition: the state of the underlying data change as well as the 
     1118        :postcondition: the state of the underlying data changes as well as the 
    11231119            state of the graphic interface 
    11241120        """ 
     
    11561152        self._show_combox_helper() 
    11571153        # select the current model 
    1158         state._convert_to_sasmodels() 
    1159         state.categorycombobox = unicode(state.categorycombobox) 
    1160         if state.categorycombobox in self.categorybox.Items: 
    1161             category_pos = self.categorybox.Items.index( 
    1162                 state.categorycombobox) 
    1163         else: 
    1164             # Look in master list for model name (model.lower) 
    1165             category_pos = self.get_cat_combo_box_pos(state) 
     1154        try: 
     1155            # to support older version 
     1156            category_pos = int(state.categorycombobox) 
     1157        except: 
     1158            state.formfactorcombobox = state.formfactorcombobox.lower() 
     1159            state.formfactorcombobox = \ 
     1160                state.formfactorcombobox.replace('model', '') 
     1161            state.formfactorcombobox = unicode(state.formfactorcombobox) 
     1162            state.categorycombobox = unicode(state.categorycombobox) 
     1163            if state.categorycombobox in self.categorybox.Items: 
     1164                category_pos = self.categorybox.Items.index( 
     1165                    state.categorycombobox) 
     1166            else: 
     1167                # Look in master list for model name (model.lower) 
     1168                category_pos = self.get_cat_combo_box_pos(state) 
    11661169 
    11671170        self.categorybox.Select(category_pos) 
    11681171        self._show_combox(None) 
    1169         from models import PLUGIN_NAME_BASE 
    1170         if self.categorybox.GetValue() == 'Customized Models' \ 
    1171                 and PLUGIN_NAME_BASE not in state.formfactorcombobox: 
    1172             state.formfactorcombobox = \ 
    1173                 PLUGIN_NAME_BASE + state.formfactorcombobox 
    1174         formfactor_pos = 0 
    1175         for ind_form in range(self.formfactorbox.GetCount()): 
    1176             if self.formfactorbox.GetString(ind_form) == \ 
    1177                                                 (state.formfactorcombobox): 
    1178                 formfactor_pos = int(ind_form) 
    1179                 break 
     1172        try: 
     1173            # to support older version 
     1174            formfactor_pos = int(state.formfactorcombobox) 
     1175        except: 
     1176            formfactor_pos = 0 
     1177            for ind_form in range(self.formfactorbox.GetCount()): 
     1178                if self.formfactorbox.GetString(ind_form) == \ 
     1179                                                    (state.formfactorcombobox): 
     1180                    formfactor_pos = int(ind_form) 
     1181                    break 
    11801182 
    11811183        self.formfactorbox.Select(formfactor_pos) 
    11821184 
    11831185        structfactor_pos = 0 
    1184         if state.structurecombobox is not None: 
    1185             state.structurecombobox = unicode(state.structurecombobox) 
    1186             for ind_struct in range(self.structurebox.GetCount()): 
    1187                 if self.structurebox.GetString(ind_struct) == \ 
    1188                                                 (state.structurecombobox): 
    1189                     structfactor_pos = int(ind_struct) 
    1190                     break 
     1186        try: 
     1187            # to support older version 
     1188            structfactor_pos = int(state.structurecombobox) 
     1189        except: 
     1190            if state.structurecombobox is not None: 
     1191                state.structurecombobox = unicode(state.structurecombobox) 
     1192                for ind_struct in range(self.structurebox.GetCount()): 
     1193                    if self.structurebox.GetString(ind_struct) == \ 
     1194                                                    (state.structurecombobox): 
     1195                        structfactor_pos = int(ind_struct) 
     1196                        break 
    11911197 
    11921198        self.structurebox.SetSelection(structfactor_pos) 
     
    13361342    def _selectDlg(self): 
    13371343        """ 
    1338         open a dialog file to selected the customized dispersity 
     1344        open a dialog file to select the customized polydispersity function 
    13391345        """ 
    13401346        if self.parent is not None: 
     
    13781384        # self.state.struct_rbutton = self.struct_rbutton.GetValue() 
    13791385        # self.state.plugin_rbutton = self.plugin_rbutton.GetValue() 
    1380         self.state.structurecombobox = self.structurebox.GetValue() 
    1381         self.state.formfactorcombobox = self.formfactorbox.GetValue() 
    1382         self.state.categorycombobox = self.categorybox.GetValue() 
     1386        self.state.structurecombobox = self.structurebox.GetLabel() 
     1387        self.state.formfactorcombobox = self.formfactorbox.GetLabel() 
     1388        self.state.categorycombobox = self.categorybox.GetLabel() 
    13831389 
    13841390        # post state to fit panel 
     
    14511457                self.state_change = True 
    14521458                self._draw_model() 
     1459                # Time delay has been introduced to prevent _handle error 
     1460                # on Windows 
     1461                # This part of code is executed when model is selected and 
     1462                # it's parameters are changed (with respect to previously 
     1463                # selected model). There are two Iq evaluations occuring one 
     1464                # after another and therefore there may be compilation error 
     1465                # if model is calculated for the first time. 
     1466                # This seems to be Windows only issue - haven't tested on Linux 
     1467                # though.The proper solution (other than time delay) requires 
     1468                # more fundemental code refatoring 
     1469                # Wojtek P. Nov 7, 2016 
     1470                if not ON_MAC: 
     1471                    time.sleep(0.1) 
    14531472                self.Refresh() 
    14541473 
     
    15681587        if len(statelist) == 0 or len(listtorestore) == 0: 
    15691588            return 
     1589        if len(statelist) != len(listtorestore): 
     1590            return 
    15701591 
    15711592        for j in range(len(listtorestore)): 
    1572             for param in statelist: 
    1573                 if param[1] == listtorestore[j][1]: 
    1574                     item_page = listtorestore[j] 
    1575                     item_page_info = param 
    1576                     if (item_page_info[1] == "theta" or item_page_info[1] == 
    1577                             "phi") and not self._is_2D(): 
    1578                         break 
    1579                     # change the state of the check box for simple parameters 
    1580                     if item_page[0] is not None: 
    1581                         item_page[0].SetValue(item_page_info[0]) 
    1582                     if item_page[2] is not None: 
    1583                         item_page[2].SetValue(item_page_info[2]) 
    1584                         if item_page[2].__class__.__name__ == "ComboBox": 
    1585                             if item_page_info[2] in self.model.fun_list: 
    1586                                 fun_val = self.model.fun_list[item_page_info[2]] 
    1587                                 self.model.setParam(item_page_info[1], fun_val) 
    1588                     if item_page[3] is not None: 
    1589                         # show or hide text +/- 
    1590                         if item_page_info[2]: 
    1591                             item_page[3].Show(True) 
    1592                         else: 
    1593                             item_page[3].Hide() 
    1594                     if item_page[4] is not None: 
    1595                         # show of hide the text crtl for fitting error 
    1596                         if item_page_info[4][0]: 
    1597                             item_page[4].Show(True) 
    1598                             item_page[4].SetValue(str(item_page_info[4][1])) 
    1599                         else: 
    1600                             item_page[3].Hide() 
    1601                     if item_page[5] is not None: 
    1602                         # show of hide the text crtl for fitting error 
    1603                         item_page[5].Show(True) 
    1604                         item_page[5].SetValue(str(item_page_info[5][1])) 
    1605                     if item_page[6] is not None: 
    1606                         # show of hide the text crtl for fitting error 
    1607                         item_page[6].Show(True) 
    1608                         item_page[6].SetValue(str(item_page_info[6][1])) 
    1609                     break 
     1593            item_page = listtorestore[j] 
     1594            item_page_info = statelist[j] 
     1595            # change the state of the check box for simple parameters 
     1596            if item_page[0] is not None: 
     1597                item_page[0].SetValue(item_page_info[0]) 
     1598            if item_page[2] is not None: 
     1599                item_page[2].SetValue(item_page_info[2]) 
     1600                if item_page[2].__class__.__name__ == "ComboBox": 
     1601                    if item_page_info[2] in self.model.fun_list: 
     1602                        fun_val = self.model.fun_list[item_page_info[2]] 
     1603                        self.model.setParam(item_page_info[1], fun_val) 
     1604            if item_page[3] is not None: 
     1605                # show or hide text +/- 
     1606                if item_page_info[2]: 
     1607                    item_page[3].Show(True) 
     1608                else: 
     1609                    item_page[3].Hide() 
     1610            if item_page[4] is not None: 
     1611                # show of hide the text crtl for fitting error 
     1612                if item_page_info[4][0]: 
     1613                    item_page[4].Show(True) 
     1614                    item_page[4].SetValue(item_page_info[4][1]) 
     1615                else: 
     1616                    item_page[3].Hide() 
     1617            if item_page[5] is not None: 
     1618                # show of hide the text crtl for fitting error 
     1619                item_page[5].Show(item_page_info[5][0]) 
     1620                item_page[5].SetValue(item_page_info[5][1]) 
     1621 
     1622            if item_page[6] is not None: 
     1623                # show of hide the text crtl for fitting error 
     1624                item_page[6].Show(item_page_info[6][0]) 
     1625                item_page[6].SetValue(item_page_info[6][1]) 
    16101626 
    16111627    def _reset_strparam_state(self, listtorestore, statelist): 
     
    17481764    def _set_multfactor_combobox(self, multiplicity=10): 
    17491765        """ 
    1750         Set comboBox for muitfactor of CoreMultiShellModel 
     1766        Set comboBox for multitfactor of CoreMultiShellModel 
    17511767        :param multiplicit: no. of multi-functionality 
    17521768        """ 
     
    17861802        Fill panel's combo box according to the type of model selected 
    17871803        """ 
    1788         custom_model = 'Customized Models' 
     1804        custom_model = 'Plugin Models' 
    17891805        mod_cat = self.categorybox.GetStringSelection() 
    17901806        self.structurebox.SetSelection(0) 
     
    21292145                flag = False 
    21302146            else: 
    2131                 self.Npts_fit.SetValue(str(len(index_data[index_data is True]))) 
     2147                self.Npts_fit.SetValue(str(len(index_data[index_data]))) 
    21322148                self.fitrange = True 
    21332149 
     
    21642180                flag = False 
    21652181            else: 
    2166                 val = index_data[index_data is True] 
    2167                 val = len(val) if isinstance(val, list) else 1 
    2168                 self.Npts_fit.SetValue(str(val)) 
     2182                self.Npts_fit.SetValue(str(len(index_data[index_data]))) 
    21692183                self.fitrange = True 
    21702184 
     
    23902404 
    23912405        # Redraw the model 
    2392         self._draw_model() 
     2406        #  Wojtek P. Nov 7, 2016: Redrawing seems to be unnecessary here 
     2407        # self._draw_model() 
    23932408        # self._undo.Enable(True) 
    23942409        event = PageInfoEvent(page=self) 
     
    26092624            Layout after self._draw_model 
    26102625        """ 
    2611         if ON_MAC is True: 
     2626        if ON_MAC: 
    26122627            time.sleep(1) 
    26132628 
     
    34423457        fills out the category list box 
    34433458        """ 
    3444         uncat_str = 'Customized Models' 
     3459        uncat_str = 'Plugin Models' 
    34453460        self._read_category_info() 
    34463461 
     
    34713486        self.model_box.Clear() 
    34723487 
    3473         if category == 'Customized Models': 
     3488        if category == 'Plugin Models': 
    34743489            for model in self.model_list_box[category]: 
    34753490                str_m = str(model).split(".")[0] 
Note: See TracChangeset for help on using the changeset viewer.