Changeset a0373d5 in sasview
- Timestamp:
- Sep 27, 2016 7:35:38 AM (8 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:
- b61bd57
- Parents:
- 31d7803
- Location:
- src/sas/sasgui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/utils.py
rd85c194 ra0373d5 46 46 return flag 47 47 48 48 49 def check_int(item): 50 """ 51 :param item: txtcrtl containing a value 52 """ 53 flag = True 54 try: 55 mini = int(item.GetValue()) 56 item.SetBackgroundColour(wx.WHITE) 57 item.Refresh() 58 except: 59 flag = False 60 item.SetBackgroundColour("pink") 61 item.Refresh() 62 return flag 63 64 49 65 class PanelMenu(wx.Menu): 50 66 """ -
src/sas/sasgui/perspectives/fitting/basepage.py
ree4b3cb ra0373d5 17 17 from wx.lib.scrolledpanel import ScrolledPanel 18 18 19 import sasmodels.sasview_model 19 from sasmodels.weights import MODELS as POLYDISPERSITY_MODELS 20 20 21 from sas.sasgui.guiframe.panel_base import PanelBase 21 from sas.sasgui.guiframe.utils import format_number, check_float, IdList 22 from sas.sasgui.guiframe.utils import format_number, check_float, IdList, check_int 22 23 from sas.sasgui.guiframe.events import PanelOnFocusEvent 23 24 from sas.sasgui.guiframe.events import StatusEvent … … 626 627 self.disp_help_bt.Bind(wx.EVT_BUTTON, self.on_pd_help_clicked, 627 628 id=self.disp_help_bt.GetId()) 628 self.disp_help_bt.SetToolTipString("Help s for Polydispersion.")629 self.disp_help_bt.SetToolTipString("Help for polydispersion.") 629 630 630 631 self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, … … 1123 1124 state.disp_cb_dict[item]) 1124 1125 # Create the dispersion objects 1125 from sas.models.dispersion_models import ArrayDispersion 1126 disp_model = ArrayDispersion() 1126 disp_model = POLYDISPERSITY_MODELS['array']() 1127 1127 if hasattr(state, "values") and \ 1128 1128 self.disp_cb_dict[item].GetValue() == True: … … 2281 2281 continue 2282 2282 2283 name = str(item[1]) 2284 if name.endswith(".npts") or name.endswith(".nsigmas"): 2283 value_ctrl = item[2] 2284 if not value_ctrl.IsEnabled(): 2285 # ArrayDispersion disables PD, Min, Max, Npts, Nsigs 2285 2286 continue 2286 2287 2287 # Check that min, max and value are floats 2288 value_ctrl, min_ctrl, max_ctrl = item[2], item[5], item[6] 2289 min_str = min_ctrl.GetValue().strip() 2290 max_str = max_ctrl.GetValue().strip() 2288 name = item[1] 2291 2289 value_str = value_ctrl.GetValue().strip() 2292 validity = check_float(value_ctrl) 2293 if min_str != "": 2294 validity = validity and check_float(min_ctrl) 2295 if max_str != "": 2296 validity = validity and check_float(max_ctrl) 2297 if not validity: 2298 continue 2299 2300 # Check that min is less than max 2301 low = -numpy.inf if min_str == "" else float(min_str) 2302 high = numpy.inf if max_str == "" else float(max_str) 2303 if high < low: 2304 min_ctrl.SetBackgroundColour("pink") 2305 min_ctrl.Refresh() 2306 max_ctrl.SetBackgroundColour("pink") 2307 max_ctrl.Refresh() 2308 #msg = "Invalid fit range for %s: min must be smaller than max"%name 2309 #wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 2310 continue 2311 2312 # Force value between min and max 2313 value = float(value_str) 2314 if value < low: 2315 value = low 2316 value_ctrl.SetValue(format_number(value)) 2317 elif value > high: 2318 value = high 2319 value_ctrl.SetValue(format_number(value)) 2290 if name.endswith(".npts"): 2291 validity = check_int(value_ctrl) 2292 if not validity: 2293 continue 2294 value = int(value_str) 2295 2296 elif name.endswith(".nsigmas"): 2297 validity = check_float(value_ctrl) 2298 if not validity: 2299 continue 2300 value = float(value_str) 2301 2302 else: # value or polydispersity 2303 2304 # Check that min, max and value are floats 2305 min_ctrl, max_ctrl = item[5], item[6] 2306 min_str = min_ctrl.GetValue().strip() 2307 max_str = max_ctrl.GetValue().strip() 2308 validity = check_float(value_ctrl) 2309 if min_str != "": 2310 validity = validity and check_float(min_ctrl) 2311 if max_str != "": 2312 validity = validity and check_float(max_ctrl) 2313 if not validity: 2314 continue 2315 2316 # Check that min is less than max 2317 low = -numpy.inf if min_str == "" else float(min_str) 2318 high = numpy.inf if max_str == "" else float(max_str) 2319 if high < low: 2320 min_ctrl.SetBackgroundColour("pink") 2321 min_ctrl.Refresh() 2322 max_ctrl.SetBackgroundColour("pink") 2323 max_ctrl.Refresh() 2324 #msg = "Invalid fit range for %s: min must be smaller than max"%name 2325 #wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 2326 continue 2327 2328 # Force value between min and max 2329 value = float(value_str) 2330 if value < low: 2331 value = low 2332 value_ctrl.SetValue(format_number(value)) 2333 elif value > high: 2334 value = high 2335 value_ctrl.SetValue(format_number(value)) 2336 2337 if name not in self.model.details.keys(): 2338 self.model.details[name] = ["", None, None] 2339 old_low, old_high = self.model.details[name][1:3] 2340 if old_low != low or old_high != high: 2341 # The configuration has changed but it won't change the 2342 # computed curve so no need to set is_modified to True 2343 #is_modified = True 2344 self.model.details[name][1:3] = low, high 2320 2345 2321 2346 # Update value in model if it has changed … … 2323 2348 self.model.setParam(name, value) 2324 2349 is_modified = True 2325 2326 if name not in self.model.details.keys():2327 self.model.details[name] = ["", None, None]2328 old_low, old_high = self.model.details[name][1:3]2329 if old_low != low or old_high != high:2330 # The configuration has changed but it won't change the2331 # computed curve so no need to set is_modified to True2332 #is_modified = True2333 self.model.details[name][1:3] = low, high2334 2350 2335 2351 return is_modified … … 2687 2703 :param disp_function: dispersion distr. function 2688 2704 """ 2689 # List of the poly_model name in the combobox2690 list = ["RectangleDispersion", "ArrayDispersion",2691 "LogNormalDispersion", "GaussianDispersion",2692 "SchulzDispersion"]2693 2694 2705 # Find the selection 2695 try: 2696 selection = list.index(disp_func.__class__.__name__) 2697 return selection 2698 except: 2699 return 3 2706 if disp_func is not None: 2707 try: 2708 return POLYDISPERSITY_MODELS.values().index(disp_func.__class__) 2709 except ValueError: 2710 pass # Fall through to default class 2711 return POLYDISPERSITY_MODELS.keys().index('gaussian') 2700 2712 2701 2713 def on_reset_clicked(self, event):
Note: See TracChangeset
for help on using the changeset viewer.