Changeset 376916c in sasview for sansview/perspectives/fitting
- Timestamp:
- Apr 1, 2009 4:37:27 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:
- 89ef796
- Parents:
- 208de57
- Location:
- sansview/perspectives/fitting
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
r1328e03 r376916c 471 471 472 472 for k, list in self.model_list_box.iteritems(): 473 if k == "shapes":473 if k in["P(Q)*S(Q)","Shapes" ] and class_name in self.model_list_box["Shapes"]: 474 474 self.shape_rbutton.SetValue(True) 475 elif k == "Shape-independent": 475 ## fill the form factor list with new model 476 self._populate_box(self.formfactorbox,self.model_list_box["Shapes"]) 477 items = self.formfactorbox.GetItems() 478 ## set comboxbox to the selected item 479 for i in range(len(items)): 480 if items[i]== str(name): 481 self.formfactorbox.SetSelection(i) 482 break 483 return 484 elif k == "Shape-Independent": 476 485 self.shape_indep_rbutton.SetValue(True) 477 486 elif k == "Structure Factors": … … 479 488 else: 480 489 self.plugin_rbutton.SetValue(True) 481 490 482 491 if class_name in list: 483 492 ## fill the form factor list with new model … … 491 500 break 492 501 else: 493 ## Select the model from the combo 502 ## Select the model from the combobox 494 503 class_name = model.__class__ 495 504 name = model.name 496 505 self.formfactorbox.Clear() 497 506 items = self.formfactorbox.GetItems() 507 498 508 for k, list in self.model_list_box.iteritems(): 499 if k == "shapes":509 if k in["P(Q)*S(Q)","Shapes" ] and class_name in self.model_list_box["Shapes"]: 500 510 self.shape_rbutton.SetValue(True) 501 elif k == "Shape-independent": 511 ## fill the form factor list with new model 512 self._populate_box(self.formfactorbox,self.model_list_box["Shapes"]) 513 items = self.formfactorbox.GetItems() 514 ## set comboxbox to the selected item 515 for i in range(len(items)): 516 if items[i]== str(name): 517 self.formfactorbox.SetSelection(i) 518 break 519 return 520 elif k == "Shape-Independent": 502 521 self.shape_indep_rbutton.SetValue(True) 503 522 elif k == "Structure Factors": … … 506 525 self.plugin_rbutton.SetValue(True) 507 526 if class_name in list: 508 ## fill the form factor list with new model527 ## fill the form factor list with new model 509 528 self._populate_box(self.formfactorbox, list) 510 529 items = self.formfactorbox.GetItems() … … 541 560 boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 542 561 #-------------------------------------------------------- 543 self.shape_rbutton = wx.RadioButton(self, -1, 'Shape ', style=wx.RB_GROUP)544 self.shape_indep_rbutton = wx.RadioButton(self, -1, "Shape 545 self.struct_rbutton = wx.RadioButton(self, -1, "Structure ")546 self.plugin_rbutton = wx.RadioButton(self, -1, " customized Model")562 self.shape_rbutton = wx.RadioButton(self, -1, 'Shapes', style=wx.RB_GROUP) 563 self.shape_indep_rbutton = wx.RadioButton(self, -1, "Shape-Independent") 564 self.struct_rbutton = wx.RadioButton(self, -1, "Structure Factor ") 565 self.plugin_rbutton = wx.RadioButton(self, -1, "Customized Models") 547 566 self.multip_cb = wx.CheckBox(self, -1,"P(Q)*S(Q)") 548 567 … … 591 610 ## fill combox box 592 611 if len(self.model_list_box)>0: 593 self._populate_box( self.formfactorbox,self.model_list_box[" shapes"])612 self._populate_box( self.formfactorbox,self.model_list_box["Shapes"]) 594 613 595 614 if len(self.model_list_box)>0: … … 631 650 self.page_info.save_radiobox_state( self.plugin_rbutton ) 632 651 633 634 635 if self.shape_rbutton.GetValue():636 ##fill the combo xbox with form factor list652 ## Don't want to populate combo box again if the event comes from check box 653 if self.shape_rbutton.GetValue()and\ 654 event.GetEventObject()==self.shape_rbutton: 655 ##fill the combobox with form factor list 637 656 self.structurebox.Hide() 638 657 self.text2.Hide() 639 658 self.formfactorbox.Clear() 640 self._populate_box( self.formfactorbox,self.model_list_box["shapes"]) 641 642 if self.shape_indep_rbutton.GetValue(): 643 ##fill the comboxbox with shape independent factor list 659 self._populate_box( self.formfactorbox,self.model_list_box["Shapes"]) 660 661 if self.shape_indep_rbutton.GetValue()and\ 662 event.GetEventObject()==self.shape_indep_rbutton: 663 ##fill the combobox with shape independent factor list 644 664 self.structurebox.Hide() 645 665 self.text2.Hide() 646 666 self.formfactorbox.Clear() 647 667 self._populate_box( self.formfactorbox, 648 self.model_list_box["Shape-independent"]) 649 650 if self.struct_rbutton.GetValue(): 651 ##fill the comboxbox with structure factor list 668 self.model_list_box["Shape-Independent"]) 669 670 if self.struct_rbutton.GetValue() and\ 671 event.GetEventObject()==self.struct_rbutton: 672 ##fill the combobox with structure factor list 652 673 self.structurebox.Hide() 653 674 self.text2.Hide() … … 656 677 self.model_list_box["Structure Factors"]) 657 678 658 if self.plugin_rbutton.GetValue(): 659 ##fill the comboxbox with form factor list 679 if self.plugin_rbutton.GetValue()and\ 680 event.GetEventObject()==self.plugin_rbutton: 681 682 ##fill the combobox with form factor list 660 683 self.structurebox.Hide() 661 684 self.text2.Hide() 662 685 self.formfactorbox.Clear() 663 686 self._populate_box( self.formfactorbox, 664 self.model_list_box["Added models"]) 687 self.model_list_box["Customized Models"]) 688 665 689 if not self.multip_cb.GetValue(): 666 model = self.formfactorbox.GetClientData(0) 690 self.structurebox.Hide() 691 self.text2.Hide() 692 n = self.formfactorbox.GetCurrentSelection() 693 model = self.formfactorbox.GetClientData(n) 667 694 self.model = model() 668 695 ## user check multiplication option 669 696 else: 670 ## multplication not available for structure factor 671 if self.struct_rbutton.GetValue(): 697 ##for this release 698 flag1= self.plugin_rbutton.GetValue()or self.struct_rbutton.GetValue()\ 699 or self.shape_indep_rbutton.GetValue() 700 flag2= False 701 702 n = self.formfactorbox.GetCurrentSelection() 703 form_factor = self.formfactorbox.GetClientData(n) 704 ## selecting only multiplication model 705 if self.shape_rbutton.GetValue(): 706 if not form_factor in self.model_list_box["multiplication"]: 707 flag2 = True 708 ## multiplication not available for structure factor 709 if flag1 or flag2: 672 710 self.multip_cb.SetValue(False) 673 711 self.structurebox.Hide() 712 self.text2.Hide() 674 713 return 675 ##fill the comboxbox with form factor list 714 ## allow only some to have multiplication 715 676 716 self.structurebox.Show(True) 677 717 self.text2.Show(True) 678 ## draw mult plication model679 form_factor = self.formfactorbox.GetClientData(0)680 struct_factor = self.structurebox.GetClientData( 0)718 ## draw multiplication model 719 n = self.structurebox.GetCurrentSelection() 720 struct_factor = self.structurebox.GetClientData(n) 681 721 682 722 from sans.models.MultiplicationModel import MultiplicationModel … … 707 747 combobox.Append(name,models) 708 748 try: 749 709 750 combobox.SetSelection(0) 710 751 … … 719 760 call back for model selection 720 761 """ 762 ## reset dictionary containing reference to dispersion 763 self._disp_obj_dict = {} 764 self.disp_cb_dict ={} 765 721 766 f_id = self.formfactorbox.GetCurrentSelection() 722 767 s_id = self.structurebox.GetCurrentSelection() 723 768 form_factor = self.formfactorbox.GetClientData( f_id ) 724 769 struct_factor = self.structurebox.GetClientData( s_id ) 725 770 771 if not form_factor in self.model_list_box["multiplication"]: 772 self.multip_cb.SetValue(False) 773 self.structurebox.Hide() 774 self.text2.Hide() 775 self.sizer4_4.Clear() 776 self.sizer4.Layout() 777 726 778 if self.multip_cb.GetValue(): 727 779 from sans.models.MultiplicationModel import MultiplicationModel … … 796 848 self.sizer4_4.Clear(True) 797 849 self._reset_dispersity() 798 self._draw_model()799 850 800 851 self.sizer4.Layout() … … 817 868 model_disp = wx.StaticText(self, -1, 'No PolyDispersity for this model') 818 869 self.sizer4_4.Add(model_disp,( iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 819 #self.sizer4_4.Layout()820 870 self.sizer4.Layout() 821 871 self.SetScrollbars(20,20,200,100) 822 872 return 823 873 824 def _reset_gaussian_dispers(self): 825 """ 826 reset model paramaters to gaussian 827 TO IMPLEMENT 828 """ 829 return 830 if self.model==None: 831 return 832 from sans.models.dispersion_models import GaussianDispersion 833 list = self.model.dispersion.keys() 834 835 for key in list: 836 ## The parameter was un-selected. Go back to Gaussian model (with 0 pts) 837 disp_model = GaussianDispersion() 838 ## Set the new model as the dispersion object for the selected parameter 839 self.model.set_dispersion(key,disp_model) 840 self._draw_model() 841 874 842 875 843 876 def _reset_dispersity(self): … … 847 880 self.fittable_param=[] 848 881 self.fixed_param=[] 882 849 883 from sans.models.dispersion_models import GaussianDispersion 850 884 if len(self.disp_cb_dict)==0: … … 857 891 #TODO: refactor model to clean this up? 858 892 self._disp_obj_dict[p] = disp_model 859 860 893 # Set the new model as the dispersion object for the selected parameter 861 894 self.model.set_dispersion(p, disp_model) 862 863 895 # Redraw the model 864 896 self._draw_model() 865 897 866 898 … … 872 904 dispersity =event.GetClientData() 873 905 name= dispersity.__name__ 874 875 if name == "GaussianModel": 906 if name == "GaussianDispersion": 876 907 self._set_sizer_gaussian() 877 908 -
sansview/perspectives/fitting/fitpage.py
r1328e03 r376916c 171 171 self.qmax_x= data_max 172 172 173 173 174 def _fill_model_sizer(self, sizer): 174 175 """ … … 201 202 self.fittable_param=[] 202 203 self.fixed_param=[] 203 ##reset model dispersity to gaussian 204 self._reset_gaussian_dispers() 205 204 206 205 self.sizer4_4.Clear(True) 207 206 … … 212 211 ## the user didn't select dispersity display 213 212 return 213 214 self._reset_dispersity() 215 # Create the dispersion objects 216 for item in self.model.dispersion.keys(): 217 disp_model = GaussianDispersion() 218 self._disp_obj_dict[item] = disp_model 219 self.model.set_dispersion(item, disp_model) 220 214 221 ix=0 215 222 iy=1 … … 233 240 234 241 for item in self.model.dispersion.keys(): 242 self.disp_cb_dict[item]= None 235 243 name1=item+".width" 236 244 name2=item+".npts" -
sansview/perspectives/fitting/modelpage.py
r1328e03 r376916c 125 125 self.fittable_param=[] 126 126 self.fixed_param=[] 127 ##reset model dispersity to gaussian 128 self._reset_gaussian_dispers() 129 127 130 128 self.sizer4_4.Clear(True) 131 129 if self.model==None: … … 135 133 ## the user didn't select dispersity display 136 134 return 135 self._reset_dispersity() 136 # Create the dispersion objects 137 for item in self.model.dispersion.keys(): 138 disp_model = GaussianDispersion() 139 self._disp_obj_dict[item] = disp_model 140 self.model.set_dispersion(item, disp_model) 141 142 137 143 ix=0 138 144 iy=1 … … 153 159 154 160 for item in self.model.dispersion.keys(): 161 162 self.disp_cb_dict[item]= None 155 163 name1=item+".width" 156 164 name2=item+".npts" … … 243 251 self._draw_model() 244 252 ## keep the sizer view consistent with the model menu selecting 245 ## 246 self.structurebox.Hide() 247 self.text2.Hide() 248 self.multip_cb.SetValue(False) 249 250 if hasattr( model,"model1"): 251 self._set_model_sizer_selection( model ) 253 self._set_model_sizer_selection( self.model ) 252 254 253 255 self.model_view.SetFocus() -
sansview/perspectives/fitting/models.py
rc77d859 r376916c 103 103 ##list of structure factors 104 104 struct_list= [] 105 ##list of model allowing multiplication 106 multiplication_factor=[] 105 107 ## list of added models 106 108 plugins=[] … … 119 121 from sans.models.SphereModel import SphereModel 120 122 self.shape_list.append(SphereModel) 123 self.multiplication_factor.append(SphereModel) 121 124 122 125 from sans.models.CylinderModel import CylinderModel 123 126 self.shape_list.append(CylinderModel) 124 127 self.multiplication_factor.append(CylinderModel) 128 125 129 from sans.models.CoreShellModel import CoreShellModel 126 130 self.shape_list.append(CoreShellModel) … … 134 138 from sans.models.EllipsoidModel import EllipsoidModel 135 139 self.shape_list.append(EllipsoidModel) 140 self.multiplication_factor.append(EllipsoidModel) 136 141 137 from sans.models.LineModel import LineModel 138 self.shape_list.append(LineModel) 142 139 143 140 144 ## Structure factor 141 from sans.models.NoStructure import NoStructure 142 self.struct_list.append(NoStructure) 143 145 144 146 from sans.models.SquareWellStructure import SquareWellStructure 145 147 self.struct_list.append(SquareWellStructure) … … 170 172 from sans.models.PorodModel import PorodModel 171 173 self.shape_indep_list.append(PorodModel ) 174 175 from sans.models.LineModel import LineModel 176 self.shape_indep_list.append(LineModel) 172 177 173 178 from sans.models.FractalModel import FractalModel … … 218 223 structure_factor = wx.Menu() 219 224 added_models = wx.Menu() 225 multip_models = wx.Menu() 220 226 ## create menu with shape 221 self._fill_ menu( menuinfo = ["shapes",shape_submenu," simple shape"],222 list1 = self.shape_list ,223 list2 = self.struct_list )224 self._fill_ menu( menuinfo = ["Shape-independent",shape_indep_submenu,227 self._fill_simple_menu( menuinfo = ["Shapes",shape_submenu," simple shape"], 228 list1 = self.shape_list ) 229 230 self._fill_simple_menu( menuinfo = ["Shape-Independent",shape_indep_submenu, 225 231 "List of shape-independent models"], 226 list1 = self.shape_indep_list, 227 list2 = self.struct_list ) 228 self._fill_menu( menuinfo = ["Added models", added_models, 229 "List of additional models"], 230 list1= self.plugins, 231 list2 = self.struct_list) 232 list1 = self.shape_indep_list ) 232 233 233 234 self._fill_simple_menu( menuinfo= ["Structure Factors",structure_factor, 234 235 "List of Structure factors models" ], 235 236 list1= self.struct_list ) 237 238 self._fill_simple_menu( menuinfo = ["Customized Models", added_models, 239 "List of additional models"], 240 list1= self.plugins ) 241 242 self._fill_menu(menuinfo=["P(Q)*S(Q)",multip_models, 243 "mulplication of 2 models"], 244 list1 = self.multiplication_factor , 245 list2 = self.struct_list) 236 246 237 247 … … 324 334 def get_model_list(self): 325 335 """ @ return dictionary of models for fitpanel use """ 336 self.model_combobox.set_list("multiplication", self.multiplication_factor) 326 337 return self.model_combobox 327 338 328 329 def get_form_struct(self):330 """ retunr list of form structures"""331 return self.struct_list332 333 334 335 339 340 341 342 343
Note: See TracChangeset
for help on using the changeset viewer.