Package mbdyn :: Package interface :: Module application
[hide private]

Source Code for Module mbdyn.interface.application

 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  """A small application to show a geometry. This module is finally 
23  just a draft, used for some examples and research.""" 
24  import vtk 
25  import gtk 
26  from mbdyn.interface.renderWindowInteractor import GtkRenderWindowInteractor 
27   
28   
29 -class ShowGeometry:
30 """An application supposed to show a MBDyn geometry 31 """ 32
33 - def __init__(self):
34 self.window = gtk.Window() 35 self.window.set_size_request(500, 500) 36 self.window.set_border_width(10) 37 self.window.connect("destroy", gtk.main_quit) 38 39 box = gtk.VBox() 40 box.show() 41 42 self.renderer = vtk.vtkRenderer() 43 self.renderer.SetBackground(1., 1., 1.) 44 self.win_interactor = GtkRenderWindowInteractor() 45 self.win_interactor.GetRenderWindow().AddRenderer(self.renderer) 46 self.win_interactor.Initialize() 47 self.win_interactor.Start() 48 box.pack_start(self.win_interactor, True, True) 49 50 button = gtk.Button("Start render") 51 button.connect("clicked", self.start_render) 52 button.show() 53 box.pack_start(button, False, False) 54 55 self.window.add(box)
56
57 - def start_render(self, *args):
58 """Start the VTK Render, supposed to be defined by the user""" 59 print "Heritates from the class ShowGeometry " + \ 60 "to start what you want here"
61
62 - def run(self):
63 """Run the application""" 64 gtk.main()
65