Package data :: Module gui
[hide private]
[frames] | no frames]

Source Code for Module data.gui

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2010-2011 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax is free software; you can redistribute it and/or modify               # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation; either version 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax is distributed in the hope that it will be useful,                    # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Module docstring. 
 24  """Data store objects for holding all the GUI specific variables.""" 
 25   
 26  # relax module imports. 
 27  from data_classes import Element, RelaxListType 
 28  from relax_xml import xml_to_object 
 29   
 30   
31 -class Gui(Element):
32 """Container for the global GUI data structures.""" 33
34 - def __init__(self):
35 """Initialise the container info.""" 36 37 # Execute the base class __init__() method. 38 super(Gui, self).__init__() 39 40 # Add the analysis list object. 41 self.analyses = Analyses() 42 43 # The free format file settings. 44 self.free_file_format = Free_file_format() 45 46 # Set the name and description. 47 self.name = 'relax_gui' 48 self.desc = 'The relax GUI information store.'
49 50
51 - def from_xml(self, gui_node):
52 """Recreate the gui data structure from the XML gui node. 53 54 @param gui_node: The gui XML node. 55 @type gui_node: xml.dom.minicompat.Element instance 56 """ 57 58 # Init. 59 self.analyses = Analyses() 60 self.free_file_format = Free_file_format() 61 62 # Get the analyses node and recreate the analyses structure. 63 analyses_nodes = gui_node.getElementsByTagName('analyses') 64 self.analyses.from_xml(analyses_nodes[0]) 65 66 # Get the file settings node and recreate the structure. 67 format_nodes = gui_node.getElementsByTagName('free_file_format') 68 if format_nodes: 69 self.free_file_format.from_xml(format_nodes[0]) 70 71 # Recreate all the other data structures. 72 xml_to_object(gui_node, self, blacklist=['analyses', 'free_file_format'])
73 74 75
76 -class Analyses(RelaxListType):
77 """A list object for holding all the GUI info specific to a certain analysis type.""" 78
79 - def __init__(self):
80 """Initialise some class variables.""" 81 82 # Execute the base class __init__() method. 83 super(Analyses, self).__init__() 84 85 # Some generic initial names. 86 self.list_name = 'analyses' 87 self.list_desc = 'GUI information specific to relax analysis types'
88 89
90 - def add(self, type=None):
91 """Add a new analysis type. 92 93 @keyword type: The analysis type. This can be currently one of 'noe', 'r1', 'r2', or 'model-free'. 94 @type type: str 95 @return: The index of the data container added to the list. 96 @rtype: int 97 """ 98 99 # Append an empty element. 100 self.append(Element(name='analysis', desc='GUI information for a relax analysis')) 101 102 # Set the analysis type. 103 self[-1].analysis_type = type 104 105 # Return the index of the container. 106 return len(self)-1
107 108
109 - def from_xml(self, analyses_node):
110 """Recreate the analyses data structure from the XML analyses node. 111 112 @param analyses_node: The analyses XML node. 113 @type analyses_node: xml.dom.minicompat.Element instance 114 """ 115 116 # Get all the analysis nodes. 117 analysis_nodes = analyses_node.getElementsByTagName('analysis') 118 119 # Loop over the nodes. 120 for node in analysis_nodes: 121 # Add a blank analysis container. 122 index = self.add() 123 124 # Recreate the analysis container. 125 self[index].from_xml(node)
126 127
128 -class Free_file_format(Element):
129 """Container for the free format file settings (column numbers, column separators, etc.).""" 130
131 - def __init__(self):
132 """Set up the initial values.""" 133 134 # Execute the base class __init__() method. 135 super(Free_file_format, self).__init__(name='free_file_format', desc='The column numbers and separator for the free format file.') 136 137 # Reset. 138 self.reset()
139 140
141 - def reset(self):
142 """Reset all variables to the initial values.""" 143 144 # The default column numbers. 145 self.spin_id_col = None 146 self.mol_name_col = 1 147 self.res_num_col = 2 148 self.res_name_col = 3 149 self.spin_num_col = 4 150 self.spin_name_col = 5 151 self.data_col = 6 152 self.err_col = 7 153 154 # The column separator (set to None for white space). 155 self.sep = None
156