mailr11926 - in /branches/bieri_gui/gui_bieri/components: mol_res_spin_tree.py spin_view.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on December 21, 2010 - 15:38:
Author: bugman
Date: Tue Dec 21 15:38:59 2010
New Revision: 11926

URL: http://svn.gna.org/viewcvs/relax?rev=11926&view=rev
Log:
Moved the gui_bieri.components.mol_res_spin_tree module to spin_view.


Added:
    branches/bieri_gui/gui_bieri/components/spin_view.py
      - copied unchanged from r11925, 
branches/bieri_gui/gui_bieri/components/mol_res_spin_tree.py
Removed:
    branches/bieri_gui/gui_bieri/components/mol_res_spin_tree.py

Removed: branches/bieri_gui/gui_bieri/components/mol_res_spin_tree.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/components/mol_res_spin_tree.py?rev=11925&view=auto
==============================================================================
--- branches/bieri_gui/gui_bieri/components/mol_res_spin_tree.py (original)
+++ branches/bieri_gui/gui_bieri/components/mol_res_spin_tree.py (removed)
@@ -1,501 +1,0 @@
-###############################################################################
-#                                                                            
 #
-# Copyright (C) 2010 Edward d'Auvergne                                       
 #
-#                                                                            
 #
-# This file is part of the program relax.                                    
 #
-#                                                                            
 #
-# relax is free software; you can redistribute it and/or modify              
 #
-# it under the terms of the GNU General Public License as published by       
 #
-# the Free Software Foundation; either version 2 of the License, or          
 #
-# (at your option) any later version.                                        
 #
-#                                                                            
 #
-# relax is distributed in the hope that it will be useful,                   
 #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of             
 #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              
 #
-# GNU General Public License for more details.                               
 #
-#                                                                            
 #
-# You should have received a copy of the GNU General Public License          
 #
-# along with relax; if not, write to the Free Software                       
 #
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
 #
-#                                                                            
 #
