Changeset 71bd773 in sasview for guiframe


Ignore:
Timestamp:
Mar 23, 2011 10:10:16 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:
72323d1
Parents:
05319e2
Message:

working on datapanel

File:
1 edited

Legend:

Unmodified
Added
Removed
  • guiframe/data_panel.py

    ra3c96f7a r71bd773  
    288288        self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_CHECKING, self.on_check_item) 
    289289        self.sizer1.Add(self.tree_ctrl,1, wx.EXPAND|wx.ALL, 10) 
     290        self.theory_root = self.tree_ctrl.InsertItem(self.tree_ctrl.root,0, 
     291                                                   "THEORIES", ct_type=0) 
    290292         
    291293    def onContextMenu(self, event):  
     
    335337        for state_id, dstate in list.iteritems(): 
    336338            data = dstate.get_data() 
    337             if data is None: 
    338                 data_name = "Unkonwn" 
    339                 data_class = "Unkonwn" 
    340                 path = "Unkonwn" 
    341                 process_list = [] 
    342                 data_id = "Unkonwn" 
    343             else: 
     339            theory_list = dstate.get_theory() 
     340            if data is not None: 
    344341                data_name = data.name 
    345342                data_class = data.__class__.__name__ 
     
    347344                process_list = data.process 
    348345                data_id = data.id 
    349             theory_list = dstate.get_theory() 
    350             if state_id not in self.list_cb_data: 
    351                 #new state 
    352                 data_c = self.tree_ctrl.InsertItem(self.tree_ctrl.root,0, 
    353                                                    data_name, ct_type=1,  
    354                                      data=(data_id, data_class, state_id)) 
    355                 data_c.Check(True) 
    356                 self.enable_button(data_c) 
    357                 d_i_c = self.tree_ctrl.AppendItem(data_c, 'Info') 
    358                 i_c_c = self.tree_ctrl.AppendItem(d_i_c,  
    359                                               'Type: %s' % data_class) 
    360                 p_c_c = self.tree_ctrl.AppendItem(d_i_c, 
    361                                               'Path: %s' % str(path)) 
    362                 d_p_c = self.tree_ctrl.AppendItem(d_i_c, 'Process') 
    363346                 
    364                 for process in process_list: 
    365                     i_t_c = self.tree_ctrl.AppendItem(d_p_c, 
    366                                                       process.__str__()) 
    367                 theory_child = self.tree_ctrl.AppendItem(data_c, "THEORIES") 
    368                 
    369                 self.list_cb_data[state_id] = [data_c,  
    370                                                d_i_c, 
    371                                                i_c_c, 
    372                                                 p_c_c, 
    373                                                  d_p_c, 
    374                                                  theory_child] 
    375             else: 
    376                 data_ctrl_list =  self.list_cb_data[state_id] 
    377                 #This state is already display replace it contains 
    378                 data_c, d_i_c, i_c_c, p_c_c, d_p_c, t_c = data_ctrl_list 
    379                 self.tree_ctrl.SetItemText(data_c, data_name)  
    380                 temp = (data_id, data_class, state_id) 
    381                 self.tree_ctrl.SetItemPyData(data_c, temp)  
    382                 self.tree_ctrl.SetItemText(i_c_c, 'Type: %s' % data_class) 
    383                 self.tree_ctrl.SetItemText(p_c_c, 'Path: %s' % str(path))  
    384                 self.tree_ctrl.DeleteChildren(d_p_c)  
    385                 for process in process_list: 
    386                     i_t_c = self.tree_ctrl.AppendItem(d_p_c, 
    387                                                       process.__str__()) 
     347                if state_id not in self.list_cb_data: 
     348                    #new state 
     349                    data_c = self.tree_ctrl.InsertItem(self.tree_ctrl.root,0, 
     350                                                       data_name, ct_type=1,  
     351                                         data=(data_id, data_class, state_id)) 
     352                    data_c.Check(True) 
     353                    self.enable_button(data_c) 
     354                    d_i_c = self.tree_ctrl.AppendItem(data_c, 'Info') 
     355                    i_c_c = self.tree_ctrl.AppendItem(d_i_c,  
     356                                                  'Type: %s' % data_class) 
     357                    p_c_c = self.tree_ctrl.AppendItem(d_i_c, 
     358                                                  'Path: %s' % str(path)) 
     359                    d_p_c = self.tree_ctrl.AppendItem(d_i_c, 'Process') 
     360                     
     361                    for process in process_list: 
     362                        i_t_c = self.tree_ctrl.AppendItem(d_p_c, 
     363                                                          process.__str__()) 
     364                    theory_child = self.tree_ctrl.AppendItem(data_c, "THEORIES") 
     365                    
     366                    self.list_cb_data[state_id] = [data_c,  
     367                                                   d_i_c, 
     368                                                   i_c_c, 
     369                                                    p_c_c, 
     370                                                     d_p_c, 
     371                                                     theory_child] 
     372                else: 
     373                    data_ctrl_list =  self.list_cb_data[state_id] 
     374                    #This state is already display replace it contains 
     375                    data_c, d_i_c, i_c_c, p_c_c, d_p_c, t_c = data_ctrl_list 
     376                    self.tree_ctrl.SetItemText(data_c, data_name)  
     377                    temp = (data_id, data_class, state_id) 
     378                    self.tree_ctrl.SetItemPyData(data_c, temp)  
     379                    self.tree_ctrl.SetItemText(i_c_c, 'Type: %s' % data_class) 
     380                    self.tree_ctrl.SetItemText(p_c_c, 'Path: %s' % str(path))  
     381                    self.tree_ctrl.DeleteChildren(d_p_c)  
     382                    for process in process_list: 
     383                        i_t_c = self.tree_ctrl.AppendItem(d_p_c, 
     384                                                          process.__str__()) 
    388385            self.append_theory(state_id, theory_list) 
    389386             
     
    397394            return  
    398395        if state_id not in self.list_cb_data.keys(): 
    399             msg = "Invalid state ID : %s requested for theory" % str(state_id) 
    400             raise ValueError, msg 
    401              
    402         item = self.list_cb_data[state_id] 
    403         data_c, _, _, _, _, theory_child = item 
    404         data_id, _, _ = self.tree_ctrl.GetItemPyData(data_c)  
    405          
    406         if data_id in self.list_cb_theory.keys(): 
     396            root = self.theory_root 
     397        else: 
     398            item = self.list_cb_data[state_id] 
     399            data_c, _, _, _, _, _ = item 
     400            root = data_c 
     401        if root is not None: 
     402             self.append_theory_helper(root=root,  
     403                                       state_id=state_id,  
     404                                       theory_list=theory_list) 
     405       
     406    def append_theory_helper(self, root, state_id, theory_list): 
     407        """ 
     408        """ 
     409        if state_id in self.list_cb_theory.keys(): 
    407410            #update current list of theory for this data 
    408             theory_list_ctrl = self.list_cb_theory[data_id] 
     411            theory_list_ctrl = self.list_cb_theory[state_id] 
    409412 
    410413            for theory_id, item in theory_list.iteritems(): 
     
    424427                if theory_id not in theory_list_ctrl: 
    425428                    #add new theory 
    426                     t_child = self.tree_ctrl.AppendItem(theory_child, 
     429                    t_child = self.tree_ctrl.AppendItem(root, 
    427430                                                    name, ct_type=1, data=temp) 
    428431                    t_i_c = self.tree_ctrl.AppendItem(t_child, 'Info') 
     
    460463                    #    name = theory_state.model.name  
    461464                    temp = (theory_id, theory_class, state_id) 
    462                     t_child = self.tree_ctrl.AppendItem(theory_child, 
     465                    t_child = self.tree_ctrl.AppendItem(root, 
    463466                            name, ct_type=1,  
    464467                            data=(theory_data.id, theory_class, state_id)) 
     
    473476             
    474477                    theory_list_ctrl[theory_id] = [t_child, i_c_c, t_p_c] 
    475                 self.list_cb_theory[data_id] = theory_list_ctrl 
     478                #self.list_cb_theory[data_id] = theory_list_ctrl 
     479                self.list_cb_theory[state_id] = theory_list_ctrl 
    476480             
    477481    
     
    543547        for key in theory_key: 
    544548            for t_key, theory_dict in self.list_cb_theory.iteritems(): 
    545                 del theory_dict[key] 
     549                if key in theory_dict: 
     550                    del theory_dict[key] 
    546551             
    547552        self.parent.remove_data(data_id=data_to_remove, 
     
    645650        self.msg += "name  value\n" 
    646651        return msg 
    647 def set_data_state(data, path, theory, state): 
     652def set_data_state(data=None, path=None, theory=None, state=None): 
    648653    dstate = DataState(data=data) 
    649654    dstate.set_path(path=path) 
     
    729734        #state 6 
    730735        data_list['6']=set_data_state(None, path,theory, state) 
    731          
     736        data_list['6']=set_data_state(theory=theory, state=None) 
     737        theory = Theory1D() 
     738        theory.id = 7 
     739        data_list['6']=set_data_state(theory=theory, state=None) 
     740        data_list['7']=set_data_state(theory=theory, state=None) 
    732741        window = DataFrame(list=data_list) 
    733742        window.load_data_list(list=data_list) 
Note: See TracChangeset for help on using the changeset viewer.