mailr13444 - /branches/gui_testing/gui/components/spin_view.py


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

Header


Content

Posted by edward on July 06, 2011 - 12:07:
Author: bugman
Date: Wed Jul  6 12:07:44 2011
New Revision: 13444

URL: http://svn.gna.org/viewcvs/relax?rev=13444&view=rev
Log:
Created right click select and deselect menu entries for the molecules, 
residues and spins.


Modified:
    branches/gui_testing/gui/components/spin_view.py

Modified: branches/gui_testing/gui/components/spin_view.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/components/spin_view.py?rev=13444&r1=13443&r2=13444&view=diff
==============================================================================
--- branches/gui_testing/gui/components/spin_view.py (original)
+++ branches/gui_testing/gui/components/spin_view.py Wed Jul  6 12:07:44 2011
@@ -604,7 +604,7 @@
 
         # Some ids.
         ids = []
-        for i in range(2):
+        for i in range(3):
             ids.append(wx.NewId())
 
         # The menu.
@@ -612,9 +612,19 @@
         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))
 
+        # Selection or deselection.
+        if self.info['select']:
+            menu.AppendItem(self.gui.menu.build_menu_item(menu, id=ids[2], 
text="Deselect"))
+        else:
+            menu.AppendItem(self.gui.menu.build_menu_item(menu, id=ids[2], 
text="Select"))
+
         # 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])
+        if self.info['select']:
+            self.Bind(wx.EVT_MENU, self.deselect_molecule, id=ids[2])
+        else:
+            self.Bind(wx.EVT_MENU, self.select_molecule, id=ids[2])
 
         # Show the menu.
         self.PopupMenu(menu)
@@ -623,6 +633,122 @@
 
     def _res_menu(self):
         """The right click molecule menu."""
+
+        # Some ids.
+        ids = []
+        for i in range(3):
+            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))
+
+        # Selection or deselection.
+        if self.info['select']:
+            menu.AppendItem(self.gui.menu.build_menu_item(menu, id=ids[2], 
text="Deselect"))
+        else:
+            menu.AppendItem(self.gui.menu.build_menu_item(menu, id=ids[2], 
text="Select"))
+
+        # 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])
+        if self.info['select']:
+            self.Bind(wx.EVT_MENU, self.deselect_residue, id=ids[2])
+        else:
+            self.Bind(wx.EVT_MENU, self.select_residue, id=ids[2])
+
+        # 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['type'] == 'mol':
+            self._mol_menu()
+
+        # Bring up the residue menu.
+        elif self.info['type'] == 'res':
+            self._res_menu()
+
+        # Bring up the spin menu.
+        elif self.info['type'] == '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 _selection(self, event):
+        """Handle changes in selection in the tree.
+
+        @param event:   The wx event.
+        @type event:    wx event
+        """
+
+        # Find the item clicked on.
+        item = event.GetItem()
+
+        # The python data.
+        info = self.tree.GetItemPyData(item)
+
+        # Display the container.
+        self.gui.spin_view.container.display(info)
+
+
+    def _spin_menu(self):
+        """The right click spin menu."""
 
         # Some ids.
         ids = []
@@ -631,120 +757,76 @@
 
         # 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))
+        menu.AppendItem(self.gui.menu.build_menu_item(menu, id=ids[0], 
text="Delete spin", icon=paths.icon_16x16.remove))
+
+        # Selection or deselection.
+        if self.info['select']:
+            menu.AppendItem(self.gui.menu.build_menu_item(menu, id=ids[1], 
text="Deselect"))
+        else:
+            menu.AppendItem(self.gui.menu.build_menu_item(menu, id=ids[1], 
text="Select"))
 
         # 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])
+        self.Bind(wx.EVT_MENU, self.spin_delete, id=ids[0])
+        if self.info['select']:
+            self.Bind(wx.EVT_MENU, self.deselect_spin, id=ids[1])
+        else:
+            self.Bind(wx.EVT_MENU, self.select_spin, 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['type'] == 'mol':
-            self._mol_menu()
-
-        # Bring up the residue menu.
-        elif self.info['type'] == 'res':
-            self._res_menu()
-
-        # Bring up the spin menu.
-        elif self.info['type'] == '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 _selection(self, event):
-        """Handle changes in selection in the tree.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # Find the item clicked on.
-        item = event.GetItem()
-
-        # The python data.
-        info = self.tree.GetItemPyData(item)
-
-        # Display the container.
-        self.gui.spin_view.container.display(info)
-
-
-    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 deselect_molecule(self, event):
+        """Wrapper method.
+
+        @param event:   The wx event.
+        @type event:    wx event
+        """
+
+        # Ask if this should be done.
+        msg = "Are you sure you would like to deselect all spins of this 
molecule?"
+        if not question(msg, default=False):
+            return
+
+        # Deselect the molecule.
+        
self.gui.user_functions.interpreter.deselect.spin(spin_id=gui_to_str(self.info['id']),
 change_all=False)
+
+        # Update.
+        self.update()
+
+
+    def deselect_residue(self, event):
+        """Wrapper method.
+
+        @param event:   The wx event.
+        @type event:    wx event
+        """
+
+        # Ask if this should be done.
+        msg = "Are you sure you would like to deselect all spins of this 
residue?"
+        if not question(msg, default=False):
+            return
+
+        # Deselect the residue.
+        
self.gui.user_functions.interpreter.deselect.spin(spin_id=gui_to_str(self.info['id']),
 change_all=False)
+
+        # Update.
+        self.update()
+
+
+    def deselect_spin(self, event):
+        """Wrapper method.
+
+        @param event:   The wx event.
+        @type event:    wx event
+        """
+
+        # Deselect the spin.
+        
self.gui.user_functions.interpreter.deselect.spin(spin_id=gui_to_str(self.info['id']),
 change_all=False)
+
+        # Update.
+        self.update()
 
 
     def molecule_delete(self, event):
@@ -859,6 +941,58 @@
 
         # Delete the residue.
         
self.gui.user_functions.interpreter.residue.delete(gui_to_str(self.info['id']))
+
+        # Update.
+        self.update()
+
+
+    def select_molecule(self, event):
+        """Wrapper method.
+
+        @param event:   The wx event.
+        @type event:    wx event
+        """
+
+        # Ask if this should be done.
+        msg = "Are you sure you would like to select all spins of this 
molecule?"
+        if not question(msg, default=False):
+            return
+
+        # Select the molecule.
+        
self.gui.user_functions.interpreter.select.spin(spin_id=gui_to_str(self.info['id']),
 change_all=False)
+
+        # Update.
+        self.update()
+
+
+    def select_residue(self, event):
+        """Wrapper method.
+
+        @param event:   The wx event.
+        @type event:    wx event
+        """
+
+        # Ask if this should be done.
+        msg = "Are you sure you would like to select all spins of this 
residue?"
+        if not question(msg, default=False):
+            return
+
+        # Select the residue.
+        
self.gui.user_functions.interpreter.select.spin(spin_id=gui_to_str(self.info['id']),
 change_all=False)
+
+        # Update.
+        self.update()
+
+
+    def select_spin(self, event):
+        """Wrapper method.
+
+        @param event:   The wx event.
+        @type event:    wx event
+        """
+
+        # Select the spin.
+        
self.gui.user_functions.interpreter.select.spin(spin_id=gui_to_str(self.info['id']),
 change_all=False)
 
         # Update.
         self.update()




Related Messages


Powered by MHonArc, Updated Wed Jul 06 12:20:02 2011