Package windSimSuite :: Package interface :: Module blade
[hide private]

Source Code for Module windSimSuite.interface.blade

 1  #!/usr/bin/env python 
 2  # -*- coding: utf-8 -*- 
 3  # 
 4  # This file is part of MBDyn sim suite. 
 5  # Copyright (C) 2007 André ESPAZE, as part of a Master thesis supervised by 
 6  # Martin O.L.Hansen (DTU) and Nicolas Chauvat (Logilab) 
 7   
 8  # MBDyn sim suite is free software; you can redistribute it and/or modify 
 9  # it under the terms of the GNU General Public License as published by 
10  # the Free Software Foundation; either version 2 of the License, or 
11  # (at your option) any later version. 
12  # 
13  # This program is distributed in the hope that it will be useful, 
14  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
16  # GNU General Public License for more details. 
17  # 
18  # You should have received a copy of the GNU General Public License 
19  # along with this program; if not, write to the Free Software 
20  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
21  # 
22  """The blade defined in a graphical environment""" 
23  import gtk 
24   
25  from windSimSuite.blade import Blade as BladeBase 
26   
27  from windSimSuite.interface.common import WithNodesAndElemsMenu 
28  from windSimSuite.interface.common import GobjectWithNodesAndElems 
29   
30  from windSimSuite.interface.sections import Section 
31   
32  from mbdyn.interface.nodes import NODE_CLASS 
33   
34  # Common description, shared with the blade 
35  PYLAB_ROTOR_DESC = [\ 
36  ("power", "_Plot _Power"), 
37  ("torque", "_Plot _Torque"), 
38  ("tangential_force", "_Plot _Tangential _Force"), 
39  ("normal_force", "_Plot _Normal _Force"), 
40  ("coupling_torque", "_Plot _Coupling _Torque"), 
41  ] 
42   
43  PYLAB_ROTOR_DESC.append(("plot_pressures", "_Plot _current _Pressures")) 
44   
45  PYLAB_ROTOR = [] 
46  for key, string in PYLAB_ROTOR_DESC: 
47      PYLAB_ROTOR.append((key, gtk.MenuItem(string))) 
48   
49  DESC = {} 
50   
51  DESC["pylab"] = PYLAB_ROTOR  
52   
53   
54 -class BladeMenu(WithNodesAndElemsMenu):
55 """The blade menu 56 """ 57
58 - def __init__(self):
59 WithNodesAndElemsMenu.__init__(self, build=False) 60 for dkey in DESC.keys(): 61 self.add_items(dkey, DESC[dkey]) 62 self.build()
63 64
65 -class Blade(BladeBase, GobjectWithNodesAndElems):
66 """A blade able to display its results in GTK. 67 """ 68
69 - def __init__(self, idx=0):
70 BladeBase.__init__(self, idx) 71 GobjectWithNodesAndElems.__init__(self) 72 self.set_node_class(NODE_CLASS) 73 self.menu_type = "blade"
74
75 - def init_from_loaded_file(self):
76 """Init the available results from the file""" 77 if self.save_pressures: 78 self.feature_keys.append("plot_pressures") 79 self.common_init_from_loaded_file()
80
81 - def display_on(self, gtk_tree, giter):
82 """Display the blade on the GTK treeview""" 83 self.display_nodes_on(gtk_tree, giter) 84 for section in self.sections: 85 child_giter = gtk_tree.get_from(giter) 86 gtk_tree.add_at(child_giter, section)
87
88 - def set_parameters(self, para):
89 """The section will have C{Section} instances that 90 can interact with GTK""" 91 self.set_own_parameters(para) 92 self.set_node_parameters() 93 self.set_elt_parameters() 94 for section_para in self.section_paras: 95 section = Section() 96 section.set_parameters(section_para) 97 self.sections.append(section)
98