Changeset fb59ed9 in sasview for theoryview/perspectives/theory/model_panel.py
- Timestamp:
- Oct 20, 2010 6:08:34 PM (14 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:
- d2539aa
- Parents:
- f118fe2f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
theoryview/perspectives/theory/model_panel.py
r20905a0 rfb59ed9 362 362 event = PageInfoEvent(page = self) 363 363 wx.PostEvent(self.parent, event) 364 365 def _set_fun_box_list(self,fun_box): 366 """ 367 Set the list of func for multifunctional models 368 369 :param fun_box: function combo box 370 """ 371 # Check if it is multi_functional model 372 if self.model.__class__ not in self.model_list_box["Multi-Functions"]: 373 return None 374 # Get the func name list 375 list = self.model.fun_list 376 377 if len(list) == 0: 378 return None 379 380 # build function (combo)box 381 ind = 0 382 while(ind < len(list)): 383 for key, val in list.iteritems(): 384 if (val == ind): 385 fun_box.Append(key,val) 386 break 387 ind += 1 388 389 def _on_fun_box(self,event): 390 """ 391 Select an func: Erf,Rparabola,LParabola... 392 """ 393 fun_val = None 394 fun_box = event.GetEventObject() 395 name = fun_box.Name 396 value = fun_box.GetValue() 397 if self.model.fun_list.has_key(value): 398 fun_val = self.model.fun_list[value] 399 400 self.model.setParam(name,fun_val) 401 # save state 402 self._copy_parameters_state(self.str_parameters, self.state.str_parameters) 403 # update params 404 #self._update_paramv_on_fit() 405 406 # draw 407 self._draw_model() 408 self.Refresh() 409 # get ready for new event 410 event.Skip() 364 411 365 412 def set_data(self, list=[], state=None): … … 507 554 self.sizer3.Clear(True) 508 555 self.parameters = [] 556 self.str_parameters = [] 509 557 self.param_toFit=[] 510 558 self.fixed_param=[] … … 532 580 Custom compare to order, first by alphabets then second by number. 533 581 """ 582 # number at the last digit 534 583 a_last = a[len(a)-1] 535 584 b_last = b[len(b)-1] 536 585 # default 537 586 num_a = None 538 587 num_b = None 588 # split the names 589 a2 = a.lower().split('_') 590 b2 = b.lower().split('_') 591 # check length of a2, b2 592 len_a2 = len(a2) 593 len_b2 = len(b2) 539 594 # check if it contains a int number(<10) 540 595 try: … … 544 599 num_b = int(b_last) 545 600 except: pass 601 # Put 'scale' near the top; happens 602 # when numbered param name exists 603 if a == 'scale': 604 return -1 546 605 # both have a number 547 606 if num_a != None and num_b != None: 548 if num_a > num_b: return 1 607 if num_a > num_b: return -1 608 # same number 549 609 elif num_a == num_b: 550 return cmp(a.lower(), b.lower()) 551 else: return -1 610 # different last names 611 if a2[len_a2-1] != b2[len_b2-1] and num_a != 0: 612 return -cmp(a2[len_a2-1], b2[len_b2-1]) 613 else: 614 return cmp(a, b) 615 else: return 1 552 616 # one of them has a number 553 617 elif num_a != None: return 1 554 618 elif num_b != None: return -1 555 # no nu umbers619 # no numbers 556 620 else: return cmp(a.lower(), b.lower()) 557 621 558 622 keys.sort(custom_compare) 559 623 … … 578 642 iy += 1 579 643 ix = 0 580 name = wx.StaticText(self, -1,item) 581 sizer.Add( name,( iy, ix),(1,1), 582 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 583 584 ix += 1 585 value= self.model.getParam(item) 586 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 587 style=wx.TE_PROCESS_ENTER) 588 589 ctl1.SetValue(str (format_number(value))) 590 591 sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) 592 ix +=1 593 # Units 594 if self.model.details.has_key(item): 595 units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) 644 if self.model.__class__ in self.model_list_box["Multi-Functions"]\ 645 and item in self.model.non_fittable: 646 non_fittable_name = wx.StaticText(self, -1, item ) 647 sizer.Add(non_fittable_name,(iy, ix),(1,1),\ 648 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 649 ## add parameter value 650 ix += 1 651 value= self.model.getParam(item) 652 if len(self.model.fun_list) > 0: 653 num = item.split('_')[1][5:7] 654 fun_box = wx.ComboBox(self, -1,size=(100,-1),style=wx.CB_READONLY, name = '%s'% item) 655 self._set_fun_box_list(fun_box) 656 fun_box.SetSelection(0) 657 #self.fun_box.SetToolTipString("A function describing the interface") 658 wx.EVT_COMBOBOX(fun_box,-1, self._on_fun_box) 659 else: 660 fun_box = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 661 style=wx.TE_PROCESS_ENTER, name ='%s'% item) 662 fun_box.SetToolTipString("Hit 'Enter' after typing.") 663 fun_box.SetValue(format_number(value)) 664 sizer.Add(fun_box, (iy,ix),(1,1), wx.EXPAND) 665 ##[cb state, name, value, "+/-", error of fit, min, max , units] 666 self.str_parameters.append([None,item, fun_box, \ 667 None,None,None,None,None]) 596 668 else: 597 units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) 598 sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 599 ##[cb state, name, value, "+/-", error of fit, min, max , units] 600 self.parameters.append([None,item, ctl1, 601 None,None, None, None,None]) 669 name = wx.StaticText(self, -1,item) 670 sizer.Add( name,( iy, ix),(1,1), 671 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 672 673 ix += 1 674 value= self.model.getParam(item) 675 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 676 style=wx.TE_PROCESS_ENTER) 677 678 ctl1.SetValue(str (format_number(value))) 679 680 sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) 681 ix +=1 682 # Units 683 if self.model.details.has_key(item): 684 units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) 685 else: 686 units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) 687 sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 688 ##[cb state, name, value, "+/-", error of fit, min, max , units] 689 self.parameters.append([None,item, ctl1, 690 None,None, None, None,None]) 602 691 iy+=1 603 692 sizer.Add((10,10),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
Note: See TracChangeset
for help on using the changeset viewer.