Changeset fa02d95 in sasview for fittingview/src/sans
- Timestamp:
- Nov 21, 2011 2:02:35 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:
- afea8fe
- Parents:
- cacd1d6
- Location:
- fittingview/src/sans/perspectives/fitting
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
fittingview/src/sans/perspectives/fitting/basepage.py
r8a5fecd rfa02d95 309 309 chain_menu.Enable(self.batch_on) 310 310 sim_menu = self._manager.menu1.FindItemById(self._manager.id_simfit) 311 sim_menu.Enable(not self.batch_on and self.data.is_data\ 312 and (self.model!=None)) 311 flag = self.data.is_data\ 312 and (self.model!=None) 313 sim_menu.Enable(not self.batch_on and flag) 314 batch_menu = self._manager.menu1.FindItemById(self._manager.id_batchfit) 315 batch_menu.Enable(self.batch_on and flag) 313 316 314 317 class ModelTextCtrl(wx.TextCtrl): -
fittingview/src/sans/perspectives/fitting/fitpanel.py
rf3f6746 rfa02d95 61 61 #page of simultaneous fit 62 62 self.sim_page = None 63 self.batch_page = None 63 64 self.fit_engine_type = "scipy" 64 65 ## get the state of a page … … 85 86 if page.batch_on: 86 87 pos = self.GetPageIndex(page) 87 if pos != -1 and page != self.sim_page:88 if pos != -1 and page not in [self.sim_page, self.batch_page]: 88 89 msg += "%s .\n" % str(self.GetPageText(pos)) 89 90 else: … … 116 117 """ 117 118 self.fit_engine_type = name 118 if panel != self.sim_page:119 if panel not in[self.batch_page, self.sim_page]: 119 120 panel._on_engine_change(name=self.fit_engine_type) 120 121 … … 314 315 return self.GetPage(self.GetSelection()) 315 316 316 def add_sim_page(self ):317 def add_sim_page(self, caption="Simultaneous Fit"): 317 318 """ 318 319 Add the simultaneous fit page 319 320 """ 320 321 from simfitpage import SimultaneousFitPage 321 page_finder= self._manager.get_page_finder() 322 self.sim_page = SimultaneousFitPage(self,page_finder=page_finder, id=-1) 323 self.sim_page.uid = wx.NewId() 324 self.AddPage(self.sim_page,"Simultaneous Fit", True) 325 self.sim_page.set_manager(self._manager) 326 self.enable_close_button() 327 return self.sim_page 322 page_finder = self._manager.get_page_finder() 323 if caption == "Simultanous Fit": 324 self.sim_page = SimultaneousFitPage(self,page_finder=page_finder, 325 id=-1, batch_on=False) 326 self.sim_page.window_caption = caption 327 self.sim_page.window_name = caption 328 self.sim_page.uid = wx.NewId() 329 self.AddPage(self.sim_page, caption, True) 330 self.sim_page.set_manager(self._manager) 331 self.enable_close_button() 332 return self.sim_page 333 else: 334 self.batch_page = SimultaneousFitPage(self, batch_on=True, 335 page_finder=page_finder) 336 self.batch_page.window_caption = caption 337 self.batch_page.window_name = caption 338 self.batch_page.uid = wx.NewId() 339 self.AddPage(self.batch_page, caption, True) 340 self.batch_page.set_manager(self._manager) 341 self.enable_close_button() 342 return self.batch_page 328 343 329 344 … … 566 581 self._manager.sim_page=None 567 582 return 583 if selected_page == self.batch_page : 584 self._manager.batch_page=None 585 return 568 586 """ 569 587 # The below is not working when delete #5 and still have #6. … … 608 626 ##non existing page 609 627 pass 628 try: 629 self.batch_page.draw_page() 630 except: 631 ## that page is already deleted no need to remove check box on 632 ##non existing page 633 pass 634 -
fittingview/src/sans/perspectives/fitting/fitting.py
rbb8a180 rfa02d95 98 98 #keep reference of the simultaneous fit page 99 99 self.sim_page = None 100 self.sim_menu = None 101 self.batch_page = None 102 self.batch_menu = None 100 103 self.index_model = 0 101 104 self.test_model_color = None … … 170 173 self.menu1.Append(self.id_simfit, '&Simultaneous Fit',simul_help) 171 174 wx.EVT_MENU(owner, self.id_simfit, self.on_add_sim_page) 172 sim_menu = self.menu1.FindItemById(self.id_simfit) 173 sim_menu.Enable(False) 174 175 self.sim_menu = self.menu1.FindItemById(self.id_simfit) 176 self.sim_menu.Enable(False) 177 #combined Batch 178 self.id_batchfit = wx.NewId() 179 batch_help = "Batch Fit" 180 self.menu1.Append(self.id_batchfit, '&Combine Batch Fit', batch_help) 181 wx.EVT_MENU(owner, self.id_batchfit, self.on_add_sim_page) 182 self.batch_menu = self.menu1.FindItemById(self.id_batchfit) 183 self.batch_menu.Enable(False) 175 184 self.menu1.AppendSeparator() 176 185 #Set park engine 177 scipy_help = "Scipy Engine: Perform Simple fit. More in Help window...."186 scipy_help = "Scipy Engine: Perform Simple fit. More in Help window...." 178 187 self.menu1.AppendCheckItem(self.scipy_id, "Simple FitEngine [LeastSq]", 179 188 scipy_help) … … 209 218 #create menubar items 210 219 return [(self.menu1, self.sub_menu)] 211 220 221 212 222 def on_add_sim_page(self, event): 213 223 """ 214 224 Create a page to access simultaneous fit option 215 225 """ 216 if self.sim_page != None: 217 self.sim_page.Show(True) 218 self.sim_page.Refresh() 219 self.sim_page.SetFocus() 226 id = event.GetId() 227 caption = "Simultaneous Fit" 228 page = self.sim_page 229 if id == self.id_batchfit: 230 caption = "Batch Fit" 231 page = self.batch_page 232 233 def set_focus_page(page): 234 page.Show(True) 235 page.Refresh() 236 page.SetFocus() 220 237 self.parent._mgr.Update() 221 msg= "Simultaneous Fit page already opened" 222 wx.PostEvent(self.parent, StatusEvent(status= msg)) 223 return 224 225 self.sim_page= self.fit_panel.add_sim_page() 238 msg = "%s already opened\n" % str(page.window_caption) 239 wx.PostEvent(self.parent, StatusEvent(status=msg)) 240 241 if page != None: 242 return set_focus_page(page) 243 if caption == "Simultaneous Fit": 244 self.sim_page = self.fit_panel.add_sim_page(caption=caption) 245 else: 246 self.batch_page = self.fit_panel.add_sim_page(caption=caption) 226 247 227 248 def help(self, evt): … … 547 568 sim_page_id = self.sim_page.uid 548 569 for uid, value in self.page_finder.iteritems(): 549 if uid != sim_page_id :570 if uid != sim_page_id and uid != self.batch_page.uid: 550 571 list = value.get_model() 551 572 model = list[0] … … 614 635 #set the fit button label of page when fit stop is trigger from 615 636 #simultaneous fit pane 616 if self.sim_page is not None and uid == self.sim_page.uid: 637 sim_flag = self.sim_page is not None and uid == self.sim_page.uid 638 batch_flag = self.batch_page is not None and uid == self.batch_page.uid 639 if sim_flag or batch_flag: 617 640 for uid, value in self.page_finder.iteritems(): 618 641 if value.get_scheduled() == 1: 619 642 if uid in self.fit_panel.opened_pages.keys(): 620 643 panel = self.fit_panel.opened_pages[uid] 621 panel. 644 panel._on_fit_complete() 622 645 623 646 def set_smearer(self, uid, smearer, fid, qmin=None, qmax=None, draw=True, … … 746 769 sim_fitter = None 747 770 is_single_fit = True 771 batch_on = False 748 772 if self.sim_page is not None and self.sim_page.uid == uid: 749 773 #simulatanous fit only one engine need to be created … … 751 775 self._on_change_engine(engine='park') 752 776 sim_fitter = Fit(self._fit_engine) 777 sim_fitter.fitter_id = self.sim_page.uid 753 778 fitter_list.append(sim_fitter) 754 779 is_single_fit = False 780 batch_on = self.sim_page.batch_on 755 781 756 782 … … 770 796 # if uid is specified (singlefit), do it only on the page. 771 797 if engineType == "Single Fit": 772 if page_id != uid: 773 continue 798 #combine more than 1 batch page on single mode 799 if self.batch_page is None or self.batch_page.uid != uid: 800 if page_id != uid: 801 continue 774 802 try: 775 803 if value.get_scheduled() == 1: … … 799 827 if sim_fitter is None: 800 828 fitter = Fit(self._fit_engine) 829 fitter.fitter_id = page_id 801 830 self._fit_helper(fitproblem=fitproblem, 802 831 pars=pars, … … 840 869 batch_on = page.batch_on 841 870 except: 842 batch_on = False 843 871 try: 872 #if the id cannot be found then we deal with a self.sim_page 873 #or a self.batch_page 874 if self.sim_page is not None and uid == self.sim_page.uid: 875 batch_on = self.sim_page.uid 876 if self.batch_page is not None and uid == self.batch_page.uid: 877 batch_on = self.batch_page.uid 878 except: 879 raise 880 844 881 # batch fit 845 882 if batch_on: … … 978 1015 if self.sim_page is not None and not self.batch_on: 979 1016 self.sim_page.draw_page() 1017 if self.batch_page is not None and self.batch_on: 1018 self.batch_page.draw_page() 1019 980 1020 return page 981 1021 … … 1102 1142 wx.PostEvent(self.parent, StatusEvent(status=msg, info="info", 1103 1143 type="stop")) 1104 pid = page_id[0] 1105 cpage = self.fit_panel.get_page_by_id(pid) 1106 batch_on = cpage.batch_on 1144 1107 1145 if batch_outputs is None: 1108 1146 batch_outputs = {} 1109 if batch_on: 1110 # format batch_outputs 1111 batch_outputs["Chi2"] = [] 1112 for index in range(len(pars)): 1113 batch_outputs[pars[index]] = [] 1114 batch_inputs["error on %s" % pars[index]] = [] 1115 msg = "" 1116 for list_res in result: 1117 for res in list_res: 1118 model, data = res.inputs[0] 1119 correct_result = False 1120 if model is not None and hasattr(model, "model"): 1121 model = model.model 1122 if data is not None and hasattr(data, "sans_data"): 1123 data = data.sans_data 1124 is_data2d = issubclass(data.__class__, Data2D) 1125 #check consistency of arrays 1147 1148 # format batch_outputs 1149 batch_outputs["Chi2"] = [] 1150 #Don't like these loops 1151 # Need to create dictionary of all fitted parameters 1152 # since the number of parameters can differ between each fit result 1153 for list_res in result: 1154 for res in list_res: 1155 model, data = res.inputs[0] 1156 if model is not None and hasattr(model, "model"): 1157 model = model.model 1158 #get all fittable parameters of the current model 1159 for param in model.getParamList(): 1160 if param not in batch_outputs.keys(): 1161 batch_outputs[param] = [] 1162 for param in model.getDispParamList(): 1163 if not model.is_fittable(param) and \ 1164 param in batch_outputs.keys(): 1165 del batch_outputs[param] 1166 # Add fitted parameters and their error 1167 for param in res.param_list: 1168 if param not in batch_outputs.keys(): 1169 batch_outputs[param] = [] 1170 err_param = "error on %s" % str(param) 1171 if err_param not in batch_inputs.keys(): 1172 batch_inputs[err_param] = [] 1173 msg = "" 1174 for list_res in result: 1175 for res in list_res: 1176 pid = res.fitter_id 1177 model, data = res.inputs[0] 1178 correct_result = False 1179 if model is not None and hasattr(model, "model"): 1180 model = model.model 1181 if data is not None and hasattr(data, "sans_data"): 1182 data = data.sans_data 1183 1184 is_data2d = issubclass(data.__class__, Data2D) 1185 #check consistency of arrays 1186 if not is_data2d: 1187 if len(res.theory) == len(res.index[res.index]) and \ 1188 len(res.index) == len(data.y): 1189 correct_result = True 1190 else: 1191 copy_data = deepcopy(data) 1192 new_theory = copy_data.data 1193 new_theory[res.index] = res.theory 1194 new_theory[res.index == False] = numpy.nan 1195 correct_result = True 1196 #get all fittable parameters of the current model 1197 param_list = model.getParamList() 1198 for param in model.getDispParamList(): 1199 if not model.is_fittable(param) and \ 1200 param in param_list: 1201 param_list.remove(param) 1202 if not correct_result or res.fitness is None or \ 1203 not numpy.isfinite(res.fitness) or \ 1204 numpy.any(res.pvec == None) or not \ 1205 numpy.all(numpy.isfinite(res.pvec)): 1206 data_name = str(None) 1207 if data is not None: 1208 data_name = str(data.name) 1209 model_name = str(None) 1210 if model is not None: 1211 model_name = str(model.name) 1212 msg += "Data %s and Model %s did not fit.\n" % (data_name, 1213 model_name) 1214 ERROR = numpy.NAN 1215 cell = BatchCell() 1216 cell.label = res.fitness 1217 cell.value = res.fitness 1218 batch_outputs["Chi2"].append(ERROR) 1219 for param in param_list: 1220 # save value of fixed parameters 1221 if param not in res.param_list: 1222 batch_outputs[str(param)].append(ERROR) 1223 else: 1224 #save only fitted values 1225 batch_outputs[param].append(ERROR) 1226 batch_inputs["error on %s" % str(param)].append(ERROR) 1227 else: 1228 cell = BatchCell() 1229 cell.label = res.fitness 1230 cell.value = res.fitness 1231 batch_outputs["Chi2"].append(cell) 1232 # add parameters to batch_results 1233 for param in param_list: 1234 # save value of fixed parameters 1235 if param not in res.param_list: 1236 batch_outputs[str(param)].append(model.getParam(param)) 1237 else: 1238 index = res.param_list.index(param) 1239 #save only fitted values 1240 batch_outputs[param].append(res.pvec[index]) 1241 if res.stderr is not None and \ 1242 len(res.stderr) == len(res.param_list): 1243 item = res.stderr[index] 1244 batch_inputs["error on %s" % param].append(item) 1245 model.setParam(param, res.pvec[index]) 1246 #fill the batch result with emtpy value if not in the current 1247 #model 1248 EMPTY = "-" 1249 for key in batch_outputs.keys(): 1250 if key not in param_list and key not in ["Chi2", "Data"]: 1251 batch_outputs[key].append(EMPTY) 1252 for key in batch_inputs.keys(): 1253 if key not in param_list and key not in ["Chi2", "Data"]: 1254 batch_inputs[key].append(EMPTY) 1255 1256 self.page_finder[pid].set_batch_result(batch_inputs=batch_inputs, 1257 batch_outputs=batch_outputs) 1258 1259 cpage = self.fit_panel.get_page_by_id(pid) 1260 cpage._on_fit_complete() 1261 self.page_finder[pid][data.id].set_result(res) 1262 fitproblem = self.page_finder[pid][data.id] 1263 qmin, qmax = fitproblem.get_range() 1264 1265 if correct_result: 1126 1266 if not is_data2d: 1127 if len(res.theory) == len(res.index[res.index]) and \ 1128 len(res.index) == len(data.y): 1129 correct_result = True 1267 self._complete1D(x=data.x, y=res.theory, page_id=pid, 1268 elapsed=None, 1269 index=res.index, model=model, 1270 weight=None, fid=data.id, 1271 toggle_mode_on=False, state=None, 1272 data=data, update_chisqr=False, 1273 source='fit') 1130 1274 else: 1131 copy_data = deepcopy(data) 1132 new_theory = copy_data.data 1133 new_theory[res.index] = res.theory 1134 new_theory[res.index == False] = numpy.nan 1135 correct_result = True 1136 #get all fittable parameters of the current model 1137 param_list = model.getParamList() 1138 for param in model.getDispParamList(): 1139 if not model.is_fittable(param) and \ 1140 param in param_list: 1141 param_list.remove(param) 1142 if not correct_result or res.fitness is None or \ 1143 not numpy.isfinite(res.fitness) or \ 1144 numpy.any(res.pvec == None) or not \ 1145 numpy.all(numpy.isfinite(res.pvec)): 1146 data_name = str(None) 1147 if data is not None: 1148 data_name = str(data.name) 1149 model_name = str(None) 1150 if model is not None: 1151 model_name = str(model.name) 1152 msg += "Data %s and Model %s did not fit.\n" % (data_name, 1153 model_name) 1154 ERROR = numpy.NAN 1155 cell = BatchCell() 1156 cell.label = res.fitness 1157 cell.value = res.fitness 1158 batch_outputs["Chi2"].append(ERROR) 1159 for param in param_list: 1160 # save value of fixed parameters 1161 if param not in batch_outputs.keys(): 1162 batch_outputs[param] = [] 1163 if param not in res.param_list: 1164 batch_outputs[str(param)].append(ERROR) 1165 for index in range(len(res.param_list)): 1166 #save only fitted values 1167 batch_outputs[res.param_list[index]].append(ERROR) 1168 batch_inputs["error on %s" % res.param_list[index]].append(ERROR) 1169 else: 1170 cell = BatchCell() 1171 cell.label = res.fitness 1172 cell.value = res.fitness 1173 batch_outputs["Chi2"].append(cell) 1174 # add parameters to batch_results 1175 for param in param_list: 1176 # save value of fixed parameters 1177 if param not in batch_outputs.keys(): 1178 batch_outputs[param] = [] 1179 if param not in res.param_list: 1180 batch_outputs[str(param)].append(model.getParam(param)) 1181 for index in range(len(res.param_list)): 1182 #save only fitted values 1183 batch_outputs[res.param_list[index]].append(res.pvec[index]) 1184 if res.stderr is not None and len(res.stderr) == len(res.param_list): 1185 item = res.stderr[index] 1186 batch_inputs["error on %s" % res.param_list[index]].append(item) 1187 if res.param_list[index] in model.getParamList(): 1188 model.setParam(res.param_list[index], res.pvec[index]) 1189 1190 self.page_finder[pid].set_batch_result(batch_inputs=batch_inputs, 1191 batch_outputs=batch_outputs) 1192 cpage = self.fit_panel.get_page_by_id(pid) 1193 cpage._on_fit_complete() 1194 self.page_finder[pid][data.id].set_result(res) 1195 fitproblem = self.page_finder[pid][data.id] 1196 qmin, qmax = fitproblem.get_range() 1197 1198 if correct_result: 1199 if not is_data2d: 1200 self._complete1D(x=data.x, y=res.theory, page_id=pid, 1201 elapsed=None, 1202 index=res.index, model=model, 1203 weight=None, fid=data.id, 1204 toggle_mode_on=False, state=None, 1205 data=data, update_chisqr=False, 1206 source='fit') 1207 else: 1208 self._complete2D(image=new_theory, data=data, 1209 model=model, 1210 page_id=pid, elapsed=None, 1211 index=res.index, 1212 qmin=qmin, 1213 qmax=qmax, fid=data.id, weight=None, 1214 toggle_mode_on=False, state=None, 1215 update_chisqr=False, 1216 source='fit') 1217 self.on_set_batch_result(page_id=pid, 1218 fid=data.id, 1219 batch_outputs=batch_outputs, 1220 batch_inputs=batch_inputs) 1275 self._complete2D(image=new_theory, data=data, 1276 model=model, 1277 page_id=pid, elapsed=None, 1278 index=res.index, 1279 qmin=qmin, 1280 qmax=qmax, fid=data.id, weight=None, 1281 toggle_mode_on=False, state=None, 1282 update_chisqr=False, 1283 source='fit') 1284 self.on_set_batch_result(page_id=pid, 1285 fid=data.id, 1286 batch_outputs=batch_outputs, 1287 batch_inputs=batch_inputs) 1221 1288 1222 1289 wx.PostEvent(self.parent, StatusEvent(status=msg, error="error", … … 1480 1547 if self.sim_page is not None and not self.batch_on: 1481 1548 self.sim_page.draw_page() 1549 if self.batch_page is not None and self.batch_on: 1550 self.batch_page.draw_page() 1482 1551 1483 1552 def _update1D(self, x, output): -
fittingview/src/sans/perspectives/fitting/simfitpage.py
r81a7b6c rfa02d95 44 44 45 45 46 def __init__(self, parent,page_finder ={}, *args, **kwargs): 47 ScrolledPanel.__init__(self, parent,style= wx.FULL_REPAINT_ON_RESIZE ) 46 def __init__(self, parent,page_finder ={}, id=-1, batch_on=False, 47 *args, **kwargs): 48 ScrolledPanel.__init__(self, parent, id=id, 49 style= wx.FULL_REPAINT_ON_RESIZE, 50 *args, **kwargs) 48 51 PanelBase.__init__(self, parent) 49 52 """ … … 55 58 self.uid = wx.NewId() 56 59 self.parent = parent 60 self.batch_on = batch_on 57 61 ## store page_finder 58 62 self.page_finder = page_finder … … 139 143 140 144 """ 145 flag = False 146 # check if the current page a simultaneous fit page or a batch page 147 if self == self._manager.sim_page: 148 flag = (self._manager.sim_page.uid == self.uid) 149 141 150 ## making sure all parameters content a constraint 142 151 ## validity of the constraint expression is own by fit engine 143 if self.parent._manager._fit_engine != "park" and\ 144 self._manager.sim_page.uid == self.uid: 152 if self.parent._manager._fit_engine != "park" and flag: 145 153 msg = "The FitEnging will be set to 'Park' fit engine\n" 146 154 msg += " for the simultaneous fit..." … … 176 184 self.manager = manager 177 185 178 def check_all_model_name(self, event):186 def check_all_model_name(self, event=None): 179 187 """ 180 188 check all models names … … 189 197 ## constraint info 190 198 self._store_model() 191 ## display constraint fields 192 if self.show_constraint.GetValue() and\ 193 len(self.constraints_list)==0: 194 self._show_all_constraint() 195 self._show_constraint() 199 if not self.batch_on: 200 ## display constraint fields 201 if self.show_constraint.GetValue() and\ 202 len(self.constraints_list)==0: 203 self._show_all_constraint() 204 self._show_constraint() 196 205 else: 197 206 for item in self.model_list: … … 199 208 200 209 self.model_toFit=[] 201 ##constraint info 202 self._hide_constraint() 210 if not self.batch_on: 211 ##constraint info 212 self._hide_constraint() 203 213 204 214 self._update_easy_setup_cb() … … 303 313 self.cb1 = wx.CheckBox(self, -1,'Select all') 304 314 self.cb1.SetValue(False) 315 305 316 wx.EVT_CHECKBOX(self, self.cb1.GetId(), self.check_all_model_name) 306 317 … … 313 324 self._fill_sizer_model_list(sizer_couples) 314 325 ## draw the sizer containing constraint info 315 self._fill_sizer_constraint() 326 if not self.batch_on: 327 self._fill_sizer_constraint() 316 328 ## draw fit button 317 329 self._fill_sizer_fit() … … 675 687 self.btFit.Bind(wx.EVT_BUTTON, self.onFit,id= self.btFit.GetId()) 676 688 self.btFit.SetToolTipString("Perform fit.") 677 text = " Note: Park fitting engine will be used automatically. \n" 678 text += " This page requires at least one FitPage with a data \n" 679 text += " and a model set for fitting." 680 #text+= "automatically for more than 2 combinations checked" 681 text_hint = wx.StaticText(self,-1,text) 689 if self.batch_on: 690 text = " Fit in Parallel all Data set and model selected.\n" 691 else: 692 text = " Note: Park fitting engine will be used automatically. \n" 693 text += " This page requires at least one FitPage with a data \n" 694 text += " and a model set for fitting." 695 #text+= "automatically for more than 2 combinations checked" 696 text_hint = wx.StaticText(self, -1, text) 682 697 683 698 sizer_button.Add(text_hint, wx.RIGHT|wx.EXPAND, 10) … … 697 712 698 713 self.sizer2.Clear(True) 714 if self.batch_on: 715 self.sizer2.Hide() 716 return 699 717 box_description= wx.StaticBox(self, -1,"Fit Constraints") 700 718 boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) … … 709 727 self.Bind( wx.EVT_RADIOBUTTON, self._display_constraint, 710 728 id= self.hide_constraint.GetId() ) 711 self.Bind( wx.EVT_RADIOBUTTON, self._display_constraint, 712 id= self.show_constraint.GetId() ) 729 self.Bind(wx.EVT_RADIOBUTTON, self._display_constraint, 730 id= self.show_constraint.GetId()) 731 if self.batch_on: 732 self.hide_constraint.Enable(False) 733 self.show_constraint.Enable(False) 713 734 self.hide_constraint.SetValue(True) 714 sizer_title.Add( wx.StaticText(self,-1," Model") ) 735 self.show_constraint.SetValue(False) 736 737 sizer_title.Add(wx.StaticText(self,-1," Model")) 715 738 sizer_title.Add(( 10,10) ) 716 sizer_title.Add( wx.StaticText(self,-1," Parameter") 739 sizer_title.Add( wx.StaticText(self,-1," Parameter")) 717 740 sizer_title.Add(( 10,10) ) 718 741 sizer_title.Add( wx.StaticText(self,-1," Add Constraint?") ) … … 721 744 sizer_title.Add( self.hide_constraint ) 722 745 sizer_title.Add(( 10,10) ) 746 723 747 724 748 self.btAdd =wx.Button(self,wx.NewId(),'Add') … … 742 766 self.sizer2.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) 743 767 self.sizer2.Layout() 768 744 769 #self.SetScrollbars(20,20,25,65) 745 770 … … 836 861 if id not in self.parent.opened_pages: 837 862 continue 838 try: 839 ix = 0 840 for fitproblem in value.get_fit_problem(): 841 if self.parent.get_page_by_id(id).batch_on: 842 continue 843 data = fitproblem.get_fit_data() 844 if not data.is_data: 845 continue 846 model = fitproblem.get_model() 847 if model == None: 848 continue 849 iy += 1 850 name = '_' 851 if model is not None: 852 name = str(model.name) 853 cb = wx.CheckBox(self, -1, name) 854 cb.SetValue(False) 855 cb.Enable(model is not None and data.is_data) 856 sizer.Add(cb, (iy, ix), (1, 1), 857 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 858 wx.EVT_CHECKBOX(self, cb.GetId(), self.check_model_name) 859 ix += 2 860 type = model.__class__.__name__ 861 model_type = wx.StaticText(self, -1, str(type)) 862 sizer.Add(model_type, (iy, ix), (1, 1), 863 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 864 name = '-' 865 if data is not None and data.is_data: 866 name = str(data.name) 867 data_used = wx.StaticText(self, -1, name) 868 ix += 1 869 sizer.Add(data_used, (iy, ix), (1, 1), 870 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 871 ix += 1 872 caption = value.get_fit_tab_caption() 873 tab_caption_used= wx.StaticText(self, -1, str(caption)) 874 sizer.Add(tab_caption_used, (iy, ix), (1, 1), 875 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 863 864 if self.batch_on != self.parent.get_page_by_id(id).batch_on: 865 continue 866 867 data_list = [] 868 model_list = [] 869 # get data name and model objetta 870 for fitproblem in value.get_fit_problem(): 876 871 877 self.model_list.append([cb,value,id,model]) 878 except: 879 raise 880 #pass 872 data = fitproblem.get_fit_data() 873 if not data.is_data: 874 continue 875 name = '-' 876 if data is not None and data.is_data: 877 name = str(data.name) 878 data_list.append(name) 879 880 model = fitproblem.get_model() 881 if model is None: 882 continue 883 model_list.append(model) 884 885 if len(model_list) == 0: 886 continue 887 # Draw sizer 888 ix = 0 889 iy += 1 890 model = model_list[0] 891 name = '_' 892 if model is not None: 893 name = str(model.name) 894 cb = wx.CheckBox(self, -1, name) 895 cb.SetValue(False) 896 cb.Enable(model is not None and data.is_data) 897 sizer.Add(cb, (iy, ix), (1, 1), 898 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 899 wx.EVT_CHECKBOX(self, cb.GetId(), self.check_model_name) 900 ix += 2 901 type = model.__class__.__name__ 902 model_type = wx.StaticText(self, -1, str(type)) 903 sizer.Add(model_type, (iy, ix), (1, 1), 904 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 905 if self.batch_on: 906 data_used = wx.ComboBox(self, -1, style=wx.CB_READONLY) 907 data_used.AppendItems(data_list) 908 data_used.SetSelection(0) 909 else: 910 data_used = wx.StaticText(self, -1, data_list[0]) 911 912 ix += 1 913 sizer.Add(data_used, (iy, ix), (1, 1), 914 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 915 ix += 1 916 caption = value.get_fit_tab_caption() 917 tab_caption_used= wx.StaticText(self, -1, str(caption)) 918 sizer.Add(tab_caption_used, (iy, ix), (1, 1), 919 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 920 921 self.model_list.append([cb, value, id, model]) 922 881 923 iy += 1 882 924 sizer.Add((20, 20), (iy, ix), (1, 1),
Note: See TracChangeset
for help on using the changeset viewer.