Changeset 72a6bf8 in sasview
- Timestamp:
- Jul 26, 2010 5:39:54 PM (14 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:
- cef847c
- Parents:
- 343fdb6
- Location:
- sansview/perspectives/fitting
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/fitpanel.py
r3c44c66 r72a6bf8 190 190 from hint_fitpage import HintFitPage 191 191 self.hint_page = HintFitPage(self) 192 self.AddPage(page=self.hint_page, caption="Hint") 193 #Add the first fit page 194 self.add_empty_page() 195 192 self.AddPage(page=self.hint_page, caption="Loaded Data") 196 193 # increment number for model name 197 self.count =0194 self.count = 0 198 195 #updating the panel 199 196 self.Update() 200 197 self.Center() 201 198 202 def set_data(self, list=[]): 203 """ 204 Receive a list of data and create new 205 """ 206 if list==[]: 207 msg = "Please select data for Fitting perspective.\n" 208 dial = wx.MessageDialog(None, msg, 'Error Loading File', 209 wx.OK | wx.ICON_EXCLAMATION) 210 dial.ShowModal() 199 def set_data(self, list=[], state=None): 200 """ 201 Receive a list of data from data manager 202 """ 203 if len(list) ==0: 211 204 return 212 for data, path in list: 213 self.manager.add_fit_page(data=data) 214 205 self.hint_page.set_data(list=list) 206 215 207 def set_state(self, state): 216 208 """ … … 220 212 if state is not None: 221 213 page_info = self.get_page_info(data=state.data) 222 for name, panel in self.opened_pages.values():214 for name, panel, type in self.opened_pages.values(): 223 215 #Don't return any panel is the exact same page is created 224 216 if name == page_info.window_name: … … 231 223 panel.initialize_combox() 232 224 panel.set_page_info(page_info=page_info) 233 self.opened_pages[page_info. type] = [page_info.window_name, panel]225 self.opened_pages[page_info.window_name] = [page_info.window_name, panel, page_info.type] 234 226 if panel is not None: 235 227 self.manager.store_page(page=panel, data=state.data) … … 249 241 """ 250 242 nbr_page = self.GetPageCount() 251 if nbr_page == 1: 243 pos = self.GetSelection() 244 if nbr_page == 1 or self.GetPage(pos)== self.hint_page: 252 245 event.Veto() 253 246 return … … 354 347 panel = FitPage(parent=self, page_info=page_info) 355 348 self.AddPage(page=panel, caption=page_info.window_name, select=True) 356 self.opened_pages[page_info. type] = [page_info.window_name, panel]349 self.opened_pages[page_info.window_name] = [page_info.window_name, panel, page_info.type] 357 350 return panel 358 351 … … 381 374 panel.initialize_combox() 382 375 panel.set_page_info(page_info=page_info) 383 self.opened_pages[page_info. type] = [page_info.window_name, panel]376 self.opened_pages[page_info.window_name] = [page_info.window_name, panel, page_info.type] 384 377 return panel 385 378 … … 389 382 """ 390 383 self.DeletePage(index) 391 del self.opened_pages[ type]384 del self.opened_pages[page_info.window_name] 392 385 return self.add_page(page_info=page_info) 393 386 … … 406 399 type = page_info.type 407 400 npages = len(self.opened_pages.keys()) 408 #check if only and empty page is opened 409 if len(self.opened_pages.keys()) > 0: 410 first_page_type = self.opened_pages.keys()[0] 411 if npages == 1 and first_page_type in ['empty']: 412 #replace the first empty page 413 name, panel = self.opened_pages[first_page_type] 414 index = self.GetPageIndex(panel) 415 panel = self.change_page_content(data=data, index=index) 416 del self.opened_pages[first_page_type] 417 return panel 418 if type in self.opened_pages.keys(): 419 #this type of page is already created but it is a theory 420 # meaning the same page is just to fit different data 421 if not type.lower() in ['data']: 422 #delete the previous theory page and add a new one 423 name, panel = self.opened_pages[type] 424 #self.manager.reset_plot_panel(panel.get_data()) 425 #delete the existing page and replace it 426 index = self.GetPageIndex(panel) 427 panel = self.replace_page(index=index, page_info=page_info, type=type) 401 if npages == 0: 402 # create new type of page 403 panel = self.add_page(page_info=page_info) 404 return panel 405 else: 406 if page_info.window_name not in self.opened_pages.keys() and \ 407 page_info.type.lower() in ['data']: 408 #create new data type page 409 panel = self.add_page(page_info=page_info) 410 return panel 411 elif page_info.type.lower() not in ['data']: 412 #create new theory page 413 for open_tab_caption, value in self.opened_pages.iteritems(): 414 open_tab = value[1] 415 open_type = value[2] 416 if page_info.type == open_type: 417 #replace theory fit tab 418 existing_value = self.opened_pages[open_tab_caption] 419 panel = existing_value[1] 420 #delete the existing page and replace it 421 index = self.GetPageIndex(panel) 422 panel = self.replace_page(index=index, page_info=page_info, 423 type=type) 424 return panel 425 panel = self.add_page(page_info=page_info) 428 426 return panel 429 427 else: 430 for value in self.opened_pages.values(): 431 if page_info.window_name == str(value[0]): 432 #Don't return any panel is the exact same page is created 433 return None 434 panel = self.add_page(page_info=page_info) 435 return panel 436 else: 437 #a new type of page is created 438 panel = self.add_page(page_info=page_info) 439 return panel 440 428 _, panel, _ = self.opened_pages[page_info.window_name] 429 index = self.GetPageIndex(panel) 430 self.SetSelection(index) 431 #page already existing 432 return None 433 441 434 def _onGetstate(self, event): 442 435 """ -
sansview/perspectives/fitting/fitting.py
r0b12abb5 r72a6bf8 670 670 if page != None: 671 671 self.store_page(page=page, data=data) 672 if hasattr(data,"title"): 673 title = str(data.title.lstrip().rstrip()) 674 if title == "": 675 title = str(data.name) 676 else: 677 title = str(data.name) 678 wx.PostEvent(self.parent, NewPlotEvent(plot=data, title=title)) 672 679 wx.PostEvent(self.parent, StatusEvent(status="Page Created", 673 680 info="info")) … … 676 683 wx.PostEvent(self.parent, StatusEvent(status=msg, info="warning")) 677 684 except: 678 msg = "Creating Fit page: %s"%sys.exc_value 679 wx.PostEvent(self.parent, StatusEvent(status=msg, info="error")) 685 raise 686 #msg = "Creating Fit page: %s"%sys.exc_value 687 #wx.PostEvent(self.parent, StatusEvent(status=msg, info="error")) 680 688 681 689 def _onEVT_SLICER_PANEL(self, event): -
sansview/perspectives/fitting/hint_fitpage.py
r5062bbf r72a6bf8 1 1 2 import os 2 3 import wx 4 from wx.lib.scrolledpanel import ScrolledPanel 5 from sans.guicomm.events import NewPlotEvent 3 6 4 5 class HintFitPage(wx.ScrolledWindow): 7 class HintFitPage(ScrolledPanel): 6 8 """ 7 9 This class provide general structure of fitpanel page … … 15 17 """ 16 18 """ 17 wx.ScrolledWindow.__init__(self, parent, 18 style= wx.FULL_REPAINT_ON_RESIZE ) 19 19 ScrolledPanel.__init__(self, parent, 20 style=wx.FULL_REPAINT_ON_RESIZE) 21 self.SetupScrolling() 22 self.parent = parent 20 23 msg = "right click on the data when it is highlighted " 21 24 msg += "the select option to fit for futher options" 22 25 self.do_layout() 26 27 28 def set_data(self, list=[], state=None): 29 """ 30 """ 31 if not list: 32 return 33 for data, path in list: 34 if data.name not in self.data_cbbox.GetItems(): 35 self.data_cbbox.Insert(item=data.name, pos=0, 36 clientData=(data, path)) 37 if self.data_cbbox.GetCount() >0: 38 self.data_cbbox.SetSelection(0) 39 self.data_cbbox.Enable() 40 self.on_select_data(event=None) 23 41 24 42 def do_layout(self): … … 26 44 Draw the page 27 45 """ 28 name="Hint" 29 box_description= wx.StaticBox(self, -1,name) 30 boxsizer = wx.StaticBoxSizer(box_description, wx.VERTICAL) 46 self.vbox = wx.BoxSizer(wx.VERTICAL) 47 sizer1 = wx.BoxSizer(wx.HORIZONTAL) 48 sizer2 = wx.GridBagSizer(0,0) 49 box_description = wx.StaticBox(self, -1, "Hint") 50 boxsizer = wx.StaticBoxSizer(box_description, wx.HORIZONTAL) 51 boxsizer.SetMinSize((450,100)) 31 52 msg = " How to link data to the control panel: \n \n" 32 53 msg += " First load data file from 'File' menu. \n" … … 34 55 msg += " Finally, select 'Select data for fitting' in the pop-up menu. \n" 35 56 self.hint_txt = wx.StaticText(self, -1, msg, style=wx.ALIGN_LEFT) 36 boxsizer.Add(self.hint_txt, wx.ALL|wx.EXPAND, 20) 37 self.vbox = wx.BoxSizer(wx.VERTICAL) 38 self.vbox.Add(boxsizer ) 39 self.vbox.Layout() 40 self.vbox.Fit(self) 57 self.data_txt = wx.StaticText(self, -1,"Loaded Data: ") 58 self.data_cbbox = wx.ComboBox(self, -1, size=(260,20)) 59 self.data_cbbox.Disable() 60 wx.EVT_COMBOBOX(self.data_cbbox ,-1, self.on_select_data) 61 62 sizer1.Add(self.hint_txt) 63 ix = 0 64 iy = 0 65 66 sizer2.Add(self.data_txt, (iy, ix), (1,1), 67 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 68 ix += 1 69 sizer2.Add( self.data_cbbox, (iy, ix), (1,1), 70 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 71 boxsizer.Add(sizer1) 72 73 self.vbox.Add(boxsizer,0, wx.ALL, 10) 74 self.vbox.Add(sizer2) 41 75 self.SetSizer(self.vbox) 42 self.SetScrollbars(20,20,25,65) 43 self.Layout() 76 77 def on_select_data(self, event=None): 78 """ 79 """ 80 n = self.data_cbbox.GetCurrentSelection() 81 data, path = self.data_cbbox.GetClientData(n) 82 self.parent.manager.add_fit_page(data=data) 83 title = os.path.basename(path) 84 44 85 45 86 def createMemento(self): … … 47 88 """ 48 89 return 49 """ 50 Example: :: 51 52 class HelpWindow(wx.Frame): 53 def __init__(self, parent, id, title): 54 wx.Frame.__init__(self, parent, id, title, size=(570, 400)) 55 56 self.page = HintFitPage(self) 57 self.Centre() 58 self.Show(True) 59 60 if __name__=="__main__": 61 app = wx.App() 62 HelpWindow(None, -1, 'HelpWindow') 63 app.MainLoop() 64 """ 90
Note: See TracChangeset
for help on using the changeset viewer.