Changeset ea5fa58 in sasview for fittingview/src
- Timestamp:
- Sep 20, 2012 1:22:02 PM (12 years ago)
- 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:
- bda809e
- Parents:
- b71a53b
- Location:
- fittingview/src/sans/perspectives/fitting
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
fittingview/src/sans/perspectives/fitting/basepage.py
rdf7a7e3 rea5fa58 2 2 Base Page for fitting 3 3 """ 4 5 4 import sys 6 5 import os … … 27 26 from sans.perspectives.fitting.pagestate import PageState 28 27 from sans.guiframe.CategoryInstaller import CategoryInstaller 29 30 31 28 32 29 (PageInfoEvent, EVT_PAGE_INFO) = wx.lib.newevent.NewEvent() … … 137 134 self.sld_axes = None 138 135 self.multi_factor = None 139 self.model_name = None140 self.model_dict = {}141 136 142 137 self.disp_cb_dict = {} … … 155 150 self.formfactorbox = None 156 151 self.structurebox = None 152 self.categorybox = None 157 153 ##list of model parameters. each item must have same length 158 154 ## each item related to a given parameters … … 170 166 self.disp_list = [] 171 167 self.disp_name = "" 172 173 ## category stuff174 self.category_box = None175 self.model_box = None176 168 177 169 ## list of orientation parameters … … 226 218 ## layout 227 219 self.set_layout() 228 229 230 220 231 221 def set_index_model(self, index): … … 474 464 self.model_list_box = page_info.model_list_box 475 465 ## Data member to store the dispersion object created 476 466 self.populate_box(dict=self.model_list_box) 477 467 478 468 def onContextMenu(self, event): … … 577 567 self.state.manager = manager 578 568 579 def populate_box(self, m_dict):569 def populate_box(self, dict): 580 570 """ 581 571 Store list of model … … 584 574 585 575 """ 586 self.model_list_box = m_dict587 #self.state.model_list_box = self.model_list_box588 #self.initialize_combox()576 self.model_list_box = dict 577 self.state.model_list_box = self.model_list_box 578 self.initialize_combox() 589 579 590 580 def set_model_dictionary(self, model_dict): … … 603 593 if self.model_list_box is None: 604 594 return 595 if len(self.model_list_box) > 0: 596 self._populate_box(self.formfactorbox, 597 self.model_list_box["Shapes"]) 605 598 606 599 if len(self.model_list_box) > 0: … … 901 894 self.state.structurecombobox = self.structurebox.\ 902 895 GetString(s_select) 903 # if self.formfactorbox != None: 904 # f_select = self.formfactorbox.GetSelection() 905 # if f_select > 0: 906 self.state.formfactorcombobox = \ 907 self.model_box.GetStringSelection() 908 896 if self.formfactorbox != None: 897 f_select = self.formfactorbox.GetSelection() 898 if f_select > 0: 899 self.state.formfactorcombobox = self.formfactorbox.\ 900 GetString(f_select) 901 if self.categorybox != None: 902 cb_select = self.categorybox.GetSelection() 903 if cb_select > 0: 904 self.state.categorycombobox = self.categorybox.\ 905 GetString(cb_select) 909 906 #save radiobutton state for model selection 910 # ILL 911 # self.state.shape_rbutton = self.shape_rbutton.GetValue() 912 # self.state.shape_indep_rbutton = self.shape_indep_rbutton.GetValue() 913 # self.state.struct_rbutton = self.struct_rbutton.GetValue() 914 # self.state.plugin_rbutton = self.plugin_rbutton.GetValue() 907 #self.state.shape_rbutton = self.shape_rbutton.GetValue() 908 #self.state.shape_indep_rbutton = self.shape_indep_rbutton.GetValue() 909 #self.state.struct_rbutton = self.struct_rbutton.GetValue() 910 #self.state.plugin_rbutton = self.plugin_rbutton.GetValue() 915 911 916 912 self.state.enable2D = copy.deepcopy(self.enable2D) … … 1061 1057 self.disp_list = state.disp_list 1062 1058 1059 ## set the state of the radio box 1060 #self.shape_rbutton.SetValue(state.shape_rbutton) 1061 #self.shape_indep_rbutton.SetValue(state.shape_indep_rbutton) 1062 #self.struct_rbutton.SetValue(state.struct_rbutton) 1063 #self.plugin_rbutton.SetValue(state.plugin_rbutton) 1064 1065 ## fill model combobox 1063 1066 self._show_combox_helper() 1064 1065 # select the model in the gui 1066 self._regenerate_model_dict() 1067 if(len(self.by_model_dict[state.formfactorcombobox]) == 0): 1068 self.category_box.SetStringSelection('Uncategorized') 1069 self.model_box.SetStringSelection(state.formfactorcombobox) 1070 else: 1071 self.category_box.SetStringSelection(\ 1072 self.by_model_dict[state.formfactorcombobox][0] ) 1073 self.model_box.SetStringSelection(state.formfactorcombobox) 1074 1075 1067 #select the current model 1068 try: 1069 # to support older version 1070 category_pos = int(state.categorycombobox) 1071 except: 1072 category_pos = 0 1073 for ind_cat in range(self.categorybox.GetCount()): 1074 if self.categorycombobox.GetString(ind_form) == \ 1075 state.categorycombobox: 1076 category_pos = int(ind_cat) 1077 break 1078 1079 self.categorybox.Select(category_pos) 1080 try: 1081 # to support older version 1082 formfactor_pos = int(state.formfactorcombobox) 1083 except: 1084 formfactor_pos = 0 1085 for ind_form in range(self.formfactorbox.GetCount()): 1086 if self.formfactorbox.GetString(ind_form) == \ 1087 state.formfactorcombobox: 1088 formfactor_pos = int(ind_form) 1089 break 1090 1091 self.formfactorbox.Select(formfactor_pos) 1092 1076 1093 try: 1077 1094 # to support older version … … 1118 1135 state.disp_cb_dict[item]) 1119 1136 # Create the dispersion objects 1120 from sans.models.dispersion_models \ 1121 import ArrayDispersion 1137 from sans.models.dispersion_models import ArrayDispersion 1122 1138 disp_model = ArrayDispersion() 1123 1139 if hasattr(state, "values") and \ … … 1218 1234 self.disp_list = state.disp_list 1219 1235 1236 ## set the state of the radio box 1237 #self.shape_rbutton.SetValue(state.shape_rbutton) 1238 #self.shape_indep_rbutton.SetValue(state.shape_indep_rbutton) 1239 #self.struct_rbutton.SetValue(state.struct_rbutton) 1240 #self.plugin_rbutton.SetValue(state.plugin_rbutton) 1220 1241 1221 1242 ## fill model combobox 1222 1243 self._show_combox_helper() 1223 1244 #select the current model 1224 1225 1226 self._regenerate_model_dict() 1227 if(len(self.by_model_dict[state.formfactorcombobox]) == 0): 1228 self.category_box.SetStringSelection('Uncategorized') 1229 self.model_box.SetStringSelection(state.formfactorcombobox) 1230 else: 1231 self.category_box.SetStringSelection(\ 1232 self.by_model_dict[state.formfactorcombobox][0] ) 1233 self.model_box.SetStringSelection(state.formfactorcombobox) 1234 1245 try: 1246 # to support older version 1247 category_pos = int(state.categorycombobox) 1248 except: 1249 category_pos = 0 1250 for ind_cat in range(self.categorybox.GetCount()): 1251 if self.categorybox.GetString(ind_cat) == \ 1252 state.categorycombobox: 1253 category_pos = int(ind_cat) 1254 break 1255 1256 self.categorybox.Select(category_pos) 1257 self._show_combox(None) 1258 try: 1259 # to support older version 1260 formfactor_pos = int(state.formfactorcombobox) 1261 except: 1262 formfactor_pos = 0 1263 for ind_form in range(self.formfactorbox.GetCount()): 1264 if self.formfactorbox.GetString(ind_form) == \ 1265 (state.formfactorcombobox): 1266 formfactor_pos = int(ind_form) 1267 break 1268 1269 self.formfactorbox.Select(formfactor_pos) 1270 1235 1271 try: 1236 1272 # to support older version … … 1432 1468 save radiobutton containing the type model that can be selected 1433 1469 """ 1434 # 1435 # 1436 # 1437 # 1470 #self.state.shape_rbutton = self.shape_rbutton.GetValue() 1471 #self.state.shape_indep_rbutton = self.shape_indep_rbutton.GetValue() 1472 #self.state.struct_rbutton = self.struct_rbutton.GetValue() 1473 #self.state.plugin_rbutton = self.plugin_rbutton.GetValue() 1438 1474 self.state.structurecombobox = self.structurebox.GetLabel() 1439 self.state.formfactorcombobox = self.model_box.GetStringSelection() 1475 self.state.formfactorcombobox = self.formfactorbox.GetLabel() 1476 self.state.categorycombobox = self.categorybox.GetLabel() 1440 1477 1441 1478 ## post state to fit panel … … 1772 1809 class_name = model.p_model.__class__ 1773 1810 name = model.p_model.name 1774 #self.formfactorbox.Clear()1811 self.formfactorbox.Clear() 1775 1812 1776 1813 for k, list in self.model_list_box.iteritems(): 1777 1814 if k in["P(Q)*S(Q)", "Shapes"] and \ 1778 1815 class_name in self.model_list_box["Shapes"]: 1779 #self.shape_rbutton.SetValue(True)1816 self.shape_rbutton.SetValue(True) 1780 1817 ## fill the form factor list with new model 1781 #self._populate_box(self.formfactorbox,1782 #self.model_list_box["Shapes"])1783 #items = self.formfactorbox.GetItems()1784 # ## set comboxbox to the selected item1785 #for i in range(len(items)):1786 #if items[i] == str(name):1787 #self.formfactorbox.SetSelection(i)1788 #break1818 self._populate_box(self.formfactorbox, 1819 self.model_list_box["Shapes"]) 1820 items = self.formfactorbox.GetItems() 1821 ## set comboxbox to the selected item 1822 for i in range(len(items)): 1823 if items[i] == str(name): 1824 self.formfactorbox.SetSelection(i) 1825 break 1789 1826 return 1790 #elif k == "Shape-Independent":1791 #self.shape_indep_rbutton.SetValue(True)1792 #elif k == "Structure Factors":1793 #self.struct_rbutton.SetValue(True)1794 #elif k == "Multi-Functions":1795 #continue1796 #else:1797 #self.plugin_rbutton.SetValue(True)1827 elif k == "Shape-Independent": 1828 self.shape_indep_rbutton.SetValue(True) 1829 elif k == "Structure Factors": 1830 self.struct_rbutton.SetValue(True) 1831 elif k == "Multi-Functions": 1832 continue 1833 else: 1834 self.plugin_rbutton.SetValue(True) 1798 1835 1799 #if class_name in list:1800 # ### fill the form factor list with new model1801 # #self._populate_box(self.formfactorbox, list)1802 # #items = self.formfactorbox.GetItems()1803 # ### set comboxbox to the selected item1804 # #for i in range(len(items)):1805 # #if items[i] == str(name):1806 # #self.formfactorbox.SetSelection(i)1807 # #break1808 # #break1809 #else:1836 if class_name in list: 1837 ## fill the form factor list with new model 1838 self._populate_box(self.formfactorbox, list) 1839 items = self.formfactorbox.GetItems() 1840 ## set comboxbox to the selected item 1841 for i in range(len(items)): 1842 if items[i] == str(name): 1843 self.formfactorbox.SetSelection(i) 1844 break 1845 break 1846 else: 1810 1847 ## Select the model from the menu 1811 1848 class_name = model.__class__ 1812 1849 name = model.name 1813 ##self.formfactorbox.Clear()1814 #items = self.formfactorbox.GetItems()1850 self.formfactorbox.Clear() 1851 items = self.formfactorbox.GetItems() 1815 1852 1816 1853 for k, list in self.model_list_box.iteritems(): … … 1830 1867 self.text2.Disable() 1831 1868 1832 #self.shape_rbutton.SetValue(True)1869 self.shape_rbutton.SetValue(True) 1833 1870 ## fill the form factor list with new model 1834 #self._populate_box(self.formfactorbox,1835 #self.model_list_box["Shapes"])1836 #items = self.formfactorbox.GetItems()1837 # ## set comboxbox to the selected item1838 #for i in range(len(items)):1839 #if items[i] == str(name):1840 #self.formfactorbox.SetSelection(i)1841 #break1871 self._populate_box(self.formfactorbox, 1872 self.model_list_box["Shapes"]) 1873 items = self.formfactorbox.GetItems() 1874 ## set comboxbox to the selected item 1875 for i in range(len(items)): 1876 if items[i] == str(name): 1877 self.formfactorbox.SetSelection(i) 1878 break 1842 1879 return 1843 #elif k == "Shape-Independent":1844 #self.shape_indep_rbutton.SetValue(True)1845 #elif k == "Structure Factors":1846 #self.struct_rbutton.SetValue(True)1847 #elif k == "Multi-Functions":1848 #continue1849 #else:1850 #self.plugin_rbutton.SetValue(True)1880 elif k == "Shape-Independent": 1881 self.shape_indep_rbutton.SetValue(True) 1882 elif k == "Structure Factors": 1883 self.struct_rbutton.SetValue(True) 1884 elif k == "Multi-Functions": 1885 continue 1886 else: 1887 self.plugin_rbutton.SetValue(True) 1851 1888 if class_name in list: 1852 1889 self.structurebox.SetSelection(0) … … 1854 1891 self.text2.Disable() 1855 1892 ## fill the form factor list with new model 1856 #self._populate_box(self.formfactorbox, list)1857 #items = self.formfactorbox.GetItems()1893 self._populate_box(self.formfactorbox, list) 1894 items = self.formfactorbox.GetItems() 1858 1895 ## set comboxbox to the selected item 1859 #for i in range(len(items)):1860 #if items[i] == str(name):1861 #self.formfactorbox.SetSelection(i)1862 #break1896 for i in range(len(items)): 1897 if items[i] == str(name): 1898 self.formfactorbox.SetSelection(i) 1899 break 1863 1900 break 1864 1901 … … 1953 1990 if self.multifactorbox.IsShown(): 1954 1991 self.multifactorbox.Hide() 1955 1992 1993 def formfactor_combo_init(self): 1994 """ 1995 First time calls _show_combox_helper 1996 """ 1997 self._show_combox(None) 1998 1956 1999 def _show_combox_helper(self): 1957 2000 """ 1958 2001 Fill panel's combo box according to the type of model selected 1959 2002 """ 1960 # if self.shape_rbutton.GetValue(): 1961 # ##fill the combobox with form factor list 1962 #self.structurebox.SetSelection(0)1963 #self.structurebox.Disable()1964 # #self.formfactorbox.Clear()1965 # # self._populate_box(self.formfactorbox, 1966 # # self.model_list_box["Shapes"]) 1967 # if self.shape_indep_rbutton.GetValue(): 1968 # ##fill the combobox with shape independent factor list 1969 # self.structurebox.SetSelection(0) 1970 # self.structurebox.Disable() 1971 # # self.formfactorbox.Clear() 1972 # self._populate_box(self.formfactorbox, 1973 # self.model_list_box["Shape-Independent"])1974 # if self.struct_rbutton.GetValue():1975 # ##fill the combobox with structure factor list 1976 # self.structurebox.SetSelection(0) 1977 # self.structurebox.Disable()1978 # # self.formfactorbox.Clear() 1979 # self._populate_box(self.formfactorbox, 1980 # self.model_list_box["Structure Factors"]) 1981 # if self.plugin_rbutton.GetValue(): 1982 # ##fill the combobox with form factor list 1983 # self.structurebox.Disable()1984 # # self.formfactorbox.Clear() 1985 # self._populate_box(self.formfactorbox, 1986 # self.model_list_box["Customized Models"])2003 custom_model = 'Customized Models' 2004 mod_cat = self.categorybox.GetStringSelection() 2005 self.structurebox.SetSelection(0) 2006 self.structurebox.Disable() 2007 self.formfactorbox.Clear() 2008 if mod_cat == None: 2009 return 2010 m_list = [] 2011 try: 2012 if mod_cat == custom_model: 2013 for model in self.model_list_box[mod_cat]: 2014 str_m = str(model).split(".")[0] 2015 #self.model_box.Append(str_m) 2016 m_list.append(self.model_dict[str_m]) 2017 else: 2018 for (model, enabled) in self.master_category_dict[mod_cat]: 2019 if enabled: 2020 m_list.append(self.model_dict[model]) 2021 else: 2022 msg = "This model is diabled by Category Manager." 2023 wx.PostEvent(self.parent.parent, 2024 StatusEvent(status=msg, info="error")) 2025 except: 2026 msg = "%s\n" % (sys.exc_value) 2027 wx.PostEvent(self.parent.parent, 2028 StatusEvent(status=msg, info="error")) 2029 self._populate_box(self.formfactorbox, m_list) 1987 2030 1988 2031 def _show_combox(self, event=None): … … 2000 2043 self.Refresh() 2001 2044 2002 def _populate_box(self, combobox, model_list):2045 def _populate_box(self, combobox, list): 2003 2046 """ 2004 2047 fill combox box with dict item … … 2008 2051 """ 2009 2052 mlist = [] 2010 for models in model_list:2053 for models in list: 2011 2054 model = models() 2012 2055 name = model.__class__.__name__ … … 2139 2182 """ 2140 2183 ## reset dictionary containing reference to dispersion 2141 if self.model_name == None:2142 return2143 2144 2184 self._disp_obj_dict = {} 2145 2185 self.disp_cb_dict = {} 2146 2186 self.temp_multi_functional = False 2147 2148 form_factor = self.model_dict[self.model_name] 2187 f_id = self.formfactorbox.GetCurrentSelection() 2188 #For MAC 2189 form_factor = None 2190 if f_id >= 0: 2191 form_factor = self.formfactorbox.GetClientData(f_id) 2149 2192 2150 2193 if not form_factor in self.model_list_box["multiplication"]: … … 2160 2203 self.text2.Enable() 2161 2204 2162 2163 2164 2205 if form_factor != None: 2165 2206 # set multifactor for Mutifunctional models … … 2339 2380 return flag 2340 2381 2341 def _check_value_enter(self, m_list, modified):2342 """ 2343 :param m_list: model parameter and panel info2344 :Note: each item of the m_list should be as follow:2382 def _check_value_enter(self, list, modified): 2383 """ 2384 :param list: model parameter and panel info 2385 :Note: each item of the list should be as follow: 2345 2386 item=[check button state, parameter's name, 2346 2387 paramater's value, string="+/-", … … 2351 2392 """ 2352 2393 is_modified = modified 2353 if len( m_list) == 0:2394 if len(list) == 0: 2354 2395 return is_modified 2355 for item in m_list:2396 for item in list: 2356 2397 #skip angle parameters for 1D 2357 2398 if not self.enable2D: … … 2903 2944 if self.model == None: 2904 2945 name = 'FuncHelp' 2905 2946 else: 2947 name = self.formfactorbox.GetValue() 2906 2948 frame = HelpWindow(None, -1, pageToOpen=model_path) 2907 # If model name exists and model is not a custom model2908 # if frame.rhelp.HasAnchor(name) and not self.plugin_rbutton.GetValue():2909 # frame.Show(True)2910 # frame.rhelp.ScrollToAnchor(name)2911 # else:2912 # if self.model != None:2913 # frame.Destroy()2914 # msg = 'Model description:\n'2915 # if str(self.model.description).rstrip().lstrip() == '':2916 # msg += "Sorry, no information is available for this model."2917 # else:2918 # msg += self.model.description + '\n'2919 # info = "Info"2920 # wx.MessageBox(msg, info)2921 # else:2922 # frame.Show(True) 2923 2949 if frame.rhelp.HasAnchor(name): 2950 frame.Show(True) 2951 frame.rhelp.ScrollToAnchor(name) 2952 else: 2953 if self.model != None: 2954 frame.Destroy() 2955 msg = 'Model description:\n' 2956 if str(self.model.description).rstrip().lstrip() == '': 2957 msg += "Sorry, no information is available for this model." 2958 else: 2959 msg += self.model.description + '\n' 2960 info = "Info" 2961 wx.MessageBox(msg, info) 2962 else: 2963 frame.Show(True) 2964 2965 2924 2966 def on_pd_help_clicked(self, event): 2925 2967 """ … … 3297 3339 return 3298 3340 3341 3342 3343 3299 3344 def _read_category_info(self): 3300 3345 """ … … 3307 3352 self.model_enabled_dict = defaultdict(bool) 3308 3353 3309 categorization_file = CategoryInstaller.get_user_file()3310 3311 3312 3354 try: 3355 categorization_file = CategoryInstaller.get_user_file() 3356 if not os.path.isfile(categorization_file): 3357 categorization_file = CategoryInstaller.get_default_file() 3313 3358 cat_file = open(categorization_file, 'rb') 3314 3359 … … 3317 3362 3318 3363 except IOError: 3364 raise 3319 3365 print 'Problem reading in category file.' 3320 3366 print 'We even looked for it, made sure it was there.' … … 3330 3376 self.by_model_dict = defaultdict(list) 3331 3377 for category in self.master_category_dict: 3332 for (model, enabled) in self.master_category_dict[category]:3378 for (model, enabled) in self.master_category_dict[category]: 3333 3379 self.by_model_dict[model].append(category) 3334 3380 self.model_enabled_dict[model] = enabled … … 3338 3384 fills out the category list box 3339 3385 """ 3386 uncat_str = 'Customized Models' 3340 3387 self._read_category_info() 3341 3388 3342 self.category _box.Clear()3389 self.categorybox.Clear() 3343 3390 cat_list = sorted(self.master_category_dict.keys()) 3344 cat_list.append('Customized') 3345 3391 if not uncat_str in cat_list: 3392 cat_list.append(uncat_str) 3393 3346 3394 for category in cat_list: 3347 3395 if category != '': 3348 self.category _box.Append(category)3349 3350 if self.category _box.GetSelection() == wx.NOT_FOUND:3351 self.category _box.SetSelection(0)3396 self.categorybox.Append(category) 3397 3398 if self.categorybox.GetSelection() == wx.NOT_FOUND: 3399 self.categorybox.SetSelection(0) 3352 3400 else: 3353 self.category _box.SetSelection( \3354 self.category _box.GetSelection())3355 3356 self._on_change_cat(None)3401 self.categorybox.SetSelection( \ 3402 self.categorybox.GetSelection()) 3403 3404 #self._on_change_cat(None) 3357 3405 3358 3406 … … 3362 3410 """ 3363 3411 self.model_name = None 3364 category = self.category _box.GetStringSelection()3412 category = self.categorybox.GetStringSelection() 3365 3413 if category == None: 3366 3414 return 3367 3415 self.model_box.Clear() 3368 3416 3369 if category == 'Customized ':3370 for model in self.model_list_box[ "Customized Models"]:3417 if category == 'Customized Models': 3418 for model in self.model_list_box[category]: 3371 3419 str_m = str(model).split(".")[0] 3372 3420 self.model_box.Append(str_m) … … 3379 3427 self.model_box.Append(model) 3380 3428 3429 3430 3431 3381 3432 def _fill_model_sizer(self, sizer): 3382 3433 """ 3383 3434 fill sizer containing model info 3384 3435 """ 3385 3386 3436 ##Add model function Details button in fitpanel. 3387 3437 ##The following 3 lines are for Mac. Let JHC know before modifying... … … 3391 3441 self.mbox_description = wx.StaticBox(self, -1, str(title)) 3392 3442 boxsizer1 = wx.StaticBoxSizer(self.mbox_description, wx.VERTICAL) 3443 sizer_cat = wx.BoxSizer(wx.HORIZONTAL) 3393 3444 self.mbox_description.SetForegroundColour(wx.RED) 3394 3445 id = wx.NewId() … … 3401 3452 hint = "toggle view of model from 1D to 2D or 2D to 1D" 3402 3453 self.model_view.SetToolTipString(hint) 3403 3404 3405 # ILL mod starts here - Aug 2012 3406 3407 3408 cat_text = wx.StaticText(self, -1, 'Category') 3409 mod_text = wx.StaticText(self, -1, 'Model') 3410 3411 id = wx.NewId() 3412 self.category_box = wx.ListBox(self, size=(150, 100)) 3413 self.category_box.Bind(wx.EVT_LISTBOX, self._on_change_cat) 3414 self.model_box = wx.ListBox(self, -1, size=(150, 100)) 3415 self.model_box.Bind(wx.EVT_LISTBOX, self._on_select_model) 3416 3417 sizer_radiobutton = wx.GridSizer(2, 3, 5, 5) 3418 hbox1 = wx.BoxSizer(wx.HORIZONTAL) 3419 hbox2 = wx.BoxSizer(wx.HORIZONTAL) 3420 vbox1 = wx.BoxSizer(wx.VERTICAL) 3421 vbox2 = wx.BoxSizer(wx.VERTICAL) 3422 vbox3 = wx.BoxSizer(wx.VERTICAL) 3423 3424 vbox1.Add(cat_text, border = 5, flag = wx.EXPAND | wx.ALL) 3425 vbox2.Add(mod_text, border=5, flag = wx.EXPAND | wx.ALL) 3426 vbox3.Add(self.model_view, flag= wx.ALL | wx.ALIGN_LEFT 3427 , border =5) 3428 vbox1.Add(self.category_box, border = 5, flag = wx.EXPAND | wx.ALL) 3429 vbox2.Add(self.model_box, flag = wx.EXPAND | wx.ALL, border = 5) 3430 vbox3.Add(self.model_help, border = 5, 3431 flag = wx.LEFT | wx.ALIGN_LEFT ) 3432 3433 hbox1.Add(vbox1, border = 5, flag = wx.EXPAND | wx.ALL) 3434 hbox1.Add(vbox2, border = 5, flag = wx.EXPAND | wx.ALL) 3435 hbox1.Add(vbox3, border = 5, flag = wx.EXPAND | wx.ALL) 3436 3454 3455 cat_set_box = wx.StaticBox(self, -1, 'Category') 3456 sizer_cat_box = wx.StaticBoxSizer(cat_set_box, wx.HORIZONTAL) 3457 sizer_cat_box.SetMinSize((200, 50)) 3458 self.categorybox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 3459 self._populate_listbox() 3460 wx.EVT_COMBOBOX(self.categorybox, -1, self._show_combox) 3461 #self.shape_rbutton = wx.RadioButton(self, -1, 'Shapes', 3462 # style=wx.RB_GROUP) 3463 #self.shape_indep_rbutton = wx.RadioButton(self, -1, 3464 # "Shape-Independent") 3465 #self.struct_rbutton = wx.RadioButton(self, -1, "Structure Factor ") 3466 #self.plugin_rbutton = wx.RadioButton(self, -1, "Uncategorized") 3467 3468 #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 3469 # id=self.shape_rbutton.GetId()) 3470 #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 3471 # id=self.shape_indep_rbutton.GetId()) 3472 #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 3473 # id=self.struct_rbutton.GetId()) 3474 #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 3475 # id=self.plugin_rbutton.GetId()) 3476 #MAC needs SetValue 3477 sizer_cat_box.Add(self.categorybox, 1, wx.LEFT|wx.RIGHT|wx.EXPAND, 2.5) 3478 #self.shape_rbutton.SetValue(True) 3479 3480 sizer_radiobutton = wx.GridSizer(2, 2, 5, 5) 3481 3482 #sizer_radiobutton.Add(self.shape_rbutton) 3483 #sizer_radiobutton.Add(self.shape_indep_rbutton) 3484 sizer_radiobutton.Add((5,5)) 3485 sizer_radiobutton.Add(self.model_view, 1, wx.RIGHT, 15) 3486 #sizer_radiobutton.Add(self.plugin_rbutton) 3487 #sizer_radiobutton.Add(self.struct_rbutton) 3488 sizer_radiobutton.Add((5,5)) 3489 sizer_radiobutton.Add(self.model_help, 1, wx.RIGHT, 15) 3490 sizer_cat.Add(sizer_cat_box, 1, wx.LEFT, 2.5) 3491 sizer_cat.Add(sizer_radiobutton) 3437 3492 sizer_selection = wx.BoxSizer(wx.HORIZONTAL) 3438 3493 mutifactor_selection = wx.BoxSizer(wx.HORIZONTAL) 3439 3494 3440 3495 self.text1 = wx.StaticText(self, -1, "") 3441 self.text2 = wx.StaticText(self, -1, "P(Q)*S(Q) 3496 self.text2 = wx.StaticText(self, -1, "P(Q)*S(Q)") 3442 3497 self.mutifactor_text = wx.StaticText(self, -1, "No. of Shells: ") 3443 3498 self.mutifactor_text1 = wx.StaticText(self, -1, "") … … 3445 3500 self.show_sld_button.Bind(wx.EVT_BUTTON, self._on_show_sld) 3446 3501 3502 self.formfactorbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 3503 if self.model != None: 3504 self.formfactorbox.SetValue(self.model.name) 3447 3505 self.structurebox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 3448 3506 self.multifactorbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 3449 3507 self.initialize_combox() 3508 wx.EVT_COMBOBOX(self.formfactorbox, -1, self._on_select_model) 3450 3509 3451 3510 wx.EVT_COMBOBOX(self.structurebox, -1, self._on_select_model) 3452 3511 wx.EVT_COMBOBOX(self.multifactorbox, -1, self._on_select_model) 3453 3512 ## check model type to show sizer 3454 3455 hbox2.Add(self.text2, border = 5, flag = wx.EXPAND | wx.ALL )3456 hbox2.Add(self.structurebox, border = 5, flag = wx.EXPAND | \3457 wx.ALL )3458 3459 3513 if self.model != None: 3460 self._set_model_sizer_selection(self.model) 3461 3462 self._populate_listbox() 3463 3514 print "_set_model_sizer_selection: disabled." 3515 #self._set_model_sizer_selection(self.model) 3516 3517 sizer_selection.Add(self.text1) 3518 sizer_selection.Add((10, 5)) 3519 sizer_selection.Add(self.formfactorbox) 3520 sizer_selection.Add((5, 5)) 3521 sizer_selection.Add(self.text2) 3522 sizer_selection.Add((5, 5)) 3523 sizer_selection.Add(self.structurebox) 3464 3524 3465 mutifactor_selection.Add((1 0, 5))3525 mutifactor_selection.Add((13, 5)) 3466 3526 mutifactor_selection.Add(self.mutifactor_text) 3467 3527 mutifactor_selection.Add(self.multifactorbox) … … 3471 3531 mutifactor_selection.Add(self.show_sld_button) 3472 3532 3473 boxsizer1.Add(hbox1, flag = wx.EXPAND) 3474 boxsizer1.Add(hbox2, flag = wx.EXPAND) 3533 boxsizer1.Add(sizer_cat) 3475 3534 boxsizer1.Add((10, 10)) 3476 3535 boxsizer1.Add(sizer_selection) 3536 boxsizer1.Add((10, 10)) 3477 3537 boxsizer1.Add(mutifactor_selection) 3478 3538 -
fittingview/src/sans/perspectives/fitting/fitpage.py
rdf7a7e3 rea5fa58 36 36 """ 37 37 38 def __init__(self, parent, m_dict,color='rand'):38 def __init__(self, parent, color='rand'): 39 39 """ 40 40 Initialization of the Panel 41 41 """ 42 42 BasicPage.__init__(self, parent, color=color) 43 self.populate_box(m_dict) 44 43 45 44 ## draw sizer 46 45 self._fill_data_sizer() … … 68 67 #create a default data for an empty panel 69 68 self.create_default_data() 70 69 71 70 def enable_fit_button(self): 72 71 """ … … 1088 1087 call back for model selection 1089 1088 """ 1090 # if we're just clearing the box then do nothing1091 if self.model_box.GetCount() == 0 or \1092 self.model_box.GetStringSelection() == '':1093 return1094 1095 1096 1089 self.Show(False) 1097 1090 copy_flag = False 1098 1091 is_poly_enabled = None 1099 1092 if event != None: 1100 # if (event.GetEventObject() == self.formfactorbox\ 1101 # and self.structurebox.GetLabel() != 'None')\ 1102 # or event.GetEventObject() == self.structurebox\ 1103 # or event.GetEventObject() == self.multifactorbox: 1104 copy_flag = self.get_copy_params() 1105 is_poly_enabled = self.enable_disp.GetValue() 1106 1107 self.model_name = self.model_box.GetStringSelection() 1093 if (event.GetEventObject() == self.formfactorbox\ 1094 and self.structurebox.GetLabel() != 'None')\ 1095 or event.GetEventObject() == self.structurebox\ 1096 or event.GetEventObject() == self.multifactorbox: 1097 copy_flag = self.get_copy_params() 1098 is_poly_enabled = self.enable_disp.GetValue() 1099 1108 1100 self._on_select_model_helper() 1109 1101 self.set_model_param_sizer(self.model) … … 1124 1116 1125 1117 self.state.structurecombobox = self.structurebox.GetLabel() 1126 self.state.formfactorcombobox = self. model_box.GetStringSelection()1118 self.state.formfactorcombobox = self.formfactorbox.GetLabel() 1127 1119 self.enable_fit_button() 1128 1120 if self.model != None: … … 1183 1175 wx.PostEvent(self.parent, new_event) 1184 1176 #update list of plugins if new plugin is available 1185 # if self.plugin_rbutton.GetValue(): 1186 # temp = self.parent.update_model_list() 1187 # if temp: 1188 # self.model_list_box = temp 1189 # current_val = self.formfactorbox.GetLabel() 1190 # pos = self.formfactorbox.GetSelection() 1191 # self._show_combox_helper() 1192 # self.formfactorbox.SetSelection(pos) 1193 # self.formfactorbox.SetValue(current_val) 1177 custom_model = 'Customized Models' 1178 mod_cat = self.categorybox.GetStringSelection() 1179 if mod_cat == custom_model: 1180 temp = self.parent.update_model_list() 1181 if temp: 1182 self.model_list_box = temp 1183 current_val = self.formfactorbox.GetLabel() 1184 pos = self.formfactorbox.GetSelection() 1185 self._show_combox_helper() 1186 self.formfactorbox.SetSelection(pos) 1187 self.formfactorbox.SetValue(current_val) 1194 1188 # when select a model only from guictr/button 1195 1189 if is_poly_enabled != None: … … 1822 1816 self.dI_idata.Enable(True) 1823 1817 1824 #self.formfactorbox.Enable()1818 self.formfactorbox.Enable() 1825 1819 self.structurebox.Enable() 1826 1820 data_name = self.data.name -
fittingview/src/sans/perspectives/fitting/fitpanel.py
rdf7a7e3 rea5fa58 48 48 self.menu_mng = models.ModelManager() 49 49 self.model_list_box = self.menu_mng.get_model_list() 50 #pageClosedEvent = nb.EVT_FLATNOTEBOOK_PAGE_CLOSING 50 51 self.model_dictionary = self.menu_mng.get_model_dictionary() 51 #pageClosedEvent = nb.EVT_FLATNOTEBOOK_PAGE_CLOSING52 52 self.pageClosedEvent = wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE 53 53 … … 305 305 page.set_manager(self._manager) 306 306 307 def set_model_list(self, m_dict):307 def set_model_list(self, dict): 308 308 """ 309 309 copy a dictionary of model into its own dictionary … … 312 312 as value 313 313 """ 314 self.model_list_box = m_dict314 self.model_list_box = dict 315 315 316 316 def set_model_dict(self, m_dict): … … 368 368 else: 369 369 """ 370 371 370 from fitpage import FitPage 372 panel = FitPage(parent=self, m_dict = self.model_list_box) 373 371 panel = FitPage(parent=self) 374 372 if self.batch_on: 375 373 self.batch_page_index += 1 … … 384 382 panel._set_save_flag(not panel.batch_on) 385 383 panel.set_model_dictionary(self.model_dictionary) 384 panel.populate_box(dict=self.model_list_box) 385 panel.formfactor_combo_init() 386 386 panel.set_manager(self._manager) 387 387 panel.window_caption = caption -
fittingview/src/sans/perspectives/fitting/fitting.py
rdf7a7e3 rea5fa58 321 321 Update custom model list in the fitpage combo box 322 322 """ 323 custom_model = 'Customized Models' 323 324 try: 324 325 # Update edit menus … … 332 333 page.model_list_box = temp 333 334 current_val = page.formfactorbox.GetLabel() 334 if page.plugin_rbutton.GetValue(): 335 #if page.plugin_rbutton.GetValue(): 336 mod_cat = page.categorybox.GetStringSelection() 337 if mod_cat == custom_model: 335 338 #pos = page.formfactorbox.GetSelection() 336 339 page._show_combox_helper() -
fittingview/src/sans/perspectives/fitting/models.py
rdf7a7e3 rea5fa58 679 679 self.stored_plugins = self.findModels() 680 680 self.plugins = self.stored_plugins.values() 681 681 for name, plug in self.stored_plugins.iteritems(): 682 self.model_dictionary[name] = plug 683 682 684 self._get_multifunc_models() 683 685 … … 710 712 self.stored_plugins[name] = plug 711 713 self.plugins.append(plug) 714 self.model_dictionary[name] = plug 712 715 self.model_combobox.set_list("Customized Models", self.plugins) 713 716 return self.model_combobox.get_list() … … 725 728 if name == stored_name: 726 729 del self.stored_plugins[name] 730 del self.model_dictionary[name] 727 731 break 728 732 self.stored_plugins[name] = plug 729 733 self.plugins.append(plug) 734 self.model_dictionary[name] = plug 730 735 731 736 self.model_combobox.reset_list("Customized Models", self.plugins) -
fittingview/src/sans/perspectives/fitting/pagestate.py
r7c720e9 rea5fa58 44 44 ["qmax", "qmax", "float"], 45 45 ["npts", "npts", "float"], 46 ["shape_rbutton", "shape_rbutton", "bool"], 47 ["shape_indep_rbutton", "shape_indep_rbutton", "bool"], 48 ["plugin_rbutton", "plugin_rbutton", "bool"], 49 ["struct_rbutton", "struct_rbutton", "bool"], 46 #["shape_rbutton", "shape_rbutton", "bool"], 47 #["shape_indep_rbutton", "shape_indep_rbutton", "bool"], 48 #["plugin_rbutton", "plugin_rbutton", "bool"], 49 #["struct_rbutton", "struct_rbutton", "bool"], 50 ["categorycombobox", "categorycombobox", "string"], 50 51 ["formfactorcombobox", "formfactorcombobox", "string"], 51 52 ["structurecombobox", "structurecombobox", "string"], … … 224 225 ## save selection of combobox 225 226 self.formfactorcombobox = None 227 self.categorycombobox = None 226 228 self.structurecombobox = None 227 229 228 230 ## radio box to select type of model 229 self.shape_rbutton = False230 self.shape_indep_rbutton = False231 self.struct_rbutton = False232 self.plugin_rbutton = False231 #self.shape_rbutton = False 232 #self.shape_indep_rbutton = False 233 #self.struct_rbutton = False 234 #self.plugin_rbutton = False 233 235 ## the indice of the current selection 234 236 self.disp_box = 0 … … 281 283 obj.engine_type = copy.deepcopy(self.engine_type) 282 284 285 obj.categorycombobox = self.categorycombobox 283 286 obj.formfactorcombobox = self.formfactorcombobox 284 287 obj.structurecombobox = self.structurecombobox 285 288 286 obj.shape_rbutton = self.shape_rbutton287 obj.shape_indep_rbutton = self.shape_indep_rbutton288 obj.struct_rbutton = self.struct_rbutton289 obj.plugin_rbutton = self.plugin_rbutton289 #obj.shape_rbutton = self.shape_rbutton 290 #obj.shape_indep_rbutton = self.shape_indep_rbutton 291 #obj.struct_rbutton = self.struct_rbutton 292 #obj.plugin_rbutton = self.plugin_rbutton 290 293 291 294 obj.manager = self.manager … … 380 383 else: 381 384 rep += "model name : None\n" 382 rep += "model type (form factor) selected: %s\n" % self.shape_rbutton385 #rep += "model type (form factor) selected: %s\n" % self.shape_rbutton 383 386 rep += "multi_factor : %s\n" % str(self.multi_factor) 384 rep += "model type (shape independent) selected: %s\n" % self.shape_indep_rbutton 385 rep += "model type (structure factor) selected: %s\n" % self.struct_rbutton 386 rep += "model type (plug-in ) selected: %s\n" % self.plugin_rbutton 387 rep += "model type (Category) selected: %s\n" % self.categorycombobox 388 #rep += "model type (shape independent) selected: %s\n" % self.shape_indep_rbutton 389 #rep += "model type (structure factor) selected: %s\n" % self.struct_rbutton 390 #rep += "model type (plug-in ) selected: %s\n" % self.plugin_rbutton 387 391 rep += "data : %s\n" % str(self.data) 388 392 rep += "Plotting Range: min: %s, max: %s, steps: %s\n" % (str(self.qmin),
Note: See TracChangeset
for help on using the changeset viewer.