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

Source Code for Module mbdyn.interface.references

 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 reference frames described for VTK.""" 
23  from mbdyn.references import ReferenceFrame as ReferenceFrameBase 
24   
25  from mbdyn.interface.common import BaseMenu 
26  from mbdyn.interface.vectors import ReferenceFrame as VtkReferenceFrame 
27   
28  DESC = {} 
29   
30  DESC["vtk"] = [\ 
31  ("visibility", "_Show") 
32  ] 
33   
34 -class ReferenceFrameMenu(BaseMenu):
35 """The reference frame menu 36 """ 37
38 - def __init__(self):
39 BaseMenu.__init__(self) 40 self.add_vtk_items(DESC["vtk"]) 41 self.build()
42 43
44 -class ReferenceFrame(ReferenceFrameBase):
45 """A reference frame based in a VTK environment 46 """ 47
48 - def __init__(self):
49 ReferenceFrameBase.__init__(self) 50 self.vtk_ref = VtkReferenceFrame() 51 52 self.menu_type = "reference_frame" 53 54 self.feature_keys = ["visibility"] 55 self.boolean = {} 56 self.boolean["visibility"] = False
57
58 - def set_unit_arrow(self, unit_arrow):
59 """Set the arrow mapper representing a unit vector""" 60 for axe in self.vtk_ref.axes: 61 axe.set_arrow(unit_arrow)
62
63 - def activate(self, key_feature, current_frame_id, vtk_area):
64 """Show the reference frame""" 65 res = self.results 66 self.vtk_ref.set_position(res.position[0]) 67 self.vtk_ref.set_orientation_matrix(res.orientation_matrix[0]) 68 69 for axe in self.vtk_ref.axes: 70 vtk_area.add_actor(axe.actor) 71 self.boolean["visibility"] = True 72 return "Show %s reference" % self.name
73
74 - def desactivate(self, key_feature, vtk_area):
75 """Hide the reference frame""" 76 for axe in self.vtk_ref.axes: 77 vtk_area.remove_actor(axe.actor) 78 self.boolean["visibility"] = False 79 return "Hide %s reference" % self.name
80