Changeset 8bd4dc0 in sasview for sansview/perspectives
- Timestamp:
- Mar 26, 2009 3:22:24 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:
- dfae8b3
- Parents:
- b28717b
- Location:
- sansview/perspectives/fitting
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
rc77d859 r8bd4dc0 85 85 self.sizer2 = wx.BoxSizer(wx.VERTICAL) 86 86 self.sizer3 = wx.BoxSizer(wx.VERTICAL) 87 88 87 self.sizer4 = wx.BoxSizer(wx.VERTICAL) 89 88 self.sizer5 = wx.BoxSizer(wx.VERTICAL) 89 90 self.sizer0.SetMinSize((375,-1)) 91 self.sizer1.SetMinSize((375,-1)) 92 self.sizer2.SetMinSize((375,-1)) 93 self.sizer3.SetMinSize((375,-1)) 94 self.sizer4.SetMinSize((375,-1)) 95 self.sizer5.SetMinSize((375,-1)) 90 96 91 97 self.vbox.Add(self.sizer0) … … 165 171 import sans.models.dispersion_models 166 172 self.polydisp= sans.models.dispersion_models.models 167 self.disp_box = wx.ComboBox(self, -1 )173 self.disp_box = wx.ComboBox(self, -1,style=wx.CB_READONLY) 168 174 self.disp_box.SetValue("GaussianModel") 169 175 … … 474 480 self.text2.Hide() 475 481 476 self.formfactorbox = wx.ComboBox(self, -1 )482 self.formfactorbox = wx.ComboBox(self, -1,style=wx.CB_READONLY) 477 483 if self.model!=None: 478 484 self.formfactorbox.SetValue(self.model.name) 479 485 480 self.structurebox = wx.ComboBox(self, -1 )486 self.structurebox = wx.ComboBox(self, -1,style=wx.CB_READONLY) 481 487 wx.EVT_COMBOBOX(self.formfactorbox,-1, self._on_select_model) 482 488 wx.EVT_COMBOBOX(self.structurebox,-1, self._on_select_model) -
sansview/perspectives/fitting/modelpage.py
raa306e4 r8bd4dc0 377 377 value= self.model.getParam(item) 378 378 ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), 379 379 style=wx.TE_PROCESS_ENTER) 380 380 381 381 ctl1.SetValue(str (format_number(value))) … … 412 412 self.sizer3.Layout() 413 413 self.SetScrollbars(20,20,200,100) 414 414 415 def _onHighlight(self, event ): 416 print" hightlignt" 415 417 416 418 -
sansview/perspectives/fitting/simfitpage.py
rb28717b r8bd4dc0 4 4 from sans.guicomm.events import StatusEvent 5 5 6 class FitConstraint: 6 7 def get_fittableParam( model): 7 8 """ 8 Contains info on selected model to fit9 via simultaneous page9 @return list of fittable parameters name of a model 10 @param model: the model used 10 11 """ 11 def __init__(self, model, page=None): 12 """ 13 initialization 14 """ 15 self.model= model 16 self.page = page 17 self.fittable_param =[] 18 self._set_fittableParam() 19 20 def _set_fittableParam(self): 21 """ 22 fill self.fittable_param 23 """ 24 for item in self.model.getParamList(): 25 if not item in self.model.getDispParamList(): 26 self.fittable_param.append(item) 27 for item in self.model.fixed: 28 self.fittable_param.append(item) 29 12 fittable_param=[] 13 14 for item in model.getParamList(): 15 if not item in model.getDispParamList(): 16 fittable_param.append(item) 17 18 for item in model.fixed: 19 fittable_param.append(item) 20 21 return fittable_param 30 22 31 23 class SimultaneousFitPage(wx.ScrolledWindow): … … 50 42 self.page_finder = page_finder 51 43 ## list contaning info to set constraint 52 ## look like self.constraint_dict[page]= FitConstraint(model, page)44 ## look like self.constraint_dict[page]= page 53 45 self.constraint_dict={} 54 46 ## item list self.constraints_list=[combobox1, combobox2,=,textcrtl, button ] … … 74 66 self.sizer1 = wx.BoxSizer(wx.VERTICAL) 75 67 self.sizer2 = wx.BoxSizer(wx.VERTICAL) 76 68 self.sizer3 = wx.BoxSizer(wx.VERTICAL) 69 self.sizer1.SetMinSize((375,-1)) 70 self.sizer2.SetMinSize((375,-1)) 71 self.sizer3.SetMinSize((375,-1)) 77 72 self.vbox.Add(self.sizer1) 78 73 self.vbox.Add(self.sizer2) 74 self.vbox.Add(self.sizer3) 79 75 80 76 def set_scroll(self): … … 92 88 self.set_scroll() 93 89 self.Centre() 90 91 def onRemove(self, event): 92 """ 93 Remove constraint fields 94 """ 95 if len(self.constraints_list)<=1: 96 return 97 for item in self.constraints_list: 98 length= len(item) 99 if event.GetId()==item[length-2].GetId(): 100 sizer= item[length-1] 101 self.sizer_constraints.Remove(sizer) 102 self.sizer_constraints.Layout() 103 self.sizer2.Layout() 104 self.SetScrollbars(20,20,200,100) 105 self.constraints_list.remove(item) 106 self.nb_constraint -= 1 107 break 108 94 109 95 110 def onFit(self,event): … … 187 202 self.model_list=[] 188 203 self.model_toFit=[] 204 self.constraints_list=[] 189 205 if len(self.model_list)>0: 190 206 for item in self.model_list: … … 195 211 196 212 197 box_description= wx.StaticBox(self, -1,"Fit Co uples")213 box_description= wx.StaticBox(self, -1,"Fit Combinations") 198 214 boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 199 215 sizer_title = wx.BoxSizer(wx.HORIZONTAL) … … 202 218 #------------------------------------------------------ 203 219 if len(self.page_finder)==0: 204 sizer_title.Add(wx.StaticText(self,-1," No fit co upleavailable !"))220 sizer_title.Add(wx.StaticText(self,-1," No fit combination available !")) 205 221 else: 206 222 ## store model 207 223 self._store_model() 208 224 209 self.cb1 = wx.CheckBox(self, -1,'Select all Fit Couples')225 self.cb1 = wx.CheckBox(self, -1,'Select all') 210 226 self.cb1.SetValue(False) 211 227 wx.EVT_CHECKBOX(self, self.cb1.GetId(), self.check_all_model_name) 212 228 213 sizer_title.Add((15,15)) 214 sizer_title.Add(self.cb1) 215 ## draw list of model name 229 sizer_title.Add((10,10),0, 230 wx.TOP|wx.BOTTOM|wx.EXPAND|wx.ADJUST_MINSIZE,border=5) 231 sizer_title.Add(self.cb1,0, 232 wx.TOP|wx.BOTTOM|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE,border=5) 233 234 ## draw list of model and data name 216 235 self._fill_sizer_model_list(sizer_couples) 217 236 ## draw the sizer containing constraint info 218 237 self._fill_sizer_constraint() 238 ## draw fit button 239 self._fill_sizer_fit() 240 219 241 #-------------------------------------------------------- 220 boxsizer1.Add((5, 5)) 221 boxsizer1.Add(sizer_title) 222 boxsizer1.Add((5, 5)) 223 boxsizer1.Add(sizer_couples) 224 boxsizer1.Add((5,5)) 225 226 self.sizer1.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) 242 boxsizer1.Add(sizer_title, flag= wx.TOP|wx.BOTTOM,border=5) 243 boxsizer1.Add(sizer_couples, flag= wx.TOP|wx.BOTTOM,border=5) 244 245 self.sizer1.Add(boxsizer1,1, wx.EXPAND | wx.ALL, 10) 227 246 self.sizer1.Layout() 228 247 self.SetScrollbars(20,20,200,100) … … 239 258 for item in self.model_toFit: 240 259 if model in item and not model in self.constraint_dict.keys(): 241 self.constraint_dict[model] =FitConstraint(model=model, page=page)260 self.constraint_dict[model] = page 242 261 243 262 … … 266 285 if len(self.constraints_list)!= 0: 267 286 nb_fit_param = 0 268 for value in self.constraint_dict.values():269 nb_fit_param += len( value.fittable_param)287 for model in self.constraint_dict.keys(): 288 nb_fit_param += len(get_fittableParam(model)) 270 289 ##Don't add anymore 271 290 if len(self.constraints_list) == nb_fit_param: … … 287 306 288 307 sizer_constraint = wx.BoxSizer(wx.HORIZONTAL) 289 290 model_cbox = wx.ComboBox(self, -1) 308 model_cbox = wx.ComboBox(self, -1,style=wx.CB_READONLY) 291 309 model_cbox.Clear() 292 293 param_cbox = wx.ComboBox(self, -1) 310 param_cbox = wx.ComboBox(self, -1,style=wx.CB_READONLY) 294 311 param_cbox.Hide() 295 312 wx.EVT_COMBOBOX(param_cbox,-1, self._on_select_param) 296 297 313 ctl2 = wx.TextCtrl(self, -1) 298 299 314 egal_txt= wx.StaticText(self,-1," = ") 300 315 btRemove = wx.Button(self,wx.NewId(),'Remove') 316 btRemove.Bind(wx.EVT_BUTTON, self.onRemove,id= btRemove.GetId()) 317 btRemove.SetToolTipString("Remove constraint.") 301 318 302 319 … … 309 326 wx.EVT_COMBOBOX(model_cbox,-1, self._on_select_model) 310 327 311 ##[combobox1, combobox2,=,textcrtl ] 312 self.constraints_list.append([model_cbox, param_cbox, egal_txt, ctl2]) 313 328 314 329 sizer_constraint.Add(model_cbox, flag= wx.RIGHT|wx.EXPAND,border=10) 315 330 sizer_constraint.Add(param_cbox, flag= wx.RIGHT|wx.EXPAND,border=5) 316 331 sizer_constraint.Add(egal_txt, flag= wx.RIGHT|wx.EXPAND,border=5) 317 332 sizer_constraint.Add(ctl2, flag= wx.RIGHT|wx.EXPAND,border=10) 333 sizer_constraint.Add(btRemove, flag= wx.RIGHT|wx.EXPAND,border=10) 318 334 319 335 self.sizer_constraints.Insert(before=self.nb_constraint, 320 336 item=sizer_constraint, flag= wx.TOP|wx.BOTTOM|wx.EXPAND, 321 border=5, userData=0) 337 border=5) 338 ##[combobox1, combobox2,=,textcrtl, remove button ] 339 self.constraints_list.append([model_cbox, param_cbox, egal_txt, ctl2,btRemove,sizer_constraint]) 340 322 341 323 342 self.nb_constraint += 1 … … 330 349 hide buttons related constraint 331 350 """ 332 if len(self.constraint _dict)>0:351 if len(self.constraints_list)>0: 333 352 for item in self.constraints_list: 334 353 model = item[0].GetClientData(item[0].GetCurrentSelection()) 335 354 if model in self.constraint_dict.keys(): 336 page = self.constraint_dict[model] .page355 page = self.constraint_dict[model] 337 356 self.page_finder[page].clear_model_param() 338 357 … … 355 374 """ 356 375 model = event.GetClientData() 357 param_list= self.constraint_dict[model].fittable_param376 param_list= get_fittableParam(model) 358 377 length = len(self.constraints_list) 359 378 if length < 1: … … 398 417 Add another line for constraint 399 418 """ 400 msg= " " 401 wx.PostEvent(self.parent.Parent, StatusEvent(status= msg )) 402 419 420 if not self.show_constraint.GetValue(): 421 msg= " Select Yes to add Constraint " 422 wx.PostEvent(self.parent.Parent, StatusEvent(status= msg )) 423 return 424 403 425 ## check that a constraint is added before allow to add another cosntraint 404 426 … … 424 446 self._show_constraint() 425 447 426 427 428 448 def _fill_sizer_fit(self): 449 """ 450 Draw fit fit button 451 """ 452 self.sizer3.Clear(True) 453 box_description= wx.StaticBox(self, -1,"Fit ") 454 boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 455 sizer_button = wx.BoxSizer(wx.HORIZONTAL) 456 457 self.btFit = wx.Button(self,wx.NewId(),'Fit') 458 self.btFit.Bind(wx.EVT_BUTTON, self.onFit,id= self.btFit.GetId()) 459 self.btFit.SetToolTipString("Perform fit.") 460 461 text= "Hint: Park fitting engine will be selected \n" 462 text+= "automatically for more than 2 combinations checked" 463 text_hint = wx.StaticText(self,-1,text) 464 465 sizer_button.Add(text_hint, wx.RIGHT|wx.EXPAND, 10) 466 sizer_button.Add(self.btFit, 0, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 467 468 boxsizer1.Add(sizer_button, flag= wx.TOP|wx.BOTTOM,border=10) 469 self.sizer3.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) 470 self.sizer3.Layout() 471 self.SetScrollbars(20,20,200,100) 429 472 430 473 def _fill_sizer_constraint(self): … … 465 508 self.btAdd.Bind(wx.EVT_BUTTON, self._onAdd_constraint,id= self.btAdd.GetId()) 466 509 self.btAdd.SetToolTipString("Add another constraint?") 467 468 469 self.btFit = wx.Button(self,wx.NewId(),'Fit') 470 self.btFit.Bind(wx.EVT_BUTTON, self.onFit,id= self.btFit.GetId()) 471 self.btFit.SetToolTipString("Perform fit.") 510 472 511 473 512 text_hint = wx.StaticText(self,-1,"Example: M0.paramter = M1.parameter") 474 513 sizer_button.Add(text_hint, 0 , wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 475 514 sizer_button.Add(self.btAdd, 0, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 476 sizer_button.Add(self.btFit, 0, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 477 478 boxsizer1.Add(sizer_title) 479 boxsizer1.Add((10,10)) 480 boxsizer1.Add(self.sizer_constraints) 481 boxsizer1.Add((10,10)) 482 boxsizer1.Add(sizer_button) 515 516 517 boxsizer1.Add(sizer_title, flag= wx.TOP|wx.BOTTOM,border=10) 518 boxsizer1.Add(self.sizer_constraints, flag= wx.TOP|wx.BOTTOM,border=10) 519 boxsizer1.Add(sizer_button, flag= wx.TOP|wx.BOTTOM,border=10) 483 520 484 521 self.sizer2.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) … … 501 538 constraint = item[3].GetValue().lstrip().rstrip() 502 539 if model in self.constraint_dict.keys(): 503 page = self.constraint_dict[model] .page540 page = self.constraint_dict[model] 504 541 if constraint == "": 505 542 constraint = None … … 545 582 wx.EVT_CHECKBOX(self, cb.GetId(), self.check_model_name) 546 583 547 548 584 ix +=2 549 585 type = model.__class__.__name__ … … 555 591 data_used= wx.StaticText(self, -1, str(data.name)) 556 592 sizer.Add(data_used,( iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 557 558 593 559 594 self.model_list.append([cb,value,page,model])
Note: See TracChangeset
for help on using the changeset viewer.