Changeset cfc0913 in sasview
- Timestamp:
- Apr 6, 2009 2:56:35 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:
- 40f9745
- Parents:
- ddfcd90
- Location:
- sansview/perspectives/fitting
- Files:
-
- 5 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
r87a43fe rcfc0913 6 6 from sans.guiframe.utils import format_number 7 7 from sans.guicomm.events import StatusEvent 8 8 import pagestate 9 from pagestate import PageState 10 (PageInfoEvent, EVT_PAGE_INFO) = wx.lib.newevent.NewEvent() 9 11 _BOX_WIDTH = 80 10 12 … … 13 15 This class provide general structure of fitpanel page 14 16 """ 15 ## Internal name for the AUI manager 16 window_name = "Fit page" 17 ## Title to appear on top of the window 18 window_caption = "Fit Page" 19 20 name="" 21 22 def __init__(self,parent, pageinfo, name): 17 18 def __init__(self,parent, page_info): 23 19 wx.ScrolledWindow.__init__(self, parent) 24 20 ## store name 25 self.name = name 26 ## store info of panel 27 self.page_info= pageinfo 28 self.page_info.page_name = name 21 self.name = page_info.name 22 ##window_name 23 self.window_name = page_info.window_name 24 ##window_caption 25 self.window_caption = page_info.window_caption 29 26 ## parent of the page 30 27 self.parent = parent 31 28 ## manager is the fitting plugin 32 self.manager= None29 self.manager= page_info.manager 33 30 ## owner of the page (fitting plugin) 34 self.event_owner= None 35 ## create the basic structure of the panel with empty sizer 36 self.define_page_structure() 31 self.event_owner= page_info.event_owner 32 ## current model 33 self.model = page_info.model 34 ## data 35 self.data = page_info.data 37 36 ## dictionary containing list of models 38 self.model_list_box ={}37 self.model_list_box = page_info.model_list_box 39 38 ## Data member to store the dispersion object created 40 39 self._disp_obj_dict = {} 40 ## selected parameters to apply dispersion 41 41 self.disp_cb_dict ={} 42 42 ##list of model parameters. each item must have same length … … 52 52 ##list of dispersion parameters 53 53 self.disp_list=[] 54 54 if self.model !=None: 55 self.disp_list= self.model.getDispParamList() 55 56 ##enable model 2D draw 56 57 self.enable2D= False 57 58 ## check that the fit range is correct to plot the model again 58 59 self.fitrange= True 59 ## current model60 self.model= None61 ## data62 self.data=None63 60 ## Q range 64 61 self.qmin_x= 0.001 65 62 self.qmax_x= 0.1 66 63 self.num_points= 100 67 ## changing initial values given page_info value 68 if self.page_info !=None and len(self.page_info.model_list_box) >0: 69 self.model_list_box = self.page_info.model_list_box 70 ## current model 71 self.model=self.page_info.model 72 self.data = self.page_info.data 73 self.event_owner = self.page_info.event_owner 74 self.manager=self.page_info.manager 75 76 if self.model !=None: 77 self.disp_list= self.model.getDispParamList() 64 ## Create memento to save the current state 65 66 self.state= PageState(parent= self.parent,model=self.model, data=self.data) 67 ## create the basic structure of the panel with empty sizer 68 self.define_page_structure() 78 69 ## drawing Initial dispersion parameters sizer 79 70 self.set_dispers_sizer() 80 71 self._fill_save_sizer() 72 81 73 ## layout 82 74 self.set_layout() … … 134 126 """ 135 127 self.event_owner = owner 136 self. page_info.event_owner = owner128 self.state.event_owner = owner 137 129 138 130 def set_manager(self, manager): … … 142 134 """ 143 135 self.manager = manager 144 self. page_info.manager = manager136 self.state.manager = manager 145 137 146 138 def populate_box(self, dict): … … 150 142 """ 151 143 self.model_list_box = dict 152 if self.page_info!=None: 153 self.page_info.model_list_box = self.model_list_box 144 self.state.model_list_box = self.model_list_box 154 145 155 146 … … 165 156 self.disable_disp = wx.RadioButton(self, -1, 'No', (10, 10), style=wx.RB_GROUP) 166 157 self.enable_disp = wx.RadioButton(self, -1, 'Yes', (10, 30)) 158 ## saving the state of enable dispersity button 159 self.state.enable_disp= self.enable_disp.GetValue() 160 167 161 self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, id=self.disable_disp.GetId()) 168 162 self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, id=self.enable_disp.GetId()) … … 278 272 save history of the data and model 279 273 """ 280 self. page_info.model= self.model281 self. page_info.data = self.data274 self.state.model= self.model 275 self.state.data = self.data 282 276 import os 283 277 … … 363 357 after fitting 364 358 """ 359 365 360 if hasattr(self,"text2_3"): 366 361 self.text2_3.Hide() … … 420 415 except: 421 416 raise 422 423 417 418 419 def createMemento(self): 420 """ 421 return the current state of the page 422 """ 423 return self.state.clone() 424 425 426 def save_current_state(self): 427 """ 428 Store current state 429 """ 430 self.state.model = self.model.clone() 431 self.state.save_data(self.data) 432 433 if hasattr(self,"cb1"): 434 self.state.cb1= self.cb1.GetValue() 435 436 if hasattr(self,"enable_disp"): 437 self.state.enable_disp= self.enable_disp.GetValue() 438 439 if hasattr(self,"enable_smearer"): 440 self.state.enable_smearer = self.enable_smearer.GetValue() 441 442 ## save checkbutton state and txtcrtl values 443 self.state.parameters=[] 444 self.state.fittable_param=[] 445 self.state.fixed_param=[] 446 self._copy_parameters_state(self.parameters, self.state.parameters) 447 self._copy_parameters_state(self.fittable_param, self.state.fittable_param) 448 self._copy_parameters_state(self.fixed_param, self.state.fixed_param) 449 450 ## post state to fit panel 451 event = PageInfoEvent(page = self) 452 wx.PostEvent(self.parent, event) 453 454 def reset_page(self, state): 455 """ 456 Use page_info and change the state of existing button 457 """ 458 self.state = state.clone() 459 self.model= self.state.model 460 self.data = self.state.data 461 self._set_model_sizer_selection( self.model ) 462 self.set_model_param_sizer(self.model) 463 self._reset_plotting_range() 464 465 self.enable_disp.SetValue(self.state.enable_disp) 466 self._set_dipers_Param(event=None) 467 468 if hasattr(self,"enable_smearer"): 469 self.enable_smearer= self.state.enable_smearer 470 if hasattr(self, "cb1"): 471 self.cb1.SetValue(self.state.cb1) 472 self._reset_parameters_state(self.parameters,state.parameters) 473 self._reset_parameters_state(self.fittable_param,state.fittable_param) 474 self._reset_parameters_state(self.fixed_param,state.fixed_param) 475 self._draw_model() 476 477 424 478 def _selectDlg(self): 425 479 """ … … 433 487 dlg.Destroy() 434 488 return path 435 436 489 490 491 def _reset_plotting_range(self): 492 """ 493 Reset the plotting range to a given state 494 """ 495 496 self.qmin.SetValue(format_number(self.state.qmin)) 497 self.qmax.SetValue(format_number(self.state.qmax)) 498 if self.state.npts!=None: 499 self.npts= self.state.npts 500 501 self.qmin_x = float(self.qmin.GetValue()) 502 self.qmax_x = float(self.qmax.GetValue()) 503 504 505 def _save_plotting_range(self ): 506 """ 507 save the state of plotting range 508 """ 509 self.state.qmin = self.qmin.GetValue() 510 self.state.qmax = self.qmax.GetValue() 511 if self.npts!=None: 512 self.state.npts= self.npts.GetValue() 513 514 437 515 def _onparamEnter_helper(self): 438 516 """ … … 442 520 """ 443 521 if self.model !=None: 444 522 self.save_current_state() 445 523 # Flag to register when a parameter has changed. 446 524 is_modified = False … … 449 527 is_modified =self._check_value_enter( self.parameters ,is_modified) 450 528 529 451 530 self.Layout() 452 531 # Here we should check whether the boundaries have been modified. … … 473 552 474 553 554 def _reset_parameters_state(self, listtorestore,statelist): 555 """ 556 Reset the parameters at the given state 557 """ 558 if len(self.state.parameters)!= len(listtorestore) : 559 return 560 for j in range(len(listtorestore)): 561 item_page = listtorestore[j] 562 item_page_info = statelist[j] 563 ##change the state of the check box for simple parameters 564 if item_page[0]!=None: 565 item_page[0].SetValue(item_page_info[0]) 566 567 if item_page[2]!=None: 568 item_page[2].SetValue(item_page_info[2]) 569 570 if item_page[3]!=None: 571 ## show or hide text +/- 572 if item_page_info[2]: 573 item_page[3].Show(True) 574 else: 575 item_page[3].Hide() 576 if item_page[4]!=None: 577 ## show of hide the text crtl for fitting error 578 if item_page_info[4][0]: 579 item_page[4].Show(True) 580 item_page[4].SetValue(item_page_info[4][1]) 581 else: 582 item_page[3].Hide() 583 if item_page[5]!=None: 584 ## show of hide the text crtl for fitting error 585 if item_page_info[5][0]: 586 item_page[5].Show(True) 587 item_page[5].SetValue(item_page_info[4][1]) 588 else: 589 item_page[5].Hide() 590 591 if item_page[6]!=None: 592 ## show of hide the text crtl for fitting error 593 if item_page_info[6][0]: 594 item_page[6].Show(True) 595 item_page[6].SetValue(item_page_info[6][1]) 596 else: 597 item_page[6].Hide() 598 599 def _copy_parameters_state(self, listtocopy, statelist): 600 """ 601 copy the state of button 602 @param listtocopy: the list of check button to copy 603 @param statelist: list of state object to store the current state 604 """ 605 if len(listtocopy)==0: 606 return 607 608 for item in listtocopy: 609 checkbox_state = None 610 if item[0]!= None: 611 checkbox_state= item[0].GetValue() 612 parameter_name = item[1] 613 parameter_value = None 614 if item[2]!=None: 615 parameter_value = item[2].GetValue() 616 static_text = None 617 if item[3]!=None: 618 static_text = item[3].IsShown() 619 error_value = None 620 error_state = None 621 if item[4]!= None: 622 error_value = item[4].GetValue() 623 error_state = item[4].IsShown() 624 625 min_value = None 626 min_state = None 627 if item[5]!= None: 628 min_value = item[5].GetValue() 629 min_state = item[5].IsShown() 630 631 max_value = None 632 max_state = None 633 if item[6]!= None: 634 max_value = item[6].GetValue() 635 max_state = item[6].IsShown() 636 637 statelist.append([checkbox_state, parameter_name, parameter_value, 638 static_text ,[error_state,error_value], 639 [min_state,min_value],[max_state , max_value],None]) 640 641 642 475 643 def _set_model_sizer_selection(self, model): 476 644 """ … … 565 733 566 734 567 568 735 def _draw_model(self): 569 736 """ … … 606 773 id= self.plugin_rbutton.GetId() ) 607 774 wx.EVT_CHECKBOX(self, self.multip_cb.GetId() , self._show_combox ) 608 ## store state 609 self.page_info.save_radiobox_state( self.shape_rbutton ) 610 self.page_info.save_radiobox_state( self.shape_indep_rbutton ) 611 self.page_info.save_radiobox_state( self.struct_rbutton ) 612 self.page_info.save_radiobox_state( self.plugin_rbutton ) 613 614 775 615 776 sizer_radiobutton = wx.GridSizer(3, 3,5, 5) 616 777 sizer_radiobutton.Add(self.shape_rbutton) … … 674 835 Show combox box associate with type of model selected 675 836 """ 676 self.page_info.save_radiobox_state( self.shape_rbutton )677 self.page_info.save_radiobox_state( self.shape_indep_rbutton )678 self.page_info.save_radiobox_state( self.struct_rbutton )679 self.page_info.save_radiobox_state( self.plugin_rbutton )680 681 837 ## Don't want to populate combo box again if the event comes from check box 682 838 if self.shape_rbutton.GetValue()and\ … … 758 914 759 915 self.set_scroll() 760 761 762 916 763 917 … … 781 935 except: 782 936 pass 783 #wx.EVT_COMBOBOX(combobox,-1, self._on_select_model)937 784 938 return 0 785 939 … … 811 965 else: 812 966 self.model= form_factor() 813 self.page_info.model= self.model 967 968 ## post state to fit panel 969 self.save_current_state() 814 970 815 971 … … 842 998 if format_number(item[5].GetValue())!="NaN": 843 999 param_min = float(item[5].GetValue()) 844 self.model.details[name][1]=param_min1000 845 1001 ## check maximum value 846 1002 if item[6]!= None: … … 854 1010 msg+= "name %s of model %s "%(name, self.model.name) 855 1011 wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 856 857 self.model.details[name][1:]= param_min,param_max1012 if name in self.model.details.keys(): 1013 self.model.details[name][1:]= param_min,param_max 858 1014 859 1015 ## hide statictext +/- … … 878 1034 return is_modified 879 1035 880 881 1036 882 1037 def _set_dipers_Param(self, event): … … 889 1044 return 890 1045 else: 1046 891 1047 if self.enable_disp.GetValue(): 892 1048 self.model_disp.Show(True) … … 903 1059 self.sizer4_4.Clear(True) 904 1060 self._reset_dispersity() 1061 1062 1063 ## post state to fit panel 1064 self.save_current_state() 905 1065 906 1066 self.sizer4.Layout() … … 908 1068 self.SetScrollbars(20,20,200,100) 909 1069 910 911 1070 912 1071 def _layout_sizer_noDipers(self): … … 929 1088 return 930 1089 931 932 1090 933 1091 def _reset_dispersity(self): … … 966 1124 if name=="ArrayDispersion": 967 1125 self._set_sizer_arraydispersion() 968 969 1126 970 1127 971 1128 … … 1038 1195 boxsizer1.Add((10,10)) 1039 1196 boxsizer1.Add(sizer_horizontal) 1040 1197 ## save state 1198 self.save_current_state() 1041 1199 #---------------------------------------------------------------- 1042 1200 self.sizer5.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) … … 1044 1202 self.Layout() 1045 1203 self.SetScrollbars(20,20,200,100) 1204 1046 1205 1047 1206 def _fill_save_sizer(self): -
sansview/perspectives/fitting/fitpage.py
rdcf29d7 rcfc0913 26 26 27 27 """ 28 def __init__(self,parent, page_info , name=""):29 BasicPage.__init__(self, parent, page_info ,name)28 def __init__(self,parent, page_info): 29 BasicPage.__init__(self, parent, page_info) 30 30 """ 31 31 Initialization of the Panel 32 32 """ 33 self.name= self.data.name 34 page_info.page_name= self.data.name 35 33 self.name = self.data.name 34 36 35 ## fit page does not content npts txtcrtl 37 36 self.npts=None … … 42 41 43 42 self._fill_datainfo_sizer() 43 44 44 self._fill_model_sizer( self.sizer1) 45 self._on_select_model(event=None) 45 46 self._fill_range_sizer() 46 self.model = self.formfactorbox.GetClientData(0)()47 self.page_info.model= self.model48 self._on_select_model(event=None)47 48 49 ## to update the panel according to the fit engine type selected 49 50 self.Bind(EVT_FITTER_TYPE,self._on_engine_change) 50 51 … … 92 93 """ 93 94 ## save state of radiobox 94 self.page_info. save_radiobox_state( self.description_hide )95 self.page_info. save_radiobox_state( self.description_show )95 #self.page_info. save_radiobox_state( self.description_hide ) 96 #self.page_info. save_radiobox_state( self.description_show ) 96 97 ## Show description 97 98 if not self.description_show.GetValue(): … … 99 100 100 101 else: 101 model=self.page_info.model 102 #model=self.page_info.model 103 102 104 description="" 103 if model!=None: 104 description = self.page_info.model.description 105 if self.model!=None: 106 description = self.model.description 107 #description = self.page_info.model.description 105 108 self.description = wx.StaticText( self,-1,str(description) ) 106 109 self.sizer_description.Add( self.description, 1, wx.EXPAND | wx.ALL, 10 ) … … 410 413 self.compute_chisqr() 411 414 415 412 416 def get_range(self): 413 417 """ … … 512 516 "Data contains smearing information %s"%msg)) 513 517 self.manager.set_smearer(smear, qmin= self.qmin_x, qmax= self.qmax_x) 514 518 ## save the state enable smearing 519 self.save_current_state() 515 520 516 521 def compute_chisqr2D(self): … … 593 598 """ 594 599 self.param_toFit=[] 600 595 601 if self.parameters !=[]: 596 602 if self.cb1.GetValue()==True: … … 608 614 item[0].SetValue(False) 609 615 self.param_toFit=[] 610 616 self.save_current_state() 617 611 618 612 619 … … 640 647 else: 641 648 self.cb1.SetValue(False) 642 649 ## save current state of the page 650 self.save_current_state() 651 643 652 644 653 def set_model_description(self,description,sizer): … … 669 678 670 679 671 self.page_info.save_radiobox_state( self.description_hide )672 self.page_info.save_radiobox_state( self.description_show )680 #self.page_info.save_radiobox_state( self.description_hide ) 681 #self.page_info.save_radiobox_state( self.description_show ) 673 682 674 683 sizer_selection.Add( self.description_show ) … … 700 709 self.sizer3.Clear(True) 701 710 self.parameters = [] 711 #self.page_info.parameters=[] 702 712 self.param_toFit=[] 703 713 self.fittable_param=[] … … 823 833 self.parameters.append([cb,item, ctl1, 824 834 text2,ctl2, ctl3, ctl4,None]) 835 #self.page_info.parameters.append([cb.GetValue(),item, ctl1.GetValue(), 836 # text2.IsShown(),[ctl2.IsShown(),ctl2.GetValue()], 837 #[ctl3.IsShown(),ctl3.GetValue()],[ ctl4.IsShown(),ctl4.GetValue()],None]) 825 838 826 839 iy+=1 … … 855 868 data= Data1D(x=[1,2], y=[3,4], dy=[0.1, 0,1]) 856 869 857 from pageInfoimport PageInfo870 from fitpanel import PageInfo 858 871 myinfo = PageInfo(self, model, data=data ) 859 872 -
sansview/perspectives/fitting/fitpanel.py
rdcf29d7 rcfc0913 6 6 #import models 7 7 _BOX_WIDTH = 80 8 (PageInfoEvent, EVT_PAGE_INFO) = wx.lib.newevent.NewEvent() 9 8 import basepage 9 10 class PageInfo(object): 11 """ 12 this class contains the minimum numbers of data members 13 a fitpage or model page need to be initialized. 14 """ 15 data = None 16 model= None 17 manager= None 18 event_owner= None 19 model_list_box = None 20 name=None 21 ## Internal name for the AUI manager 22 window_name = "Page" 23 ## Title to appear on top of the window 24 window_caption = "Page" 25 26 def __init__(self, model=None,data=None, manager=None, 27 event_owner=None,model_list_box=None , name=None): 28 """ 29 Initialize data members 30 """ 31 self.data = data 32 self.model= model 33 self.manager= manager 34 self.event_owner= event_owner 35 self.model_list_box = model_list_box 36 self.name=None 37 self.window_name = "Page" 38 self.window_caption = "Page" 39 10 40 class FitPanel(wx.aui.AuiNotebook): 11 41 … … 42 72 ##dictionary of page info 43 73 self.page_info_dict={} 44 # save the title of the last page tab added 45 self.fit_page_name=[] 74 ## save the title of the last page tab added 75 self.fit_page_name={} 76 ## list of existing fit page 77 self.list_fitpage_name=[] 46 78 self.draw_model_name=None 47 79 #model page info … … 50 82 self.model_page=None 51 83 self.sim_page=None 84 ## get the state of a page 85 self.Bind(basepage.EVT_PAGE_INFO, self._onGetstate) 52 86 # increment number for model name 53 87 self.count=0 … … 61 95 close page and remove all references to the closed page 62 96 """ 63 page_info = self.get_current_page().page_info.clone()64 page_ info.page_name = self.get_current_page().page_info.page_name97 state = self.get_current_page().createMemento() 98 page_name = self.get_current_page().name 65 99 page_finder = self.manager.get_page_finder() 66 100 fitproblem = None … … 69 103 fitproblem= page_finder[self.get_current_page()] 70 104 71 self.manager._add_page_onmenu(page_ info.page_name, page_info, fitproblem)105 self.manager._add_page_onmenu(page_name, fitproblem) 72 106 73 107 selected_page = self.GetPage(self.GetSelection()) … … 80 114 81 115 #Delete the page from notebook 82 if selected_page.name in self. fit_page_name:83 self. fit_page_name.remove(selected_page.name)116 if selected_page.name in self.list_fitpage_name: 117 self.list_fitpage_name.remove(selected_page.name) 84 118 85 119 if selected_page.name== self.draw_model_name: … … 139 173 return self.sim_page 140 174 141 def add_fit_page( self,data, page_info=None ):175 def add_fit_page( self,data, reset=False ): 142 176 """ 143 177 Add a fitting page on the notebook contained by fitpanel … … 149 183 except: 150 184 name = 'Fit' 151 if page_info==None: 152 from pageInfo import PageInfo 153 myinfo = PageInfo( self, data=data ) 185 if not name in self.list_fitpage_name: 186 myinfo = PageInfo( data=data, name=name ) 154 187 myinfo.model_list_box = self.model_list_box.get_list() 155 188 myinfo.event_owner = self.event_owner 156 189 myinfo.manager = self.manager 157 else:158 myinfo = page_info159 160 if not name in self.fit_page_name :190 myinfo.window_name = "Fit Page" 191 myinfo.window_caption = "Fit Page" 192 193 #if not name in self.fit_page_name : 161 194 from fitpage import FitPage 162 panel = FitPage(parent= self, page_info=myinfo, name=name ) 163 panel.name = name 164 panel.window_name= "fitpage" 195 panel = FitPage(parent= self, page_info=myinfo) 165 196 self.AddPage(page=panel,caption=name,select=True) 166 self.fit_page_name.append(name) 167 197 self.list_fitpage_name.append(name) 198 if reset: 199 if name in self.fit_page_name.keys(): 200 memento= self.fit_page_name[name][0] 201 panel.reset_page(memento) 202 else: 203 self.fit_page_name[name]=[] 204 self.fit_page_name[name].insert(0,panel.createMemento()) 205 168 206 return panel 169 207 else: … … 195 233 npts=npts, page_info=page_info) 196 234 235 def _onGetstate(self, event): 236 """ 237 copy the state of a page 238 """ 239 page= event.page 240 if page.name in self.fit_page_name: 241 self.fit_page_name[page.name].insert(0,page.createMemento()) 242 197 243 198 244 def _help_add_model_page(self,model,page_title, qmin=0, … … 218 264 ## creating object that contaning info about model 219 265 if page_info==None: 220 from pageInfo import PageInfo221 myinfo = PageInfo( self, model=model)266 267 myinfo = PageInfo(model=model ,name=page_title) 222 268 myinfo.model_list_box = self.model_list_box.get_list() 223 269 myinfo.event_owner = self.event_owner 224 270 myinfo.manager = self.manager 271 myinfo.window_name = "Model Page" 272 myinfo.window_caption = "Model Page" 225 273 else: 226 274 myinfo = page_info 227 275 228 276 from modelpage import ModelPage 229 panel = ModelPage(self,myinfo ,page_title)277 panel = ModelPage(self,myinfo) 230 278 231 279 self.AddPage(page=panel,caption="Model",select=True) 232 280 233 panel.name = page_title234 281 self.draw_model_name=page_title 235 282 self.model_page_number=self.GetSelection() -
sansview/perspectives/fitting/fitting.py
r0f5fe6b rcfc0913 447 447 448 448 449 def _add_page_onmenu(self, name, page_info,fitproblem=None):449 def _add_page_onmenu(self, name,fitproblem=None): 450 450 """ 451 451 Add name of a closed page of fitpanel in a menu … … 454 454 for item in list: 455 455 if name == item.GetItemLabel(): 456 self.closed_page_dict[name][1 :] = page_info,fitproblem456 self.closed_page_dict[name][1] = fitproblem 457 457 458 458 if not name in self.closed_page_dict.keys(): … … 460 460 event_id = wx.NewId() 461 461 self.menu1.Append(event_id, name, "Show %s fit panel" % name) 462 self.closed_page_dict[name]= [event_id, page_info,fitproblem]462 self.closed_page_dict[name]= [event_id, fitproblem] 463 463 wx.EVT_MENU(self.parent,event_id, self._open_closed_page) 464 464 … … 468 468 reopen a closed page 469 469 """ 470 for value in self.closed_page_dict.values():470 for name, value in self.closed_page_dict.iteritems(): 471 471 if event.GetId() in value: 472 id, page_info,fitproblem = value473 474 if page_info.page_name !="Model Page":475 page = self.fit_panel.add_fit_page(data= page_info.data,476 page_info=page_info)472 id,fitproblem = value 473 474 if name !="Model Page": 475 data= fitproblem.get_fit_data() 476 page = self.fit_panel.add_fit_page(data= data,reset=True) 477 477 if fitproblem != None: 478 478 self.page_finder[page]=fitproblem … … 591 591 wx.PostEvent(self.parent, StatusEvent(status="Page was already Created")) 592 592 except: 593 wx.PostEvent(self.parent, StatusEvent(status="Creating Fit page: %s"\ 594 %sys.exc_value)) 595 return 593 raise 594 #wx.PostEvent(self.parent, StatusEvent(status="Creating Fit page: %s"\ 595 #%sys.exc_value)) 596 #return 596 597 597 598 def _single_fit_completed(self,result,pars,cpage, elapsed=None): … … 605 606 606 607 """ 607 #wx.PostEvent(self.parent, StatusEvent(status="Single fit \608 #complete! " , type="stop"))608 wx.PostEvent(self.parent, StatusEvent(status="Single fit \ 609 complete! " , type="stop")) 609 610 try: 610 611 for page, value in self.page_finder.iteritems(): -
sansview/perspectives/fitting/modelpage.py
rdcf29d7 rcfc0913 25 25 """ 26 26 def __init__(self,parent, page_info, name=""): 27 BasicPage.__init__(self, parent, page_info ,name)27 BasicPage.__init__(self, parent, page_info) 28 28 """ 29 29 Initialization of the Panel … … 33 33 self._fill_model_sizer( self.sizer1) 34 34 self._fill_range_sizer() 35 if hasattr(self.page_info,"model"):36 model=self.page_info.model37 description=""38 if model!=None:39 description = self.page_info.model.description35 36 description="" 37 if self.model!=None: 38 #description = self.page_info.model.description 39 description = self.model.description 40 40 self.set_model_param_sizer(self.model) 41 41 self.set_model_description(description,self.sizer2) … … 59 59 """ 60 60 ## save state of radiobox 61 self.page_info. save_radiobox_state( self.description_hide )62 self.page_info. save_radiobox_state( self.description_show )61 #self.page_info. save_radiobox_state( self.description_hide ) 62 #self.page_info. save_radiobox_state( self.description_show ) 63 63 ## Show description 64 64 if not self.description_show.GetValue(): … … 66 66 67 67 else: 68 model=self.page_info.model68 #model=self.page_info.model 69 69 description="" 70 if model!=None: 71 description = self.page_info.model.description 70 if self.model!=None: 71 #description = self.page_info.model.description 72 description = self.model.description 72 73 self.description = wx.StaticText( self,-1,str(description) ) 73 74 self.sizer_description.Add( self.description, 1, wx.EXPAND | wx.ALL, 10 ) … … 93 94 sizer_npts.Add(self.npts,1, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) 94 95 self._set_range_sizer( title="Plotted Q Range", object= sizer_npts) 96 95 97 96 98 def _on_select_model(self, event): … … 291 293 self.model_description.SetToolTipString("See more description in help menu.") 292 294 293 self.page_info.save_radiobox_state( self.description_hide )294 self.page_info.save_radiobox_state( self.description_show )295 #self.page_info.save_radiobox_state( self.description_hide ) 296 #self.page_info.save_radiobox_state( self.description_show ) 295 297 296 298 sizer_selection.Add( self.description_show ) … … 435 437 #from sans.models.LineModel import LineModel 436 438 #model = LineModel() 437 from pageInfoimport PageInfo439 from fitpanel import PageInfo 438 440 myinfo = PageInfo(self,model) 439 441 from models import ModelList -
sansview/perspectives/fitting/pagestate.py
rdcf29d7 rcfc0913 4 4 import copy 5 5 6 class Page Info(object):6 class PageState(object): 7 7 """ 8 8 Contains info to reconstruct a page … … 16 16 ## Data member to store the dispersion object created 17 17 self._disp_obj_dict = {} 18 18 ## reset True change the state of exsiting button 19 self.reset = False 19 20 #Data used for fitting 20 21 self.data = data 21 22 # flag to allow data2D plot 22 self.enable2D =False23 self.enable2D = False 23 24 # model on which the fit would be performed 24 25 self.model = model … … 31 32 self.event_owner = None 32 33 ##page name 33 self.page_name =""34 self.page_name = "" 34 35 # Contains link between model ,all its parameters, and panel organization 35 self.parameters =[]36 self.parameters =[] 36 37 # Contains list of parameters that cannot be fitted and reference to 37 38 #panel objects 38 self.fixed_param =[]39 self.fixed_param =[] 39 40 # Contains list of parameters with dispersity and reference to 40 41 #panel objects 41 self.fittable_param =[]42 self.fittable_param =[] 42 43 #list of dispersion paramaters 43 self.disp_list =[]44 self.disp_list =[] 44 45 #contains link between a model and selected parameters to fit 45 self.param_toFit =[]46 self.param_toFit =[] 46 47 #dictionary of model type and model class 47 self.model_list_box =None 48 ## list of check box 49 self.list_of_radiobox={} 48 self.model_list_box = None 49 50 50 ## save current value of combobox 51 51 self.formfactorcombobox = "" 52 52 self.structurecombobox = "" 53 self.disp_box="" 53 54 ## Qrange 54 self.qmin=None 55 self.qmax=None 56 self.npts=None 55 ## Q range 56 self.qmin= 0.001 57 self.qmax= 0.1 58 self.npts = None 59 ## enable smearering state 60 self.enable_smearer = False 61 ## disperity selection 62 self.enable_disp= False 63 ## state of selected all check button 64 self.cb1 = False 57 65 58 59 60 def save_radiobox_state(self, object ): 66 67 def save_data(self, data): 61 68 """ 62 save radiobox state 63 @param object: radiobox 64 self.list_of_check= ["label", id, state] 65 69 Save data 66 70 """ 67 label = object.GetLabel() 68 id = object.GetId() 69 state = object.GetValue() 70 self.list_of_radiobox[label]=[label, id, state] 71 self.data = copy.deepcopy(data) 71 72 72 73 74 73 75 def clone(self): 74 76 model=None … … 76 78 model = self.model.clone() 77 79 78 obj = Page Info( self.parent,model= model )80 obj = PageState( self.parent,model= model ) 79 81 obj.data = copy.deepcopy(self.data) 80 82 obj.model_list_box = copy.deepcopy(self.model_list_box) 81 83 obj.manager = self.manager 82 84 obj.event_owner = self.event_owner 85 obj.parameters = copy.deepcopy(self.parameters) 86 obj.fixed_param = copy.deepcopy(self.fixed_param) 87 obj.fittable_param = copy.deepcopy(self.fittable_param) 88 obj.enable_disp= self.enable_disp 89 obj.enable_smearer = self.enable_smearer 90 obj.disp_box= copy.deepcopy(self.disp_box) 91 obj.cb1 = self.cb1 83 92 return obj 84 93 94 class PageMemento(object): 95 """ 96 Store the state of a fitpage or model page of fitpanel 97 """ 98 def __init__(self, state): 99 """ Initialization""" 100 self.state = state 85 101 102 def setState(self,state): 103 """ 104 set current state 105 @param state: new state 106 """ 107 self.state = state 108 109 def getState(self): 110 """ 111 @return state 112 """ 113 return self.state 114 115 116 117
Note: See TracChangeset
for help on using the changeset viewer.