Changeset a93f525 in sasview for sansview/perspectives
- Timestamp:
- Aug 4, 2010 3:05:12 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:
- b35d3d1
- Parents:
- 10f3b23
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/fitpanel.py
r10f3b23 ra93f525 4 4 import wx 5 5 import wx.aui 6 from sans.guicomm.events import NewPlotEvent, StatusEvent 6 7 7 import basepage 8 8 … … 187 187 self.Bind(basepage.EVT_NEXT_STATE, self._onRedo) 188 188 189 #add default page189 #add default page 190 190 from hint_fitpage import HintFitPage 191 191 self.hint_page = HintFitPage(self) … … 195 195 196 196 # increment number for model name 197 self.count =0197 self.count=0 198 198 #updating the panel 199 199 self.Update() … … 207 207 if state is not None: 208 208 page_info = self.get_page_info(data=state.data) 209 if hasattr(state.data,"title"): 210 title = str(state.data.title.lstrip().rstrip()) 211 if title == "": 212 title = str(state.data.name) 213 else: 214 title = str(state.data.name) 215 for name, panel, type in self.opened_pages.values(): 209 for name, panel in self.opened_pages.values(): 216 210 #Don't return any panel is the exact same page is created 217 211 if name == page_info.window_name: 218 212 # the page is still opened 219 panel.set_manager(self.manager)220 panel.set_owner(self.event_owner)221 if panel.model_list_box is None or len(panel.model_list_box) == 0:222 page_info.model_list_box = self.model_list_box.get_list()223 panel.populate_box(dict=page_info.model_list_box)224 panel.initialize_combox()225 panel.set_page_info(page_info=page_info)226 self.opened_pages[page_info.window_name] = [page_info.window_name, panel, page_info.type]227 if panel is not None:228 self.manager.store_page(page=panel, data=state.data)229 213 panel.reset_page(state=state) 230 wx.PostEvent(self.parent, NewPlotEvent(plot=state.data, title=title))231 214 page_is_opened = True 232 233 215 if not page_is_opened: 234 216 panel = self.add_fit_page(data=state.data) … … 237 219 self.manager.store_page(page=panel, data=state.data) 238 220 panel.reset_page(state=state) 239 240 221 241 222 def on_close_page(self, event): … … 244 225 """ 245 226 nbr_page = self.GetPageCount() 246 pos = self.GetSelection() 247 if nbr_page == 1 or self.GetPage(pos)== self.hint_page: 227 if nbr_page == 1: 248 228 event.Veto() 249 229 return … … 278 258 """ 279 259 self.manager = manager 280 260 281 261 282 262 def set_owner(self,owner): … … 323 303 name = "Fit Page" 324 304 type = 'empty' 325 if data is not None and hasattr(data, "is_data"):305 if data is not None: 326 306 if data.is_data: 327 307 name = data.name … … 350 330 panel = FitPage(parent=self, page_info=page_info) 351 331 self.AddPage(page=panel, caption=page_info.window_name, select=True) 352 self.opened_pages[page_info. window_name] = [page_info.window_name, panel, page_info.type]332 self.opened_pages[page_info.type] = [page_info.window_name, panel] 353 333 return panel 354 334 … … 377 357 panel.initialize_combox() 378 358 panel.set_page_info(page_info=page_info) 379 self.opened_pages[page_info. window_name] = [page_info.window_name, panel, page_info.type]359 self.opened_pages[page_info.type] = [page_info.window_name, panel] 380 360 return panel 381 361 … … 385 365 """ 386 366 self.DeletePage(index) 387 del self.opened_pages[ page_info.window_name]367 del self.opened_pages[type] 388 368 return self.add_page(page_info=page_info) 389 369 … … 402 382 type = page_info.type 403 383 npages = len(self.opened_pages.keys()) 404 if npages == 0: 405 # create new type of page 384 #check if only and empty page is opened 385 if len(self.opened_pages.keys()) > 0: 386 first_page_type = self.opened_pages.keys()[0] 387 if npages == 1 and first_page_type in ['empty']: 388 #replace the first empty page 389 name, panel = self.opened_pages[first_page_type] 390 index = self.GetPageIndex(panel) 391 panel = self.change_page_content(data=data, index=index) 392 del self.opened_pages[first_page_type] 393 return panel 394 if type in self.opened_pages.keys(): 395 #this type of page is already created but it is a theory 396 # meaning the same page is just to fit different data 397 if not type.lower() in ['data']: 398 #delete the previous theory page and add a new one 399 name, panel = self.opened_pages[type] 400 #self.manager.reset_plot_panel(panel.get_data()) 401 #delete the existing page and replace it 402 index = self.GetPageIndex(panel) 403 panel = self.replace_page(index=index, page_info=page_info, type=type) 404 return panel 405 else: 406 for name, panel in self.opened_pages.values(): 407 #Don't return any panel is the exact same page is created 408 if name == page_info.window_name: 409 return None 410 else: 411 panel = self.add_page(page_info=page_info) 412 return panel 413 else: 414 #a new type of page is created 406 415 panel = self.add_page(page_info=page_info) 407 416 return panel 408 else: 409 if page_info.window_name not in self.opened_pages.keys() and \ 410 page_info.type.lower() in ['data']: 411 #create new data type page 412 panel = self.add_page(page_info=page_info) 413 return panel 414 elif page_info.type.lower() not in ['data']: 415 #create new theory page 416 for open_tab_caption, value in self.opened_pages.iteritems(): 417 open_tab = value[1] 418 open_type = value[2] 419 if page_info.type == open_type: 420 #replace theory fit tab 421 existing_value = self.opened_pages[open_tab_caption] 422 panel = existing_value[1] 423 #delete the existing page and replace it 424 index = self.GetPageIndex(panel) 425 panel = self.replace_page(index=index, page_info=page_info, 426 type=type) 427 return panel 428 panel = self.add_page(page_info=page_info) 429 return panel 430 else: 431 _, panel, _ = self.opened_pages[page_info.window_name] 432 index = self.GetPageIndex(panel) 433 self.SetSelection(index) 434 #page already existing 435 return None 436 417 437 418 def _onGetstate(self, event): 438 419 """
Note: See TracChangeset
for help on using the changeset viewer.