Changeset c70eb7c in sasview


Ignore:
Timestamp:
Mar 9, 2011 7:02:50 PM (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:
8b6f489
Parents:
99abf5d
Message:

working data_panel

Location:
guiframe
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • guiframe/data_manager.py

    r5c4b674 rc70eb7c  
    1717import logging 
    1818import os 
     19import wx 
     20import copy  
     21 
    1922from sans.guiframe.data_state import DataState 
    2023from sans.guiframe.utils import parse_name 
     
    2326from sans.guiframe.dataFitting import Data2D 
    2427   
    25 import wx 
    2628 
    2729class DataManager(object): 
     
    4244        self.data_name_dict = {} 
    4345       
     46    def __str__(self): 
     47        _str  = "" 
     48        _str += "No of states  is %s \n" % str(len(self.stored_data)) 
     49        n_count = 0 
     50        for  value in self.stored_data.values(): 
     51            n_count += 1  
     52            _str += "State No %s \n"  % str(n_count) 
     53            _str += str(value) + "\n" 
     54        return _str 
     55         
    4456    def create_gui_data(self, data, path=None): 
    4557        """ 
     
    121133            else: 
    122134                data_state = DataState(data) 
     135                data_state.id = wx.NewId() 
    123136                self.stored_data[data.id] = data_state 
    124137            self._selected_data[data.id] = data_state 
    125        
    126     def set_auto_plot(self, flag=False): 
    127         """ 
    128         When flag is true the data is plotted automatically 
    129         """ 
    130         self._auto_set_data = flag 
    131          
    132     def set_auto_set_data(self, flag=False): 
    133         """ 
    134         When flag is true the data is send to the current perspective 
    135         automatically 
    136         """ 
    137         self._auto_set_data = flag 
    138          
     138   
     139         
     140    def update_data(self, prev_data, new_data): 
     141        """ 
     142        """ 
     143        if prev_data.id not in self.stored_data.keys(): 
     144            return {} 
     145        data_state = self.stored_data[prev_data.id]  
     146        self.stored_data[new_data.id]  = data_state.clone() 
     147        self.stored_data[new_data.id].data = new_data 
     148        if prev_data.id in self.stored_data.keys(): 
     149            del self.stored_data[prev_data.id]  
     150        return prev_data.id, {new_data.id: self.stored_data[new_data.id]} 
     151     
    139152    def get_message(self): 
    140153        """ 
     
    153166        return self._selected_data 
    154167     
    155     def append_theory(self, data_id, theory): 
     168    def append_theory(self, data_id, theory, state=None): 
     169        """ 
     170        """ 
     171        data_state = self.stored_data[data_id] 
     172        data_state.set_theory(theory_data=theory,  
     173                              theory_state=state) 
     174        return {data_id: self.stored_data[data_id]} 
     175             
     176    def freeze_theory(self, data_id, theory_id): 
     177        """ 
     178        """ 
     179        new_data_state = [] 
     180        for d_id in data_id: 
     181            if d_id in self.stored_data: 
     182                data_state = self.stored_data[d_id] 
     183                theory_list = data_state.get_theory() 
     184                for t_id in theory_id: 
     185                    if t_id in theory_list.keys(): 
     186                        theory = theory_list[t_id] 
     187                        new_theory = copy.deepcopy(theory) 
     188                        new_theory.id  = wx.NewId() 
     189                        data_state.append_theory(new_theory) 
     190                        theory_list.append(new_theory) 
     191                        new_data_state.append(data_state) 
     192                        msg = "Theory with ID %s " % str(theory_id) 
     193                        msg += "couldn't not be frozen"  
     194                        raise ValueError, msg 
     195        return new_data_state 
     196                     
     197             
     198    def delete_data(self, data_id, theory_id=None, delete_all=False): 
     199        """ 
     200        """ 
     201        if data_id in self.stored_data.keys(): 
     202            data_state = self.stored_data[data_id] 
     203            if data_state.data.name in self.data_name_dict: 
     204                del self.data_name_dict[data_state.data.name] 
     205            del self.stored_data[data_id] 
     206        if data_id in self._selected_data.keys(): 
     207            data_state = self._selected_data[data_id] 
     208            if data_state.data.name in self.data_name_dict: 
     209                del self.data_name_dict[data_state.data.name] 
     210            del self._selected_data[data_id] 
     211         
     212        self.delete_theory(self, data_id, theory_id) 
     213        if delete_all: 
     214            self._selected_data = {} 
     215            self.stored_data = {} 
     216            self.data_name_dict = {} 
     217             
     218    def delete_theory(self, data_id, theory_id): 
    156219        """ 
    157220        """ 
    158221        if data_id in self.stored_data: 
    159222            data_state = self.stored_data[data_id] 
    160             data_state.set_theory(theory) 
    161              
    162     def delete_data(self, data_id, theory_id, delete_all): 
    163         """ 
    164         """ 
    165         if data_id in self.stored_data: 
    166             del self.stored_data[data_id] 
     223            theory_list = data_state.get_theory() 
     224            if theory_id in theory_list.key(): 
     225                del theory_list[theory_id] 
    167226        if data_id in self._selected_data: 
    168             del self._selected_data 
     227            data_state = self._selected_data[data_id] 
     228            theory_list = data_state.get_theory() 
     229            if theory_id in theory_list.key(): 
     230                del theory_list[theory_id] 
    169231             
    170232    def delete_by_id(self, id_list=None): 
  • guiframe/data_panel.py

    rcc061c3 rc70eb7c  
    5959        self.list_of_perspective = list_of_perspective 
    6060        self.list_rb_perspectives= [] 
    61         self.list_cb_data =[] 
    62         self.list_cb_theory =[] 
     61        self.list_cb_data = {} 
     62        self.list_cb_theory = {} 
     63         
    6364        self.owner = None 
    6465        self.do_layout() 
     
    181182        option = self.selection_cbox.GetString(pos) 
    182183        for item in self.list_cb_data: 
    183             data_id, data_class = self.tree_ctrl.GetItemPyData(item)  
     184            data_ctrl, _, _ = item 
     185            data_id, data_class = self.tree_ctrl.GetItemPyData(dta_ctrl)  
    184186            if option == 'Select all Data': 
    185187                self.tree_ctrl.CheckItem(item, True)  
     
    190192                    self.tree_ctrl.CheckItem(item, True)  
    191193            elif option == 'Unselect all Data 1D': 
    192                 if data_class in ['Data1D', 'Theory1D']: 
     194                if data_class == 'Data1D': 
    193195                    self.tree_ctrl.CheckItem(item, False)  
    194196            elif option == 'Select all Data 1D': 
    195                 if data_class == ['Data1D', 'Theory1D']: 
     197                if data_class == 'Data1D': 
    196198                    self.tree_ctrl.CheckItem(item, True)  
    197199            elif option == 'Select all Data 2D': 
     
    223225        self.bt_plot.SetToolTipString("To trigger plotting") 
    224226        wx.EVT_BUTTON(self, self.bt_plot.GetId(), self.on_plot) 
     227         
     228        self.bt_freeze = wx.Button(self, wx.NewId(), "Freeze") 
     229        self.bt_freeze.SetToolTipString("To trigger freeze") 
     230        wx.EVT_BUTTON(self, self.bt_freeze.GetId(), self.on_freeze) 
    225231         
    226232        self.bt_remove = wx.Button(self, wx.NewId(), "Remove Data") 
     
    253259        ix = 0           
    254260        iy += 1  
     261        self.sizer3.Add(self.bt_freeze,( iy, ix),(1,1),   
     262                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     263        ix = 0           
     264        iy += 1  
    255265        self.sizer3.Add(self.bt_remove,( iy, ix),(1,1),   
    256266                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     
    317327        item = event.GetItem() 
    318328        name = self.tree_ctrl.GetItemText(item) 
    319    
     329     
    320330    def load_data_list(self, list): 
    321331        """ 
    322          
     332        add need data with its theory under the tree 
    323333        """ 
    324334        if not list: 
    325335            return 
    326336         
    327         for dstate in list.values(): 
     337        for state_id, dstate in list.iteritems(): 
    328338            data = dstate.get_data() 
    329339            if data is None: 
    330                 data_name = str(data) 
    331                 data_class = "unkonwn" 
     340                data_name = "Unkonwn" 
     341                data_class = "Unkonwn" 
     342                path = "Unkonwn" 
     343                process_list = [] 
     344                data_id = "Unkonwn" 
    332345            else: 
    333346                data_name = data.name 
    334             data_class = data.__class__.__name__ 
    335             path = dstate.get_path()  
     347                data_class = data.__class__.__name__ 
     348                path = dstate.get_path()  
     349                process_list = data.process 
     350                data_id = data.id 
    336351            theory_list = dstate.get_theory() 
    337             data_child = None 
     352            if state_id not in self.list_cb_data: 
     353                #new state 
     354                data_c = self.tree_ctrl.InsertItem(self.tree_ctrl.root,0, 
     355                                                   data_name, ct_type=1,  
     356                                     data=(data_id, data_class, state_id)) 
     357                data_c.Check(True) 
     358                d_i_c = self.tree_ctrl.AppendItem(data_c, 'Info') 
     359                i_c_c = self.tree_ctrl.AppendItem(d_i_c,  
     360                                              'Type: %s' % data_class) 
     361                p_c_c = self.tree_ctrl.AppendItem(d_i_c, 
     362                                              'Path: %s' % str(path)) 
     363                d_p_c = self.tree_ctrl.AppendItem(d_i_c, 'Process') 
     364                 
     365                for process in process_list: 
     366                    i_t_c = self.tree_ctrl.AppendItem(d_p_c, 
     367                                                      process.__str__()) 
     368                theory_child = self.tree_ctrl.AppendItem(data_c, "THEORIES") 
     369                
     370                self.list_cb_data[state_id] = [data_c,  
     371                                               d_i_c, 
     372                                               i_c_c, 
     373                                                p_c_c, 
     374                                                 d_p_c, 
     375                                                 theory_child] 
     376            else: 
     377                data_ctrl_list =  self.list_cb_data[state_id] 
     378                #This state is already display replace it contains 
     379                data_c, d_i_c, i_c_c, p_c_c, d_p_c, t_c = data_ctrl_list 
     380                self.tree_ctrl.SetItemText(data_c, data_name)  
     381                temp = (data_id, data_class, state_id) 
     382                self.tree_ctrl.SetItemPyData(data_c, temp)  
     383                self.tree_ctrl.SetItemText(i_c_c, 'Type: %s' % data_class) 
     384                self.tree_ctrl.SetItemText(p_c_c, 'Path: %s' % str(path))  
     385                self.tree_ctrl.DeleteChildren(d_p_c)  
     386                for process in process_list: 
     387                    i_t_c = self.tree_ctrl.AppendItem(d_p_c, 
     388                                                      process.__str__()) 
     389            self.append_theory(state_id, theory_list) 
     390                   
     391    
     392    def append_theory(self, state_id, theory_list): 
     393        """ 
     394        append theory object under data from a state of id = state_id 
     395        replace that theory if  already displayed 
     396        """ 
     397        if not theory_list: 
     398            return  
     399        if state_id not in self.list_cb_data.keys(): 
     400            msg = "Invalid state ID : %s requested for theory" % str(state_id) 
     401            raise ValueError, msg 
    338402             
    339             if theory_list: 
    340                 for theory_id,theory in theory_list.iteritems(): 
    341                     for item in self.list_cb_data: 
    342                         data_id, data_class = self.tree_ctrl.GetItemPyData(item)  
    343                         if data_id == data.id: 
    344                             data_child = item 
    345                             for process in data.process: 
    346                                 theory_child = self.tree_ctrl.FindItem(data_child, 
    347                                                                 "CREATED DATA"), 
    348                                 if theory is not None: 
    349                                     av_theory_child =self.tree_ctrl.AppendItem(theory_child, 
    350                                             theory.name,ct_type=1,  
    351                                             data=(theory_id, theory)) 
    352                                     self.list_cb_theory.append(av_theory_child) 
    353                                     av_theory_child_info =self.tree_ctrl.AppendItem(av_theory_child, 
    354                                                              'info') 
    355                                     for process in theory.process: 
    356                                         info_time_child = self.tree_ctrl.AppendItem(av_theory_child_info, 
    357                                                  process.__str__()) 
    358                             
    359                         break 
    360             if data_child is None: 
    361                 data_child = self.tree_ctrl.InsertItem(self.tree_ctrl.root,0, 
    362                                             data_name, ct_type=1,  
    363                                             data=(data.id, data_class)) 
    364                 cb_data = self.tree_ctrl.GetFirstChild(self.tree_ctrl.root)  
    365                 item, id = cb_data 
    366                 item.Check(True) 
    367                 self.list_cb_data.append(item)                          
    368                 data_info_child =self.tree_ctrl.AppendItem(data_child, 'info')#, 
    369                                                             #wnd=data_info_txt) 
    370                 info_class_child =self.tree_ctrl.AppendItem(data_info_child,  
    371                                                             'Type: %s'%data_class) 
    372                 path_class_child =self.tree_ctrl.AppendItem(data_info_child, 
    373                                                              'Path: %s'%str(path)) 
    374                 for process in data.process: 
    375                     info_time_child =self.tree_ctrl.AppendItem(data_info_child,process.__str__()) 
    376                 theory_child =self.tree_ctrl.AppendItem(data_child, "Available Theories") 
    377                  
    378                 if  theory_list: 
    379                     theory = theory_list[len(theory_list)-1] 
    380                     if theory is not None: 
    381                         av_theory_child =self.tree_ctrl.AppendItem(theory_child, 
    382                                                     theory.name,ct_type=1) 
    383                         self.list_cb_theory.append(av_theory_child) 
    384                         av_theory_child_info =self.tree_ctrl.AppendItem(av_theory_child, 
    385                                                          'info') 
    386                         for process in theory.process: 
    387                             info_time_child =self.tree_ctrl.AppendItem(av_theory_child_info, 
    388                                              process.__str__()) 
    389                     
     403        item = self.list_cb_data[state_id] 
     404        data_c, _, _, _, _, theory_child = item 
     405        data_id, _, _ = self.tree_ctrl.GetItemPyData(data_c)  
     406         
     407        if data_id in self.list_cb_theory.keys(): 
     408            #update current list of theory for this data 
     409            theory_list_ctrl = self.list_cb_theory[data_id] 
     410 
     411            for theory_id, item in theory_list.iteritems(): 
     412                theory_data, _ = item 
     413                if theory_data is None: 
     414                    name = "Unknown" 
     415                    theory_class = "Unknown" 
     416                    theory_id = "Unknown" 
     417                    temp = (None, None, None) 
     418                else: 
     419                    name = theory_data.name 
     420                    theory_class = theory_data.__class__.__name__ 
     421                    theory_id = theory_data.id 
     422                    temp = (theory_id, theory_class, state_id) 
     423                if theory_id not in theory_list_ctrl: 
     424                    #add new theory 
     425                    t_child = self.tree_ctrl.AppendItem(theory_child, 
     426                                                    name, ct_type=1, data=temp) 
     427                    t_i_c = self.tree_ctrl.AppendItem(t_child, 'Info') 
     428                    i_c_c = self.tree_ctrl.AppendItem(t_i_c,  
     429                                                  'Type: %s' % theory_class) 
     430                    t_p_c = self.tree_ctrl.AppendItem(t_i_c, 'Process') 
     431                     
     432                    for process in theory_data.process: 
     433                        i_t_c = self.tree_ctrl.AppendItem(t_p_c, 
     434                                                          process.__str__()) 
     435                    theory_list_ctrl[theory_id] = [t_child,  
     436                                                   i_c_c,  
     437                                                   t_p_c] 
     438                else: 
     439                    #replace theory 
     440                    t_child, i_c_c, t_p_c = theory_list_ctrl[theory_id] 
     441                    self.tree_ctrl.SetItemText(t_child, name)  
     442                    self.tree_ctrl.SetItemPyData(t_child, temp)  
     443                    self.tree_ctrl.SetItemText(i_c_c, 'Type: %s' % theory_class)  
     444                    self.tree_ctrl.DeleteChildren(t_p_c)  
     445                    for process in theory_data.process: 
     446                        i_t_c = self.tree_ctrl.AppendItem(t_p_c, 
     447                                                          process.__str__()) 
     448               
     449        else: 
     450            #data didn't have a theory associated it before 
     451            theory_list_ctrl = {} 
     452            for theory_id, item in theory_list.iteritems(): 
     453                theory_data, _ = item 
     454                if theory_data is not None: 
     455                    theory_class = theory_data.__class__.__name__ 
     456                     
     457                    t_child = self.tree_ctrl.AppendItem(theory_child, 
     458                            theory_data.name, ct_type=1,  
     459                            data=(theory_data.id, theory_class, state_id)) 
     460                    t_i_c = self.tree_ctrl.AppendItem(t_child, 'Info') 
     461                    i_c_c = self.tree_ctrl.AppendItem(t_i_c,  
     462                                                  'Type: %s' % theory_class) 
     463                    t_p_c = self.tree_ctrl.AppendItem(t_i_c, 'Process') 
     464                     
     465                    for process in theory_data.process: 
     466                        i_t_c = self.tree_ctrl.AppendItem(t_p_c, 
     467                                                          process.__str__()) 
     468             
     469                    theory_list_ctrl[theory_id] = [t_child, i_c_c, t_p_c] 
     470            self.list_cb_theory[data_id] = theory_list_ctrl 
     471             
     472     
    390473    def set_data_helper(self): 
    391474        """ 
    392475        """ 
    393476        data_to_plot = [] 
    394         for item in self.list_cb_data: 
     477        for value in self.list_cb_data.values(): 
     478            item, _, _, _, _, _ = value 
    395479            if item.IsChecked(): 
    396                data_id, data_class = self.tree_ctrl.GetItemPyData(item)  
     480               data_id, _, _ = self.tree_ctrl.GetItemPyData(item)  
    397481               data_to_plot.append(data_id) 
    398482        theory_to_plot = [] 
    399         for item in self.list_cb_theory: 
    400             if item.IsChecked(): 
    401                 data_id, data_class = self.tree_ctrl.GetItemPyData(item) 
    402                 theory_to_plot.append(data_id) 
     483        for theory_dict in self.list_cb_theory.values(): 
     484            for key, value in theory_dict.iteritems(): 
     485                item, _, _ = value 
     486                if item.IsChecked(): 
     487                    theory_id, _, _ = self.tree_ctrl.GetItemPyData(item) 
     488                    theory_to_plot.append(theory_id) 
    403489        return data_to_plot, theory_to_plot 
    404490     
     491    def remove_by_id(self, id): 
     492        """ 
     493        """ 
     494        for item in self.list_cb_data.values(): 
     495            data_c, _, _, _, _, theory_child = item 
     496            data_id, _, state_id = self.tree_ctrl.GetItemPyData(data_c)  
     497            if id == data_id: 
     498                self.tree_ctrl.Delete(data_c) 
     499                del self.list_cb_data[state_id] 
     500                del self.list_cb_theory[data_id] 
     501                print "went here" 
     502       
    405503    def on_remove(self, event): 
    406504        """ 
     
    441539        self.post_helper(plot=True) 
    442540        
     541    def on_freeze(self, event): 
     542        """ 
     543        """ 
     544        data_to_plot, theory_to_plot = self.set_data_helper() 
     545        self.parent.freeze(data_id=data_to_plot, theory_id=theory_to_plot) 
     546         
    443547    def set_active_perspective(self, name): 
    444548        """ 
     
    457561        """ 
    458562        data_to_plot, theory_to_plot = self.set_data_helper() 
    459        
    460563        if self.parent is not None: 
    461564            self.parent.get_data_from_panel(data_id=data_to_plot, plot=plot, 
    462565                                            append=append) 
     566             
     567     
    463568 
    464569 
     
    495600        """ 
    496601        self.panel.layout_perspective(list_of_perspective=list_of_perspective) 
     602     
     603     
    497604         
    498605     
     
    512619    dstate = DataState(data=data) 
    513620    dstate.set_path(path=path) 
    514     dstate.set_theory(theory) 
    515     dstate.set_state(state) 
     621    dstate.set_theory(theory, state) 
     622   
    516623    return dstate 
    517624"""' 
     
    528635        list_of_perspective = [('perspective2', False), ('perspective1', True)] 
    529636        data_list = {} 
     637        # state 1 
    530638        data = Data1D() 
    531639        data.name = "data1" 
    532640        data.id = 1 
    533         #data.append_process() 
    534         #process = data.process[len(data.process)-1] 
    535         #process.data = "07/01/2010" 
     641        data.append_empty_process() 
     642        process = data.process[len(data.process)-1] 
     643        process.data = "07/01/2010" 
    536644        theory = Theory1D() 
    537645        theory.id = 34 
    538         theory.pseudo_name = "theory1" 
     646        theory.name = "theory1" 
    539647        path = "path1" 
    540648        state = State() 
    541649        data_list['1']=set_data_state(data, path,theory, state) 
    542          
     650        #state 2 
    543651        data = Data1D() 
    544652        data.name = "data2" 
     
    547655        theory.id = 78 
    548656        theory.name = "CoreShell 07/24/25" 
    549         theory.pseudo_name = "CoreShell" 
    550657        path = "path2" 
     658        #state3 
    551659        state = State() 
    552660        data_list['2']=set_data_state(data, path,theory, state) 
     
    556664        theory = Theory1D() 
    557665        theory.name = "CoreShell" 
    558         theory.pseudo_name = "CoreShell" 
    559666        theory.id = 4 
    560         #theory.append_process() 
    561         #process = theory.process[len(theory.process)-1] 
    562         #process.description = "this is my description" 
     667        theory.append_empty_process() 
     668        process = theory.process[len(theory.process)-1] 
     669        process.description = "this is my description" 
    563670        path = "path3" 
    564         #data.append_process() 
    565         #process = data.process[len(data.process)-1] 
    566         #process.data = "07/22/2010" 
     671        data.append_empty_process() 
     672        process = data.process[len(data.process)-1] 
     673        process.data = "07/22/2010" 
    567674        data_list['4']=set_data_state(data, path,theory, state) 
    568          
     675        #state 4 
     676        temp_data_list = {} 
     677        data.name = "data5 erasing data2" 
     678        temp_data_list['4'] = set_data_state(data, path,theory, state) 
     679        #state 5 
    569680        data = Data2D() 
    570681        data.name = "data3" 
    571682        data.id = 5 
    572         #data.append_process() 
    573         #process = data.process[len(data.process)-1] 
    574         #process.data = "07/01/2010" 
     683        data.append_empty_process() 
     684        process = data.process[len(data.process)-1] 
     685        process.data = "07/01/2010" 
    575686        theory = Theory1D() 
    576         theory.pseudo_name = "Cylinder" 
     687        theory.name = "Cylinder" 
    577688        path = "path2" 
    578689        state = State() 
     
    580691        theory = Theory1D() 
    581692        theory.id = 6 
    582         theory.pseudo_name = "Sphere" 
     693        theory.name = "CoreShell" 
    583694        dstate.set_theory(theory) 
    584         data_list['3']=dstate 
     695        theory = Theory1D() 
     696        theory.id = 6 
     697        theory.name = "CoreShell replacing coreshell in data3" 
     698        dstate.set_theory(theory) 
     699        data_list['3'] = dstate 
     700        #state 6 
     701        data_list['6']=set_data_state(None, path,theory, state) 
    585702         
    586703        window = DataFrame(list=data_list) 
    587         #window.load_data_list(list=data_list) 
    588         window.layout_perspective(list_of_perspective=list_of_perspective) 
     704        window.load_data_list(list=data_list) 
     705        #window.layout_perspective(list_of_perspective=list_of_perspective) 
    589706        window.Show(True) 
     707        window.load_data_list(list=temp_data_list) 
    590708    except: 
    591709        #raise 
    592710        print "error",sys.exc_value 
     711         
    593712    app.MainLoop()   
    594713     
  • guiframe/data_state.py

    r5c4b674 rc70eb7c  
    1010""" 
    1111""" 
     12import copy 
     13 
    1214 
    1315class DataState(object): 
     
    2426        self.path = None 
    2527        self.theory_list = {} 
    26         self.state_list = [] 
    2728        self.message = "" 
     29        self.id = None 
     30         
     31    def __str__(self): 
     32        _str  = "" 
     33        _str += "State with ID : %s \n" % str(self.id) 
     34        if self.data is not None: 
     35            _str += "Data name : %s \n" % str(self.data.name) 
     36            _str += "Data ID : %s \n" % str(self.data.id) 
     37        else: 
     38            _str += "Data: %s \n" % str(self.data) 
     39             
     40        if self.theory_list: 
     41            _str += "Theories available: \n" 
     42            for id, item in self.theory_list.iteritems(): 
     43                theory_data, theory_state = item 
     44                _str += "Theory name : %s \n" % str(theory_data.name) 
     45                _str += "Theory ID : %s \n" % str(id) 
     46        else: 
     47            for key , value in self.theory_list.iteritems(): 
     48                theory_data, theory_state = value 
     49                _str += "Theory with ID : %s \n" % str(key) 
     50                _str += str(theory_data) 
     51                _str += str(theory_state) 
     52        return _str 
     53         
     54    def clone(self): 
     55        obj = DataState(copy.deepcopy(self.data)) 
     56        obj.parent = self.parent 
     57        obj.name = self.name  
     58        obj.path = self.path  
     59        obj.message = self.message 
     60        obj.id = self.id 
     61        for id, item in self.theory_list.iteritems(): 
     62            theory_data, theory_state = item 
     63            state = None 
     64            if theory_state is not None: 
     65                state = theory_state.clone() 
     66            obj.theory_list[id] = [copy.deepcopy(theory_data),  
     67                                   state] 
     68        return obj 
    2869         
    2970    def set_name(self, name): 
    3071        self.name = name 
     72         
    3173    def get_name(self): 
    3274        return self.name 
     75     
    3376    def set_data(self, data): 
    3477        self.data = data 
     
    4992        return self.path 
    5093     
    51     def set_theory(self, theory): 
     94    def set_theory(self, theory_data, theory_state=None): 
    5295        """ 
    5396        """ 
    54         self.theory_list[theory.id] = theory 
     97        self.theory_list[theory_data.id] = [theory_data, theory_state] 
    5598         
    5699    def get_theory(self): 
    57100        return self.theory_list 
    58      
    59     def set_state(self, state): 
    60         """ 
    61         """ 
    62         #self.theory_list.append(state) 
    63         return 
    64          
    65     def get_state(self): 
    66         return self.state_list 
    67101     
    68102    def get_message(self): 
  • guiframe/gui_manager.py

    r9c169f4 rc70eb7c  
    431431                                  Hide())         
    432432       
     433    def append_theory(self, data_id, theory, state=None): 
     434        """ 
     435        """ 
     436        data_state = self._data_manager.append_theory(data_id=data_id,  
     437                                                      theory=theory, 
     438                                                      state=state) 
     439        self._data_panel.load_data_list(data_state) 
     440         
     441    def update_data(self, prev_data, new_data): 
     442        """ 
     443        """ 
     444        prev_id, data_state = self._data_manager.update_data(prev_data=prev_data,  
     445                                       new_data=new_data) 
     446        self._data_panel.remove_by_id(prev_id) 
     447        self._data_panel.load_data_list(data_state) 
     448        
     449         
     450    def freeze(self, data_id, theory_id): 
     451        """ 
     452        """ 
     453        data_state_list = self._data_manager.freeze_theory(data_id=data_id,  
     454                                                theory_id=theory_id) 
     455         
     456        self._data_panel.load_data_list(list=data_state_list) 
     457        for data_state in data_state_list: 
     458            theory_list = data_state.get_theory() 
     459            for new_plot in theory_list: 
     460                wx.PostEvent(self, NewplotEvent(plot=new_plot, 
     461                                             title=new_plot.title)) 
     462         
     463    def delete_data(self, data): 
     464        """ 
     465        """ 
     466        self._current_perspective.delete_data(data) 
     467         
     468     
    433469    def get_context_menu(self, plotpanel=None): 
    434470        """ 
     
    12071243            self.__gui_style = self.__gui_style & (~GUIFRAME.MANAGER_ON) 
    12081244            self._data_panel_menu.SetText('Data Explorer ON') 
    1209   
     1245     
     1246    def add_data_helper(self, data_list): 
     1247        """ 
     1248        """ 
     1249        self._data_manager.add_data(data_list) 
     1250         
    12101251    def add_data(self, data_list): 
    12111252        """ 
     
    12151256        #send a list of available data to plotting plugin 
    12161257        avalaible_data = [] 
     1258        theory_list = [] 
    12171259        if self._data_manager is not None: 
    12181260            self._data_manager.add_data(data_list) 
    12191261            avalaible_data = self._data_manager.get_all_data() 
    1220          
    1221         # set data in the data panel 
    1222         if self._data_panel is not None: 
    1223             data_state = self._data_manager.get_selected_data() 
    1224             self._data_panel.load_data_list(data_state) 
    12251262        style = self.__gui_style & GUIFRAME.MANAGER_ON 
    12261263        if style == GUIFRAME.MANAGER_ON: 
     
    12321269            #automatically send that to the current perspective 
    12331270            self.set_data(data_list) 
    1234                  
     1271        
     1272         # set data in the data panel 
     1273        if self._data_panel is not None: 
     1274            data_state = self._data_manager.get_selected_data() 
     1275            self._data_panel.load_data_list(data_state) 
     1276            
    12351277    def get_data_from_panel(self, data_id, plot=False,append=False): 
    12361278        """ 
     
    12901332                                                  title=str(new_plot.title))) 
    12911333             
    1292     def add_theory(self, data_id, theory): 
    1293         """ 
    1294         """ 
    1295         self._data_manager.append_theory(data_id, theory) 
    1296         style = self.__gui_style & GUIFRAME.MANAGER_ON 
    1297         if style == GUIFRAME.MANAGER_ON: 
    1298             if self._data_panel is not None: 
    1299                 data_state = self._data_manager.get_by_id([data_id]) 
    1300                 self._data_panel.load_data_list(data_state) 
     1334   
    13011335                 
    13021336    def remove_data(self, data_id, theory_id=None, delete_all=True): 
  • guiframe/local_perspectives/plotting/plotting.py

    r5c4b674 rc70eb7c  
    7676        pass 
    7777     
    78     #def _on_plot_event(self, event): 
    79     #     return profile(self.tested_on_plot_event, event) 
    80      
     78   
    8179    def _on_plot_event(self, event): 
    8280        """ 
     
    165163             
    166164        return 
    167  
    168 def profile(fn, *args, **kw): 
    169     import cProfile, pstats, os 
    170     global call_result 
    171     def call(): 
    172         global call_result 
    173         call_result = fn(*args, **kw) 
    174     cProfile.runctx('call()', dict(call=call), {}, 'profile.txt') 
    175     stats = pstats.Stats('profile.txt') 
    176     stats.sort_stats('time') 
    177     #stats.sort_stats('calls') 
    178     stats.print_stats() 
    179     #os.unlink('profile.out') 
    180     return call_result 
    181  
    182165    
  • guiframe/panel_base.py

    r03314e7 rc70eb7c  
    4646        self._reset_flag = False 
    4747        self._has_changed = False 
     48        self.group_id = None 
    4849         
    4950        self.Bind(wx.EVT_LEFT_DOWN, self.on_set_focus) 
Note: See TracChangeset for help on using the changeset viewer.