Changeset ac11e40 in sasview
- Timestamp:
- Mar 25, 2009 5:37:30 PM (16 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:
- d0d2ab5
- Parents:
- 2140e68
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/simfitpage.py
r2140e68 rac11e40 16 16 self.page = page 17 17 self.fittable_param =[] 18 self.selected_params=[]19 18 self._set_fittableParam() 20 19 … … 51 50 self.page_finder=page_finder 52 51 ## list contaning info to set constraint 53 ## look like self.constraint_dict[page]= [ model_name, parameter_name, constraint(string)]52 ## look like self.constraint_dict[page]=FitConstraint(model, page) 54 53 self.constraint_dict={} 55 54 ## item list self.constraints_list=[combobox1, combobox2,=,textcrtl, button ] … … 59 58 ## selected mdoel to fit 60 59 self.model_toFit=[] 61 62 63 60 ## draw 64 61 self.define_page_structure() … … 99 96 ## making sure all parameters content a constraint 100 97 ## validity of the constraint expression is own by fit engine 101 self._set_constraint() 98 if self.show_constraint.GetValue(): 99 self._set_constraint() 102 100 ## get the fit range of very fit problem 103 101 for page, value in self.page_finder.iteritems(): … … 262 260 return 263 261 if self.show_constraint.GetValue(): 264 self. sizer_couples.Clear(True)262 self._hide_constraint() 265 263 self._show_constraint() 266 264 return … … 274 272 Show constraint fields 275 273 """ 276 flag = False277 274 if len(self.constraints_list)!= 0: 278 275 nb_fit_param = 0 … … 281 278 ##Don't add anymore 282 279 if len(self.constraints_list) == nb_fit_param: 283 flag = True 284 if len(self.model_toFit) < 2 or flag: 280 msg= "Cannot add another constraint .Maximum of number " 281 msg += "Parameters name reached %s"%str(nb_fit_param) 282 wx.PostEvent(self.parent.Parent, StatusEvent(status= msg )) 283 self.sizer_couples.Layout() 284 self.sizer2.Layout() 285 self.SetScrollbars(20,20,200,100) 286 return 287 288 if len(self.model_toFit) < 2 : 285 289 msg= "Select at least 2 model to add constraint " 286 290 wx.PostEvent(self.parent.Parent, StatusEvent(status= msg )) … … 300 304 301 305 ctl2 = wx.TextCtrl(self, -1) 302 ctl2.Bind(wx.EVT_TEXT_ENTER,self._onTextEnter)303 306 ctl2.Hide() 304 307 … … 310 313 ## check if all parameters have been selected for constraint 311 314 ## then do not allow add constraint on parameters 312 if len(value.fittable_param)!= len(value.selected_params): 313 ## the user can apply constraint only on model select to fit 314 model_cbox.Append( str(model.name), model) 315 model_cbox.Append( str(model.name), model) 315 316 316 317 … … 337 338 """ 338 339 hide buttons related constraint 339 """ 340 """ 340 341 if len(self.constraint_dict)>0: 341 for value in self.constraint_dict.itervalues(): 342 value.selected_params=[] 343 param = value.fittable_param## list of parameter name 344 ## reset the constraint to None on fitproblem 345 for item in param: 346 self.page_finder[value.page].set_model_param(item,None) 347 342 for item in self.constraints_list: 343 model = item[0].GetClientData(0) 344 if model in self.constraint_dict.keys(): 345 page = self.constraint_dict[model].page 346 self.page_finder[page].clear_model_param() 347 348 self.constraint_dict={} 349 self._store_model() 348 350 self.btAdd.Hide() 349 351 self.constraints_list=[] … … 354 356 self.AdjustScrollbars() 355 357 356 358 357 359 358 360 def _on_select_model(self, event): … … 370 372 ## insert only fittable paramaters 371 373 for param in param_list: 372 if not param in self.constraint_dict[model].selected_params:373 param_cbox.Append( str(param), model)374 param_cbox.Append( str(param), model) 375 374 376 param_cbox.Show(True) 375 377 … … 385 387 model = event.GetClientData() 386 388 param = event.GetString() 387 self.constraint_dict[model].selected_params.append(param) 388 389 389 390 length = len(self.constraints_list) 390 391 if length < 1: … … 423 424 ctl2 = item[3] 424 425 if ctl2.GetValue().lstrip().rstrip()=="": 425 msg= " Enter a constraint for %s.%s! "%( model_cbox.GetString(0),426 msg= " Enter a constraint for %s.%s! "%(param_cbox.GetClientData(0).name, 426 427 param_cbox.GetString(0)) 427 428 wx.PostEvent(self.parent.Parent, StatusEvent(status= msg )) … … 458 459 self.Bind( wx.EVT_RADIOBUTTON, self._display_constraint, 459 460 id= self.show_constraint.GetId() ) 460 461 462 463 461 464 462 sizer_title.Add( wx.StaticText(self,-1," Model") ) … … 472 470 sizer_title.Add(( 10,10) ) 473 471 474 475 476 ## Draw combobox box related to model name and model parameters477 if self.show_constraint.GetValue():478 self._fill_sizer_constraint_helper(self.sizer_couples)479 480 472 self.btAdd =wx.Button(self,wx.NewId(),'Add') 481 473 self.btAdd.Bind(wx.EVT_BUTTON, self._onAdd_constraint,id= self.btAdd.GetId()) … … 504 496 505 497 506 def _onTextEnter(self, event):507 """508 callback function for textcrtl509 """510 self.btAdd.Show(True)511 self.sizer2.Layout()512 self.SetScrollbars(20,20,200,100)513 self._set_constraint()514 515 498 def _set_constraint(self): 516 499 """ … … 521 504 """ 522 505 for item in self.constraints_list: 523 model = item[0].GetClientData(0) 524 param = item[1].GetString(0) 506 507 model = item[0].GetClientData(item[0].GetCurrentSelection()) 508 param = item[1].GetString(item[1].GetCurrentSelection()) 525 509 constraint = item[3].GetValue().lstrip().rstrip() 526 510 if model in self.constraint_dict.keys(): 527 511 page = self.constraint_dict[model].page 528 if constraint != "": 529 self.page_finder[page].set_model_param(param,constraint) 512 if constraint == "": 513 constraint = None 514 515 self.page_finder[page].set_model_param(param,constraint) 530 516 531 517
Note: See TracChangeset
for help on using the changeset viewer.