Changeset e88ebfd in sasview for guiframe/gui_manager.py


Ignore:
Timestamp:
Mar 11, 2011 4:39:00 PM (14 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:
ee2b492
Parents:
14cd91b1
Message:

working on guiframe

File:
1 edited

Legend:

Unmodified
Added
Removed
  • guiframe/gui_manager.py

    rc9937c0 re88ebfd  
    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          
    441433    def update_data(self, prev_data, new_data): 
    442434        """ 
     
    444436        prev_id, data_state = self._data_manager.update_data(prev_data=prev_data,  
    445437                                       new_data=new_data) 
     438         
    446439        self._data_panel.remove_by_id(prev_id) 
    447440        self._data_panel.load_data_list(data_state) 
    448         
     441         
     442    def update_theory(self, data_id, theory, state=None): 
     443        """ 
     444        """  
     445        data_state = self._data_manager.update_theory(data_id=data_id,  
     446                                         theory=theory, 
     447                                         state=state)   
     448        self._data_panel.load_data_list(data_state) 
    449449         
    450450    def freeze(self, data_id, theory_id): 
     
    12711271        """ 
    12721272        """ 
    1273         self._data_manager.add_data(data_list) 
    1274          
    1275     def add_data(self, data_list): 
    1276         """ 
    1277         receive a list of data . store them its data manager if possible 
    1278         determine if data was be plot of send to data perspectives 
    1279         """ 
    1280         #send a list of available data to plotting plugin 
    1281         avalaible_data = [] 
    1282         theory_list = [] 
    12831273        if self._data_manager is not None: 
    12841274            self._data_manager.add_data(data_list) 
    1285             avalaible_data = self._data_manager.get_all_data() 
     1275         
     1276    def add_data(self, data_list): 
     1277        """ 
     1278        receive a dictionary of data from loader 
     1279        store them its data manager if possible 
     1280        send to data the current active perspective if the data panel  
     1281        is not active.  
     1282        :param data_list: dictionary of data's ID and value Data 
     1283        """ 
     1284        #Store data into manager 
     1285        self.add_data_helper(data_list) 
     1286        # set data in the data panel 
     1287        if self._data_panel is not None: 
     1288            data_state = self._data_manager.get_data_state(data_list.keys()) 
     1289            self._data_panel.load_data_list(data_state) 
     1290        #if the data panel is shown wait for the user to press a button  
     1291        #to send data to the current perspective. if the panel is not 
     1292        #show  automatically send the data to the current perspective 
    12861293        style = self.__gui_style & GUIFRAME.MANAGER_ON 
    12871294        if style == GUIFRAME.MANAGER_ON: 
     
    12921299        else: 
    12931300            #automatically send that to the current perspective 
    1294             self.set_data(data_list) 
     1301            self.set_data(data_id=data_list.keys()) 
    12951302        
    1296          # set data in the data panel 
    1297         if self._data_panel is not None: 
    1298             data_state = self._data_manager.get_selected_data() 
    1299             self._data_panel.load_data_list(data_state) 
    1300             
    1301     def get_data_from_panel(self, data_id, plot=False,append=False): 
    1302         """ 
    1303         receive a list of data key retreive the data from data manager and set  
    1304         then to the current perspective 
    1305         """ 
    1306         data_dict = self._data_manager.get_by_id(data_id) 
    1307         data_list = [] 
    1308         for data_state in data_dict.values(): 
    1309             data_list.append(data_state.data) 
    1310         if plot: 
    1311             self.plot_data(data_list, append=append) 
     1303    def set_data(self, data_id):  
     1304        """ 
     1305        set data to current perspective 
     1306        """ 
     1307        list_data, _ = self._data_manager.get_by_id(data_id) 
     1308        if self._current_perspective is not None: 
     1309            self._current_perspective.set_data(list_data) 
    13121310        else: 
    1313             #sent data to active application 
    1314             self.set_data(data_list=data_list) 
    1315         
    1316          
    1317     def set_data(self, data_list): 
    1318         """ 
    1319         set data to current perspective 
    1320         """ 
     1311            msg = "Guiframe does not have a current perspective" 
     1312            logging.info(msg) 
     1313             
     1314    def set_theory(self, state_id, theory_id=None): 
     1315        """ 
     1316        """ 
     1317        _, list_theory = self._data_manager.get_by_id(state_id, theory_id) 
    13211318        if self._current_perspective is not None: 
    13221319            try: 
    1323                 self._current_perspective.set_data(data_list) 
     1320                self._current_perspective.set_theory(list_theory) 
    13241321            except: 
    1325                 msg = str(sys.exc_value) 
     1322                msg = "Guiframe set_theory: \n" + str(sys.exc_value) 
     1323                logging.info(msg) 
    13261324                wx.PostEvent(self, StatusEvent(status=msg, info="error")) 
    13271325        else: 
     
    13291327            logging.info(msg) 
    13301328             
    1331     def plot_data(self, data_list, append=False): 
     1329    def plot_data(self,  state_id, data_id=None, 
     1330                  theory_id=None, append=False): 
    13321331        """ 
    13331332        send a list of data to plot 
    13341333        """ 
    1335         if not data_list: 
    1336             message = "Please check data to plot or append" 
    1337             wx.PostEvent(self, StatusEvent(status=message, info='warning')) 
    1338             return  
     1334        data_list, _ = self._data_manager.get_by_id(data_id) 
     1335        _, temp_list_theory = self._data_manager.get_by_id(state_id, theory_id) 
     1336        for item in temp_list_theory: 
     1337            theory_data, theory_state = item 
     1338            data_list.append(theory_data) 
     1339        GROUP_ID = wx.NewId() 
    13391340        for new_plot in data_list: 
    13401341            if append: 
     
    13471348                    return  
    13481349                else: 
    1349                     if self.enable_add_data(new_plot) and \ 
    1350                     hasattr(self.panel_on_focus, 'group_id'): 
    1351                         new_plot.group_id.append(self.panel_on_focus.group_id) 
     1350                    if self.enable_add_data(new_plot): 
     1351                        new_plot.group_id = self.panel_on_focus.group_id 
     1352                    else: 
     1353                        message = "Only 1D Data can be append to plot panel\n" 
     1354                        message += "%s will be plot separetly\n" %str(new_plot.name) 
     1355                        wx.PostEvent(self, StatusEvent(status=message,  
     1356                                                   info='warning')) 
    13521357            else: 
    13531358                #if not append then new plot 
    1354                 new_plot.group_id.append(wx.NewId()) 
     1359                new_plot.group_id = GROUP_ID 
     1360            title = "PLOT " + str(new_plot.title) 
    13551361            wx.PostEvent(self, NewPlotEvent(plot=new_plot, 
    1356                                                   title=str(new_plot.title))) 
     1362                                                  title=title)) 
    13571363             
    13581364   
Note: See TracChangeset for help on using the changeset viewer.