def set_data(self, data_list): """ Add a fitting page on the notebook contained by fitpanel :param data_list: data to fit :return panel : page just added for further used. is used by fitting module """ if not data_list: return None if self.batch_on: return self.set_data_on_batch_mode(data_list) else: data = None try: data = data_list[0] except Exception: # for 'fitv' files data_list = [data] data = data_list[0] if data is None: return None focused_page = self.GetPage(self.GetSelection()) for page in self.opened_pages.values(): # check if the selected data existing in the fitpanel pos = self.GetPageIndex(page) if not check_data_validity(page.get_data()) and not page.batch_on: if page.model is not None and page != focused_page: # Page has an active theory and is in background - don't # send data here. continue # make sure data get placed in 1D empty tab if data is 1D # else data get place on 2D tab empty tab enable2D = page.get_view_mode() if (data.__class__.__name__ == "Data2D" and enable2D)\ or (data.__class__.__name__ == "Data1D" and not enable2D): page.batch_on = self.batch_on page._set_save_flag(not page.batch_on) page.fill_data_combobox(data_list) # caption = "FitPage" + str(self.fit_page_index) self.SetPageText(pos, page.window_caption) self.SetSelection(pos) return page # create new page and add data page = self.add_empty_page() pos = self.GetPageIndex(page) page.fill_data_combobox(data_list) self.opened_pages[page.uid] = page self.SetSelection(pos) return page
def set_data_on_batch_mode(self, data_list): """ Add all data to a single tab when the application is on Batch mode. However all data in the set of data must be either 1D or 2D type. This method presents option to select the data type before creating a tab. """ data_1d_list = [] data_2d_list = [] group_id_1d = wx.NewId() # separate data into data1d and data2d list for data in data_list: if data.__class__.__name__ == "Data1D": data.group_id = group_id_1d data_1d_list.append(data) if data.__class__.__name__ == "Data2D": data.group_id = wx.NewId() data_2d_list.append(data) page = None for p in self.opened_pages.values(): # check if there is an empty page to fill up if not check_data_validity(p.get_data()) and p.batch_on: # make sure data get placed in 1D empty tab if data is 1D # else data get place on 2D tab empty tab enable2D = p.get_view_mode() if (data.__class__.__name__ == "Data2D" and enable2D)\ or (data.__class__.__name__ == "Data1D" and not enable2D): page = p break if data_1d_list and data_2d_list: # need to warning the user that this batch is a special case from sas.sasgui.perspectives.fitting.fitting_widgets import \ BatchDataDialog dlg = BatchDataDialog(self) if dlg.ShowModal() == wx.ID_OK: data_type = dlg.get_data() dlg.Destroy() if page is None: page = self.add_empty_page() if data_type == 1: # user has selected only data1D page.fill_data_combobox(data_1d_list) elif data_type == 2: page.fill_data_combobox(data_2d_list) else: # the batch analysis is canceled dlg.Destroy() return None else: if page is None: page = self.add_empty_page() if data_1d_list and not data_2d_list: # only on type of data page.fill_data_combobox(data_1d_list) elif not data_1d_list and data_2d_list: page.fill_data_combobox(data_2d_list) pos = self.GetPageIndex(page) page.batch_on = self.batch_on page._set_save_flag(not page.batch_on) self.SetSelection(pos) self.opened_pages[page.uid] = page return page
def set_data_on_batch_mode(self, data_list): """ Add all data to a single tab when the application is on Batch mode. However all data in the set of data must be either 1D or 2D type. This method presents option to select the data type before creating a tab. """ data_1d_list = [] data_2d_list = [] group_id_1d = wx.NewId() # separate data into data1d and data2d list for data in data_list: if data.__class__.__name__ == "Data1D": data.group_id = group_id_1d data_1d_list.append(data) if data.__class__.__name__ == "Data2D": data.group_id = wx.NewId() data_2d_list.append(data) page = None for p in self.opened_pages.values(): #check if there is an empty page to fill up if not check_data_validity(p.get_data()) and p.batch_on: #make sure data get placed in 1D empty tab if data is 1D #else data get place on 2D tab empty tab enable2D = p.get_view_mode() if (data.__class__.__name__ == "Data2D" and enable2D)\ or (data.__class__.__name__ == "Data1D" and not enable2D): page = p break if data_1d_list and data_2d_list: # need to warning the user that this batch is a special case from sas.sasgui.perspectives.fitting.fitting_widgets import BatchDataDialog dlg = BatchDataDialog(self) if dlg.ShowModal() == wx.ID_OK: data_type = dlg.get_data() dlg.Destroy() if page is None: page = self.add_empty_page() if data_type == 1: #user has selected only data1D page.fill_data_combobox(data_1d_list) elif data_type == 2: page.fill_data_combobox(data_2d_list) else: #the batch analysis is canceled dlg.Destroy() return None else: if page is None: page = self.add_empty_page() if data_1d_list and not data_2d_list: #only on type of data page.fill_data_combobox(data_1d_list) elif not data_1d_list and data_2d_list: page.fill_data_combobox(data_2d_list) pos = self.GetPageIndex(page) page.batch_on = self.batch_on page._set_save_flag(not page.batch_on) self.SetSelection(pos) self.opened_pages[page.uid] = page return page