Ignore:
Timestamp:
Aug 1, 2011 8:36:34 AM (13 years ago)
Author:
Gervaise Alina <gervyh@…>
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
Message:

working on batch fit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansview/perspectives/fitting/fitpanel.py

    rcc31608 r3f36675  
    313313        add an empty page 
    314314        """ 
     315        """ 
    315316        if self.batch_on: 
    316317            from batchfitpage import BatchFitPage 
     
    320321            index = self.batch_page_index 
    321322        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 
    327329        panel.uid = wx.NewId() 
    328330        panel.populate_box(dict=self.model_list_box) 
     
    342344        if self.GetPageCount() <= 1: 
    343345            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: 
    345348                style = style & ~wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB 
    346349                self.SetWindowStyle(style) 
    347350        else: 
    348351            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: 
    350354                style |= wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB 
    351355                self.SetWindowStyle(style) 
     
    372376                self._manager.on_add_new_page(event=None) 
    373377         
     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     
    374430    def set_data(self, data_list): 
    375431        """  
     
    378434        :param data: data to fit 
    379435         
    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 
    381438         
    382439        """ 
    383440        if not data_list: 
    384441            return None 
    385          
    386442        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) 
    393444        else: 
    394445            data = None 
Note: See TracChangeset for help on using the changeset viewer.