1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 """Describe the main wind-sim-suite application"""
23 import gtk
24 import gtk.glade as glade
25 import gobject
26
27 import os
28
29 from windSimSuite.interface.manager import Manager
30
31 PREFIX_FILE = os.path.dirname(__file__)
32
33 import sys
34 if getattr(sys, 'frozen', None):
35 PREFIX_FILE = sys.path[0]
36 del sys
37
38 GLADE_FILE = os.path.join(PREFIX_FILE, "interface.glade")
39
40
42 """A base class for the window of that application.
43 Each window will be described inside a glade file, so
44 its part of the glade file and the wigdet
45 will be set as attributes. Moreover any item could
46 be got from its glade name.
47 """
48
50 self.xml = glade.XML(GLADE_FILE, window_name)
51 self.win = self.xml.get_widget(window_name)
52 self.win.hide()
53
54
55 - def hide(self, *args):
56 """Hide the window"""
57 self.win.hide()
58
60 """Do not destroy the window"""
61 self.win.hide()
62 return True
63
65 """Return a widget from its glade key"""
66 return self.xml.get_widget(key)
67
68
70 """The file chooser dialog
71 """
72
75
77 """Show the dialog and return a filename or None"""
78 resp = self.win.run()
79 if resp == gtk.RESPONSE_OK:
80
81 filename = self.win.get_filename()
82 self.win.destroy()
83 return filename
84 else:
85 self.win.destroy()
86
87 return None
88
89
91 """The window about the application
92 """
93
95 from windSimSuite import __version__
96 gtk.AboutDialog.__init__(self)
97 self.set_name("Wind Sim Suite")
98 self.set_version(__version__)
99
100 self.set_authors(self._build_credits())
101 self.set_website("http://mbdynsimsuite.sourceforge.net/")
102
103 self.set_license("GPL version 2 or later")
104 self.set_wrap_license(True)
105
106 self.set_comments("Based on MBDyn 1.2.7")
107
121
122
124 """The width an height of the screen
125 """
126
130
132 """Return the screen width as an integer"""
133 return int(value * self.width)
134
136 """Return the screen height as an integer"""
137 return int(value * self.height)
138
139
141 """The wind sim suite application
142 """
143
145 CommonWindow.__init__(self, "application")
146
147 handlers = {
148 "on_application_destroy" : gtk.main_quit,
149
150 "on_dialog_open_activate" : self.load_file,
151 "on_tjaereborg_activate" : self.load_tjaerborg,
152 "on_nrel_activate" : self.load_nrel,
153 "on_quit_activate" : gtk.main_quit,
154
155 "on_show_animation_toolbar_activate" : self.show_animation_toolbar,
156 "on_windturbine_tree_activate" : (self.select_treeview,
157 ["turbine"]),
158 "on_mbdyn_tree_activate" : (self.select_treeview, ["mbdyn"]),
159 "on_both_trees_activate" : (self.select_treeview,
160 ["turbine", "mbdyn"]),
161 "on_scale_table_activate" : self.show_scale_table,
162 "on_absolute_ref_activate" : self.show_absolute_ref,
163 "on_notebook_tab_activate" : self.show_notebook_tab,
164
165 "on_stop_task_clicked" : self.stop_current_task,
166
167 "on_about_activate" : self.show_about_window
168 }
169 self.xml.signal_autoconnect(handlers)
170
171 self.screen_info = ScreenInfo(self.win.get_screen())
172 self["hpaned"].set_position(self.screen_info.get_width(0.2))
173 self.win.resize(self.screen_info.get_width(0.8),
174 self.screen_info.get_height(0.8))
175 self.win.move(0, 20)
176
177
178 self.dialog_open = FileChooserDialog()
179
180 self.manager = Manager(self)
181 self["gvtk_box"].pack_start(self.manager.vtk_area)
182 self["scrolledwindow_turbine"].add(self.manager.treeview["turbine"])
183 self["scrolledwindow_mbdyn"].add(self.manager.treeview["mbdyn"])
184
185 self.task_id = None
186
187 self.about_window = AboutWindow()
188
189 self.win.show()
190 self.manager.vtk_area.show()
191
199
205
211
213 """Stop the loading task"""
214 gobject.source_remove(self.task_id)
215 self["task_box"].hide()
216
223
225 """Select which object treeview to display"""
226 if radio_menu_item.get_active():
227 for key in keys:
228 self["scrolledwindow_%s" % key].show()
229 else:
230 for key in keys:
231 self["scrolledwindow_%s" % key].hide()
232
234 """Show or hide the table for entering the scale factor"""
235 if check_item.get_active():
236 self.manager.scale_table.show()
237 else:
238 self.manager.scale_table.hide()
239
246
248 """Show or hide the notebok table"""
249 if check_item.get_active():
250 self.manager.notebook.set_show_tabs(True)
251 else:
252 self.manager.notebook.set_show_tabs(False)
253
255 """Show the about window"""
256 resp = self.about_window.run()
257 self.about_window.hide()
258
260 """Run the main application. Always wait an
261 event from the user"""
262 gtk.main()
263