Changeset ffa69b6 in sasview for sansview/perspectives
- Timestamp:
- Jan 26, 2010 4:30:58 PM (15 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:
- fcd8887d
- Parents:
- 2377cd4
- Location:
- sansview/perspectives/fitting
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
r9237df4 rffa69b6 43 43 self.SetWindowVariant(variant=FONT_VARIANT) 44 44 ##window_name 45 self.window_name = page_info.window_name 46 ##window_caption 47 self.window_caption = page_info.window_caption 45 48 46 ## parent of the page 49 47 self.parent = parent 50 48 ## manager is the fitting plugin 51 self.manager= page_info.manager49 self.manager= None 52 50 ## owner of the page (fitting plugin) 53 self.event_owner= page_info.event_owner51 self.event_owner= None 54 52 ## current model 55 self.model = page_info.model53 self.model = None 56 54 ## data 57 self.data = page_info.data 55 self.data = None 56 self.state = PageState(parent=parent) 58 57 ## dictionary containing list of models 59 self.model_list_box = page_info.model_list_box 58 self.model_list_box = None 59 self.set_page_info(page_info=page_info) 60 60 ## Data member to store the dispersion object created 61 61 self._disp_obj_dict = {} … … 79 79 self.disp_list=[] 80 80 self.disp_name="" 81 81 82 ## list of orientation parameters 82 83 self.orientation_params=[] … … 209 210 control.SetSelection(-1,-1) 210 211 211 212 def set_page_info(self, page_info): 213 """ 214 set some page important information at once 215 """ 216 ##window_name 217 self.window_name = page_info.window_name 218 ##window_caption 219 self.window_caption = page_info.window_caption 220 ## manager is the fitting plugin 221 self.manager= page_info.manager 222 ## owner of the page (fitting plugin) 223 self.event_owner= page_info.event_owner 224 ## current model 225 self.model = page_info.model 226 ## data 227 self.data = page_info.data 228 ## dictionary containing list of models 229 self.model_list_box = page_info.model_list_box 230 ## Data member to store the dispersion object created 231 self.populate_box(dict=self.model_list_box) 232 212 233 def onContextMenu(self, event): 213 234 """ … … 312 333 self.model_list_box = dict 313 334 self.state.model_list_box = self.model_list_box 314 315 316 335 336 def initialize_combox(self): 337 """ 338 put default value in the combobox 339 """ 340 ## fill combox box 341 if self.model_list_box is None: 342 return 343 if len(self.model_list_box)>0: 344 self._populate_box( self.formfactorbox,self.model_list_box["Shapes"]) 345 346 if len(self.model_list_box)>0: 347 self._populate_box( self.structurebox, 348 self.model_list_box["Structure Factors"]) 349 self.structurebox.Insert("None", 0,None) 350 self.structurebox.SetSelection(0) 351 self.structurebox.Hide() 352 self.text2.Hide() 353 self.structurebox.Disable() 354 self.text2.Disable() 355 356 if self.model.__class__ in self.model_list_box["P(Q)*S(Q)"]: 357 self.structurebox.Show() 358 self.text2.Show() 359 self.structurebox.Enable() 360 self.text2.Enable() 361 317 362 def set_dispers_sizer(self): 318 363 """ … … 728 773 self._copy_parameters_state(self.fixed_param, self.state.fixed_param) 729 774 730 775 776 def check_invalid_panel(self): 777 """ 778 check if the user can already perform some action with this panel 779 """ 780 flag = False 781 if self.data is None and self.model is None: 782 msg = "Please load a Data to start" 783 wx.MessageBox(msg, 'Info') 784 return True 731 785 def reset_page_helper(self, state): 732 786 """ … … 881 935 Reset the plotting range to a given state 882 936 """ 937 if self.check_invalid_panel(): 938 return 883 939 self.qmin.SetValue(str(state.qmin)) 884 940 self.qmax.SetValue(str(state.qmax)) … … 1224 1280 [Note to coder: This way future changes will be done in only one place.] 1225 1281 """ 1282 if self.check_invalid_panel(): 1283 return 1226 1284 if self.model !=None: 1227 1285 temp_smear=None … … 1236 1294 qstep= float(self.num_points), 1237 1295 enable2D=self.enable2D) 1238 print "_draw_model" 1239 for name in self.model.getParamList(): 1240 print name , self.model.getParam(name) 1296 1241 1297 1242 1298 def _set_model_sizer(self,sizer, box_sizer, title="", object=None): … … 1283 1339 1284 1340 self.formfactorbox = wx.ComboBox(self, -1,style=wx.CB_READONLY) 1285 if self.model!= None:1341 if self.model!= None: 1286 1342 self.formfactorbox.SetValue(self.model.name) 1287 1288 1343 1289 1344 self.structurebox = wx.ComboBox(self, -1,style=wx.CB_READONLY) 1290 1345 wx.EVT_COMBOBOX(self.formfactorbox,-1, self._on_select_model) 1291 1346 wx.EVT_COMBOBOX(self.structurebox,-1, self._on_select_model) 1292 1347 1293 1294 ## fill combox box1295 if len(self.model_list_box)>0:1296 self._populate_box( self.formfactorbox,self.model_list_box["Shapes"])1297 1348 1298 if len(self.model_list_box)>0: 1299 self._populate_box( self.structurebox, 1300 self.model_list_box["Structure Factors"]) 1301 self.structurebox.Insert("None", 0,None) 1302 self.structurebox.SetSelection(0) 1303 self.structurebox.Hide() 1304 self.text2.Hide() 1305 self.structurebox.Disable() 1306 self.text2.Disable() 1349 self.initialize_combox() 1307 1350 1308 if self.model.__class__ in self.model_list_box["P(Q)*S(Q)"]:1309 self.structurebox.Show()1310 self.text2.Show()1311 self.structurebox.Enable()1312 self.text2.Enable()1313 1314 1351 ## check model type to show sizer 1315 1352 if self.model !=None: … … 1342 1379 Show combox box associate with type of model selected 1343 1380 """ 1381 if self.check_invalid_panel(): 1382 return 1383 1344 1384 ## Don't want to populate combo box again if the event comes from check box 1345 1385 if self.shape_rbutton.GetValue()and\ … … 1661 1701 Redraw the model with the default dispersity (Gaussian) 1662 1702 """ 1663 1703 if self.check_invalid_panel(): 1704 return 1664 1705 self._reset_dispersity() 1665 1706 … … 1988 2029 #On 'Reset' button for Q range clicked 1989 2030 """ 2031 if self.check_invalid_panel(): 2032 return 1990 2033 ##For 3 different cases: Data2D, Data1D, and theory 1991 2034 if self.data.__class__.__name__ == "Data2D": -
sansview/perspectives/fitting/fitpage.py
r9237df4 rffa69b6 55 55 self._fill_range_sizer() 56 56 #self._on_select_model(event=None) 57 if self.data !=None: 57 if self.data is None: 58 self.formfactorbox.Disable() 59 self.structurebox.Disable() 60 else: 58 61 self.smearer = smear_selection( self.data ) 59 62 if self.smearer ==None: … … 64 67 self.Bind(EVT_FITTER_TYPE,self._on_engine_change) 65 68 self.Bind(EVT_FIT_STOP,self._on_fit_complete) 69 66 70 67 71 def _on_fit_complete(self, event): … … 577 581 """ 578 582 #make sure all parameter values are updated. 579 583 if self.check_invalid_panel(): 584 return 580 585 flag = self._update_paramv_on_fit() 581 586 … … 708 713 Check validity of value enter in the parameters range field 709 714 """ 710 715 if self.check_invalid_panel(): 716 return 711 717 tcrtl= event.GetEventObject() 712 718 #Clear msg if previously shown. … … 740 746 Check validity of value enter in the Q range field 741 747 """ 742 748 if self.check_invalid_panel(): 749 return 743 750 tcrtl= event.GetEventObject() 744 751 #Clear msg if previously shown. … … 845 852 data_max = "" 846 853 data_name = "" 854 self.formfactorbox.Disable() 855 self.structurebox.Disable() 847 856 else: 857 self.formfactorbox.Enable() 858 self.structurebox.Enable() 848 859 data_name = self.data.name 849 860 #set maximum range for x in linear scale … … 862 873 863 874 self.dataSource.SetValue(data_name) 875 self.qmin_x = data_min 876 self.qmax_x = data_max 864 877 self.minimum_q.SetValue(str(data_min)) 865 878 self.maximum_q.SetValue(str(data_max)) 866 self.qmin_x = data_min 867 self.qmax_x = data_max 868 self.state.data = data, data_max 869 print "set_data",data_min 879 self.qmin.SetValue(str(data_min)) 880 self.qmax.SetValue(str(data_max)) 881 self.qmin.SetBackgroundColour("white") 882 self.qmax.SetBackgroundColour("white") 883 self.state.data = data 884 self.state.qmin = self.qmin_x 885 self.state.qmax = self.qmax_x 886 870 887 871 888 def reset_page(self, state,first=False): … … 1063 1080 are compute when fitting 1064 1081 """ 1082 if self.check_invalid_panel(): 1083 return 1065 1084 if self.model ==None: 1066 1085 msg="Need model and data to smear plot" -
sansview/perspectives/fitting/fitpanel.py
r2377cd4 rffa69b6 98 98 """ 99 99 data = None 100 model =None101 manager = None100 model = None 101 manager = None 102 102 event_owner= None 103 103 model_list_box = None 104 name =None104 name = None 105 105 ## Internal name for the AUI manager 106 106 window_name = "Page" … … 157 157 158 158 #model page info 159 self.model_page_number =None159 self.model_page_number = None 160 160 ## fit page number for model plot 161 self.fit_page1D_number=None 162 self.fit_page2D_number=None 163 self.model_page=None 164 self.sim_page=None 161 self.fit_page1D_number = None 162 self.fit_page2D_number = None 163 self.model_page = None 164 self.sim_page = None 165 self.default_page = None 166 self.check_first_data = False 165 167 ## get the state of a page 166 168 self.Bind(basepage.EVT_PAGE_INFO, self._onGetstate) … … 172 174 self.hint_page = HintFitPage(self) 173 175 self.AddPage(page=self.hint_page, caption="Hint") 176 #Add the first fit page 177 self.default_page = self.add_fit_page(data=None) 178 174 179 # increment number for model name 175 180 self.count=0 … … 243 248 self.event_owner = owner 244 249 245 def set_model_list(self, dict):250 def set_model_list(self, dict): 246 251 """ 247 252 copy a dictionary of model into its own dictionary … … 270 275 return self.sim_page 271 276 272 def add_fit_page( self,data, reset=False ): 277 278 def add_fit_page( self,data=None, reset=False ): 273 279 """ 274 280 Add a fitting page on the notebook contained by fitpanel 275 281 @param data: data to fit 276 282 @return panel : page just added for further used. is used by fitting module 277 """ 278 if data.is_data: 279 name = data.name 280 else: 281 if data.__class__.__name__=="Data2D": 282 name = 'Model 2D Fit' 283 """ 284 if data is not None: 285 if data.is_data: 286 name = data.name 283 287 else: 284 name = 'Model 1D Fit' 285 if not name in self.list_fitpage_name: 288 if data.__class__.__name__=="Data2D": 289 name = 'Model 2D Fit' 290 else: 291 name = 'Model 1D Fit' 286 292 myinfo = PageInfo( data=data, name=name ) 287 293 myinfo.model_list_box = self.model_list_box.get_list() … … 291 297 myinfo.window_caption = name 292 298 293 #if not name in self.fit_page_name : 294 from fitpage import FitPage 295 panel = FitPage(parent= self, page_info=myinfo) 296 297 self.AddPage(page=panel, caption=name, select=True) 298 if name == 'Model 1D Fit': 299 self.fit_page1D_number= self.GetPageIndex(panel) 300 if name =='Model 2D Fit': 301 self.fit_page2D_number= self.GetPageIndex(panel) 299 else : 300 name = "Fit Page" 301 myinfo = PageInfo( data=data, name=name ) 302 303 if not name in self.list_fitpage_name: 304 # the first data loading 305 if not self.check_first_data and self.default_page is not None: 306 page_number = self.GetPageIndex(self.default_page) 307 self.SetPageText(page_number , name) 308 self.default_page.set_data(data) 309 self.default_page.set_page_info(page_info=myinfo) 310 self.default_page.initialize_combox() 311 if data is not None: 312 self.check_first_data = True 313 panel = self.default_page 314 else: 315 #if not name in self.fit_page_name : 316 from fitpage import FitPage 317 panel = FitPage(parent=self, page_info=myinfo) 302 318 303 self.list_fitpage_name.append(name) 304 if reset: 305 if name in self.fit_page_name.keys(): 306 memento= self.fit_page_name[name][0] 307 panel.reset_page(memento) 308 else: 309 self.fit_page_name[name]=ListOfState() 310 311 #self.fit_page_name[name].appendItem(panel.createMemento()) 319 self.AddPage(page=panel, caption=name, select=True) 320 if name == 'Model 1D Fit': 321 self.fit_page1D_number= self.GetPageIndex(panel) 322 if name =='Model 2D Fit': 323 self.fit_page2D_number= self.GetPageIndex(panel) 324 325 self.list_fitpage_name.append(name) 326 if data is not None: 327 if reset: 328 if name in self.fit_page_name.keys(): 329 memento= self.fit_page_name[name][0] 330 panel.reset_page(memento) 331 else: 332 self.fit_page_name[name]=ListOfState() 333 334 #self.fit_page_name[name].appendItem(panel.createMemento()) 312 335 #GetPage(self, page_idx) 313 336 return panel
Note: See TracChangeset
for help on using the changeset viewer.