Changeset 2f4b430 in sasview for src/sas/perspectives/fitting/fitpanel.py
- Timestamp:
- Mar 4, 2015 3:39:45 PM (10 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:
- 74f419d
- Parents:
- 2f732b0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/perspectives/fitting/fitpanel.py
r386ffe1 r2f4b430 4 4 :note: For Fit to be performed the user should check at least one parameter 5 5 on fit Panel window. 6 6 7 7 """ 8 8 import wx … … 22 22 """ 23 23 FitPanel class contains fields allowing to fit models and data 24 24 25 25 :note: For Fit to be performed the user should check at least one parameter 26 26 on fit Panel window. 27 27 28 28 """ 29 29 ## Internal name for the AUI manager … … 32 32 window_caption = "Fit Panel " 33 33 CENTER_PANE = True 34 34 35 35 def __init__(self, parent, manager=None, *args, **kwargs): 36 36 """ 37 37 """ 38 38 nb.__init__(self, parent, -1, 39 style=wx.aui.AUI_NB_WINDOWLIST_BUTTON |40 wx.aui.AUI_NB_DEFAULT_STYLE |39 style=wx.aui.AUI_NB_WINDOWLIST_BUTTON | 40 wx.aui.AUI_NB_DEFAULT_STYLE | 41 41 wx.CLIP_CHILDREN) 42 42 PanelBase.__init__(self, parent) … … 51 51 self.model_dictionary = self.menu_mng.get_model_dictionary() 52 52 self.pageClosedEvent = wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE 53 53 54 54 self.Bind(self.pageClosedEvent, self.on_close_page) 55 55 ## save the title of the last page tab added … … 71 71 self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, self.on_page_changing) 72 72 self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSED, self.on_closed) 73 73 74 74 def on_closed(self, event): 75 75 """ … … 78 78 self.add_empty_page() 79 79 self.enable_close_button() 80 80 81 81 def save_project(self, doc=None): 82 82 """ … … 109 109 info="warning")) 110 110 return doc 111 111 112 112 def update_model_list(self): 113 113 """ … … 117 117 self.model_list_box = temp 118 118 return temp 119 119 120 120 def reset_pmodel_list(self): 121 121 """ … … 125 125 self.model_list_box = temp 126 126 return temp 127 127 128 128 def get_page_by_id(self, uid): 129 129 """ … … 134 134 else: 135 135 return self.opened_pages[uid] 136 136 137 137 def on_page_changing(self, event): 138 138 """ … … 141 141 """ 142 142 wx.CallAfter(self.helper_on_page_change) 143 143 144 144 def helper_on_page_change(self): 145 145 """ … … 148 148 if pos != -1: 149 149 selected_page = self.GetPage(pos) 150 wx.PostEvent(self._manager.parent, 150 wx.PostEvent(self._manager.parent, 151 151 PanelOnFocusEvent(panel=selected_page)) 152 152 self.enable_close_button() 153 153 154 154 def on_set_focus(self, event): 155 155 """ … … 158 158 if pos != -1: 159 159 selected_page = self.GetPage(pos) 160 wx.PostEvent(self._manager.parent, 160 wx.PostEvent(self._manager.parent, 161 161 PanelOnFocusEvent(panel=selected_page)) 162 162 163 163 def get_data(self): 164 164 """ … … 169 169 selected_page = self.GetPage(pos) 170 170 return selected_page.get_data() 171 171 172 172 def set_model_state(self, state): 173 173 """ … … 178 178 selected_page = self.GetPage(pos) 179 179 selected_page.set_model_state(state) 180 180 181 181 def get_state(self): 182 182 """ … … 187 187 selected_page = self.GetPage(pos) 188 188 return selected_page.get_state() 189 189 190 190 def close_all(self): 191 191 """ 192 192 remove all pages, used when a svs file is opened 193 193 """ 194 194 195 195 #get number of pages 196 196 nop = self.GetPageCount() … … 204 204 self.DeletePage(0) 205 205 nop = nop - 1 206 206 207 207 ## save the title of the last page tab added 208 208 self.fit_page_name = {} 209 209 ## list of existing fit page 210 210 self.opened_pages = {} 211 211 212 212 def set_state(self, state): 213 213 """ … … 238 238 panel.reset_page(state=state) 239 239 panel.save_current_state() 240 240 241 241 def clear_panel(self): 242 242 """ 243 243 Clear and close all panels, used by guimanager 244 244 """ 245 245 246 246 #close all panels only when svs file opened 247 247 self.close_all() 248 248 self._manager.mypanels = [] 249 249 250 250 def on_close_page(self, event=None): 251 251 """ … … 260 260 return 261 261 self._close_helper(selected_page=selected_page) 262 262 263 263 def close_page_with_data(self, deleted_data): 264 264 """ … … 271 271 if hasattr(selected_page, "get_data"): 272 272 data = selected_page.get_data() 273 273 274 274 if data is None: 275 275 #the fitpanel exists and only the initial fit page is open … … 280 280 self.DeletePage(index) 281 281 break 282 282 283 283 def set_manager(self, manager): 284 284 """ 285 285 set panel manager 286 286 287 287 :param manager: instance of plugin fitting 288 288 289 289 """ 290 290 self._manager = manager … … 297 297 """ 298 298 copy a dictionary of model into its own dictionary 299 299 300 300 :param m_dict: dictionnary made of model name as key and model class 301 301 as value 302 302 """ 303 303 self.model_list_box = dict 304 304 305 305 def set_model_dict(self, m_dict): 306 306 """ … … 313 313 """ 314 314 :return: the current page selected 315 315 316 316 """ 317 317 return self.GetPage(self.GetSelection()) 318 318 319 319 def add_sim_page(self, caption="Const & Simul Fit"): 320 320 """ … … 325 325 if caption == "Const & Simul Fit": 326 326 self.sim_page = SimultaneousFitPage(self, page_finder=page_finder, 327 id= -1, batch_on=False)327 id= -1, batch_on=False) 328 328 self.sim_page.window_caption = caption 329 329 self.sim_page.window_name = caption … … 343 343 self.enable_close_button() 344 344 return self.batch_page 345 345 346 346 def add_empty_page(self): 347 347 """ … … 385 385 panel.on_set_focus(None) 386 386 return panel 387 387 388 388 def enable_close_button(self): 389 389 """ … … 403 403 style |= wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB 404 404 self.SetWindowStyle(style) 405 405 406 406 def delete_data(self, data): 407 407 """ … … 422 422 if self.GetPageCount() == 0: 423 423 self._manager.on_add_new_page(event=None) 424 424 425 425 def set_data_on_batch_mode(self, data_list): 426 426 """ 427 427 Add all data to a single tab when the application is on Batch mode. 428 However all data in the set of data must be either 1D or 2D type. 429 This method presents option to select the data type before creating a 428 However all data in the set of data must be either 1D or 2D type. 429 This method presents option to select the data type before creating a 430 430 tab. 431 431 """ … … 445 445 #check if there is an empty page to fill up 446 446 if not check_data_validity(p.get_data()) and p.batch_on: 447 447 448 448 #make sure data get placed in 1D empty tab if data is 1D 449 449 #else data get place on 2D tab empty tab … … 479 479 elif not data_1d_list and data_2d_list: 480 480 page.fill_data_combobox(data_2d_list) 481 481 482 482 pos = self.GetPageIndex(page) 483 483 page.batch_on = self.batch_on … … 486 486 self.opened_pages[page.uid] = page 487 487 return page 488 488 489 489 def set_data(self, data_list): 490 490 """ 491 491 Add a fitting page on the notebook contained by fitpanel 492 492 493 493 :param data: data to fit 494 494 495 495 :return panel : page just added for further used. 496 496 is used by fitting module 497 497 498 498 """ 499 499 if not data_list: … … 509 509 data_list = [data] 510 510 data = data_list[0] 511 511 512 512 if data is None: 513 513 return None … … 535 535 self.SetSelection(pos) 536 536 return page 537 537 538 538 def _onGetstate(self, event): 539 539 """ … … 543 543 if page.uid in self.fit_page_name: 544 544 self.fit_page_name[page.uid].appendItem(page.createMemento()) 545 545 546 546 def _onUndo(self, event): 547 547 """ … … 556 556 page._redo.Enable(True) 557 557 page.reset_page(state) 558 558 559 559 def _onRedo(self, event): 560 560 """ … … 571 571 state = self.fit_page_name[page.uid].getNextItem() 572 572 page.reset_page(state) 573 573 574 574 def _close_helper(self, selected_page): 575 575 """ … … 606 606 for uid, list in self.opened_pages.iteritems(): 607 607 #Don't return any panel is the exact same page is created 608 608 609 609 if flag and selected_page.uid == uid: 610 610 self._manager.remove_plot(uid, theory=False) 611 611 break 612 612 del page_finder[selected_page] 613 613 614 614 #Delete the name of the page into the list of open page 615 615 for uid, list in self.opened_pages.iteritems():
Note: See TracChangeset
for help on using the changeset viewer.