| Home | Trees | Indices | Help |
|---|
|
|
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 figures manager. This part is supposed to allocate
23 new pages when a new figure is requested, however
24 the plot action will be achieved in the L{windSimSuite.interface.figures}.
25 """
26 import gtk
27 import sys
28
29 import matplotlib
30 matplotlib.use('GTK')
31 from matplotlib.figure import Figure as FigureBase
32 from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg
33 from matplotlib.backends.backend_gtk import NavigationToolbar2GTK
34
35 from windSimSuite.interface.figures import PLOT_TABLE
36
37
39 """The menu for removing a tab
40 """
41
43 gtk.Menu.__init__(self)
44 self.item = gtk.ImageMenuItem(gtk.STOCK_REMOVE)
45 self.item.show()
46 self.append(self.item)
47
49 """Set the callback action when the remove button is activated"""
50 self.item.connect("activate", callback)
51
55
56
65
66
68 """The page for a new figure. This class inherits
69 from a VBox because the figure and the Matplotlib toolbar need
70 to be packed.
71 """
72
74 gtk.VBox.__init__(self)
75 self.status = ""
76 self.tab_label = gtk.Label()
77
78 self.event_box = gtk.EventBox()
79 self.event_box.add(self.tab_label)
80 self.event_box.connect("button-press-event", manager_callback)
81
83 """Plot the figure by calling an action contained
84 in the C{PLOT_TABLE} from the L{windSimSuite.interface.figures}."""
85 fig = Figure()
86 PLOT_TABLE[prop_key](fig, obj, simu)
87
88 self.tab_label.set_text(fig.tab_name)
89
90 self._insert_figure(fig, window_ref)
91 self._show_all()
92 self.status = "Done for '%s'" % fig.tab_name
93
95 """Insert the new figure in gtk"""
96 canvas = FigureCanvasGTKAgg(fig)
97 canvas.show()
98 self.pack_start(canvas, True, True)
99
100 toolbar = NavigationToolbar2GTK(canvas, window_ref)
101 self.pack_start(toolbar, False, False)
102
107
108
110 """The figure manager. It will receive instructions
111 from the C{Manager} in the
112 L{windSimSuite.interface.manager} module and assure to open
113 a new page for a new figure in the notebook when
114 its L{plot} method is called.
115 """
116
118 self.notebook = notebook
119 self.status_bar = status_bar
120 self.window_ref = None
121
122 self.menu = ManagerMenu()
123 self.menu.remove_callback(self.remove_page)
124
125 self.pages = []
126 self.event_box = None
127 self.event_boxes = []
128
132
134 """When a right click is done on the page label, this
135 is the callaback of the manager."""
136 if event.button == 3:
137 self.event_box = event_box
138 self.menu.custom_popup(event)
139 return True
140 else:
141 return False
142
144 """Remove a page from the notebook"""
145 page_id = self.event_boxes.index(self.event_box)
146 # The VTK area in the first tab must not be suppressed
147 self.notebook.remove_page(page_id + 1)
148 # Keep the focus on the following page
149 if self.notebook.get_n_pages() > 1:
150 self.notebook.set_current_page(page_id + 1)
151 # Update the list
152 self.event_boxes.remove(self.event_box)
153 self.pages.remove(self.pages[page_id])
154
156 """Add a new page by receiving a L{FigurePage} instance."""
157 self.pages.append(figure_page)
158 self.event_boxes.append(figure_page.event_box)
159
160 self.notebook.append_page(figure_page,
161 figure_page.event_box)
162 self.notebook.set_current_page(-1)
163
165 """The method called from the C{Manager} when the user
166 has chosen a plotting action on an object."""
167 fig_page = FigurePage(self.manager_callback)
168 fig_page.plot(prop_key, obj, simu, self.window_ref)
169 self._add(fig_page)
170 return fig_page.status
171
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0beta1 on Thu Aug 30 16:31:04 2007 | http://epydoc.sourceforge.net |