-###############################################################################
-
-# Module docstring.
-"""The molecule, residue, and spin tree view GUI elements."""
-
-
-# Python module imports.
-import wx
-
-# relax module imports.
-from generic_fns.mol_res_spin import molecule_loop, residue_loop, spin_loop
-from generic_fns.pipes import cdp_name, get_pipe, pipe_names
-
-# GUI module imports.
-from gui_bieri import paths
-
-
-class Mol_res_spin_tree(wx.Window):
-    """The tree view class."""
-
-    def __init__(self, gui, parent=None, id=None):
-        """Set up the tree GUI element.
-
-        @keyword parent:    The parent GUI element that this is to be 
attached to.
-        @type parent:       wx object
-        """
-
-        # Store the args.
-        self.gui = gui
-
-        # Execute the base class method.
-        wx.Window.__init__(self, parent, id, style=wx.WANTS_CHARS)
-
-        # Some default values.
-        self.icon_size = 22
-
-        # The tree.
-        self.tree = wx.TreeCtrl(parent=self, id=-1, pos=wx.DefaultPosition, 
size=wx.DefaultSize, style=wx.TR_DEFAULT_STYLE)
-
-        # Resize the tree element.
-        self.Bind(wx.EVT_SIZE, self._resize)
-
-        # The tree roots.
-        self.root = self.tree.AddRoot("Spin system information")
-        self.tree.SetPyData(self.root, "root")
-
-        # Build the icon list.
-        icon_list = wx.ImageList(self.icon_size, self.icon_size)
-        self.icon_mol_index = 
icon_list.Add(wx.Bitmap(paths.icon_22x22.molecule, wx.BITMAP_TYPE_ANY))
-        self.icon_mol_unfold_index = 
icon_list.Add(wx.Bitmap(paths.icon_22x22.molecule_unfolded, 
wx.BITMAP_TYPE_ANY))
-        self.icon_res_index = 
icon_list.Add(wx.Bitmap(paths.icon_22x22.residue, wx.BITMAP_TYPE_ANY))
-        self.icon_spin_index = 
icon_list.Add(wx.Bitmap(paths.icon_22x22.spin, wx.BITMAP_TYPE_ANY))
-        self.tree.SetImageList(icon_list)
-
-        # Some weird black magic (this is essential)!!
-        self.icon_list = icon_list
-
-        # Populate the tree.
-        self.update()
-
-        # Catch mouse events.
-        self.tree.Bind(wx.EVT_RIGHT_DOWN, self._right_click)
-
-
-    def _mol_menu(self):
-        """The right click molecule menu."""
-
-        # Some ids.
-        ids = []
-        for i in range(2):
-            ids.append(wx.NewId())
-
-        # The menu.
-        menu = wx.Menu()
-        menu.AppendItem(self.gui.menu.build_menu_item(menu, id=ids[0], 
text="Add residue", icon=paths.icon_16x16.add))
-        menu.AppendItem(self.gui.menu.build_menu_item(menu, id=ids[1], 
text="Delete molecule", icon=paths.icon_16x16.remove))
-
-        # The menu actions.
-        self.Bind(wx.EVT_MENU, self.residue_create, id=ids[0])
-        self.Bind(wx.EVT_MENU, self.molecule_delete, id=ids[1])
-
-        # Show the menu.
-        self.PopupMenu(menu)
-        menu.Destroy()
-
-
-    def _res_menu(self):
-        """The right click molecule menu."""
-
-        # Some ids.
-        ids = []
-        for i in range(2):
-            ids.append(wx.NewId())
-
-        # The menu.
-        menu = wx.Menu()
-        menu.AppendItem(self.gui.menu.build_menu_item(menu, id=ids[0], 
text="Add spin", icon=paths.icon_16x16.add))
-        menu.AppendItem(self.gui.menu.build_menu_item(menu, id=ids[1], 
text="Delete residue", icon=paths.icon_16x16.remove))
-
-        # The menu actions.
-        self.Bind(wx.EVT_MENU, self.spin_create, id=ids[0])
-        self.Bind(wx.EVT_MENU, self.residue_delete, id=ids[1])
-
-        # Show the menu.
-        self.PopupMenu(menu)
-        menu.Destroy()
-
-
-    def _resize(self, event):
-        """Resize the tree element.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # The panel dimensions.
-        width, height = self.GetClientSizeTuple()
-
-        # Set the tree dimensions.
-        self.tree.SetDimensions(0, 0, width, height)
-
-
-    def _right_click(self, event):
-        """Handle right clicks in the tree.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # Obtain the position.
-        pos = event.GetPosition()
-
-        # Find the item clicked on.
-        item, flags = self.tree.HitTest(pos)
-
-        # The python data.
-        self.info = self.tree.GetItemPyData(item)
-
-        # Bring up the root menu.
-        if self.info == 'root':
-            self._root_menu()
-
-        # Bring up the molecule menu.
-        elif self.info[0] == 'mol':
-            self._mol_menu()
-
-        # Bring up the residue menu.
-        elif self.info[0] == 'res':
-            self._res_menu()
-
-        # Bring up the spin menu.
-        elif self.info[0] == 'spin':
-            self._spin_menu()
-
-
-    def _root_menu(self):
-        """The right click root menu."""
-
-        # Some ids.
-        ids = []
-        for i in range(1):
-            ids.append(wx.NewId())
-
-        # The menu.
-        menu = wx.Menu()
-        menu.AppendItem(self.gui.menu.build_menu_item(menu, id=ids[0], 
text="Add molecule", icon=paths.icon_16x16.add))
-
-        # The menu actions.
-        self.Bind(wx.EVT_MENU, self.gui.user_functions.molecule.create, 
id=ids[0])
-
-        # Show the menu.
-        self.PopupMenu(menu)
-        menu.Destroy()
-
-
-    def _spin_menu(self):
-        """The right click spin menu."""
-
-        # Some ids.
-        ids = []
-        for i in range(1):
-            ids.append(wx.NewId())
-
-        # The menu.
-        menu = wx.Menu()
-        menu.AppendItem(self.gui.menu.build_menu_item(menu, id=ids[0], 
text="Delete spin", icon=paths.icon_16x16.remove))
-
-        # The menu actions.
-        self.Bind(wx.EVT_MENU, self.spin_delete, id=ids[0])
-
-        # Show the menu.
-        self.PopupMenu(menu)
-        menu.Destroy()
-
-
-    def molecule_delete(self, event):
-        """Wrapper method.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # Call the dialog.
-        self.gui.user_functions.molecule.delete(event, mol_name=self.info[1])
-
-
-    def residue_create(self, event):
-        """Wrapper method.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # Call the dialog.
-        self.gui.user_functions.residue.create(event, mol_name=self.info[1])
-
-
-    def residue_delete(self, event):
-        """Wrapper method.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # Call the dialog.
-        self.gui.user_functions.residue.delete(event, mol_name=self.info[1], 
res_num=self.info[2], res_name=self.info[3])
-
-
-    def spin_create(self, event):
-        """Wrapper method.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # Call the dialog.
-        self.gui.user_functions.spin.create(event, mol_name=self.info[1], 
res_num=self.info[2], res_name=self.info[3])
-
-
-    def spin_delete(self, event):
-        """Wrapper method.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # Call the dialog.
-        self.gui.user_functions.spin.delete(event, mol_name=self.info[1], 
res_num=self.info[2], res_name=self.info[3], spin_num=self.info[4], 
spin_name=self.info[5])
-
-
-    def update(self, pipe_name=None):
-        """Update the tree view using the given data pipe."""
-
-        # The data pipe.
-        if not pipe_name:
-            pipe = cdp
-        else:
-            pipe = get_pipe(pipe_name)
-
-        # No data pipe, so do nothing.
-        if not pipe:
-            return
-
-        # Clear all.
-        self.tree.DeleteChildren(self.root)
-
-        # The molecules.
-        for mol, mol_id in molecule_loop(return_id=True):
-            # Append a molecule with name to the tree.
-            mol_branch = self.tree.AppendItem(self.root, "Molecule: %s" % 
mol.name)
-            self.tree.SetPyData(mol_branch, ['mol', mol.name])
-
-            # Set the bitmap.
-            self.tree.SetItemImage(mol_branch, self.icon_mol_index, 
wx.TreeItemIcon_Normal)
-            self.tree.SetItemImage(mol_branch, self.icon_mol_unfold_index, 
wx.TreeItemIcon_Expanded)
-
-            # The residues.
-            for res, res_id in residue_loop(mol_id, return_id=True):
-                # Append a residue with name and number to the tree.
-                res_branch = self.tree.AppendItem(mol_branch, "Residue: %s 
%s" % (res.num, res.name))
-                self.tree.SetPyData(res_branch, ['res', mol.name, res.num, 
res.name])
-
-                # Set the bitmap.
-                self.tree.SetItemImage(res_branch, self.icon_res_index, 
wx.TreeItemIcon_Normal & wx.TreeItemIcon_Expanded)
-
-                # The spins.
-                for spin, spin_id in spin_loop(res_id, return_id=True):
-                    # Append a spin with name and number to the tree.
-                    spin_branch = self.tree.AppendItem(res_branch, "Spin: %s 
%s" % (spin.num, spin.name))
-                    self.tree.SetPyData(spin_branch, ['spin', mol.name, 
res.num, res.name, spin.num, spin.name])
-
-                    # Set the bitmap.
-                    self.tree.SetItemImage(spin_branch, 
self.icon_spin_index, wx.TreeItemIcon_Normal & wx.TreeItemIcon_Expanded)
-
-            # Expand the molecule view.
-            self.tree.Expand(mol_branch)
-
-        # Expand the root.
-        self.tree.Expand(self.root)
-
-
-
-class Spin_view_window(wx.Frame):
-    """A window element for the tree view."""
-
-    def __init__(self, *args, **kwds):
-        """Set up the relax prompt."""
-
-        # Store the parent object.
-        self.gui = kwds.pop('parent')
-
-        # Create GUI elements
-        kwds["style"] = wx.DEFAULT_FRAME_STYLE
-        wx.Frame.__init__(self, *args, **kwds)
-
-        # Some default values.
-        self.size_x = 1000
-        self.size_y = 800
-        self.border = 0
-
-        # Set up the window.
-        sizer = self.setup_window()
-
-        # Build the toolbar.
-        self.toolbar()
-
-        # The splitter window.
-        splitter = Tree_splitter(self, -1)
-        sizer.Add(splitter, 1, wx.EXPAND|wx.ALL, self.border)
-
-
-    def Show(self, show=True):
-        """Change the behaviour of showing the window to update the content.
-
-        @keyword show:  A flag which is True shows the window.
-        @type show:     bool
-        """
-
-        # First update.
-        self.refresh()
-
-        # Then show the window using the baseclass method.
-        wx.Frame.Show(self, show)
-
-
-    def refresh(self, event=None):
-        """Event handler for the refresh action.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # Update the data pipe selector.
-        self.update_pipes()
-
-        # Update the tree.
-        self.tree_panel.update()
-
-
-    def handler_close(self, event):
-        """Event handler for the close window action.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # Close the window.
-        self.Hide()
-
-
-    def setup_window(self):
-        """Set up the window.
-
-        @return:    The sizer object.
-        @rtype:     wx.Sizer instance
-        """
-
-        # Set the frame title.
-        self.SetTitle("The molecule, residue, and spin window")
-
-        # Use a box sizer for packing the shell.
-        sizer = wx.BoxSizer(wx.VERTICAL)
-        self.SetSizer(sizer)
-
-        # Close the window cleanly (hide so it can be reopened).
-        self.Bind(wx.EVT_CLOSE, self.handler_close)
-
-        # Set the default size of the controller.
-        self.SetSize((self.size_x, self.size_y))
-
-        # Return the sizer.
-        return sizer
-
-
-    def toolbar(self):
-        """Create the toolbar."""
-
-        # Init.
-        self.bar = self.CreateToolBar(wx.TB_HORIZONTAL)
-
-        # The refresh button.
-        id = wx.NewId()
-        self.bar.AddLabelTool(id, "Refresh", 
wx.Bitmap(paths.icon_32x32.view_refresh, wx.BITMAP_TYPE_ANY), 
shortHelp="Refresh", longHelp="Refresh the spin view")
-        self.Bind(wx.EVT_TOOL, self.refresh, id=id)
-
-        # A separator.
-        self.bar.AddSeparator()
-
-        # The pipe text.
-        text = wx.StaticText(self.bar, -1, ' Current data pipe:  ', 
style=wx.ALIGN_LEFT)
-        self.bar.AddControl(text)
-
-        # The pipe selection.
-        self.pipe_name = wx.ComboBox(self.bar, -1, "", 
style=wx.CB_DROPDOWN|wx.CB_READONLY, choices=[])
-        self.bar.AddControl(self.pipe_name)
-        self.Bind(wx.EVT_COMBOBOX, self.update_pipes, self.pipe_name)
-        self.update_pipes(None)
-
-
-    def update_pipes(self, event=None):
-        """Update the spin view data pipe selector.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # The selected pipe.
-        if event:
-            pipe = str(event.GetString())
-        else:
-            pipe = cdp_name()
-        if not pipe:
-            pipe = ''
-
-        # Clear the previous data.
-        self.pipe_name.Clear()
-
-        # Set the pipe name to the cdp.
-        self.pipe_name.SetValue(pipe)
-
-        # The list of pipe names.
-        for name in pipe_names():
-            self.pipe_name.Append(name)
-
-        # Switch.
-        if pipe:
-            # Switch data pipes.
-            self.gui.user_functions.interpreter.pipe.switch(pipe)
-
-            # Update the tree view.
-            self.tree_panel.update()
-
-
-
-class Tree_splitter(wx.SplitterWindow):
-    """This splits the view of the tree view and spin container."""
-
-    def __init__(self, parent, id):
-        """Initialise the tree splitter window.
-
-        @param parent:  The parent wx object.
-        @type parent:   wx object
-        @param id:      The ID number.
-        @type id:       int
-        """
-
-        # Execute the base class __init__() method.
-        wx.SplitterWindow.__init__(self, parent, id, style = 
wx.SP_LIVE_UPDATE)
-
-        # The container window.
-        parent.container = wx.Window(self, style=wx.BORDER_SUNKEN)
-        wx.StaticText(parent.container, -1, "The spin view window", (5,5))
-
-        # Add the tree view panel.
-        parent.tree_panel = Mol_res_spin_tree(self, parent=self, id=-1)
-
-        # Make sure the panes cannot be hidden.
-        self.SetMinimumPaneSize(100)
-
-        # Split.
-        self.SplitVertically(parent.tree_panel, parent.container, 400)




Related Messages


Powered by MHonArc, Updated Tue Dec 21 16:00:02 2010