Changeset 0a2fdca in sasview


Ignore:
Timestamp:
Apr 12, 2011 3:00:08 PM (13 years ago)
Author:
Jae Cho <jhjcho@…>
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:
a1a252e
Parents:
f69b5830
Message:

fixing plot panel and control panels focusing problems

Location:
guiframe
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • guiframe/data_panel.py

    r1b1bbf9 r0a2fdca  
    255255        wx.EVT_BUTTON(self, self.bt_remove.GetId(), self.on_remove) 
    256256         
    257         self.tctrl_perspective = wx.StaticText(self, -1, 'No Active Application') 
     257        self.tctrl_perspective = wx.StaticText(self, -1,  
     258                            'No Active Application', 
     259                        style=wx.SUNKEN_BORDER|wx.ALIGN_LEFT) 
    258260        self.tctrl_perspective.SetToolTipString("Active Application") 
    259         self.tctrl_plotpanel = wx.StaticText(self, -1, 'No Plot panel on focus') 
    260         self.tctrl_plotpanel.SetToolTipString("Active Plot Panel") 
     261        perspective_font = self.tctrl_perspective.GetFont() 
     262        perspective_font.SetWeight(wx.BOLD) 
     263        self.tctrl_perspective.SetFont(perspective_font) 
     264        self.tctrl_perspective.SetClientSize((80,20)) 
     265        self.cb_plotpanel = wx.ComboBox(self, -1,  
     266                                style=wx.CB_READONLY|wx.CB_SORT) 
     267        wx.EVT_COMBOBOX(self.cb_plotpanel,-1, self._on_plot_selection) 
     268        self.cb_plotpanel.Append('None') 
     269        self.cb_plotpanel.SetStringSelection('None') 
     270 
     271        #self.tctrl_plotpanel = wx.StaticText(self, -1, 'No Plot panel on focus') 
     272        #self.tctrl_plotpanel.SetToolTipString("Active Plot Panel") 
    261273     
    262274        ix = 0 
     
    272284                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    273285        ix += 1 
    274         self.sizer3.Add(self.tctrl_plotpanel,(iy, ix),(1,1), 
     286        self.sizer3.Add(self.cb_plotpanel,(iy, ix),(1,1), 
    275287                          wx.EXPAND|wx.ADJUST_MINSIZE, 0)   
    276288        ix = 0           
     
    624636        append plot to plot panel on focus 
    625637        """ 
     638        self._on_plot_selection() 
    626639        data_id, theory_id, state_id = self.set_data_helper() 
    627640        self.parent.plot_data(data_id=data_id,   
     
    662675        """ 
    663676        self.tctrl_perspective.SetLabel(str(name)) 
     677        #perspective_font = self.tctrl_perspective.GetFont() 
     678        #perspective_font.SetWeight(wx.BOLD) 
     679        self.tctrl_perspective.SetClientSize((80,20))#SetFont(perspective_font) 
    664680      
    665681    def set_panel_on_focus(self, name): 
     
    667683        set the plot panel on focus 
    668684        """ 
    669         self.tctrl_plotpanel.SetLabel(str(name)) 
     685        for key, value in self.parent.plot_panels.iteritems(): 
     686            name_plot_panel = str(value.window_caption) 
     687            if name_plot_panel not in self.cb_plotpanel.GetItems(): 
     688                self.cb_plotpanel.Append(name_plot_panel, value) 
     689            self.cb_plotpanel.SetStringSelection(name_plot_panel) 
     690 
    670691  
     692    def _on_plot_selection(self, event = None): 
     693        """ 
     694        On source combobox selection 
     695        """ 
     696        if event != None: 
     697            combo = event.GetEventObject() 
     698            event.Skip() 
     699        else: 
     700            combo = self.cb_plotpanel 
     701        selection = combo.GetSelection() 
     702 
     703        if combo.GetValue() != 'None': 
     704            panel = combo.GetClientData(selection) 
     705            self.parent.on_set_plot_focus(panel)    
     706 
    671707     
    672708 
  • guiframe/gui_manager.py

    rf69b5830 r0a2fdca  
    144144        ## List of panels 
    145145        self.panels = {} 
     146        # List of plot panels 
     147        self.plot_panels = {} 
    146148 
    147149        # Default locations 
     
    152154        #panel on focus 
    153155        self.panel_on_focus = None 
     156        #control_panel on focus 
     157        self.cpanel_on_focus = None 
    154158        self.loader = Loader()    
    155159        #data manager 
     
    199203        update edit menu if available 
    200204        """ 
    201         self.panel_on_focus = event.panel 
     205        if event != None: 
     206            self.panel_on_focus = event.panel 
    202207        panel_name = 'No panel on focus' 
    203208        application_name = 'No Selected Application' 
     
    209214            if self._data_panel is not None: 
    210215                panel_name = self.panel_on_focus.window_caption 
    211                 self._data_panel.set_panel_on_focus(panel_name) 
     216                self._data_panel.set_panel_on_focus(ID)#panel_name) 
     217                #update combo 
     218                if self.panel_on_focus in self.plot_panels.values(): 
     219                    self._data_panel.cb_plotpanel.SetStringSelection(str\ 
     220                                         (self.panel_on_focus.window_caption)) 
     221                elif self.panel_on_focus != self._data_panel: 
     222                    self.cpanel_on_focus = self.panel_on_focus 
    212223                #update toolbar 
    213224                self._update_toolbar_helper() 
    214225                #update edit menu 
    215226                self.enable_edit_menu() 
     227 
    216228 
    217229    def build_gui(self): 
     
    612624        # Register for showing/hiding the panel 
    613625        wx.EVT_MENU(self, ID, self._on_view) 
    614          
     626        if p not in self.plot_panels.values(): 
     627            self.plot_panels[ID] = p 
     628            if self._data_panel is not None and \ 
     629                self._plotting_plugin is not None: 
     630                ind = self._data_panel.cb_plotpanel.FindString('None') 
     631                if ind != wx.NOT_FOUND: 
     632                    self._data_panel.cb_plotpanel.Delete(ind) 
     633                self._data_panel.cb_plotpanel.Append(str(caption), p) 
    615634        self._mgr.Update() 
    616635        return ID 
     
    649668        if self._toolbar is  None: 
    650669            return 
    651         self._toolbar.update_toolbar(self.panel_on_focus) 
     670        self._toolbar.update_toolbar(self.cpanel_on_focus) 
    652671        if self._current_perspective is not None: 
    653672            application_name = self._current_perspective.sub_menu 
    654         if self.panel_on_focus is not None: 
    655             panel_name = self.panel_on_focus.window_caption 
     673        if self.cpanel_on_focus is not None: 
     674            panel_name = self.cpanel_on_focus.window_caption 
    656675        self._toolbar.update_button(application_name=application_name,  
    657676                                        panel_name=panel_name) 
     
    10371056        """ 
    10381057        ID = str(uid) 
     1058        caption = self.panels[ID].window_caption 
    10391059        config.printEVT("hide_panel: %s" % ID) 
    10401060        if ID in self.panels.keys(): 
    10411061            if self._mgr.GetPane(self.panels[ID].window_name).IsShown(): 
    10421062                self._mgr.GetPane(self.panels[ID].window_name).Hide() 
     1063                if self._data_panel is not None and \ 
     1064                            ID in self.plot_panels.keys(): 
     1065                    self._data_panel.cb_plotpanel.Append(str(caption), p) 
    10431066                # Hide default panel 
    10441067                self._mgr.GetPane(self.panels["default"].window_name).Hide() 
    10451068            self._mgr.Update() 
    1046              
     1069                 
    10471070    def delete_panel(self, uid): 
    10481071        """ 
     
    10511074        ID = str(uid) 
    10521075        config.printEVT("delete_panel: %s" % ID) 
    1053          
     1076        caption = self.panels[ID].window_caption 
    10541077        if ID in self.panels.keys(): 
    10551078            panel = self.panels[ID] 
     
    10581081            panel.Destroy() 
    10591082            del self.panels[ID] 
     1083            del self.plot_panels[ID] 
     1084            if self._data_panel is not None: 
     1085                ind = self._data_panel.cb_plotpanel.FindString(str(caption)) 
     1086                if ind != wx.NOT_FOUND: 
     1087                    self._data_panel.cb_plotpanel.Delete(ind) 
    10601088            self._mgr.Update() 
    10611089       
     
    11421170                        plug.clear_panel()   
    11431171            self.panel_on_focus = None     
     1172            self.cpanel_on_focus = None  
    11441173            self.get_data(path) 
    11451174        if self.defaultPanel is not None and \ 
     
    12241253        save the state of the current active application 
    12251254        """ 
    1226         if self.panel_on_focus is not None: 
    1227             self.panel_on_focus.on_save(event) 
     1255        if self.cpanel_on_focus is not None: 
     1256            self.cpanel_on_focus.on_save(event) 
    12281257             
    12291258    def _on_save_project(self, event): 
     
    14881517            self.on_close_welcome_panel() 
    14891518        
    1490     def set_data(self, data_id):  
     1519    def set_data(self, data_id, theory_id=None):  
    14911520        """ 
    14921521        set data to current perspective 
     
    16801709        Enable append data on a plot panel 
    16811710        """ 
     1711 
    16821712        if self.panel_on_focus not in self._plotting_plugin.plot_panels.values(): 
    16831713            return 
     
    16861716             
    16871717        is_data2d = hasattr(new_plot, 'data') 
     1718         
    16881719        is_data1d = self.panel_on_focus.__class__.__name__ == "ModelPanel1D"\ 
    16891720            and self.panel_on_focus.group_id is not None 
     
    17031734        enable menu item under edit menu depending on the panel on focus 
    17041735        """ 
    1705         if self.panel_on_focus is not None and self._edit_menu is not None: 
    1706             flag = self.panel_on_focus.get_undo_flag() 
     1736        if self.cpanel_on_focus is not None and self._edit_menu is not None: 
     1737            flag = self.cpanel_on_focus.get_undo_flag() 
    17071738            self._edit_menu.Enable(GUIFRAME_ID.UNDO_ID, flag) 
    1708             flag = self.panel_on_focus.get_redo_flag() 
     1739            flag = self.cpanel_on_focus.get_redo_flag() 
    17091740            self._edit_menu.Enable(GUIFRAME_ID.REDO_ID, flag) 
    1710             flag = self.panel_on_focus.get_print_flag() 
     1741            flag = self.cpanel_on_focus.get_print_flag() 
    17111742            self._edit_menu.Enable(GUIFRAME_ID.PRINT_ID, flag) 
    1712             flag = self.panel_on_focus.get_preview_flag() 
     1743            flag = self.cpanel_on_focus.get_preview_flag() 
    17131744            self._edit_menu.Enable(GUIFRAME_ID.PREVIEW_ID, flag) 
    1714             flag = self.panel_on_focus.get_reset_flag() 
     1745            flag = self.cpanel_on_focus.get_reset_flag() 
    17151746            self._edit_menu.Enable(GUIFRAME_ID.RESET_ID, flag) 
    17161747        else: 
     
    17261757        undo previous action of the last panel on focus if possible 
    17271758        """ 
    1728         if self.panel_on_focus is not None: 
    1729             self.panel_on_focus.on_undo(event) 
     1759        if self.cpanel_on_focus is not None: 
     1760            self.cpanel_on_focus.on_undo(event) 
    17301761             
    17311762    def on_redo_panel(self, event=None): 
     
    17331764        redo the last cancel action done on the last panel on focus 
    17341765        """ 
    1735         if self.panel_on_focus is not None: 
    1736             self.panel_on_focus.on_redo(event) 
     1766        if self.cpanel_on_focus is not None: 
     1767            self.cpanel_on_focus.on_redo(event) 
    17371768             
    17381769    def on_bookmark_panel(self, event=None): 
     
    17401771        bookmark panel 
    17411772        """ 
    1742         if self.panel_on_focus is not None: 
    1743             self.panel_on_focus.on_bookmark(event) 
     1773        if self.cpanel_on_focus is not None: 
     1774            self.cpanel_on_focus.on_bookmark(event) 
    17441775             
    17451776    def append_bookmark(self, event=None): 
     
    17531784        save possible information on the current panel 
    17541785        """ 
    1755         if self.panel_on_focus is not None: 
    1756             self.panel_on_focus.on_save(event) 
     1786        if self.cpanel_on_focus is not None: 
     1787            self.cpanel_on_focus.on_save(event) 
    17571788             
    17581789    def on_preview_panel(self, event=None): 
     
    17601791        preview information on the panel on focus 
    17611792        """ 
    1762         if self.panel_on_focus is not None: 
    1763             self.panel_on_focus.on_preview(event) 
     1793        if self.cpanel_on_focus is not None: 
     1794            self.cpanel_on_focus.on_preview(event) 
    17641795             
    17651796    def on_print_panel(self, event=None): 
     
    17671798        print available information on the last panel on focus 
    17681799        """ 
    1769         if self.panel_on_focus is not None: 
    1770             self.panel_on_focus.on_print(event) 
     1800        if self.cpanel_on_focus is not None: 
     1801            self.cpanel_on_focus.on_print(event) 
    17711802             
    17721803    def on_zoom_panel(self, event=None): 
     
    17741805        zoom on the current panel if possible 
    17751806        """ 
    1776         if self.panel_on_focus is not None: 
    1777             self.panel_on_focus.on_zoom(event) 
     1807        if self.cpanel_on_focus is not None: 
     1808            self.cpanel_on_focus.on_zoom(event) 
    17781809             
    17791810    def on_zoom_in_panel(self, event=None): 
     
    17811812        zoom in of the panel on focus 
    17821813        """ 
    1783         if self.panel_on_focus is not None: 
    1784             self.panel_on_focus.on_zoom_in(event) 
     1814        if self.cpanel_on_focus is not None: 
     1815            self.cpanel_on_focus.on_zoom_in(event) 
    17851816             
    17861817    def on_zoom_out_panel(self, event=None): 
     
    17881819        zoom out on the panel on focus 
    17891820        """ 
    1790         if self.panel_on_focus is not None: 
    1791             self.panel_on_focus.on_zoom_out(event) 
     1821        if self.cpanel_on_focus is not None: 
     1822            self.cpanel_on_focus.on_zoom_out(event) 
    17921823             
    17931824    def on_drag_panel(self, event=None): 
     
    17951826        drag apply to the panel on focus 
    17961827        """ 
    1797         if self.panel_on_focus is not None: 
    1798             self.panel_on_focus.on_drag(event) 
     1828        if self.cpanel_on_focus is not None: 
     1829            self.cpanel_on_focus.on_drag(event) 
    17991830             
    18001831    def on_reset_panel(self, event=None): 
     
    18021833        reset the current panel 
    18031834        """ 
    1804         if self.panel_on_focus is not None: 
    1805             self.panel_on_focus.on_reset(event) 
     1835        if self.cpanel_on_focus is not None: 
     1836            self.cpanel_on_focus.on_reset(event) 
    18061837             
    18071838    def enable_undo(self): 
     
    18091840        enable undo related control 
    18101841        """ 
    1811         if self.panel_on_focus is not None: 
    1812             self._toolbar.enable_undo(self.panel_on_focus) 
     1842        if self.cpanel_on_focus is not None: 
     1843            self._toolbar.enable_undo(self.cpanel_on_focus) 
    18131844             
    18141845    def enable_redo(self): 
     
    18161847        enable redo  
    18171848        """ 
    1818         if self.panel_on_focus is not None: 
    1819             self._toolbar.enable_redo(self.panel_on_focus) 
     1849        if self.cpanel_on_focus is not None: 
     1850            self._toolbar.enable_redo(self.cpanel_on_focus) 
    18201851             
    18211852    def enable_bookmark(self): 
     
    18231854        Bookmark  
    18241855        """ 
    1825         if self.panel_on_focus is not None: 
    1826             self._toolbar.enable_bookmark(self.panel_on_focus) 
     1856        if self.cpanel_on_focus is not None: 
     1857            self._toolbar.enable_bookmark(self.cpanel_on_focus) 
    18271858             
    18281859    def enable_save(self): 
     
    18301861        save  
    18311862        """ 
    1832         if self.panel_on_focus is not None: 
    1833             self._toolbar.enable_save(self.panel_on_focus) 
     1863        if self.cpanel_on_focus is not None: 
     1864            self._toolbar.enable_save(self.cpanel_on_focus) 
    18341865             
    18351866    def enable_preview(self): 
     
    18371868        preview  
    18381869        """ 
    1839         if self.panel_on_focus is not None: 
    1840             self._toolbar.enable_preview(self.panel_on_focus) 
     1870        if self.cpanel_on_focus is not None: 
     1871            self._toolbar.enable_preview(self.cpanel_on_focus) 
    18411872             
    18421873    def enable_print(self): 
     
    18441875        print  
    18451876        """ 
    1846         if self.panel_on_focus is not None: 
    1847             self._toolbar.enable_print(self.panel_on_focus) 
     1877        if self.cpanel_on_focus is not None: 
     1878            self._toolbar.enable_print(self.cpanel_on_focus) 
    18481879             
    18491880    def enable_zoom(self): 
     
    18511882        zoom  
    18521883        """ 
    1853         if self.panel_on_focus is not None: 
     1884        if self.cpanel_on_focus is not None: 
    18541885            self._toolbar.enable_zoom(self.panel_on_focus) 
    18551886             
     
    18581889        zoom in  
    18591890        """ 
    1860         if self.panel_on_focus is not None: 
     1891        if self.cpanel_on_focus is not None: 
    18611892            self._toolbar.enable_zoom_in(self.panel_on_focus) 
    18621893             
     
    18651896        zoom out  
    18661897        """ 
    1867         if self.panel_on_focus is not None: 
     1898        if self.cpanel_on_focus is not None: 
    18681899            self._toolbar.enable_zoom_out(self.panel_on_focus) 
    18691900             
     
    18721903        drag  
    18731904        """ 
    1874         if self.panel_on_focus is not None: 
     1905        if self.cpanel_on_focus is not None: 
    18751906            self._toolbar.enable_drag(self.panel_on_focus) 
    18761907             
     
    18791910        reset the current panel 
    18801911        """ 
    1881         if self.panel_on_focus is not None: 
     1912        if self.cpanel_on_focus is not None: 
    18821913            self._toolbar.enable_reset(self.panel_on_focus) 
    18831914 
     
    19671998        return self.schedule 
    19681999     
    1969          
     2000    def on_set_plot_focus(self, panel): 
     2001        """ 
     2002        Set focus on a plot panel 
     2003        """ 
     2004        for plot in self.plot_panels.values(): 
     2005            # make sure we don't double focus 
     2006            if panel != plot: 
     2007                plot.on_kill_focus(None) 
     2008        panel.on_set_focus(None)   
     2009        # set focusing panel 
     2010        self.panel_on_focus = panel   
     2011        self.set_panel_on_focus(None) 
     2012          
    19702013    def _onDrawIdle(self, *args, **kwargs): 
    19712014        """ 
  • guiframe/panel_base.py

    rf69b5830 r0a2fdca  
    7171        self._print_flag = flag 
    7272        if self._manager is not None and self._manager.parent is not None: 
    73             self._manager.parent.panel_on_focus = self 
     73            self._manager.parent.cpanel_on_focus = self 
    7474            self._manager.parent.enable_print() 
    7575      
     
    9191        self._undo_flag = flag 
    9292        if self._manager is not None and self._manager.parent is not None: 
    93             self._manager.parent.panel_on_focus = self 
     93            self._manager.parent.cpanel_on_focus = self 
    9494            self._manager.parent.enable_undo() 
    9595       
     
    111111        self._redo_flag = flag 
    112112        if self._manager is not None and self._manager.parent is not None: 
    113             self._manager.parent.panel_on_focus = self 
     113            self._manager.parent.cpanel_on_focus = self 
    114114            self._manager.parent.enable_redo() 
    115115       
     
    131131        self._zoom_in_flag = flag 
    132132        if self._manager is not None and self._manager.parent is not None: 
    133             self._manager.parent.panel_on_focus = self 
     133            self._manager.parent.cpanel_on_focus = self 
    134134            self._manager.parent.enable_zoom_in() 
    135135        
     
    171171        self._zoom_flag = flag 
    172172        if self._manager is not None and self._manager.parent is not None: 
    173             self._manager.parent.panel_on_focus = self 
     173            self._manager.parent.cpanel_on_focus = self 
    174174            self._manager.parent.enable_zoom() 
    175175      
     
    191191        self._bookmark_flag = flag 
    192192        if self._manager is not None and self._manager.parent is not None: 
    193             self._manager.parent.panel_on_focus = self 
     193            self._manager.parent.cpanel_on_focus = self 
    194194            self._manager.parent.enable_bookmark() 
    195195        
     
    211211        self._preview_flag = flag 
    212212        if self._manager is not None and self._manager.parent is not None: 
    213             self._manager.parent.panel_on_focus = self 
     213            self._manager.parent.cpanel_on_focus = self 
    214214            self._manager.parent.enable_preview() 
    215215        
     
    231231        self._save_flag = flag 
    232232        if self._manager is not None and self._manager.parent is not None: 
    233             self._manager.parent.panel_on_focus = self 
     233            self._manager.parent.cpanel_on_focus = self 
    234234            self._manager.parent.enable_save() 
    235235 
     
    251251        self._drag_flag = flag 
    252252        if self._manager is not None and self._manager.parent is not None: 
    253             self._manager.parent.panel_on_focus = self 
     253            self._manager.parent.cpanel_on_focus = self 
    254254            self._manager.parent.enable_drag() 
    255255        
     
    271271        self._reset_flag = flag 
    272272        if self._manager is not None and self._manager.parent is not None: 
    273             self._manager.parent.panel_on_focus = self 
     273            self._manager.parent.cpanel_on_focus = self 
    274274            self._manager.parent.enable_reset() 
    275275       
Note: See TracChangeset for help on using the changeset viewer.