Changeset 3f36675 in sasview for sansview/perspectives/fitting
- Timestamp:
- Aug 1, 2011 10:36:34 AM (13 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:
- 0fd2f27
- Parents:
- d6a3cf0
- Location:
- sansview/perspectives/fitting
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/batchfitpage.py
rcc31608 r3f36675 142 142 sizer_smearer.Add((10,10)) 143 143 """ 144 144 """ 145 145 # StaticText for chi2, N(for fitting), Npts 146 146 self.tcChi = BGTextCtrl(self, -1, "-", size=(75,20), style=0) … … 155 155 self.Npts_total.SetToolTipString(\ 156 156 " Total Npts : total number of data points") 157 157 """ 158 158 # Update and Draw button 159 159 self.draw_button = wx.Button(self,wx.NewId(),'Compute', size=(88,24)) … … 161 161 self._onDraw,id= self.draw_button.GetId()) 162 162 self.draw_button.SetToolTipString("Compute and Draw.") 163 163 """ 164 164 box_description_1= wx.StaticText(self, -1,' Chi2/Npts') 165 165 box_description_2= wx.StaticText(self, -1,'Npts(Fit)') … … 168 168 " Total Npts : total number of data points") 169 169 #box_description_4= wx.StaticText(self, -1,' ') 170 171 170 """ 171 172 """ 172 173 sizer_fit.Add(box_description_1,0,0) 173 174 sizer_fit.Add(box_description_2,0,0) 174 sizer_fit.Add(box_description_3,0,0) 175 sizer_fit.Add(box_description_3,0,0) 176 """ 175 177 sizer_fit.Add(self.draw_button,0,0) 178 """ 176 179 sizer_fit.Add(self.tcChi,0,0) 177 180 sizer_fit.Add(self.Npts_fit ,0,0) 178 181 sizer_fit.Add(self.Npts_total,0,0) 182 """ 179 183 sizer_fit.Add(self.btFit,0,0) 180 184 """ … … 572 576 # Maximum value of data 573 577 data_max = max(self.data.x) 578 """ 574 579 #number of total data points 575 580 self.Npts_total.SetValue(str(len(self.data.x))) 576 581 #default:number of data points selected to fit 577 582 self.Npts_fit.SetValue(str(len(self.data.x))) 583 """ 578 584 self.btEditMask.Disable() 579 585 self.EditMask_title.Disable() … … 586 592 ## Maximum value of data 587 593 data_max = math.sqrt(x*x + y*y) 594 """ 588 595 #number of total data points 589 596 self.Npts_total.SetValue(str(len(self.data.data))) 590 597 #default:number of data points selected to fit 591 598 self.Npts_fit.SetValue(str(len(self.data.data))) 599 """ 592 600 self.btEditMask.Enable() 593 601 self.EditMask_title.Enable() 602 """ 594 603 self.Npts_total.SetEditable(False) 595 604 self.Npts_total.SetBackgroundColour(\ … … 598 607 self.Npts_total.Bind(wx.EVT_MOUSE_EVENTS, self._npts_click) 599 608 #self.Npts_total.Disable() 609 """ 600 610 self.dataSource.SetValue(data_name) 601 611 self.qmin_x = data_min … … 625 635 #replace data plot on combo box selection 626 636 #by removing the previous selected data 627 wx.PostEvent(self._manager.parent, NewPlotEvent(action="remove", 628 group_id=group_id, id=id)) 637 #wx.PostEvent(self._manager.parent, NewPlotEvent(action="remove", 638 # group_id=group_id, id=id)) 639 wx.PostEvent(self._manager.parent, 640 NewPlotEvent(group_id=group_id, 641 action="delete")) 629 642 #plot the current selected data 630 643 wx.PostEvent(self._manager.parent, NewPlotEvent(plot=self.data, -
sansview/perspectives/fitting/fitpage.py
rcc31608 r3f36675 1280 1280 msg = "Cannot Plot :No or too little npts in" 1281 1281 msg += " that data range!!! " 1282 wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 1282 wx.PostEvent(self.parent.parent, 1283 StatusEvent(status=msg)) 1283 1284 return 1284 1285 else: … … 1732 1733 #plot the current selected data 1733 1734 wx.PostEvent(self._manager.parent, NewPlotEvent(plot=self.data, 1734 1735 title=str(self.data.title))) 1735 1736 self._manager.store_data(uid=self.uid, data=data, 1736 1737 data_list=self.data_list, -
sansview/perspectives/fitting/fitpanel.py
rcc31608 r3f36675 313 313 add an empty page 314 314 """ 315 """ 315 316 if self.batch_on: 316 317 from batchfitpage import BatchFitPage … … 320 321 index = self.batch_page_index 321 322 else: 322 from fitpage import FitPage 323 panel = FitPage(parent=self) 324 #Increment index of fit page 325 self.fit_page_index += 1 326 index = self.fit_page_index 323 """ 324 from fitpage import FitPage 325 panel = FitPage(parent=self) 326 #Increment index of fit page 327 self.fit_page_index += 1 328 index = self.fit_page_index 327 329 panel.uid = wx.NewId() 328 330 panel.populate_box(dict=self.model_list_box) … … 342 344 if self.GetPageCount() <= 1: 343 345 style = self.GetWindowStyleFlag() 344 if style & wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB == wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB: 346 flag = wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB 347 if style & wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB == flag: 345 348 style = style & ~wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB 346 349 self.SetWindowStyle(style) 347 350 else: 348 351 style = self.GetWindowStyleFlag() 349 if style & wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB != wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB: 352 flag = wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB 353 if style & wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB != flag: 350 354 style |= wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB 351 355 self.SetWindowStyle(style) … … 372 376 self._manager.on_add_new_page(event=None) 373 377 378 def set_data_on_batch_mode(self, data_list): 379 """ 380 Add all data to a single tab when the application is on Batch mode. 381 However all data in the set of data must be either 1D or 2D type. 382 This method presents option to select the data type before creating a 383 tab. 384 """ 385 data_1d_list = [] 386 data_2d_list = [] 387 for data in data_list: 388 if data.__class__.__name__ == "Data1D": 389 data_1d_list.append(data) 390 if data.__class__.__name__ == "Data2D": 391 data_2d_list.append(data) 392 page = None 393 for p in self.opened_pages.values(): 394 #check if the selected data existing in the fitpanel 395 pos = self.GetPageIndex(page) 396 if p.get_data() is None: 397 page = p 398 break 399 400 if data_1d_list and data_2d_list: 401 # need to warning the user that this batch is a special case 402 from .fitting_widgets import BatchDataDialog 403 dlg = BatchDataDialog(self) 404 if dlg.ShowModal() == wx.ID_OK: 405 data_type = dlg.get_data() 406 dlg.Destroy() 407 if page is None: 408 page = self.add_empty_page() 409 if data_type == 1: 410 #user has selected only data1D 411 page.fill_data_combobox(data_1d_list) 412 elif data_type == 2: 413 page.fill_data_combobox(data_2d_list) 414 else: 415 #the batch analysis is canceled 416 dlg.Destroy() 417 return None 418 else: 419 if page is None: 420 page = self.add_empty_page() 421 if data_1d_list and not data_2d_list: 422 #only on type of data 423 page.fill_data_combobox(data_1d_list) 424 elif not data_1d_list and data_2d_list: 425 page.fill_data_combobox(data_2d_list) 426 427 self.opened_pages[page.uid] = page 428 return page 429 374 430 def set_data(self, data_list): 375 431 """ … … 378 434 :param data: data to fit 379 435 380 :return panel : page just added for further used. is used by fitting module 436 :return panel : page just added for further used. 437 is used by fitting module 381 438 382 439 """ 383 440 if not data_list: 384 441 return None 385 386 442 if self.batch_on: 387 page = self.add_empty_page() 388 print "batch on fitpanel", page.__class__.__name__, page.window_caption 389 pos = self.GetPageIndex(page) 390 page.fill_data_combobox(data_list) 391 self.opened_pages[page.uid] = page 392 return page 443 return self.set_data_on_batch_mode(data_list) 393 444 else: 394 445 data = None -
sansview/perspectives/fitting/fitting_widgets.py
rcfcb7207 r3f36675 17 17 HEIGHT = 300 18 18 MAX_NBR_DATA = 4 19 20 class BatchDataDialog(wx.Dialog): 21 """ 22 The current design of Batch fit allows only of type of data in the data 23 set. This allows the user to make a quick selection of the type of data 24 to use in fit tab. 25 """ 26 def __init__(self, parent=None, *args, **kwds): 27 wx.Dialog.__init__(self, parent, *args, **kwds) 28 self.SetSize((WIDTH, 250)) 29 self.data_1d_selected = None 30 self.data_2d_selected = None 31 self._do_layout() 32 33 def _do_layout(self): 34 """ 35 Draw the content of the current dialog window 36 """ 37 vbox = wx.BoxSizer(wx.VERTICAL) 38 box_description= wx.StaticBox(self, -1,str("Hint")) 39 hint_sizer = wx.StaticBoxSizer(box_description, wx.VERTICAL) 40 selection_sizer = wx.GridBagSizer(5,5) 41 button_sizer = wx.BoxSizer(wx.HORIZONTAL) 42 self.data_1d_selected = wx.RadioButton(self, -1, 'Data1D', 43 style=wx.RB_GROUP) 44 self.data_2d_selected = wx.RadioButton(self, -1, 'Data2D') 45 self.data_1d_selected.SetValue(True) 46 self.data_2d_selected.SetValue(False) 47 button_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel") 48 button_OK = wx.Button(self, wx.ID_OK, "Ok") 49 button_OK.SetFocus() 50 hint = "Selected Data set contains both 1D and 2D Data.\n" 51 hint += "Please select on type of analysis before proceeding.\n" 52 hint_sizer.Add(wx.StaticText(self, -1, hint)) 53 #draw area containing radio buttons 54 ix = 0 55 iy = 0 56 selection_sizer.Add(self.data_1d_selected, (iy, ix), 57 (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 58 iy += 1 59 selection_sizer.Add(self.data_2d_selected, (iy, ix), 60 (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 61 #contruction the sizer contaning button 62 button_sizer.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) 63 button_sizer.Add(button_cancel, 0, 64 wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 65 button_sizer.Add(button_OK, 0, 66 wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 67 vbox.Add(hint_sizer, 0, wx.EXPAND|wx.ALL, 10) 68 vbox.Add(selection_sizer, 0, wx.TOP|wx.BOTTOM, 10) 69 vbox.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0) 70 vbox.Add(button_sizer, 0 , wx.TOP|wx.BOTTOM, 10) 71 self.SetSizer(vbox) 72 73 def get_data(self): 74 """ 75 return 1 if user requested Data1D , 2 if user requested Data2D 76 """ 77 if self.data_1d_selected.GetValue(): 78 return 1 79 else: 80 return 2 81 82 19 83 20 84 class DataDialog(wx.Dialog):
Note: See TracChangeset
for help on using the changeset viewer.