Changes in src/sas/sasgui/perspectives/fitting/basepage.py [9e0aa69a:e92a352] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/basepage.py
r9e0aa69a re92a352 53 53 ON_MAC = True 54 54 55 56 55 class BasicPage(ScrolledPanel, PanelBase): 57 56 """ 58 This class provide general structure of fitpanel page57 This class provide general structure of the fitpanel page 59 58 """ 60 59 # Internal name for the AUI manager … … 678 677 def _copy_info(self, flag): 679 678 """ 680 Send event d pemding on flag681 682 : Param flag: flag that distinguish event679 Send event depending on flag 680 681 : Param flag: flag that distinguishes the event 683 682 """ 684 683 # messages depending on the flag … … 1042 1041 disp_model = POLYDISPERSITY_MODELS['array']() 1043 1042 if hasattr(state, "values") and \ 1044 self.disp_cb_dict[item].GetValue() is True:1043 self.disp_cb_dict[item].GetValue(): 1045 1044 if len(state.values) > 0: 1046 1045 self.values = state.values … … 1106 1105 """ 1107 1106 for key, value in self.master_category_dict.iteritems(): 1108 formfactor = state.formfactorcombobox.split(":")1109 if isinstance(formfactor, list):1110 formfactor = formfactor[0]1111 1107 for list_item in value: 1112 if formfactorin list_item:1108 if state.formfactorcombobox in list_item: 1113 1109 return self.categorybox.Items.index(key) 1114 1110 return 0 … … 1120 1116 :precondition: the page is already drawn or created 1121 1117 1122 :postcondition: the state of the underlying data change as well as the1118 :postcondition: the state of the underlying data changes as well as the 1123 1119 state of the graphic interface 1124 1120 """ … … 1156 1152 self._show_combox_helper() 1157 1153 # 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) 1166 1169 1167 1170 self.categorybox.Select(category_pos) 1168 1171 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 1180 1182 1181 1183 self.formfactorbox.Select(formfactor_pos) 1182 1184 1183 1185 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 1191 1197 1192 1198 self.structurebox.SetSelection(structfactor_pos) … … 1336 1342 def _selectDlg(self): 1337 1343 """ 1338 open a dialog file to select ed the customized dispersity1344 open a dialog file to select the customized polydispersity function 1339 1345 """ 1340 1346 if self.parent is not None: … … 1378 1384 # self.state.struct_rbutton = self.struct_rbutton.GetValue() 1379 1385 # self.state.plugin_rbutton = self.plugin_rbutton.GetValue() 1380 self.state.structurecombobox = self.structurebox.Get Value()1381 self.state.formfactorcombobox = self.formfactorbox.Get Value()1382 self.state.categorycombobox = self.categorybox.Get Value()1386 self.state.structurecombobox = self.structurebox.GetLabel() 1387 self.state.formfactorcombobox = self.formfactorbox.GetLabel() 1388 self.state.categorycombobox = self.categorybox.GetLabel() 1383 1389 1384 1390 # post state to fit panel … … 1451 1457 self.state_change = True 1452 1458 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) 1453 1472 self.Refresh() 1454 1473 … … 1568 1587 if len(statelist) == 0 or len(listtorestore) == 0: 1569 1588 return 1589 if len(statelist) != len(listtorestore): 1590 return 1570 1591 1571 1592 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]) 1610 1626 1611 1627 def _reset_strparam_state(self, listtorestore, statelist): … … 1748 1764 def _set_multfactor_combobox(self, multiplicity=10): 1749 1765 """ 1750 Set comboBox for mu itfactor of CoreMultiShellModel1766 Set comboBox for multitfactor of CoreMultiShellModel 1751 1767 :param multiplicit: no. of multi-functionality 1752 1768 """ … … 1786 1802 Fill panel's combo box according to the type of model selected 1787 1803 """ 1788 custom_model = ' CustomizedModels'1804 custom_model = 'Plugin Models' 1789 1805 mod_cat = self.categorybox.GetStringSelection() 1790 1806 self.structurebox.SetSelection(0) … … 2129 2145 flag = False 2130 2146 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]))) 2132 2148 self.fitrange = True 2133 2149 … … 2164 2180 flag = False 2165 2181 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]))) 2169 2183 self.fitrange = True 2170 2184 … … 2390 2404 2391 2405 # Redraw the model 2392 self._draw_model() 2406 # Wojtek P. Nov 7, 2016: Redrawing seems to be unnecessary here 2407 # self._draw_model() 2393 2408 # self._undo.Enable(True) 2394 2409 event = PageInfoEvent(page=self) … … 2609 2624 Layout after self._draw_model 2610 2625 """ 2611 if ON_MAC is True:2626 if ON_MAC: 2612 2627 time.sleep(1) 2613 2628 … … 3442 3457 fills out the category list box 3443 3458 """ 3444 uncat_str = ' CustomizedModels'3459 uncat_str = 'Plugin Models' 3445 3460 self._read_category_info() 3446 3461 … … 3471 3486 self.model_box.Clear() 3472 3487 3473 if category == ' CustomizedModels':3488 if category == 'Plugin Models': 3474 3489 for model in self.model_list_box[category]: 3475 3490 str_m = str(model).split(".")[0]
Note: See TracChangeset
for help on using the changeset viewer.