1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 """The rotor and hub definition in a graphical environment.
23 """
24 import gtk
25
26 from mbdyn.interface.nodes import NODE_CLASS
27 from mbdyn.interface.common import BaseMenu
28
29 from windSimSuite.interface.common import WithNodesAndElemsMenu
30 from windSimSuite.interface.common import GobjectBase, GobjectWithNodesAndElems
31
32 from windSimSuite.rotor import Rotor as RotorBase
33 from windSimSuite.rotor import Hub as HubBase
34
35 from windSimSuite.interface.blade import Blade, PYLAB_ROTOR_DESC
36
38 """The hub menu"""
39 pass
40
41 -class Hub(HubBase, GobjectWithNodesAndElems):
42 """The GTK hub.
43 """
44
50
51 DESC = {}
52
53 DESC["vtk"] = [\
54 ("blades_visibility", gtk.CheckMenuItem("_Show _blades"))
55 ]
56
57 PYLAB_ROTOR = []
58
59 for key, display in PYLAB_ROTOR_DESC:
60 PYLAB_ROTOR.append((key, gtk.MenuItem(display)))
61
62 PYLAB_EXTRA = [\
63 ("electrical_power", "_Plot _Elec _Power"),
64 ("rotational_speed_value", "_Plot _Rotational _Speed"),
65 ("electrical_torque", "_Plot _Elec _Torque")
66 ]
67
68 for key, display in PYLAB_EXTRA:
69 PYLAB_ROTOR.append((key, gtk.MenuItem(display)))
70
71 DESC["pylab"] = PYLAB_ROTOR
72
73
75 """The rotor menu
76 """
77
80
81
82 -class Rotor(RotorBase, GobjectBase):
83 """The GTK rotor. As in its original defintion,
84 in charge to manipulate the L{Hub} and the
85 L{Blade<windSimSuite.interface.blade.Blade>} instances.
86 """
87
89 RotorBase.__init__(self)
90 GobjectBase.__init__(self)
91 self.menu_type = "rotor"
92
93 self.feature_keys = []
94 self.boolean = {}
95
97 """Display the rotor on the GTK treeview for
98 the wind turbine"""
99 if self.has_hub:
100 child_giter = gtk_tree.get_from(giter)
101 gtk_tree.add_at(child_giter, self.hub)
102 self.hub.display_on(gtk_tree, child_giter)
103
104 for blade in self.blades:
105 child_giter = gtk_tree.get_from(giter)
106 gtk_tree.add_at(child_giter, blade)
107 blade.display_on(gtk_tree, child_giter)
108
110 """Make the rotor aware of its available results"""
111 self.feature_keys = self.results.names
112 for feature_key in self.feature_keys:
113 self.boolean[feature_key] = False
114
115 if self.has_hub:
116 self.hub.init_from_loaded_file()
117 for blade in self.blades:
118 blade.init_from_loaded_file()
119
120
121 for blade in self.blades:
122 if "nodes_visibility" in blade.feature_keys:
123 if blade.boolean["nodes_visibility"]:
124 self.boolean["blades_visibility"] = True
125 break
126
127
129 """Show the MBDyn items describing the blade"""
130 for blade in self.blades:
131 if not blade.boolean["nodes_visibility"]:
132 blade.activate_nodes_visibility(current_frame_id, vtk_area)
133 self.boolean["blades_visibility"] = True
134 return "Show all blade nodes of %s" % self.name
135
137 """Hide the MBDyn items describing the blade"""
138 for blade in self.blades:
139 if blade.boolean["nodes_visibility"]:
140 blade.desactivate_nodes_visibility(vtk_area)
141 self.boolean["blades_visibility"] = False
142 return "Hide all blade nodes of %s" % self.name
143
145 """Set C{Hub} and C{Blade} instances suited for
146 a graphical user interface."""
147 self.set_own_parameters(para)
148 if self.has_hub:
149 self.hub = Hub()
150 self.hub.set_parameters(self.hub_para)
151 for blade_para in self.blade_paras:
152 blade = Blade()
153 blade.set_parameters(blade_para)
154 self.blades.append(blade)
155