Changeset b787e68c in sasview
- Timestamp:
- Apr 7, 2009 5:41:04 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:
- 8a1ab69
- Parents:
- b94a0a6
- Location:
- sansview/perspectives/fitting
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
rcfc0913 rb787e68c 15 15 This class provide general structure of fitpanel page 16 16 """ 17 ## Internal name for the AUI manager 18 window_name = "Basic Page" 19 ## Title to appear on top of the window 20 window_caption = "Basic page " 17 21 18 22 def __init__(self,parent, page_info): 19 23 wx.ScrolledWindow.__init__(self, parent) 20 ## store name21 self.name = page_info.name22 24 ##window_name 23 25 self.window_name = page_info.window_name … … 177 179 self.polydisp= sans.models.dispersion_models.models 178 180 self.disp_box = wx.ComboBox(self, -1) 179 self.disp_box.SetValue("GaussianModel") 180 181 181 182 for key in self.polydisp.iterkeys(): 182 183 name = str(key.__name__) … … 184 185 # Remove the option until the rest of the code is ready for it 185 186 self.disp_box.Append("Select customized Model",key) 186 pass187 187 188 else: 188 self.disp_box.Append(name,key) 189 self.disp_box.Append(name,key) 190 self.disp_box.SetSelection(0) 191 189 192 wx.EVT_COMBOBOX(self.disp_box,-1, self._on_select_Disp) 190 193 … … 439 442 if hasattr(self,"enable_smearer"): 440 443 self.state.enable_smearer = self.enable_smearer.GetValue() 444 445 if hasattr(self,"disp_box"): 446 self.state.disp_box = self.disp_box.GetCurrentSelection() 447 self._save_plotting_range() 441 448 442 449 ## save checkbutton state and txtcrtl values … … 454 461 def reset_page(self, state): 455 462 """ 456 Use page_ info and change the state of existing button463 Use page_state and change the state of existing page 457 464 """ 458 465 self.state = state.clone() 459 466 self.model= self.state.model 460 467 self.data = self.state.data 468 469 ##model parameter values restore 461 470 self._set_model_sizer_selection( self.model ) 462 471 self.set_model_param_sizer(self.model) 472 473 ## display dispersion info layer 474 self.enable_disp.SetValue(self.state.enable_disp) 475 if hasattr(self, "disp_box"): 476 self.disp_box.SetSelection(self.state.disp_box) 477 self._set_dipers_Param(event=None) 478 479 ## smearing info restore 480 if hasattr(self,"enable_smearer"): 481 self.enable_smearer.SetValue(state.enable_smearer) 482 483 ##plotting range restore 463 484 self._reset_plotting_range() 464 485 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 486 ## reset state of checkbox,textcrtl and parameters value 470 487 if hasattr(self, "cb1"): 471 488 self.cb1.SetValue(self.state.cb1) … … 473 490 self._reset_parameters_state(self.fittable_param,state.fittable_param) 474 491 self._reset_parameters_state(self.fixed_param,state.fixed_param) 492 493 ## draw the model with previous parameters value 475 494 self._draw_model() 476 495 … … 497 516 self.qmax.SetValue(format_number(self.state.qmax)) 498 517 if self.state.npts!=None: 499 self.npts= self.state.npts 518 self.npts.SetValue(format_number(self.state.npts)) 519 self.num_points = float(self.state.npts) 500 520 501 521 self.qmin_x = float(self.qmin.GetValue()) … … 507 527 save the state of plotting range 508 528 """ 509 self.state.qmin = self.qmin .GetValue()510 self.state.qmax = self.qmax .GetValue()529 self.state.qmin = self.qmin_x 530 self.state.qmax = self.qmax_x 511 531 if self.npts!=None: 512 self.state.npts= self.n pts.GetValue()532 self.state.npts= self.num_points 513 533 514 534 … … 520 540 """ 521 541 if self.model !=None: 522 self.save_current_state()542 523 543 # Flag to register when a parameter has changed. 524 544 is_modified = False … … 547 567 self.num_points = float(self.npts.GetValue()) 548 568 is_modified = True 569 ## save current state 570 self.save_current_state() 571 549 572 ## if any value is modify draw model with new value 550 573 if is_modified: … … 596 619 else: 597 620 item_page[6].Hide() 621 598 622 599 623 def _copy_parameters_state(self, listtocopy, statelist): … … 1053 1077 else: 1054 1078 ## set gaussian sizer 1055 self._set_sizer_gaussian() 1079 #self._set_sizer_gaussian() 1080 self._on_select_Disp(event=None) 1056 1081 else: 1057 1082 self.model_disp.Hide() … … 1117 1142 self.disp_list should change type later .now only gaussian 1118 1143 """ 1119 dispersity =event.GetClientData() 1144 1145 n = self.disp_box.GetCurrentSelection() 1146 dispersity= self.disp_box.GetClientData(n) 1120 1147 name= dispersity.__name__ 1121 1148 if name == "GaussianDispersion": … … 1125 1152 self._set_sizer_arraydispersion() 1126 1153 1127 1128 1154 self.state.disp_box= n 1155 ## post state to fit panel 1156 event = PageInfoEvent(page = self) 1157 wx.PostEvent(self.parent, event) 1158 1159 1129 1160 def _set_sizer_arraydispersion(self): 1130 1161 """ -
sansview/perspectives/fitting/fitpage.py
rcfc0913 rb787e68c 10 10 from sans.guiframe.utils import format_number 11 11 12 ## event to post model to fit to fitting plugins 12 13 (ModelEventbox, EVT_MODEL_BOX) = wx.lib.newevent.NewEvent() 14 15 ## event to know the selected fit engine 13 16 (FitterTypeEvent, EVT_FITTER_TYPE) = wx.lib.newevent.NewEvent() 14 17 _BOX_WIDTH = 80 … … 16 19 import basepage 17 20 from basepage import BasicPage 21 from basepage import PageInfoEvent 18 22 19 23 … … 31 35 Initialization of the Panel 32 36 """ 33 self.name = self.data.name34 35 37 ## fit page does not content npts txtcrtl 36 38 self.npts=None … … 39 41 ## default fitengine type 40 42 self.engine_type = "scipy" 41 43 ## draw sizer 42 44 self._fill_datainfo_sizer() 43 44 45 self._fill_model_sizer( self.sizer1) 45 46 self._on_select_model(event=None) 46 47 self._fill_range_sizer() 47 48 48 49 49 ## to update the panel according to the fit engine type selected 50 50 self.Bind(EVT_FITTER_TYPE,self._on_engine_change) … … 515 515 wx.PostEvent(self.manager.parent, StatusEvent(status=\ 516 516 "Data contains smearing information %s"%msg)) 517 self.manager.set_smearer(smear, qmin= self.qmin_x, qmax= self.qmax_x) 517 self.manager.set_smearer(smear, qmin= float(self.qmin_x), 518 qmax= float(self.qmax_x)) 518 519 ## save the state enable smearing 519 520 self.save_current_state() 521 520 522 521 523 def compute_chisqr2D(self): -
sansview/perspectives/fitting/fitpanel.py
rcfc0913 rb787e68c 96 96 """ 97 97 state = self.get_current_page().createMemento() 98 page_name = self.get_current_page(). name98 page_name = self.get_current_page().window_name 99 99 page_finder = self.manager.get_page_finder() 100 100 fitproblem = None … … 103 103 fitproblem= page_finder[self.get_current_page()] 104 104 105 self.manager._add_page_onmenu(page_name, fitproblem)106 105 107 106 selected_page = self.GetPage(self.GetSelection()) … … 114 113 115 114 #Delete the page from notebook 116 if selected_page.name in self.list_fitpage_name: 117 self.list_fitpage_name.remove(selected_page.name) 118 119 if selected_page.name== self.draw_model_name: 115 if selected_page.window_name in self.list_fitpage_name: 116 self.list_fitpage_name.remove(selected_page.window_name) 117 118 if selected_page.window_name== "Model": 119 fitproblem = self.get_current_page().model.clone() 120 120 self.draw_model_name=None 121 121 self.model_page=None … … 128 128 self.about_page=None 129 129 else: 130 self.manager.sim_page=None 130 self.manager.sim_page=None 131 ## page on menu 132 self.manager._add_page_onmenu(page_name, fitproblem) 133 131 134 132 135 … … 177 180 Add a fitting page on the notebook contained by fitpanel 178 181 @param data: data to fit 179 @return panel : page just added for fu ther used. is used by fitting module182 @return panel : page just added for further used. is used by fitting module 180 183 """ 181 184 try: … … 188 191 myinfo.event_owner = self.event_owner 189 192 myinfo.manager = self.manager 190 myinfo.window_name = "Fit Page"191 myinfo.window_caption = "Fit Page"193 myinfo.window_name = name 194 myinfo.window_caption = name 192 195 193 196 #if not name in self.fit_page_name : 194 197 from fitpage import FitPage 195 198 panel = FitPage(parent= self, page_info=myinfo) 196 self.AddPage(page=panel,caption=name,select=True) 199 200 self.AddPage(page=panel, caption=name, select=True) 197 201 self.list_fitpage_name.append(name) 198 202 if reset: … … 209 213 210 214 211 def add_model_page(self,model, page_title,qmin=0, qmax=0.1,212 npts=50, topmenu=False, page_info=None):215 def add_model_page(self,model, qmin=0, qmax=0.1, 216 npts=50, topmenu=False, reset=False): 213 217 """ 214 218 Add a model page only one to display any model selected from the menu or the page combo box. … … 224 228 if topmenu==True: 225 229 if self.draw_model_name ==None: 226 self._help_add_model_page(model ,page_title,227 qmin=qmin, qmax=qmax, npts=npts, page_info=page_info)230 self._help_add_model_page(model=model, 231 qmin=qmin, qmax=qmax, npts=npts, reset=reset) 228 232 else: 229 233 self.model_page.select_model(model, page_title) 230 else: 231 if self.draw_model_name ==None: 232 self._create_model_page(model,page_title, qmin=qmin, qmax=qmax, 233 npts=npts, page_info=page_info) 234 235 234 236 235 237 def _onGetstate(self, event): … … 238 240 """ 239 241 page= event.page 240 if page. name in self.fit_page_name:241 self.fit_page_name[page. name].insert(0,page.createMemento())242 if page.window_name in self.fit_page_name: 243 self.fit_page_name[page.window_name].insert(0,page.createMemento()) 242 244 243 245 244 def _help_add_model_page(self,model,page_title , qmin=0,245 qmax=0.1, npts=50, page_info=None):246 def _help_add_model_page(self,model,page_title="Model", qmin=0, 247 qmax=0.1, npts=50,reset= False): 246 248 """ 247 249 #TODO: fill in description … … 251 253 @param npts: number of Q points 252 254 """ 253 self._create_model_page(model,page_title,qmin=qmin, qmax=qmax, 254 npts=npts,page_info= page_info) 255 ## creating object that contaning info about model 256 myinfo = PageInfo(model= model ,name= page_title) 257 myinfo.model_list_box = self.model_list_box.get_list() 258 myinfo.event_owner = self.event_owner 259 myinfo.manager = self.manager 260 myinfo.window_name = page_title 261 myinfo.window_caption = page_title 262 263 from modelpage import ModelPage 264 panel = ModelPage(self,myinfo) 265 266 self.AddPage(page=panel,caption=page_title,select=True) 267 268 self.model_page_number=self.GetSelection() 269 self.model_page=self.GetPage(self.GetSelection()) 270 # Set the range used to plot models 271 self.model_page.set_range(qmin, qmax, npts) 272 ## resetting page 273 if reset: 274 if page_title in self.fit_page_name.keys(): 275 276 memento= self.fit_page_name[page_title][0] 277 panel.reset_page(memento) 278 else: 279 self.fit_page_name[page_title]=[] 280 self.fit_page_name[page_title].insert(0,panel.createMemento()) 281 255 282 # We just created a model page, we are ready to plot the model 256 283 #self.manager.draw_model(model, model.name) 257 284 #FOR PLUGIN for some reason model.name is = BASEcomponent 258 285 self.manager.draw_model(model) 259 260 def _create_model_page(self,model,page_title, qmin, qmax, npts,page_info=None):261 """262 adding model page occurs here263 """264 ## creating object that contaning info about model265 if page_info==None:266 267 myinfo = PageInfo(model=model ,name=page_title)268 myinfo.model_list_box = self.model_list_box.get_list()269 myinfo.event_owner = self.event_owner270 myinfo.manager = self.manager271 myinfo.window_name = "Model Page"272 myinfo.window_caption = "Model Page"273 else:274 myinfo = page_info275 276 from modelpage import ModelPage277 panel = ModelPage(self,myinfo)278 279 self.AddPage(page=panel,caption="Model",select=True)280 281 self.draw_model_name=page_title282 self.model_page_number=self.GetSelection()283 self.model_page=self.GetPage(self.GetSelection())284 285 286 # Set the range used to plot models287 self.model_page.set_range(qmin, qmax, npts)288 289 290 286 291 292 287 -
sansview/perspectives/fitting/fitting.py
rcfc0913 rb787e68c 471 471 if event.GetId() in value: 472 472 id,fitproblem = value 473 474 if name !="Model Page": 473 if name !="Model": 475 474 data= fitproblem.get_fit_data() 476 475 page = self.fit_panel.add_fit_page(data= data,reset=True) … … 478 477 self.page_finder[page]=fitproblem 479 478 else: 480 model = page_info.model481 self.fit_panel.add_model_page(model ,model.name,topmenu=False,482 page_info=page_info)479 model = fitproblem 480 self.fit_panel.add_model_page(model=model, topmenu=True, 481 reset= True) 483 482 break 484 483 … … 787 786 @param evt: wx.menu event 788 787 """ 789 name = evt.model.__class__.__name__790 if hasattr(evt.model, "name"):791 name = evt.model.name792 788 model = evt.model 793 789 … … 795 791 # will be plotted automatically. If a page already exists, 796 792 # the content will be updated and the plot refreshed 797 self.fit_panel.add_model_page(model, name,topmenu=True)793 self.fit_panel.add_model_page(model,topmenu=True) 798 794 799 795 -
sansview/perspectives/fitting/modelpage.py
rb94a0a6 rb787e68c 24 24 25 25 """ 26 def __init__(self,parent, page_info , name=""):26 def __init__(self,parent, page_info): 27 27 BasicPage.__init__(self, parent, page_info) 28 28 """ 29 29 Initialization of the Panel 30 30 """ 31 self.name ="Model"32 page_info.page_name= "Model Page"33 31 self._fill_model_sizer( self.sizer1) 34 32 self._fill_range_sizer() … … 251 249 """ 252 250 self.model = model 253 self.parent.model_page.name = name254 self.parent.draw_model_name = name255 256 251 self.set_model_param_sizer(self.model) 257 252 self._draw_model() -
sansview/perspectives/fitting/pagestate.py
rcfc0913 rb787e68c 51 51 self.formfactorcombobox = "" 52 52 self.structurecombobox = "" 53 self.disp_box="" 53 ## the indice of the current selection 54 self.disp_box = 0 54 55 ## Qrange 55 56 ## Q range … … 70 71 """ 71 72 self.data = copy.deepcopy(data) 72 73 73 74 74 75 75 def clone(self): … … 86 86 obj.fixed_param = copy.deepcopy(self.fixed_param) 87 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 88 obj.enable_disp = copy.deepcopy(self.enable_disp) 89 obj.enable_smearer = copy.deepcopy(self.enable_smearer) 90 obj.disp_box = copy.deepcopy(self.disp_box) 91 obj.qmin = copy.deepcopy(self.qmin) 92 obj.qmax = copy.deepcopy(self.qmax) 93 obj.npts = copy.deepcopy(self.npts ) 94 obj.cb1 = copy.deepcopy(self.cb1) 95 92 96 return obj 93 97
Note: See TracChangeset
for help on using the changeset viewer.