Changes in src/sas/perspectives/fitting/fitpage.py [5265420:85ccd3a] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/perspectives/fitting/fitpage.py
r5265420 r85ccd3a 26 26 from sas.perspectives.fitting.basepage import PageInfoEvent as PageInfoEvent 27 27 from sas.models.qsmearing import smear_selection 28 from .basepage import ModelTextCtrl29 28 30 29 … … 285 284 286 285 #textcntrl for custom resolution 287 self.smear_pinhole_max = ModelTextCtrl(self, -1,286 self.smear_pinhole_max = self.ModelTextCtrl(self, -1, 288 287 size=(_BOX_WIDTH - 25, 20), 289 288 style=wx.TE_PROCESS_ENTER, 290 289 text_enter_callback=self.onPinholeSmear) 291 self.smear_pinhole_min = ModelTextCtrl(self, -1,290 self.smear_pinhole_min = self.ModelTextCtrl(self, -1, 292 291 size=(_BOX_WIDTH - 25, 20), 293 292 style=wx.TE_PROCESS_ENTER, 294 293 text_enter_callback=self.onPinholeSmear) 295 self.smear_slit_height = ModelTextCtrl(self, -1,294 self.smear_slit_height = self.ModelTextCtrl(self, -1, 296 295 size=(_BOX_WIDTH - 25, 20), 297 296 style=wx.TE_PROCESS_ENTER, 298 297 text_enter_callback=self.onSlitSmear) 299 self.smear_slit_width = ModelTextCtrl(self, -1,298 self.smear_slit_width = self.ModelTextCtrl(self, -1, 300 299 size=(_BOX_WIDTH - 25, 20), 301 300 style=wx.TE_PROCESS_ENTER, … … 304 303 ## smear 305 304 self.smear_data_left = BGTextCtrl(self, -1, 306 305 size=(_BOX_WIDTH - 25, 20), style=0) 307 306 self.smear_data_left.SetValue(str(self.dq_l)) 308 307 self.smear_data_right = BGTextCtrl(self, -1, 309 308 size=(_BOX_WIDTH - 25, 20), style=0) 310 309 self.smear_data_right.SetValue(str(self.dq_r)) 311 310 … … 356 355 self.Npts_fit.SetToolTipString(\ 357 356 " Npts : number of points selected for fitting") 358 self.Npts_total = ModelTextCtrl(self, -1,359 360 361 357 self.Npts_total = self.ModelTextCtrl(self, -1, 358 size=(_BOX_WIDTH, 20), 359 style=wx.TE_PROCESS_ENTER, 360 text_enter_callback=self._onQrangeEnter) 362 361 self.Npts_total.SetValue(format_number(self.npts_x)) 363 362 self.Npts_total.SetToolTipString(\ … … 516 515 self.sizer5.Clear(True) 517 516 518 self.qmin = ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20),519 style=wx.TE_PROCESS_ENTER,520 set_focus_callback=self.qrang_set_focus,521 text_enter_callback=self._onQrangeEnter,522 name='qmin')517 self.qmin = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 518 style=wx.TE_PROCESS_ENTER, 519 set_focus_callback=self.qrang_set_focus, 520 text_enter_callback=self._onQrangeEnter, 521 name='qmin') 523 522 self.qmin.SetValue(str(self.qmin_x)) 524 523 q_tip = "Click outside of the axes\n to remove the lines." … … 527 526 self.qmin.SetToolTipString(qmin_tip) 528 527 529 self.qmax = ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20),530 style=wx.TE_PROCESS_ENTER,531 set_focus_callback=self.qrang_set_focus,532 text_enter_callback=self._onQrangeEnter,533 name='qmax')528 self.qmax = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 529 style=wx.TE_PROCESS_ENTER, 530 set_focus_callback=self.qrang_set_focus, 531 text_enter_callback=self._onQrangeEnter, 532 name='qmax') 534 533 self.qmax.SetValue(str(self.qmax_x)) 535 534 qmax_tip = "Maximum value of Q.\n" … … 687 686 ix = 1 688 687 value = self.model.getParam(name1) 689 ctl1 = ModelTextCtrl(self, -1,690 size=(_BOX_WIDTH / 1.3, 20),691 style=wx.TE_PROCESS_ENTER)688 ctl1 = self.ModelTextCtrl(self, -1, 689 size=(_BOX_WIDTH / 1.3, 20), 690 style=wx.TE_PROCESS_ENTER) 692 691 ctl1.SetLabel('PD[ratio]') 693 692 poly_text = "Polydispersity (STD/mean) of %s\n" % item … … 716 715 717 716 ix = 4 718 ctl3 = ModelTextCtrl(self, -1,719 size=(_BOX_WIDTH / 2, 20),720 style=wx.TE_PROCESS_ENTER,721 text_enter_callback=self._onparamRangeEnter)717 ctl3 = self.ModelTextCtrl(self, -1, 718 size=(_BOX_WIDTH / 2, 20), 719 style=wx.TE_PROCESS_ENTER, 720 text_enter_callback=self._onparamRangeEnter) 722 721 723 722 self.sizer4_4.Add(ctl3, (iy, ix), (1, 1), … … 725 724 726 725 ix = 5 727 ctl4 = ModelTextCtrl(self, -1,728 size=(_BOX_WIDTH / 2, 20),729 style=wx.TE_PROCESS_ENTER,726 ctl4 = self.ModelTextCtrl(self, -1, 727 size=(_BOX_WIDTH / 2, 20), 728 style=wx.TE_PROCESS_ENTER, 730 729 text_enter_callback=self._onparamRangeEnter) 731 730 … … 739 738 ix = 6 740 739 value = self.model.getParam(name2) 741 Tctl = ModelTextCtrl(self, -1,742 size=(_BOX_WIDTH / 2.2, 20),743 style=wx.TE_PROCESS_ENTER)740 Tctl = self.ModelTextCtrl(self, -1, 741 size=(_BOX_WIDTH / 2.2, 20), 742 style=wx.TE_PROCESS_ENTER) 744 743 745 744 Tctl.SetValue(str(format_number(value))) … … 751 750 ix = 7 752 751 value = self.model.getParam(name3) 753 Tct2 = ModelTextCtrl(self, -1,754 size=(_BOX_WIDTH / 2.2, 20),755 style=wx.TE_PROCESS_ENTER)752 Tct2 = self.ModelTextCtrl(self, -1, 753 size=(_BOX_WIDTH / 2.2, 20), 754 style=wx.TE_PROCESS_ENTER) 756 755 757 756 Tct2.SetValue(str(format_number(value))) … … 812 811 ix = 1 813 812 value = self.model.getParam(name1) 814 ctl1 = ModelTextCtrl(self, -1,815 size=(_BOX_WIDTH / 1.3, 20),816 style=wx.TE_PROCESS_ENTER)813 ctl1 = self.ModelTextCtrl(self, -1, 814 size=(_BOX_WIDTH / 1.3, 20), 815 style=wx.TE_PROCESS_ENTER) 817 816 poly_tip = "Absolute Sigma for %s." % item 818 817 ctl1.SetToolTipString(poly_tip) … … 860 859 861 860 ix = 4 862 ctl3 = ModelTextCtrl(self, -1,863 size=(_BOX_WIDTH / 2, 20),864 style=wx.TE_PROCESS_ENTER,861 ctl3 = self.ModelTextCtrl(self, -1, 862 size=(_BOX_WIDTH / 2, 20), 863 style=wx.TE_PROCESS_ENTER, 865 864 text_enter_callback=self._onparamRangeEnter) 866 865 … … 871 870 872 871 ix = 5 873 ctl4 = ModelTextCtrl(self, -1,874 875 872 ctl4 = self.ModelTextCtrl(self, -1, 873 size=(_BOX_WIDTH / 2, 20), 874 style=wx.TE_PROCESS_ENTER, 876 875 text_enter_callback=self._onparamRangeEnter) 877 876 self.sizer4_4.Add(ctl4, (iy, ix), (1, 1), … … 887 886 ix = 6 888 887 value = self.model.getParam(name2) 889 Tctl = ModelTextCtrl(self, -1,890 size=(_BOX_WIDTH / 2.2, 20),891 style=wx.TE_PROCESS_ENTER)888 Tctl = self.ModelTextCtrl(self, -1, 889 size=(_BOX_WIDTH / 2.2, 20), 890 style=wx.TE_PROCESS_ENTER) 892 891 893 892 Tctl.SetValue(str(format_number(value))) … … 907 906 ix = 7 908 907 value = self.model.getParam(name3) 909 Tct2 = ModelTextCtrl(self, -1,910 size=(_BOX_WIDTH / 2.2, 20),911 style=wx.TE_PROCESS_ENTER)908 Tct2 = self.ModelTextCtrl(self, -1, 909 size=(_BOX_WIDTH / 2.2, 20), 910 style=wx.TE_PROCESS_ENTER) 912 911 913 912 Tct2.SetValue(str(format_number(value))) … … 1062 1061 label = "Fit" 1063 1062 color = "black" 1064 #self.btFit.Enable(False)1063 self.btFit.Enable(False) 1065 1064 self.btFit.SetLabel(label) 1066 1065 self.btFit.SetForegroundColour(color) … … 1141 1140 self.state.formfactorcombobox = self.formfactorbox.GetLabel() 1142 1141 self.enable_fit_button() 1143 if self.model is notNone:1142 if self.model != None: 1144 1143 self.m_name = self.model.name 1145 1144 self.state.m_name = self.m_name … … 1153 1152 self._keep.Enable(not self.batch_on) 1154 1153 self._set_save_flag(True) 1154 # Reset smearer, model and data 1155 if not copy_flag: 1156 self.disable_smearer.SetValue(True) 1157 self.enable_smearer.SetValue(False) 1155 1158 1156 1159 # more disables for 2D … … 1159 1162 try: 1160 1163 # update smearer sizer 1164 #if not self.enable_smearer.GetValue(): 1165 # self.disable_smearer.SetValue(True) 1161 1166 self.onSmear(None) 1162 1167 temp_smear = None … … 1263 1268 elif self.data.__class__.__name__ != "Data2D" and \ 1264 1269 not self.enable2D: 1265 enable_smearer = not self.disable_smearer.GetValue()1266 1270 self._manager.set_smearer(smearer=temp_smearer, 1267 1271 fid=self.data.id, … … 1269 1273 qmin=float(self.qmin_x), 1270 1274 qmax=float(self.qmax_x), 1271 enable_smearer=enable_smearer,1272 1275 enable_smearer=not self.disable_smearer.GetValue(), 1276 draw=True) 1273 1277 if flag: 1274 1278 #self.compute_chisqr(smearer= temp_smearer) … … 1768 1772 self.current_smearer = smear_selection(data, self.model) 1769 1773 flag = self.disable_smearer.GetValue() 1770 if self.current_smearer is None: 1774 self.disable_smearer.SetValue(flag) 1775 if self.current_smearer == None: 1771 1776 self.enable_smearer.Disable() 1772 1777 else: … … 1954 1959 if flag: 1955 1960 #set model view button 1961 if not self.enable_smearer.GetValue(): 1962 self.disable_smearer.SetValue(True) 1956 1963 self.onSmear(None) 1957 1964 … … 2125 2132 if numpy.isfinite(float(cov[ind])): 2126 2133 val_err = format_number(cov[ind], True) 2127 else: 2128 val_err = 'NaN' 2129 if not self.is_mac: 2130 item[3].Show(True) 2131 item[4].Show(True) 2132 item[4].SetForegroundColour(wx.RED) 2133 item[4].SetValue(val_err) 2134 has_error = True 2134 if not self.is_mac: 2135 item[3].Show(True) 2136 item[4].Show(True) 2137 item[4].SetForegroundColour(wx.BLACK) 2138 item[4].SetValue(val_err) 2139 has_error = True 2140 else: 2141 val_err = 'NaN' 2142 if not self.is_mac: 2143 item[3].Show(True) 2144 item[4].Show(True) 2145 item[4].SetForegroundColour(wx.RED) 2146 item[4].SetValue(val_err) 2147 has_error = True 2135 2148 i += 1 2136 2149 else: … … 2183 2196 2184 2197 """ 2198 if self.model == None: 2199 self.disable_smearer.SetValue(True) 2200 if event == None: 2201 return 2202 msg = "Please select a Model first..." 2203 wx.MessageBox(msg, 'Info') 2204 wx.PostEvent(self._manager.parent, 2205 StatusEvent(status="Smear: %s" % msg)) 2206 return 2207 2185 2208 # Need update param values 2186 2209 self._update_paramv_on_fit() … … 2322 2345 ## set smearing value whether or not the data contain the smearing info 2323 2346 2324 enable_smearer = not self.disable_smearer.GetValue()2325 2347 self._manager.set_smearer(smearer=self.current_smearer, 2326 2327 2328 2329 enable_smearer=enable_smearer,2330 2348 fid=self.data.id, 2349 qmin=float(self.qmin_x), 2350 qmax=float(self.qmax_x), 2351 enable_smearer=not self.disable_smearer.GetValue(), 2352 uid=self.uid) 2331 2353 return msg 2332 2354 … … 2356 2378 are compute when fitting 2357 2379 """ 2380 if self.model == None: 2381 self.disable_smearer.SetValue(True) 2382 if event == None: 2383 return 2384 msg = "Please select a Model first..." 2385 wx.MessageBox(msg, 'Info') 2386 wx.PostEvent(self._manager.parent, 2387 StatusEvent(status="Smear: %s" % msg)) 2388 return 2389 2358 2390 # Need update param values 2359 2391 self._update_paramv_on_fit() … … 2443 2475 of the values entered for slit smear 2444 2476 """ 2445 if self.data.__class__.__name__ == "Data2D" or self.enable2D: 2477 if self.data.__class__.__name__ == "Data2D" or \ 2478 self.enable2D: 2446 2479 return 2447 2480 # make sure once more if it is smearer … … 2480 2513 self.current_smearer = smear_selection(data, self.model) 2481 2514 ## set smearing value whether or not the data contain the smearing info 2482 enable_smearer = not self.disable_smearer.GetValue()2483 2515 self._manager.set_smearer(smearer=self.current_smearer, 2484 2485 2486 2487 enable_smearer=enable_smearer,2488 2516 fid=self.data.id, 2517 qmin=float(self.qmin_x), 2518 qmax=float(self.qmax_x), 2519 enable_smearer=not self.disable_smearer.GetValue(), 2520 uid=self.uid) 2489 2521 return msg 2490 2522 … … 2520 2552 return 2521 2553 2554 if self.model == None: 2555 self.disable_smearer.SetValue(True) 2556 if event == None: 2557 return 2558 msg = "Please select a Model first..." 2559 wx.MessageBox(msg, 'Info') 2560 wx.PostEvent(self._manager.parent, 2561 StatusEvent(status="Smear: %s" % msg)) 2562 return 2522 2563 # Need update param values 2523 2564 self._update_paramv_on_fit() 2524 if self.model is notNone:2565 if self.model != None: 2525 2566 if self.data.is_data: 2526 2567 self._manager.page_finder[self.uid].add_data(data=self.data) … … 2532 2573 2533 2574 ## set smearing value whether or not the data contain the smearing info 2534 enable_smearer = not self.disable_smearer.GetValue()2535 2575 wx.CallAfter(self._manager.set_smearer, uid=self.uid, 2536 2576 smearer=temp_smearer, … … 2538 2578 qmin=float(self.qmin_x), 2539 2579 qmax=float(self.qmax_x), 2540 enable_smearer= enable_smearer,2580 enable_smearer=not self.disable_smearer.GetValue(), 2541 2581 draw=True) 2542 2582 … … 2554 2594 self._get_smear_info() 2555 2595 #renew smear sizer 2556 if self.smear_type is notNone:2596 if self.smear_type != None: 2557 2597 self.smear_description_smear_type.SetValue(str(self.smear_type)) 2558 2598 self.smear_data_left.SetValue(str(self.dq_l)) … … 2567 2607 self.current_smearer = temp_smearer 2568 2608 if self.enable_smearer.GetValue(): 2569 if self.current_smearer isNone:2609 if self.current_smearer == None: 2570 2610 wx.PostEvent(self._manager.parent, 2571 2611 StatusEvent(status="Data contains no smearing information")) … … 2913 2953 wx.EVT_COMBOBOX(fun_box, -1, self._on_fun_box) 2914 2954 else: 2915 fun_box = ModelTextCtrl(self, -1,2916 size=(_BOX_WIDTH, 20),2955 fun_box = self.ModelTextCtrl(self, -1, 2956 size=(_BOX_WIDTH, 20), 2917 2957 style=wx.TE_PROCESS_ENTER, name='%s' % item) 2918 2958 fun_box.SetToolTipString(\ … … 2937 2977 ix += 1 2938 2978 value = self.model.getParam(item) 2939 ctl1 = ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20),2940 2979 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 2980 style=wx.TE_PROCESS_ENTER) 2941 2981 ctl1.SetToolTipString(\ 2942 2982 "Hit 'Enter' after typing to update the plot.") … … 2959 2999 2960 3000 ix += 1 2961 ctl3 = ModelTextCtrl(self, -1,2962 size=(_BOX_WIDTH / 1.9, 20),2963 style=wx.TE_PROCESS_ENTER,3001 ctl3 = self.ModelTextCtrl(self, -1, 3002 size=(_BOX_WIDTH / 1.9, 20), 3003 style=wx.TE_PROCESS_ENTER, 2964 3004 text_enter_callback=self._onparamRangeEnter) 2965 3005 min_bound = self.model.details[item][1] … … 2971 3011 2972 3012 ix += 1 2973 ctl4 = ModelTextCtrl(self, -1,2974 size=(_BOX_WIDTH / 1.9, 20),2975 style=wx.TE_PROCESS_ENTER,3013 ctl4 = self.ModelTextCtrl(self, -1, 3014 size=(_BOX_WIDTH / 1.9, 20), 3015 style=wx.TE_PROCESS_ENTER, 2976 3016 text_enter_callback=self._onparamRangeEnter) 2977 3017 max_bound = self.model.details[item][2] … … 3075 3115 ix += 1 3076 3116 value = self.model.getParam(item) 3077 ctl1 = ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20),3078 3117 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 3118 style=wx.TE_PROCESS_ENTER) 3079 3119 ctl1.SetToolTipString(\ 3080 3120 "Hit 'Enter' after typing to update the plot.") … … 3102 3142 3103 3143 ix += 1 3104 ctl3 = ModelTextCtrl(self, -1,3105 size=(_BOX_WIDTH / 1.8, 20),3106 style=wx.TE_PROCESS_ENTER,3144 ctl3 = self.ModelTextCtrl(self, -1, 3145 size=(_BOX_WIDTH / 1.8, 20), 3146 style=wx.TE_PROCESS_ENTER, 3107 3147 text_enter_callback=self._onparamRangeEnter) 3108 3148 … … 3112 3152 3113 3153 ix += 1 3114 ctl4 = ModelTextCtrl(self, -1,3115 size=(_BOX_WIDTH / 1.8, 20),3116 style=wx.TE_PROCESS_ENTER,3154 ctl4 = self.ModelTextCtrl(self, -1, 3155 size=(_BOX_WIDTH / 1.8, 20), 3156 style=wx.TE_PROCESS_ENTER, 3117 3157 text_enter_callback=self._onparamRangeEnter) 3118 3158 sizer.Add(ctl4, (iy, ix), (1, 1),
Note: See TracChangeset
for help on using the changeset viewer.