1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 """The common graphical objects. Used for every wind turbine object
23 that need to deal with the graphical user interface."""
24 from mbdyn.interface.common import BaseMenu
25
26 DESC = {}
27
28 DESC["vtk"] = [\
29 ("nodes_visibility", "_Show _nodes")
30 ]
31
33 """A menu for an object with nodes
34 and elements
35 """
36
38 BaseMenu.__init__(self)
39 self.add_items("vtk", DESC["vtk"])
40 if build:
41 self.build()
42
43
45 """The base of a graphical object. It is able
46 to activate or desactivate a feature from the
47 VTK area.
48 """
49
55
56 - def activate(self, feature_key, current_frame_id, vtk_area):
57 """Activate a feature on the object. The corresponding
58 method will be called"""
59 return getattr(self, "activate_" + feature_key)(current_frame_id,
60 vtk_area)
61
63 """Deactivate a feature on the object. The corresponding
64 method will be called"""
65 return getattr(self, "desactivate_" + feature_key)(vtk_area)
66
67
69 """For an abstrat turbine object manipulating nodes and elements.
70 The common methods are resumed in this class.
71 """
72
81
83 """Make the component aware of its own results"""
84 for feature in self.results.names:
85 self.feature_keys.append(feature)
86 for feature_key in self.feature_keys:
87 self.boolean[feature_key] = False
88
89
90 for node in self.nodes:
91 if "position" in node.feature_keys:
92 if node.boolean["position"]:
93 self.boolean["nodes_visibility"] = True
94 break
95
100
102 """Display the nodes object on the GTK treeview"""
103 self.display_nodes_on(gtk_tree, giter)
104
106 """Display the nodes on the GTK treeview"""
107 for node in self.nodes:
108 child_giter = gtk_tree.get_from(giter)
109 gtk_tree.add_at(child_giter, node)
110
112 """Show the nodes position"""
113 for node in self.nodes:
114 if not node.boolean["visibility"]:
115 node.activate_visibility(current_frame_id, vtk_area)
116 self.boolean["nodes_visibility"] = True
117 return "Show all nodes of %s" % self.name
118
120 """Hide the nodes position"""
121 for node in self.nodes:
122 if node.boolean["visibility"]:
123 node.desactivate_visibility(vtk_area)
124 self.boolean["nodes_visibility"] = False
125 return "Hide all nodes of %s" % self.name
126