Changeset 9087214 in sasview for src/sas/sasgui/perspectives/fitting/basepage.py
- Timestamp:
- Oct 11, 2016 11:09:47 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, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 4581ac9, 7949dcf7
- Parents:
- 392056d (diff), 46dfee9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/basepage.py
r51a4d78 r9087214 1037 1037 dispersity = self.disp_box.GetClientData(n) 1038 1038 name = dispersity.__name__ 1039 1040 1039 self._set_dipers_Param(event=None) 1041 1040 … … 1108 1107 self.Refresh() 1109 1108 1109 def get_cat_combo_box_pos(self, state): 1110 """ 1111 Iterate through the categories to find the structurefactor 1112 :return: combo_box_position 1113 """ 1114 for key, value in self.master_category_dict.iteritems(): 1115 for list_item in value: 1116 if state.formfactorcombobox in list_item: 1117 return self.categorybox.Items.index(key) 1118 1110 1119 def reset_page_helper(self, state): 1111 1120 """ … … 1163 1172 category_pos = int(state.categorycombobox) 1164 1173 except: 1174 state.formfactorcombobox = unicode(state.formfactorcombobox.lower()) 1175 state.categorycombobox = unicode(state.categorycombobox) 1165 1176 category_pos = 0 1166 for ind_cat in range(self.categorybox.GetCount()): 1167 if self.categorybox.GetString(ind_cat) == \ 1168 state.categorycombobox: 1169 category_pos = int(ind_cat) 1170 break 1177 if state.categorycombobox in self.categorybox.Items: 1178 category_pos = self.categorybox.Items.index( 1179 state.categorycombobox) 1180 else: 1181 # Look in master list for model name (model.lower) 1182 category_pos = self.get_cat_combo_box_pos(state) 1171 1183 1172 1184 self.categorybox.Select(category_pos) … … 1189 1201 structfactor_pos = int(state.structurecombobox) 1190 1202 except: 1191 structfactor_pos = 0 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 1203 if state.structurecombobox is not None: 1204 structfactor_pos = 0 1205 state.structurecombobox = unicode(state.structurecombobox) 1206 for ind_struct in range(self.structurebox.GetCount()): 1207 if self.structurebox.GetString(ind_struct) == \ 1208 (state.structurecombobox): 1209 structfactor_pos = int(ind_struct) 1210 break 1197 1211 1198 1212 self.structurebox.SetSelection(structfactor_pos) … … 1407 1421 self.state.npts = self.npts_x 1408 1422 1409 def _onparamEnter_helper(self ):1423 def _onparamEnter_helper(self,is_modified = False): 1410 1424 """ 1411 1425 check if values entered by the user are changed and valid to replot … … 1413 1427 """ 1414 1428 # Flag to register when a parameter has changed. 1415 is_modified = False1429 #is_modified = False 1416 1430 self.fitrange = True 1417 1431 is_2Ddata = False … … 1421 1435 is_2Ddata = True 1422 1436 if self.model != None: 1423 is_modified = (self._check_value_enter(self.fittable_param) 1424 or self._check_value_enter(self.fixed_param) 1425 or self._check_value_enter(self.parameters)) 1437 #Either we get a is_modified = True passed in because 1438 #_update_paramv_on_fit() has been called already or 1439 # we need to check here ourselves. 1440 if not is_modified: 1441 is_modified = (self._check_value_enter(self.fittable_param) 1442 or self._check_value_enter(self.fixed_param) 1443 or self._check_value_enter(self.parameters)) 1426 1444 1427 1445 # Here we should check whether the boundaries have been modified. … … 1472 1490 flag = True 1473 1491 self.fitrange = True 1492 is_modified = False 1474 1493 1475 1494 #wx.PostEvent(self._manager.parent, StatusEvent(status=" \ … … 1484 1503 [self.data]) 1485 1504 ##Check the values 1486 self._check_value_enter(self.fittable_param)1487 self._check_value_enter(self.fixed_param)1488 self._check_value_enter(self.parameters)1505 is_modified = (self._check_value_enter(self.fittable_param) 1506 or self._check_value_enter(self.fixed_param) 1507 or self._check_value_enter(self.parameters)) 1489 1508 1490 1509 # If qmin and qmax have been modified, update qmin and qmax and … … 1568 1587 logging.error(traceback.format_exc()) 1569 1588 1570 return flag 1589 return flag,is_modified 1571 1590 1572 1591 def _reset_parameters_state(self, listtorestore, statelist): … … 1979 1998 form_factor = self.formfactorbox.GetClientData(f_id) 1980 1999 1981 if form_factor is None or not form_factor.is_form_factor: 2000 if form_factor is None or \ 2001 not hasattr(form_factor, 'is_form_factor') or \ 2002 not form_factor.is_form_factor: 1982 2003 self.structurebox.Hide() 1983 2004 self.text2.Hide() … … 2306 2327 wx.PostEvent(self.parent, event) 2307 2328 #draw the model with the current dispersity 2308 self._draw_model() 2329 2330 #Wojtek P, Oct 8, 2016: Calling draw_model seems to be unessecary. 2331 #By comenting it we save an extra Iq calculation 2332 #self._draw_model() 2333 2309 2334 ## Need to use FitInside again here to replace the next four lines. 2310 2335 ## Otherwised polydispersity off does not resize the scrollwindow. … … 3055 3080 """ 3056 3081 content = '' 3082 bound_hi = '' 3083 bound_lo = '' 3057 3084 # go through the str params 3058 3085 for item in param: … … 3086 3113 value = item[2].GetValue() 3087 3114 3115 # Bounds 3116 try: 3117 bound_lo = item[5].GetValue() 3118 bound_hi = item[6].GetValue() 3119 except Exception: 3120 # harmless - need to just pass 3121 pass 3122 3088 3123 # add to the content 3089 3124 if disfunc != '': … … 3101 3136 except Exception: 3102 3137 logging.error(traceback.format_exc()) 3103 content += name + ',' + str(check) + ',' + value + disfunc + ':' 3138 content += name + ',' + str(check) + ',' +\ 3139 value + disfunc + ',' + bound_lo + ',' +\ 3140 bound_hi + ':' 3104 3141 3105 3142 return content … … 3152 3189 # Transfer the text to content[dictionary] 3153 3190 context[name] = [check, value] 3191 3192 # limits 3193 limit_lo = item[3] 3194 context[name].append(limit_lo) 3195 limit_hi = item[4] 3196 context[name].append(limit_hi) 3197 3154 3198 # ToDo: PlugIn this poly disp function for pasting 3155 3199 try: 3156 poly_func = item[ 3]3200 poly_func = item[5] 3157 3201 context[name].append(poly_func) 3158 3202 try: 3159 3203 # take the vals and weights for array 3160 array_values = item[ 4].split(' ')3161 array_weights = item[ 5].split(' ')3204 array_values = item[6].split(' ') 3205 array_weights = item[7].split(' ') 3162 3206 val = [float(a_val) for a_val in array_values[1:]] 3163 3207 weit = [float(a_weit) for a_weit in array_weights[1:]] … … 3207 3251 name = item[1] 3208 3252 if name in content.keys(): 3209 check = content[name][0] 3210 pd = content[name][1] 3253 values = content[name] 3254 check = values[0] 3255 pd = values[1] 3256 3211 3257 if name.count('.') > 0: 3212 3258 # If this is parameter.width, then pd may be a floating … … 3231 3277 fun_val = self.model.fun_list[content[name][1]] 3232 3278 self.model.setParam(name, fun_val) 3279 try: 3280 item[5].SetValue(str(values[-3])) 3281 item[6].SetValue(str(values[-2])) 3282 except Exception: 3283 # passing as harmless non-update 3284 pass 3233 3285 3234 3286 value = content[name][1:] … … 3275 3327 self.model.setParam(name, fun_val) 3276 3328 # save state 3329 try: 3330 item[5].SetValue(str(value[-3])) 3331 item[6].SetValue(str(value[-2])) 3332 except Exception: 3333 # passing as harmless non-update 3334 pass 3335 3277 3336 self._paste_poly_help(item, value) 3278 3337 if check == 'True': … … 3309 3368 """ 3310 3369 # Do nothing if not setting polydispersity 3311 if len(value[ 1]) == 0:3370 if len(value[3]) == 0: 3312 3371 return 3313 3372
Note: See TracChangeset
for help on using the changeset viewer.