Changeset 213892bc in sasview


Ignore:
Timestamp:
Jan 31, 2011 9:36:01 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:
0663dfb1
Parents:
3f6508f
Message:

work in data loading guiframe

Location:
guiframe
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • guiframe/data_manager.py

    r584c4c4 r213892bc  
    4747            self._selected_data[data.id] = data_state 
    4848            self.stored_data[data.id] = data_state 
    49         print "datalist", self._selected_data     
    50          
     49       
    5150    def set_auto_plot(self, flag=False): 
    5251        """ 
     
    7877        return self._selected_data 
    7978     
     79    def append_theory(self, data_id, theory): 
     80        """ 
     81        """ 
     82        print "append theory", self.stored_data, data_id 
     83        if data_id in self.stored_data: 
     84            data_state = self.stored_data[data_id] 
     85            data_state.set_theory(theory) 
     86             
     87    def delete_data(self, data_id, theory_id, delete_all): 
     88        """ 
     89        """ 
     90        #for id in  
    8091    def delete_by_id(self, id_list=None): 
    8192        """ 
  • guiframe/data_panel.py

    r584c4c4 r213892bc  
    192192         
    193193        self.bt_append_plot = wx.Button(self, wx.NewId(), "Append Plot To") 
    194         self.bt_import.SetToolTipString("Plot the selected data in the active panel") 
    195         #wx.EVT_BUTTON(self, self.bt_import.GetId(), self.on_append_plot) 
     194        self.bt_append_plot.SetToolTipString("Plot the selected data in the active panel") 
     195        wx.EVT_BUTTON(self, self.bt_append_plot.GetId(), self.on_append_plot) 
    196196         
    197197        self.bt_plot = wx.Button(self, wx.NewId(), "New Plot") 
     
    205205        self.tctrl_perspective = wx.StaticText(self, -1, 'No Active Application') 
    206206        self.tctrl_perspective.SetToolTipString("Active Application") 
    207         self.tctrl_plotpanel = wx.StaticText(self, -1, 'Plot panel on focus') 
    208         self.tctrl_plotpanel.SetToolTipString("Active Plotting Panel") 
     207        self.tctrl_plotpanel = wx.StaticText(self, -1, 'No Plot panel on focus') 
     208        self.tctrl_plotpanel.SetToolTipString("Active Plot Panel") 
    209209        #self.sizer3.AddMany([(self.bt_import,0, wx.ALL,5), 
    210210        #                     (self.bt_append_plot,0, wx.ALL,5), 
     
    296296         
    297297        """ 
    298         print "list", list 
    299298        if not list: 
    300299            return 
     
    366365        for item in self.list_cb_data: 
    367366            if item.IsChecked(): 
     367                 
    368368               data_to_plot.append(self.tree_ctrl.GetItemPyData(item)) 
    369369        theory_to_plot = [] 
    370370        for item in self.list_cb_theory: 
    371371            if item.IsChecked(): 
    372                theory_to_plot.append(self.tree_ctrl.GetItemPyData(item)) 
     372                theory_to_plot.append(self.tree_ctrl.GetItemPyData(item)) 
    373373        return data_to_plot, theory_to_plot 
    374374     
     
    379379                self.tree_ctrl.GetItemText(item) in data_to_remove: 
    380380                self.tree_ctrl.Delete(item) 
    381         for i in self.list_cb_theory: 
     381        for item in self.list_cb_theory: 
    382382            if item.IsChecked()and \ 
    383383                self.tree_ctrl.GetItemText(item) in theory_to_remove: 
    384384                self.tree_ctrl.Delete(item) 
    385         self.manager.delete_data(data_name=data_to_remove, 
    386                                   theory_name=theory_to_remove) 
     385        delete_all = False 
     386        if data_to_remove: 
     387            delete_all = True 
     388        self.parent.delete_data(data_id=data_to_remove, 
     389                                  theory_id=theory_to_remove, 
     390                                  delete_all=delete_all) 
    387391         
    388392    def on_import(self, event=None): 
     
    391395        """ 
    392396        self.post_helper(plot=False) 
    393          
     397        
     398    def on_append_plot(self, event=None): 
     399        """ 
     400        append plot to plot panel on focus 
     401        """ 
     402        self.post_helper(plot=True, append=True) 
     403    
    394404    def on_plot(self, event=None): 
    395405        """ 
     
    410420        self.tctrl_plotpanel.SetLabel(str(name)) 
    411421         
    412     def post_helper(self, plot=False): 
     422    def post_helper(self, plot=False, append=False): 
    413423        """ 
    414424        """ 
     
    416426       
    417427        if self.parent is not None: 
    418             self.parent.get_data_from_panel(data_id=data_to_plot, plot=plot) 
     428            self.parent.get_data_from_panel(data_id=data_to_plot, plot=plot, 
     429                                            append=append) 
    419430 
    420431 
  • guiframe/gui_manager.py

    r584c4c4 r213892bc  
    5353 
    5454 
     55 
    5556class ViewerFrame(wx.Frame): 
    5657    """ 
     
    9192        self.app_manager = None 
    9293        self._mgr = None 
    93         #data manager 
    94         from data_manager import DataManager 
    95         self._data_manager = DataManager() 
    96         self._data_panel = DataPanel(parent=self) 
    97          
    9894        #add current perpsective 
    9995        self._current_perspective = None 
     
    128124        #panel on focus 
    129125        self.panel_on_focus = None 
     126         #data manager 
     127        from data_manager import DataManager 
     128        self._data_manager = DataManager() 
     129        self._data_panel = DataPanel(parent=self) 
     130        if self.panel_on_focus is not None: 
     131            self._data_panel.set_panel_on_focus(self.panel_on_focus.window_name) 
    130132        # Check for update 
    131133        #self._check_update(None) 
     
    141143        Store reference to the last panel on focus 
    142144        """ 
     145        print "set_panel_on_focus", event.panel 
    143146        self.panel_on_focus = event.panel 
    144          
     147        if self.panel_on_focus is not None and self._data_panel is not None: 
     148            self._data_panel.set_panel_on_focus(self.panel_on_focus.window_name) 
     149             
    145150    def build_gui(self): 
    146151        """ 
     
    434439                              BestSize(wx.Size(PLOPANEL_WIDTH, PLOPANEL_HEIGTH))) 
    435440            self._popup_fixed_panel(p) 
    436              
     441     
    437442        elif style2 in GUIFRAME.FLOATING_PANEL: 
    438443            self._mgr.AddPane(p, wx.aui.AuiPaneInfo(). 
     
    673678            if plug.can_load_data(): 
    674679                plug.load_data(event) 
     680        self.show_data_panel(event=None) 
     681        print "_load_data" 
    675682                 
    676683    def _load_folder(self, event): 
     
    682689            if plug.can_load_data(): 
    683690                plug.load_folder(event) 
     691        self.show_data_panel(event=None) 
    684692                 
    685693    def _on_status_event(self, evt): 
     
    10081016        return path 
    10091017     
    1010     def show_data_panel(self, event): 
     1018    def show_data_panel(self, event=None): 
    10111019        """ 
    10121020        show the data panel 
    10131021        """ 
    10141022        pane = self._mgr.GetPane(self.panels["data_panel"].window_name) 
    1015         if not pane.IsShown(): 
    1016             pane.Show(True) 
    1017             self._mgr.Update() 
     1023        #if not pane.IsShown(): 
     1024        pane.Show(True) 
     1025        self._mgr.Update() 
    10181026   
    10191027    def add_data(self, data_list): 
     
    10411049                self.set_data(data_list) 
    10421050                 
    1043     def get_data_from_panel(self, data_id, plot=False): 
     1051    def get_data_from_panel(self, data_id, plot=False,append=False): 
    10441052        """ 
    10451053        receive a list of data key retreive the data from data manager and set  
     
    10511059            data_list.append(data_state.data) 
    10521060        if plot: 
    1053             self.plot_data(data_list) 
     1061            self.plot_data(data_list, append=append) 
    10541062        else: 
    10551063            #sent data to active application 
     
    10711079            logging.info(msg) 
    10721080             
    1073     def plot_data(self, data_list): 
     1081    def plot_data(self, data_list, append=False): 
    10741082        """ 
    10751083        send a list of data to plot 
    10761084        """ 
     1085        if not data_list: 
     1086            message = "Please check data to plot or append" 
     1087            wx.PostEvent(self, StatusEvent(status=message, info='warning')) 
     1088            return  
    10771089        for new_plot in data_list: 
    1078              
     1090            if append: 
     1091                if self.panel_on_focus is None: 
     1092                    message = "cannot append plot. No plot panel on focus!" 
     1093                    message += "please click on any available plot to set focus" 
     1094                    wx.PostEvent(self, StatusEvent(status=message,  
     1095                                                   info='warning')) 
     1096                    return  
     1097                else: 
     1098                    if self.enable_add_data(new_plot): 
     1099                        new_plot.group_id = self.panel_on_focus.group_id 
    10791100            wx.PostEvent(self, NewPlotEvent(plot=new_plot, 
    10801101                                                  title=str(new_plot.title))) 
    10811102             
     1103    def add_theory(self, data_id, theory): 
     1104        """ 
     1105        """ 
     1106        self._data_manager.append_theory(data_id, theory) 
     1107        style = self.__gui_style & GUIFRAME.MANAGER_ON 
     1108        if style == GUIFRAME.MANAGER_ON: 
     1109            if self._data_panel is not None: 
     1110                data_state = self._data_manager.get_by_id([data_id]) 
     1111                self._data_panel.load_data_list(data_state) 
     1112                 
     1113    def delete_data(self, data_id, theory_id=None, delete_all=True): 
     1114        """ 
     1115        Delete data state if data_id is provide 
     1116        delete theory created with data of id data_id if theory_id is provide 
     1117        if delete all true: delete the all state 
     1118        else delete theory 
     1119        """ 
     1120        self._data_manager.delete_data(data_id=data_id,  
     1121                                       theory_id=theory_id,  
     1122                                       delete_all=delete_all) 
     1123         
    10821124    def set_current_perspective(self, perspective): 
    10831125        """ 
     
    10911133            self._data_panel.set_active_perspective(name) 
    10921134            
    1093     def set_plotpanel_floating(self, event): 
     1135    def set_plotpanel_floating(self, event=None): 
    10941136        """ 
    10951137        make the plot panel floatable 
     
    11021144                    self._popup_floating_panel(p) 
    11031145         
    1104     def set_plotpanel_fixed(self, event): 
     1146    def set_plotpanel_fixed(self, event=None): 
    11051147        """ 
    11061148        make the plot panel fixed 
     
    11401182            self._mgr.GetPane(p.window_name).Show(flag) 
    11411183            self._mgr.Update() 
     1184             
     1185    def enable_add_data(self, new_plot): 
     1186        """ 
     1187        Enable append data on a plot panel 
     1188        """ 
     1189        is_theory = len(self.panel_on_focus.plots) <= 1 and \ 
     1190            self.panel_on_focus.plots.values()[0].__class__.__name__ == "Theory1D" 
     1191             
     1192        is_data2d = hasattr(new_plot, 'data') 
     1193        is_data1d = self.panel_on_focus.__class__.__name__ == "ModelPanel1D"\ 
     1194            and self.panel_on_focus.group_id is not None 
     1195        has_meta_data = hasattr(new_plot, 'meta_data') 
     1196         
     1197        #disable_add_data if the data is being recovered from  a saved state file. 
     1198        is_state_data = False 
     1199        if has_meta_data: 
     1200            if 'invstate' in new_plot.meta_data: is_state_data = True 
     1201            if  'prstate' in new_plot.meta_data: is_state_data = True 
     1202            if  'fitstate' in new_plot.meta_data: is_state_data = True 
     1203     
     1204        return is_data1d and not is_data2d and not is_theory and not is_state_data 
    11421205         
    11431206class DefaultPanel(wx.Panel): 
Note: See TracChangeset for help on using the changeset viewer.