Changeset ace0e33 in sasview for fittingview/src/sans/perspectives/fitting/basepage.py
- Timestamp:
- Oct 6, 2011 9:40:56 PM (13 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:
- 01642fec
- Parents:
- 92b2fd8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fittingview/src/sans/perspectives/fitting/basepage.py
r706667b race0e33 2488 2488 item[0].Disable() 2489 2489 item[2].Disable() 2490 item[3].Show(False) 2491 item[4].Show(False) 2490 2492 item[5].Disable() 2491 2493 item[6].Disable() … … 2904 2906 disfunc = ',' + disfunc 2905 2907 # TODO: to support array func for copy/paste 2906 if disfunc.count('array') == 0: 2907 content += name + ',' + value + disfunc + ':' 2908 try: 2909 if disfunc.count('array') > 0: 2910 disfunc += ',' 2911 for val in self.values[name]: 2912 disfunc += ' ' + str(val) 2913 disfunc += ',' 2914 for weight in self.weights[name]: 2915 disfunc += ' ' + str(weight) 2916 except: 2917 pass 2918 #if disfunc.count('array') == 0: 2919 content += name + ',' + value + disfunc + ':' 2908 2920 2909 2921 return content … … 2956 2968 try: 2957 2969 poly_func = item[2] 2970 context[name].append(poly_func) 2971 try: 2972 # take the vals and weights for array 2973 array_values = item[3].split(' ') 2974 array_weights = item[4].split(' ') 2975 val = [float(a_val) for a_val in array_values[1:]] 2976 weit = [float(a_weit) for a_weit in array_weights[1:]] 2977 2978 context[name].append(val) 2979 context[name].append(weit) 2980 except: 2981 raise 2958 2982 except: 2959 poly_func = None2960 context[name].append(poly_func)2983 poly_func = '' 2984 context[name].append(poly_func) 2961 2985 2962 2986 # Do it if params exist … … 2995 3019 name = item[1] 2996 3020 if name in content.keys(): 2997 3021 pd = content[name][0] 2998 3022 if name.count('.') > 0: 2999 3023 try: 3000 float( content[name][0])3024 float(pd) 3001 3025 except: 3002 3026 continue 3003 item[2].SetValue(content[name][0]) 3027 #if not pd and pd != '': 3028 # continue 3029 item[2].SetValue(str(pd)) 3030 3004 3031 if item[2].__class__.__name__ == "ComboBox": 3005 3032 if self.model.fun_list.has_key(content[name][0]): … … 3007 3034 self.model.setParam(name,fun_val) 3008 3035 3009 poly_func = content[name][1] 3010 if poly_func: 3011 try: 3012 item[7].SetValue(poly_func) 3013 selection = item[7].GetCurrentSelection() 3014 param_name = item[7].Name.split('.')[0] 3015 disp_name = item[7].GetValue() 3016 dispersity= item[7].GetClientData(selection) 3017 disp_model = dispersity() 3018 #disp_model = self._disp_obj_dict[name] 3019 self.model.set_dispersion(param_name, disp_model) 3020 self.state._disp_obj_dict[param_name]= disp_model 3021 except: 3022 pass 3036 value = content[name] 3037 self._paste_poly_help(item, value) 3023 3038 # 1D 3024 3039 else: … … 3029 3044 # Avoid changing combox content which needs special care 3030 3045 value = content[name] 3046 pd = value[0] 3031 3047 if name.count('.') > 0: 3032 3048 try: 3033 float(value[0])3049 pd = float(pd) 3034 3050 except: 3035 3051 continue 3036 item[2].SetValue(value[0]) 3052 #if not pd and pd != '': 3053 # continue 3054 item[2].SetValue(str(pd)) 3055 if item in self.fixed_param and pd == '': 3056 # Only array func has pd == '' case. 3057 item[2].Enable(False) 3037 3058 if item[2].__class__.__name__ == "ComboBox": 3038 3059 if self.model.fun_list.has_key(value[0]): … … 3042 3063 #self._copy_parameters_state(self.str_parameters, 3043 3064 # self.state.str_parameters) 3044 if value[1]: 3045 try: 3046 item[7].SetValue(value[1]) 3047 selection = item[7].GetCurrentSelection() 3048 param_name = item[7].Name.split('.')[0] 3049 disp_name = item[7].GetValue() 3050 dispersity= item[7].GetClientData(selection) 3051 disp_model = dispersity() 3052 self.model.set_dispersion(param_name, disp_model) 3053 self.state._disp_obj_dict[param_name]= disp_model 3054 except: 3055 pass 3065 self._paste_poly_help(item, value) 3066 3067 def _paste_poly_help(self, item, value): 3068 """ 3069 Helps get paste for poly function 3070 3071 :param item: Gui param items 3072 :param value: the values for parameter ctrols 3073 """ 3074 if len(value[1]) > 0: 3075 # Only for dispersion func.s 3076 try: 3077 item[7].SetValue(value[1]) 3078 selection = item[7].GetCurrentSelection() 3079 param_name = item[7].Name.split('.')[0] 3080 disp_name = item[7].GetValue() 3081 dispersity= item[7].GetClientData(selection) 3082 disp_model = dispersity() 3083 # Only for array disp 3084 try: 3085 pd_vals = numpy.array(value[2]) 3086 pd_weights = numpy.array(value[3]) 3087 if len(pd_vals) > 0 and len(pd_vals) > 0: 3088 if len(pd_vals) == len(pd_weights): 3089 disp_model.set_weights(pd_vals, 3090 pd_weights) 3091 self.values[param_name] = pd_vals 3092 self.weights[param_name] = pd_weights 3093 # disable the fixed items for array 3094 item[0].SetValue(False) 3095 item[0].Enable(False) 3096 item[2].Enable(False) 3097 item[4].Show(False) 3098 item[5].SetValue('') 3099 item[5].Enable(False) 3100 item[6].SetValue('') 3101 item[6].Enable(False) 3102 except: 3103 pass 3104 self._disp_obj_dict[param_name] = disp_model 3105 self.model.set_dispersion(param_name, 3106 disp_model) 3107 self.state._disp_obj_dict[param_name] = \ 3108 disp_model 3109 3110 except: 3111 pass
Note: See TracChangeset
for help on using the changeset viewer.