"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "gui/spin_viewer/tree.py" between
relax-4.1.3.src.tar.bz2 and relax-5.0.0.src.tar.bz2

About: relax allows the study of molecular dynamics through the analysis of experimental NMR data. Organic molecules, proteins, RNA, DNA, sugars, and other biomolecules are all supported.

tree.py  (relax-4.1.3.src.tar.bz2):tree.py  (relax-5.0.0.src.tar.bz2)
############################################################################### ###############################################################################
# # # #
# Copyright (C) 2010-2015 Edward d'Auvergne # # Copyright (C) 2010-2015,2019 Edward d'Auvergne #
# # # #
# This file is part of the program relax (http://www.nmr-relax.com). # # This file is part of the program relax (http://www.nmr-relax.com). #
# # # #
# This program is free software: you can redistribute it and/or modify # # This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by # # it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or # # the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. # # (at your option) any later version. #
# # # #
# This program is distributed in the hope that it will be useful, # # This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of # # but WITHOUT ANY WARRANTY; without even the implied warranty of #
skipping to change at line 29 skipping to change at line 29
# # # #
############################################################################### ###############################################################################
# Module docstring. # Module docstring.
"""The molecule, residue, and spin tree view GUI elements.""" """The molecule, residue, and spin tree view GUI elements."""
# Python module imports. # Python module imports.
import wx import wx
# relax module imports. # relax module imports.
import dep_check
from graphics import fetch_icon from graphics import fetch_icon
from gui.components.menu import build_menu_item from gui.components.menu import build_menu_item
from gui.message import Question from gui.message import Question
from gui.string_conv import gui_to_str from gui.string_conv import gui_to_str
from gui.uf_objects import Uf_storage; uf_store = Uf_storage() from gui.uf_objects import Uf_storage; uf_store = Uf_storage()
from pipe_control.mol_res_spin import get_molecule_ids, molecule_loop, residue_l oop, return_molecule, return_residue, return_spin, spin_loop from pipe_control.mol_res_spin import get_molecule_ids, molecule_loop, residue_l oop, return_molecule, return_residue, return_spin, spin_loop
from pipe_control.pipes import cdp_name, get_pipe from pipe_control.pipes import cdp_name, get_pipe
from pipe_control.selection import is_mol_selected, is_res_selected, is_spin_sel ected from pipe_control.selection import is_mol_selected, is_res_selected, is_spin_sel ected
from status import Status; status = Status() from status import Status; status = Status()
skipping to change at line 100 skipping to change at line 101
self.tree = wx.TreeCtrl(parent=self, id=-1, pos=wx.DefaultPosition, size =wx.DefaultSize, style=wx.TR_DEFAULT_STYLE) self.tree = wx.TreeCtrl(parent=self, id=-1, pos=wx.DefaultPosition, size =wx.DefaultSize, style=wx.TR_DEFAULT_STYLE)
# A tracking structure for the tree IDs. # A tracking structure for the tree IDs.
self.tree_ids = {} self.tree_ids = {}
# Resize the tree element. # Resize the tree element.
self.Bind(wx.EVT_SIZE, self._resize) self.Bind(wx.EVT_SIZE, self._resize)
# The tree roots. # The tree roots.
self.root = self.tree.AddRoot("Spin system information") self.root = self.tree.AddRoot("Spin system information")
self.tree.SetPyData(self.root, "root") if dep_check.wx_classic:
self.tree.SetPyData(self.root, "root")
else:
self.tree.SetItemData(self.root, "root")
# Build the icon list. # Build the icon list.
icon_list = wx.ImageList(self.icon_size, self.icon_size) icon_list = wx.ImageList(self.icon_size, self.icon_size)
# The normal icons. # The normal icons.
self.icon_mol_index = icon_list.Add(wx.Bitmap(fetch_icon("relax.molecule ", "22x22"), wx.BITMAP_TYPE_ANY)) self.icon_mol_index = icon_list.Add(wx.Bitmap(fetch_icon("relax.molecule ", "22x22"), wx.BITMAP_TYPE_ANY))
self.icon_mol_unfold_index = icon_list.Add(wx.Bitmap(fetch_icon("relax.m olecule_unfolded", "22x22"), wx.BITMAP_TYPE_ANY)) self.icon_mol_unfold_index = icon_list.Add(wx.Bitmap(fetch_icon("relax.m olecule_unfolded", "22x22"), wx.BITMAP_TYPE_ANY))
self.icon_res_index = icon_list.Add(wx.Bitmap(fetch_icon("relax.residue" , "22x22"), wx.BITMAP_TYPE_ANY)) self.icon_res_index = icon_list.Add(wx.Bitmap(fetch_icon("relax.residue" , "22x22"), wx.BITMAP_TYPE_ANY))
self.icon_spin_index = icon_list.Add(wx.Bitmap(fetch_icon("relax.spin", "22x22"), wx.BITMAP_TYPE_ANY)) self.icon_spin_index = icon_list.Add(wx.Bitmap(fetch_icon("relax.spin", "22x22"), wx.BITMAP_TYPE_ANY))
skipping to change at line 138 skipping to change at line 142
self.tree.Bind(wx.EVT_RIGHT_DOWN, self._right_click) self.tree.Bind(wx.EVT_RIGHT_DOWN, self._right_click)
def _resize(self, event): def _resize(self, event):
"""Resize the tree element. """Resize the tree element.
@param event: The wx event. @param event: The wx event.
@type event: wx event @type event: wx event
""" """
# The panel dimensions. # The panel dimensions.
width, height = self.GetClientSizeTuple() width, height = self.GetClientSize()
# Set the tree dimensions. # Set the tree dimensions.
self.tree.SetDimensions(0, 0, width, height) if dep_check.wx_classic:
self.tree.SetDimensions(0, 0, width, height)
else:
self.tree.SetSize(0, 0, width, height)
def _right_click(self, event): def _right_click(self, event):
"""Handle right clicks in the tree. """Handle right clicks in the tree.
@param event: The wx event. @param event: The wx event.
@type event: wx event @type event: wx event
""" """
# Obtain the position. # Obtain the position.
pos = event.GetPosition() pos = event.GetPosition()
# Find the item clicked on. # Find the item clicked on.
item, flags = self.tree.HitTest(pos) item, flags = self.tree.HitTest(pos)
# The python data (with catch for wxPython 2.9 behaviour). # The python data (with catch for wxPython 2.9 behaviour).
if not item.IsOk(): if not item.IsOk():
self.info = None self.info = None
else: elif dep_check.wx_classic:
self.info = self.tree.GetItemPyData(item) self.info = self.tree.GetItemPyData(item)
else:
self.info = self.tree.GetItemData(item)
# Bring up the default menu. # Bring up the default menu.
if self.info == None: if self.info == None:
self.menu_default() self.menu_default()
# Bring up the root menu. # Bring up the root menu.
elif self.info == 'root': elif self.info == 'root':
self.menu_root() self.menu_root()
# Bring up the molecule menu. # Bring up the molecule menu.
skipping to change at line 193 skipping to change at line 202
"""Handle changes in selection in the tree. """Handle changes in selection in the tree.
@param event: The wx event. @param event: The wx event.
@type event: wx event @type event: wx event
""" """
# Find the item clicked on. # Find the item clicked on.
item = event.GetItem() item = event.GetItem()
# The python data. # The python data.
info = self.tree.GetItemPyData(item) if dep_check.wx_classic:
info = self.tree.GetItemPyData(item)
else:
info = self.tree.GetItemData(item)
# Display the container. # Display the container.
self.gui.spin_viewer.container.display(info) self.gui.spin_viewer.container.display(info)
def action_molecule_molecule_copy(self, event): def action_molecule_molecule_copy(self, event):
"""Wrapper method. """Wrapper method.
@param event: The wx event. @param event: The wx event.
@type event: wx event @type event: wx event
""" """
skipping to change at line 493 skipping to change at line 505
""" """
# The current item. # The current item.
item = self.tree.GetSelection() item = self.tree.GetSelection()
# No data. # No data.
if not item.IsOk(): if not item.IsOk():
return return
# Return the associated python data. # Return the associated python data.
return self.tree.GetItemPyData(item) if dep_check.wx_classic:
return self.tree.GetItemPyData(item)
else:
return self.tree.GetItemData(item)
def menu_default(self): def menu_default(self):
"""The right click root menu.""" """The right click root menu."""
# The menu. # The menu.
menu = wx.Menu() menu = wx.Menu()
# The load spins entry. # The load spins entry.
item = build_menu_item(menu, id=MENU_ROOT_LOAD_SPINS, text="Load spins", icon=fetch_icon("relax.spin", "16x16")) item = build_menu_item(menu, id=MENU_ROOT_LOAD_SPINS, text="Load spins", icon=fetch_icon("relax.spin", "16x16"))
menu.AppendItem(item)
if status.exec_lock.locked(): if status.exec_lock.locked():
item.Enable(False) item.Enable(False)
# The menu actions. # The menu actions.
self.Bind(wx.EVT_MENU, self.gui.spin_viewer.load_spins_wizard, id=MENU_R OOT_LOAD_SPINS) self.Bind(wx.EVT_MENU, self.gui.spin_viewer.load_spins_wizard, id=MENU_R OOT_LOAD_SPINS)
# Show the menu. # Show the menu.
if status.show_gui: if status.show_gui:
self.PopupMenu(menu) self.PopupMenu(menu)
skipping to change at line 535 skipping to change at line 549
# Add some menu items for the spin user functions. # Add some menu items for the spin user functions.
items.append(build_menu_item(menu, id=MENU_MOLECULE_MOLECULE_COPY, text= "&Copy the molecule", icon=fetch_icon("oxygen.actions.list-add"))) items.append(build_menu_item(menu, id=MENU_MOLECULE_MOLECULE_COPY, text= "&Copy the molecule", icon=fetch_icon("oxygen.actions.list-add")))
items.append(build_menu_item(menu, id=MENU_MOLECULE_MOLECULE_DELETE, tex t="De&lete the molecule", icon=fetch_icon("oxygen.actions.list-remove"))) items.append(build_menu_item(menu, id=MENU_MOLECULE_MOLECULE_DELETE, tex t="De&lete the molecule", icon=fetch_icon("oxygen.actions.list-remove")))
items.append(build_menu_item(menu, id=MENU_MOLECULE_MOLECULE_NAME, text= "&Name the molecule", icon=fetch_icon("oxygen.actions.edit-rename"))) items.append(build_menu_item(menu, id=MENU_MOLECULE_MOLECULE_NAME, text= "&Name the molecule", icon=fetch_icon("oxygen.actions.edit-rename")))
items.append(build_menu_item(menu, id=MENU_MOLECULE_MOLECULE_TYPE, text= "Set the molecule &type", icon=fetch_icon("oxygen.actions.edit-rename"))) items.append(build_menu_item(menu, id=MENU_MOLECULE_MOLECULE_TYPE, text= "Set the molecule &type", icon=fetch_icon("oxygen.actions.edit-rename")))
items.append(build_menu_item(menu, id=MENU_MOLECULE_RESIDUE_CREATE, text ="Add a &residue", icon=fetch_icon("oxygen.actions.list-add-relax-blue"))) items.append(build_menu_item(menu, id=MENU_MOLECULE_RESIDUE_CREATE, text ="Add a &residue", icon=fetch_icon("oxygen.actions.list-add-relax-blue")))
# Add the items and activate them. # Add the items and activate them.
for item in items: for item in items:
menu.AppendItem(item)
if status.exec_lock.locked(): if status.exec_lock.locked():
item.Enable(False) item.Enable(False)
# Add a separator. # Add a separator.
menu.AppendSeparator() menu.AppendSeparator()
# Selection or deselection. # Selection or deselection.
if self.info['select']: if self.info['select']:
item = build_menu_item(menu, id=MENU_MOLECULE_MOLECULE_DESELECT, tex t="&Deselect", icon=fetch_icon("relax.molecule_grey")) item = build_menu_item(menu, id=MENU_MOLECULE_MOLECULE_DESELECT, tex t="&Deselect", icon=fetch_icon("relax.molecule_grey"))
else: else:
item = build_menu_item(menu, id=MENU_MOLECULE_MOLECULE_SELECT, text= "&Select", icon=fetch_icon("relax.molecule")) item = build_menu_item(menu, id=MENU_MOLECULE_MOLECULE_SELECT, text= "&Select", icon=fetch_icon("relax.molecule"))
menu.AppendItem(item)
if status.exec_lock.locked(): if status.exec_lock.locked():
item.Enable(False) item.Enable(False)
# The menu actions. # The menu actions.
self.Bind(wx.EVT_MENU, self.action_molecule_molecule_copy, id=MENU_MOLEC ULE_MOLECULE_COPY) self.Bind(wx.EVT_MENU, self.action_molecule_molecule_copy, id=MENU_MOLEC ULE_MOLECULE_COPY)
self.Bind(wx.EVT_MENU, self.action_molecule_molecule_delete, id=MENU_MOL ECULE_MOLECULE_DELETE) self.Bind(wx.EVT_MENU, self.action_molecule_molecule_delete, id=MENU_MOL ECULE_MOLECULE_DELETE)
self.Bind(wx.EVT_MENU, self.action_molecule_molecule_name, id=MENU_MOLEC ULE_MOLECULE_NAME) self.Bind(wx.EVT_MENU, self.action_molecule_molecule_name, id=MENU_MOLEC ULE_MOLECULE_NAME)
self.Bind(wx.EVT_MENU, self.action_molecule_molecule_type, id=MENU_MOLEC ULE_MOLECULE_TYPE) self.Bind(wx.EVT_MENU, self.action_molecule_molecule_type, id=MENU_MOLEC ULE_MOLECULE_TYPE)
self.Bind(wx.EVT_MENU, self.action_molecule_residue_create, id=MENU_MOLE CULE_RESIDUE_CREATE) self.Bind(wx.EVT_MENU, self.action_molecule_residue_create, id=MENU_MOLE CULE_RESIDUE_CREATE)
if self.info['select']: if self.info['select']:
skipping to change at line 588 skipping to change at line 600
# Add some menu items for the spin user functions. # Add some menu items for the spin user functions.
items.append(build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_COPY, text="& Copy the residue", icon=fetch_icon("oxygen.actions.list-add"))) items.append(build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_COPY, text="& Copy the residue", icon=fetch_icon("oxygen.actions.list-add")))
items.append(build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_DELETE, text= "De&lete the residue", icon=fetch_icon("oxygen.actions.list-remove"))) items.append(build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_DELETE, text= "De&lete the residue", icon=fetch_icon("oxygen.actions.list-remove")))
items.append(build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_NAME, text="& Name the residue", icon=fetch_icon("oxygen.actions.edit-rename"))) items.append(build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_NAME, text="& Name the residue", icon=fetch_icon("oxygen.actions.edit-rename")))
items.append(build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_NUMBER, text= "N&umber the residue", icon=fetch_icon("oxygen.actions.edit-rename"))) items.append(build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_NUMBER, text= "N&umber the residue", icon=fetch_icon("oxygen.actions.edit-rename")))
items.append(build_menu_item(menu, id=MENU_RESIDUE_SPIN_ADD, text="&Add a spin", icon=fetch_icon("oxygen.actions.list-add-relax-blue"))) items.append(build_menu_item(menu, id=MENU_RESIDUE_SPIN_ADD, text="&Add a spin", icon=fetch_icon("oxygen.actions.list-add-relax-blue")))
items.append(build_menu_item(menu, id=MENU_RESIDUE_SPIN_CREATE_PSEUDO, t ext="Create a &pseudo-atom", icon=fetch_icon("oxygen.actions.list-add-relax-blue "))) items.append(build_menu_item(menu, id=MENU_RESIDUE_SPIN_CREATE_PSEUDO, t ext="Create a &pseudo-atom", icon=fetch_icon("oxygen.actions.list-add-relax-blue ")))
# Add the items and activate them. # Add the items and activate them.
for item in items: for item in items:
menu.AppendItem(item)
if status.exec_lock.locked(): if status.exec_lock.locked():
item.Enable(False) item.Enable(False)
# Add a separator. # Add a separator.
menu.AppendSeparator() menu.AppendSeparator()
# Selection or deselection. # Selection or deselection.
if self.info['select']: if self.info['select']:
item = build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_DESELECT, text= "&Deselect", icon=fetch_icon("relax.residue_grey")) item = build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_DESELECT, text= "&Deselect", icon=fetch_icon("relax.residue_grey"))
else: else:
item = build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_SELECT, text="& Select", icon=fetch_icon("relax.residue")) item = build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_SELECT, text="& Select", icon=fetch_icon("relax.residue"))
menu.AppendItem(item)
if status.exec_lock.locked(): if status.exec_lock.locked():
item.Enable(False) item.Enable(False)
# The menu actions. # The menu actions.
self.Bind(wx.EVT_MENU, self.action_residue_residue_copy, id=MENU_RESIDUE _RESIDUE_COPY) self.Bind(wx.EVT_MENU, self.action_residue_residue_copy, id=MENU_RESIDUE _RESIDUE_COPY)
self.Bind(wx.EVT_MENU, self.action_residue_residue_delete, id=MENU_RESID UE_RESIDUE_DELETE) self.Bind(wx.EVT_MENU, self.action_residue_residue_delete, id=MENU_RESID UE_RESIDUE_DELETE)
self.Bind(wx.EVT_MENU, self.action_residue_residue_name, id=MENU_RESIDUE _RESIDUE_NAME) self.Bind(wx.EVT_MENU, self.action_residue_residue_name, id=MENU_RESIDUE _RESIDUE_NAME)
self.Bind(wx.EVT_MENU, self.action_residue_residue_number, id=MENU_RESID UE_RESIDUE_NUMBER) self.Bind(wx.EVT_MENU, self.action_residue_residue_number, id=MENU_RESID UE_RESIDUE_NUMBER)
self.Bind(wx.EVT_MENU, self.action_residue_spin_add, id=MENU_RESIDUE_SPI N_ADD) self.Bind(wx.EVT_MENU, self.action_residue_spin_add, id=MENU_RESIDUE_SPI N_ADD)
self.Bind(wx.EVT_MENU, self.action_residue_spin_create_pseudo, id=MENU_R ESIDUE_SPIN_CREATE_PSEUDO) self.Bind(wx.EVT_MENU, self.action_residue_spin_create_pseudo, id=MENU_R ESIDUE_SPIN_CREATE_PSEUDO)
skipping to change at line 638 skipping to change at line 648
# The menu. # The menu.
menu = wx.Menu() menu = wx.Menu()
# Add some menu items for the spin user functions. # Add some menu items for the spin user functions.
items.append(build_menu_item(menu, id=MENU_ROOT_MOLECULE_CREATE, text="& Add a molecule", icon=fetch_icon("oxygen.actions.list-add-relax-blue"))) items.append(build_menu_item(menu, id=MENU_ROOT_MOLECULE_CREATE, text="& Add a molecule", icon=fetch_icon("oxygen.actions.list-add-relax-blue")))
items.append(build_menu_item(menu, id=MENU_ROOT_LOAD_SPINS, text="&Load spins", icon=fetch_icon("relax.spin", "16x16"))) items.append(build_menu_item(menu, id=MENU_ROOT_LOAD_SPINS, text="&Load spins", icon=fetch_icon("relax.spin", "16x16")))
# Add the items and activate them. # Add the items and activate them.
for item in items: for item in items:
menu.AppendItem(item)
if status.exec_lock.locked(): if status.exec_lock.locked():
item.Enable(False) item.Enable(False)
# The menu actions. # The menu actions.
self.Bind(wx.EVT_MENU, self.action_root_molecule_create, id=MENU_ROOT_MO LECULE_CREATE) self.Bind(wx.EVT_MENU, self.action_root_molecule_create, id=MENU_ROOT_MO LECULE_CREATE)
self.Bind(wx.EVT_MENU, self.gui.spin_viewer.load_spins_wizard, id=MENU_R OOT_LOAD_SPINS) self.Bind(wx.EVT_MENU, self.gui.spin_viewer.load_spins_wizard, id=MENU_R OOT_LOAD_SPINS)
# Show the menu. # Show the menu.
if status.show_gui: if status.show_gui:
self.PopupMenu(menu) self.PopupMenu(menu)
skipping to change at line 671 skipping to change at line 680
# Add some menu items for the spin user functions. # Add some menu items for the spin user functions.
items.append(build_menu_item(menu, id=MENU_SPIN_SPIN_COPY, text="&Copy t he spin", icon=fetch_icon("oxygen.actions.list-add"))) items.append(build_menu_item(menu, id=MENU_SPIN_SPIN_COPY, text="&Copy t he spin", icon=fetch_icon("oxygen.actions.list-add")))
items.append(build_menu_item(menu, id=MENU_SPIN_SPIN_DELETE, text="De&le te the spin", icon=fetch_icon("oxygen.actions.list-remove"))) items.append(build_menu_item(menu, id=MENU_SPIN_SPIN_DELETE, text="De&le te the spin", icon=fetch_icon("oxygen.actions.list-remove")))
items.append(build_menu_item(menu, id=MENU_SPIN_SPIN_ELEMENT, text="Set the element &type of the spin", icon=fetch_icon("oxygen.actions.edit-rename"))) items.append(build_menu_item(menu, id=MENU_SPIN_SPIN_ELEMENT, text="Set the element &type of the spin", icon=fetch_icon("oxygen.actions.edit-rename")))
items.append(build_menu_item(menu, id=MENU_SPIN_SPIN_NAME, text="&Name t he spin", icon=fetch_icon("oxygen.actions.edit-rename"))) items.append(build_menu_item(menu, id=MENU_SPIN_SPIN_NAME, text="&Name t he spin", icon=fetch_icon("oxygen.actions.edit-rename")))
items.append(build_menu_item(menu, id=MENU_SPIN_SPIN_NUMBER, text="N&umb er the spin", icon=fetch_icon("oxygen.actions.edit-rename"))) items.append(build_menu_item(menu, id=MENU_SPIN_SPIN_NUMBER, text="N&umb er the spin", icon=fetch_icon("oxygen.actions.edit-rename")))
# Add the items and activate them. # Add the items and activate them.
for item in items: for item in items:
menu.AppendItem(item)
if status.exec_lock.locked(): if status.exec_lock.locked():
item.Enable(False) item.Enable(False)
# Add a separator. # Add a separator.
menu.AppendSeparator() menu.AppendSeparator()
# Selection or deselection. # Selection or deselection.
if self.info['select']: if self.info['select']:
item = build_menu_item(menu, id=MENU_SPIN_SPIN_DESELECT, text="&Dese lect", icon=fetch_icon("relax.spin_grey")) item = build_menu_item(menu, id=MENU_SPIN_SPIN_DESELECT, text="&Dese lect", icon=fetch_icon("relax.spin_grey"))
else: else:
item = build_menu_item(menu, id=MENU_SPIN_SPIN_SELECT, text="&Select ", icon=fetch_icon("relax.spin")) item = build_menu_item(menu, id=MENU_SPIN_SPIN_SELECT, text="&Select ", icon=fetch_icon("relax.spin"))
menu.AppendItem(item)
if status.exec_lock.locked(): if status.exec_lock.locked():
item.Enable(False) item.Enable(False)
# The menu actions. # The menu actions.
self.Bind(wx.EVT_MENU, self.action_spin_spin_copy, id=MENU_SPIN_SPIN_COP Y) self.Bind(wx.EVT_MENU, self.action_spin_spin_copy, id=MENU_SPIN_SPIN_COP Y)
self.Bind(wx.EVT_MENU, self.action_spin_spin_delete, id=MENU_SPIN_SPIN_D ELETE) self.Bind(wx.EVT_MENU, self.action_spin_spin_delete, id=MENU_SPIN_SPIN_D ELETE)
self.Bind(wx.EVT_MENU, self.action_spin_spin_element, id=MENU_SPIN_SPIN_ ELEMENT) self.Bind(wx.EVT_MENU, self.action_spin_spin_element, id=MENU_SPIN_SPIN_ ELEMENT)
self.Bind(wx.EVT_MENU, self.action_spin_spin_name, id=MENU_SPIN_SPIN_NAM E) self.Bind(wx.EVT_MENU, self.action_spin_spin_name, id=MENU_SPIN_SPIN_NAM E)
self.Bind(wx.EVT_MENU, self.action_spin_spin_number, id=MENU_SPIN_SPIN_N UMBER) self.Bind(wx.EVT_MENU, self.action_spin_spin_number, id=MENU_SPIN_SPIN_N UMBER)
if self.info['select']: if self.info['select']:
skipping to change at line 715 skipping to change at line 722
def prune_mol(self): def prune_mol(self):
"""Remove any molecules which have been deleted.""" """Remove any molecules which have been deleted."""
# Get a list of molecule IDs from the relax data store. # Get a list of molecule IDs from the relax data store.
mol_ids = get_molecule_ids() mol_ids = get_molecule_ids()
# Find if the molecule has been removed. # Find if the molecule has been removed.
prune_list = [] prune_list = []
for key in self.tree_ids: for key in self.tree_ids:
# Get the python data. # Get the python data.
info = self.tree.GetItemPyData(key) if dep_check.wx_classic:
info = self.tree.GetItemPyData(key)
else:
info = self.tree.GetItemData(key)
# No info. # No info.
if info == None or 'id' not in info: if info == None or 'id' not in info:
continue continue
# Add to the prune list if it has been removed. # Add to the prune list if it has been removed.
if info['id'] not in mol_ids: if info['id'] not in mol_ids:
prune_list.append(key) prune_list.append(key)
# Delete the data. # Delete the data.
skipping to change at line 743 skipping to change at line 753
@param mol_branch_id: The molecule branch ID of the wx.TreeCtrl object . @param mol_branch_id: The molecule branch ID of the wx.TreeCtrl object .
@type mol_branch_id: TreeItemId @type mol_branch_id: TreeItemId
@param mol_id: The molecule identification string. @param mol_id: The molecule identification string.
@type mol_id: str @type mol_id: str
""" """
# Find if the molecule has been removed. # Find if the molecule has been removed.
prune_list = [] prune_list = []
for key in self.tree_ids[mol_branch_id]: for key in self.tree_ids[mol_branch_id]:
# Get the python data. # Get the python data.
info = self.tree.GetItemPyData(key) if dep_check.wx_classic:
info = self.tree.GetItemPyData(key)
else:
info = self.tree.GetItemData(key)
# No info. # No info.
if info == None or 'id' not in info: if info == None or 'id' not in info:
continue continue
# Get the residue. # Get the residue.
res = return_residue(info['id']) res = return_residue(info['id'])
# Add to the prune list if it has been removed or renamed/renumbered . # Add to the prune list if it has been removed or renamed/renumbered .
if res == None or res.name != info['res_name'] or res.num != info['r es_num']: if res == None or res.name != info['res_name'] or res.num != info['r es_num']:
skipping to change at line 776 skipping to change at line 789
@param res_branch_id: The residue branch ID of the wx.TreeCtrl object. @param res_branch_id: The residue branch ID of the wx.TreeCtrl object.
@type res_branch_id: TreeItemId @type res_branch_id: TreeItemId
@param res_id: The residue identification string. @param res_id: The residue identification string.
@type res_id: str @type res_id: str
""" """
# Find if the molecule has been removed. # Find if the molecule has been removed.
prune_list = [] prune_list = []
for key in self.tree_ids[mol_branch_id][res_branch_id]: for key in self.tree_ids[mol_branch_id][res_branch_id]:
# Get the python data. # Get the python data.
info = self.tree.GetItemPyData(key) if dep_check.wx_classic:
info = self.tree.GetItemPyData(key)
else:
info = self.tree.GetItemData(key)
# No info. # No info.
if info == None or 'id' not in info: if info == None or 'id' not in info:
continue continue
# Get the spin. # Get the spin.
spin = return_spin(spin_id=info['id']) spin = return_spin(spin_id=info['id'])
# Add to the prune list if it has been removed or renamed/renumbered . # Add to the prune list if it has been removed or renamed/renumbered .
if spin == None or spin.name != info['spin_name'] or spin.num != inf o['spin_num']: if spin == None or spin.name != info['spin_name'] or spin.num != inf o['spin_num']:
skipping to change at line 900 skipping to change at line 916
@param mol: The molecule container. @param mol: The molecule container.
@type mol: MoleculeContainer instance @type mol: MoleculeContainer instance
@param mol_id: The molecule identification string. @param mol_id: The molecule identification string.
@type mol_id: str @type mol_id: str
""" """
# Find the molecule, if it already exists. # Find the molecule, if it already exists.
new_mol = True new_mol = True
for key in self.tree_ids: for key in self.tree_ids:
# Get the python data. # Get the python data.
data = self.tree.GetItemPyData(key) if dep_check.wx_classic:
data = self.tree.GetItemPyData(key)
else:
data = self.tree.GetItemData(key)
# No info. # No info.
if data == None or 'id' not in data: if data == None or 'id' not in data:
continue continue
# Check the mol_id for a match and, if so, terminate to speed things up. # Check the mol_id for a match and, if so, terminate to speed things up.
if mol_id == data['id']: if mol_id == data['id']:
new_mol = False new_mol = False
mol_branch_id = key mol_branch_id = key
break break
skipping to change at line 924 skipping to change at line 943
# Append a molecule with name to the tree. # Append a molecule with name to the tree.
mol_branch_id = self.tree.AppendItem(self.root, "Molecule: %s" % mol .name) mol_branch_id = self.tree.AppendItem(self.root, "Molecule: %s" % mol .name)
# The data to store. # The data to store.
data = { data = {
'type': 'mol', 'type': 'mol',
'mol_name': mol.name, 'mol_name': mol.name,
'id': mol_id, 'id': mol_id,
'select': is_mol_selected(mol_id) 'select': is_mol_selected(mol_id)
} }
self.tree.SetPyData(mol_branch_id, data) if dep_check.wx_classic:
self.tree.SetPyData(mol_branch_id, data)
else:
self.tree.SetItemData(mol_branch_id, data)
# Add the id to the tracking structure. # Add the id to the tracking structure.
self.tree_ids[mol_branch_id] = {} self.tree_ids[mol_branch_id] = {}
# Set the bitmap. # Set the bitmap.
self.set_bitmap_mol(mol_branch_id, select=data['select']) self.set_bitmap_mol(mol_branch_id, select=data['select'])
# An old molecule. # An old molecule.
else: else:
# Check the selection state. # Check the selection state.
skipping to change at line 976 skipping to change at line 998
@param res: The residue container. @param res: The residue container.
@type res: ResidueContainer instance @type res: ResidueContainer instance
@param res_id: The residue identification string. @param res_id: The residue identification string.
@type res_id: str @type res_id: str
""" """
# Find the residue, if it already exists. # Find the residue, if it already exists.
new_res = True new_res = True
for key in self.tree_ids[mol_branch_id]: for key in self.tree_ids[mol_branch_id]:
# Get the python data. # Get the python data.
data = self.tree.GetItemPyData(key) if dep_check.wx_classic:
data = self.tree.GetItemPyData(key)
else:
data = self.tree.GetItemData(key)
# No info. # No info.
if data == None or 'id' not in data: if data == None or 'id' not in data:
continue continue
# Check the res_id, res name, and res number for a match and, if so, terminate to speed things up. # Check the res_id, res name, and res number for a match and, if so, terminate to speed things up.
if res_id == data['id'] and res.name == data['res_name'] and res.num == data['res_num']: if res_id == data['id'] and res.name == data['res_name'] and res.num == data['res_num']:
new_res = False new_res = False
res_branch_id = key res_branch_id = key
break break
skipping to change at line 1002 skipping to change at line 1027
# The data to store. # The data to store.
data = { data = {
'type': 'res', 'type': 'res',
'mol_name': mol.name, 'mol_name': mol.name,
'res_name': res.name, 'res_name': res.name,
'res_num': res.num, 'res_num': res.num,
'id': res_id, 'id': res_id,
'select': is_res_selected(res_id) 'select': is_res_selected(res_id)
} }
self.tree.SetPyData(res_branch_id, data) if dep_check.wx_classic:
self.tree.SetPyData(res_branch_id, data)
else:
self.tree.SetItemData(res_branch_id, data)
# Add the id to the tracking structure. # Add the id to the tracking structure.
self.tree_ids[mol_branch_id][res_branch_id] = {} self.tree_ids[mol_branch_id][res_branch_id] = {}
# Set the bitmap. # Set the bitmap.
self.set_bitmap_res(res_branch_id, select=data['select']) self.set_bitmap_res(res_branch_id, select=data['select'])
# An old residue. # An old residue.
else: else:
# Check the selection state. # Check the selection state.
skipping to change at line 1055 skipping to change at line 1083
@param spin: The spin container. @param spin: The spin container.
@type spin: SpinContainer instance @type spin: SpinContainer instance
@param spin_id: The spin identification string. @param spin_id: The spin identification string.
@type spin_id: str @type spin_id: str
""" """
# Find the spin, if it already exists. # Find the spin, if it already exists.
new_spin = True new_spin = True
for key in self.tree_ids[mol_branch_id][res_branch_id]: for key in self.tree_ids[mol_branch_id][res_branch_id]:
# Get the python data. # Get the python data.
data = self.tree.GetItemPyData(key) if dep_check.wx_classic:
data = self.tree.GetItemPyData(key)
else:
data = self.tree.GetItemData(key)
# No info. # No info.
if data == None or 'id' not in data: if data == None or 'id' not in data:
continue continue
# Check the spin_id, spin name and spin number for a match and, if s o, terminate to speed things up. # Check the spin_id, spin name and spin number for a match and, if s o, terminate to speed things up.
if spin_id == data['id'] and spin.name == data['spin_name'] and spin .num == data['spin_num']: if spin_id == data['id'] and spin.name == data['spin_name'] and spin .num == data['spin_num']:
new_spin = False new_spin = False
spin_branch_id = key spin_branch_id = key
break break
skipping to change at line 1083 skipping to change at line 1114
data = { data = {
'type': 'spin', 'type': 'spin',
'mol_name': mol.name, 'mol_name': mol.name,
'res_name': res.name, 'res_name': res.name,
'res_num': res.num, 'res_num': res.num,
'spin_name': spin.name, 'spin_name': spin.name,
'spin_num': spin.num, 'spin_num': spin.num,
'id': spin_id, 'id': spin_id,
'select': is_spin_selected(spin_id) 'select': is_spin_selected(spin_id)
} }
self.tree.SetPyData(spin_branch_id, data) if dep_check.wx_classic:
self.tree.SetPyData(spin_branch_id, data)
else:
self.tree.SetItemData(spin_branch_id, data)
# Add the id to the tracking structure. # Add the id to the tracking structure.
self.tree_ids[mol_branch_id][res_branch_id][spin_branch_id] = True self.tree_ids[mol_branch_id][res_branch_id][spin_branch_id] = True
# Set the bitmap. # Set the bitmap.
self.set_bitmap_spin(spin_branch_id, select=data['select']) self.set_bitmap_spin(spin_branch_id, select=data['select'])
# An old spin. # An old spin.
else: else:
# Check the selection state. # Check the selection state.
 End of changes. 26 change blocks. 
24 lines changed or deleted 58 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)