Changeset c5e84fb in sasview


Ignore:
Timestamp:
Jan 29, 2011 12:54:54 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:
584c4c4
Parents:
3feed3e
Message:

working on data panel

Location:
guiframe
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • guiframe/data_manager.py

    rf444b20 rc5e84fb  
    1515Data_manager  make these new data available for all other perspectives. 
    1616""" 
    17  
    1817import logging 
    19 logging.basicConfig(level=logging.DEBUG, 
    20                     format='%(asctime)s %(levelname)s %(message)s', 
    21                     filename='sans_app.log', 
    22                     filemode='w')     
     18from sans.guiframe.data_state import DataState 
    2319   
    2420class DataManager(object): 
     
    3430        perspective 
    3531        """ 
    36         self._selected_data = [] 
     32        self._selected_data = {} 
    3733        self.stored_data = {} 
    3834        self.message = "" 
     
    4844                msg += "" 
    4945                logging.info(msg) 
    50             self._selected_data.append(data) 
    51             self.stored_data[id] = data 
     46            data_state = DataState(data) 
     47            self._selected_data.append(data_state) 
     48            self.stored_data[id] = data_state 
    5249             
    5350    def set_auto_plot(self, flag=False): 
  • guiframe/data_panel.py

    r3feed3e rc5e84fb  
    203203        wx.EVT_BUTTON(self, self.bt_remove.GetId(), self.on_remove) 
    204204         
    205         self.tctrl_perspective = wx.StaticText(self, -1, 'Active Application') 
     205        self.tctrl_perspective = wx.StaticText(self, -1, 'No Active Application') 
    206206        self.tctrl_perspective.SetToolTipString("Active Application") 
    207207        self.tctrl_plotpanel = wx.StaticText(self, -1, 'Plot panel on focus') 
     
    275275        """ 
    276276        print "editing data" 
     277         
    277278    def onContextMenu(self, event):  
    278279        """ 
     
    281282        # Skipping the save state functionality for release 0.9.0 
    282283        #return 
    283      
    284284        pos = event.GetPosition() 
    285285        pos = self.ScreenToClient(pos) 
     
    290290        """ 
    291291        item = event.GetItem() 
    292         name =self.tree_ctrl.GetItemText(item) 
     292        name = self.tree_ctrl.GetItemText(item) 
    293293   
    294294    def load_data_list(self, list): 
     
    408408        """ 
    409409        self.tctrl_perspective.SetLabel(str(name)) 
    410      
     410      
    411411    def set_panel_on_focus(self, name): 
    412412        """ 
     
    415415        self.tctrl_plotpanel.SetLabel(str(name)) 
    416416         
    417     def get_active_perspective(self): 
    418         """ 
    419         """ 
    420         current_perspective = None 
    421         if self.list_rb_perspectives: 
    422             for item in self.list_rb_perspectives: 
    423                 if item.GetValue(): 
    424                     current_perspective = item.GetLabelText() 
    425         return current_perspective 
    426      
    427417    def post_helper(self, plot=False): 
    428418        """ 
  • guiframe/gui_manager.py

    r3feed3e rc5e84fb  
    9595        self._data_manager = DataManager() 
    9696        self._data_panel = DataPanel(parent=self) 
    97         
     97         
    9898        #add current perpsective 
    9999        self._current_perspective = None 
     
    106106        self._window_menu = None 
    107107        self._window_menu = None 
    108         self._help = None 
    109          
     108        self._help_menu = None 
     109        self._tool_menu = None 
    110110        ## Find plug-ins 
    111111        # Modify this so that we can specify the directory to look into 
     
    114114        self.plugins += self._get_local_plugins() 
    115115        self.plugins += self._find_plugins() 
    116         print "self.plugins", self.plugins 
    117116        ## List of panels 
    118117        self.panels = {} 
     
    169168        # Load panels 
    170169        self._load_panels() 
     170        self.set_default_perspective() 
    171171        self._mgr.Update() 
    172172         
     
    430430                              MinimizeButton(). 
    431431                              Resizable(True). 
    432                               # Use a large best size to make sure the AUI manager 
    433                               # takes all the available space 
     432                              # Use a large best size to make sure the AUI  
     433                              # manager takes all the available space 
    434434                              BestSize(wx.Size(PLOPANEL_WIDTH, PLOPANEL_HEIGTH))) 
    435             print "GUIFRAME.FIXED_PANEL" 
    436435            self._popup_fixed_panel(p) 
    437436             
    438437        elif style2 in GUIFRAME.FLOATING_PANEL: 
    439             print "GUIFRAME.Floating_PANEL" 
    440438            self._mgr.AddPane(p, wx.aui.AuiPaneInfo(). 
    441439                              Name(windowname).Caption(caption). 
    442440                              MinimizeButton(). 
    443441                              Resizable(True). 
    444                               # Use a large best size to make sure the AUI manager 
    445                               # takes all the available space 
     442                              # Use a large best size to make sure the AUI 
     443                              #  manager takes all the available space 
    446444                              BestSize(wx.Size(PLOPANEL_WIDTH, PLOPANEL_HEIGTH))) 
    447445            self._popup_floating_panel(p) 
     
    478476        self._add_menu_data() 
    479477        self._add_menu_application() 
     478        self._add_current_plugin_menu() 
     479        self._add_menu_tool() 
    480480        self._add_menu_window() 
    481         # Tools menu 
    482         # Go through plug-ins and find tools to populate the tools menu 
    483         toolsmenu = None 
    484         for item in self.plugins: 
    485             if hasattr(item, "get_tools"): 
    486                 for tool in item.get_tools(): 
    487                     # Only create a menu if we have at least one tool 
    488                     if toolsmenu is None: 
    489                         toolsmenu = wx.Menu() 
    490                     id = wx.NewId() 
    491                     toolsmenu.Append(id, tool[0], tool[1]) 
    492                     wx.EVT_MENU(self, id, tool[2]) 
    493         if toolsmenu is not None: 
    494             self._menubar.Append(toolsmenu, '&Tools') 
    495   
    496         # Help menu 
    497         helpmenu = wx.Menu() 
    498         # add the welcome panel menu item 
    499         if self.defaultPanel is not None: 
    500             id = wx.NewId() 
    501             helpmenu.Append(id, '&Welcome', '') 
    502             helpmenu.AppendSeparator() 
    503             wx.EVT_MENU(self, id, self.show_welcome_panel) 
    504         # Look for help item in plug-ins  
    505         for item in self.plugins: 
    506             if hasattr(item, "help"): 
    507                 id = wx.NewId() 
    508                 helpmenu.Append(id,'&%s help' % item.sub_menu, '') 
    509                 wx.EVT_MENU(self, id, item.help) 
    510         if config._do_aboutbox: 
    511             id = wx.NewId() 
    512             helpmenu.Append(id,'&About', 'Software information') 
    513             wx.EVT_MENU(self, id, self._onAbout) 
    514              
    515         # Checking for updates needs major refactoring to work with py2exe 
    516         # We need to make sure it doesn't hang the application if the server 
    517         # is not up. We also need to make sure there's a proper executable to 
    518         # run if we spawn a new background process. 
    519         #id = wx.NewId() 
    520         #helpmenu.Append(id,'&Check for update',  
    521         #'Check for the latest version of %s' % config.__appname__) 
    522         #wx.EVT_MENU(self, id, self._check_update) 
    523          
    524         # Look for plug-in menus 
     481        self._add_help_menu() 
     482        self.SetMenuBar(self._menubar) 
     483         
     484    def _add_menu_tool(self): 
     485        """ 
     486        Tools menu 
     487        Go through plug-ins and find tools to populate the tools menu 
     488        """ 
     489        style = self.__gui_style & GUIFRAME.TOOL_ON 
     490        if style == GUIFRAME.TOOL_ON: 
     491            self._tool_menu = None 
     492            for item in self.plugins: 
     493                if hasattr(item, "get_tools"): 
     494                    for tool in item.get_tools(): 
     495                        # Only create a menu if we have at least one tool 
     496                        if self._tool_menu is None: 
     497                            self._tool_menu = wx.Menu() 
     498                        id = wx.NewId() 
     499                        self._tool_menu.Append(id, tool[0], tool[1]) 
     500                        wx.EVT_MENU(self, id, tool[2]) 
     501            if self._tool_menu is not None: 
     502                self._menubar.Append(self._tool_menu, '&Tools') 
     503                 
     504    def _add_current_plugin_menu(self): 
     505        """ 
     506        add current plugin menu 
     507        """ 
     508          # Look for plug-in menus 
    525509        # Add available plug-in sub-menus.  
    526510        for item in self.plugins: 
     
    530514                    self._menubar.Append(menu, name) 
    531515                    
    532         self._menubar.Append(helpmenu, '&Help') 
    533         self.SetMenuBar(self._menubar) 
    534      
     516    def _add_help_menu(self): 
     517        """ 
     518        add help menu 
     519        """ 
     520        # Help menu 
     521        self._help_menu = wx.Menu() 
     522        # add the welcome panel menu item 
     523        if self.defaultPanel is not None: 
     524            id = wx.NewId() 
     525            self._help_menu.Append(id, '&Welcome', '') 
     526            self._help_menu.AppendSeparator() 
     527            wx.EVT_MENU(self, id, self.show_welcome_panel) 
     528        # Look for help item in plug-ins  
     529        for item in self.plugins: 
     530            if hasattr(item, "help"): 
     531                id = wx.NewId() 
     532                self._help_menu.Append(id,'&%s help' % item.sub_menu, '') 
     533                wx.EVT_MENU(self, id, item.help) 
     534        if config._do_aboutbox: 
     535            id = wx.NewId() 
     536            self._help_menu.Append(id,'&About', 'Software information') 
     537            wx.EVT_MENU(self, id, self._onAbout) 
     538         
     539        # Checking for updates needs major refactoring to work with py2exe 
     540        # We need to make sure it doesn't hang the application if the server 
     541        # is not up. We also need to make sure there's a proper executable to 
     542        # run if we spawn a new background process. 
     543        #id = wx.NewId() 
     544        #self._help_menu.Append(id,'&Check for update',  
     545        #'Check for the latest version of %s' % config.__appname__) 
     546        #wx.EVT_MENU(self, id, self._check_update) 
     547        self._menubar.Append(self._help_menu, '&Help') 
     548             
    535549    def _add_menu_window(self): 
    536550        """ 
     
    553567        self._window_menu.AppendSeparator() 
    554568        self._menubar.Append(self._window_menu, '&Window') 
    555         if self.defaultPanel is not None : 
    556             id = wx.NewId() 
    557             self._window_menu.Append(id,'&Welcome', '') 
    558              
    559             wx.EVT_MENU(self, id, self.show_welcome_panel) 
     569      
    560570        style = self.__gui_style & GUIFRAME.MANAGER_ON 
    561571        if style == GUIFRAME.MANAGER_ON: 
     
    619629         # File menu 
    620630        self._filemenu = wx.Menu() 
    621          
    622631        # some menu of plugin to be seen under file menu 
    623632        self._populate_file_menu() 
    624          
    625633        id = wx.NewId() 
    626634        self._filemenu.Append(id, '&Save state into File', 
    627635                             'Save project as a SansView (svs) file') 
    628636        wx.EVT_MENU(self, id, self._on_save) 
    629         #self.__filemenu.AppendSeparator() 
    630          
    631637        id = wx.NewId() 
    632638        self._filemenu.Append(id, '&Quit', 'Exit')  
    633639        wx.EVT_MENU(self, id, self.Close) 
    634          
    635640        # Add sub menus 
    636641        self._menubar.Append(self._filemenu, '&File') 
     
    712717            return  
    713718        for id in self.panels.keys(): 
    714             if self._mgr.GetPane(self.panels[id].window_name).IsShown(): 
     719            if id  ==  'default': 
     720                # Show default panel 
     721                if not self._mgr.GetPane(self.panels["default"].window_name).IsShown(): 
     722                    self._mgr.GetPane(self.panels["default"].window_name).Show(True) 
     723            elif id == "data_panel": 
     724                flag = self._mgr.GetPane(self.panels["data_panel"].window_name).IsShown() 
     725                self._mgr.GetPane(self.panels["data_panel"].window_name).Show(flag) 
     726            else: 
     727                self._mgr.GetPane(self.panels[id].window_name).IsShown() 
    715728                self._mgr.GetPane(self.panels[id].window_name).Hide() 
    716         # Show default panel 
    717         if not self._mgr.GetPane(self.panels["default"].window_name).IsShown(): 
    718             self._mgr.GetPane(self.panels["default"].window_name).Show() 
    719          
    720729        self._mgr.Update() 
    721          
     730        
    722731    def show_panel(self, uid): 
    723732        """ 
     
    950959            if hasattr(item, "set_default_perspective"): 
    951960                if item.set_default_perspective(): 
    952                     self._current_perspective = item 
    953961                    item.on_perspective(event=None) 
    954962                    return  
     
    10081016            pane.Show(True) 
    10091017            self._mgr.Update() 
    1010              
    1011     def show_welcome_panel(self, event): 
    1012         """ 
    1013         show welcome panel 
    1014         """ 
    1015          
     1018   
    10161019    def add_data(self, data_list): 
    10171020        """ 
     
    10281031        if style == GUIFRAME.MANAGER_ON: 
    10291032            if self._data_panel is not None: 
     1033                data_state = self._data_manager.get_selected_data() 
     1034                self._data_panel.load_data_list(data_state) 
    10301035                self._mgr.GetPane(self._data_panel.window_name).Show(True) 
    10311036                #wait for button press from the data panel to send data 
     
    10341039            style = self.__gui_style & GUIFRAME.SINGLE_APPLICATION 
    10351040            if style == GUIFRAME.SINGLE_APPLICATION: 
    1036                 if self._current_perspective is not None: 
    1037                     try: 
    1038                         self._current_perspective.set_data(data_list) 
    1039                     except: 
    1040                         msg = str(sys.exc_value) 
    1041                         wx.PostEvent(self, StatusEvent(status=msg, 
    1042                                                   info="error")) 
    1043                 else: 
    1044                     msg = "Guiframe does not have a current perspective" 
    1045                     logging.info(msg) 
    1046              
    1047   
     1041                self.set_data(data_list) 
     1042                 
     1043    def set_data_from_panel(self, data_id): 
     1044        """ 
     1045        receive a list of data key retreive the data from data manager and set  
     1046        then to the current perspective 
     1047        """ 
     1048         
     1049    def set_data(self, data_list): 
     1050        """ 
     1051        set data to current perspective 
     1052        """ 
     1053        if self._current_perspective is not None: 
     1054            try: 
     1055                self._current_perspective.set_data(data_list) 
     1056            except: 
     1057                msg = str(sys.exc_value) 
     1058                wx.PostEvent(self, StatusEvent(status=msg, info="error")) 
     1059        else: 
     1060            msg = "Guiframe does not have a current perspective" 
     1061            logging.info(msg) 
     1062             
    10481063    def plot_data(self, data_list): 
    10491064        """ 
     
    10601075        """ 
    10611076        self._current_perspective = perspective 
    1062          
     1077        name = "No current Application selected" 
     1078        if self._current_perspective is not None and \ 
     1079            self._data_panel is not None: 
     1080            name = self._current_perspective.sub_menu 
     1081            self._data_panel.set_active_perspective(name) 
     1082            
    10631083    def set_plotpanel_floating(self, event): 
    10641084        """ 
Note: See TracChangeset for help on using the changeset viewer.