/[escript]/trunk/pyvisi/py_src/common.py
ViewVC logotype

Contents of /trunk/pyvisi/py_src/common.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 835 - (show annotations)
Mon Sep 4 22:20:28 2006 UTC (14 years, 2 months ago) by jongui
File MIME type: text/x-python
File size: 1926 byte(s)
Added more docstrings and updated the way positions, focal point and view angle are specified.


1 """
2 Class that defines the common operations invoked by the components.
3 """
4
5 import vtk
6
7 class Common:
8 """
9 @author: John Ngui
10 @author: Lutz Gross
11 """
12
13 def __init__(self, open_scene, data_collector):
14 """
15 Initialize all the instance variables.
16
17 @type open_scene: L{OpenScene <openscene.OpenScene>} object
18 @param open_scene: Scene in which components are to be added to
19 @type data_collector: L{DataCollector <datacollector.DataCollector>}
20 object
21 @param data_collector: Source of data for visualization
22 """
23
24 self.open_scene = open_scene
25 self.data_collector = data_collector
26 self.vtk_mapper = None
27 self.vtk_actor = None
28
29 def setMapper(self, component):
30 """
31 Set up the mapper and its input.
32
33 @type component: String
34 @param component: Component to be mapped
35 """
36
37 self.vtk_mapper = vtk.vtkDataSetMapper()
38 eval("self.vtk_mapper.SetInput(%s)" % component)
39
40 def setActor(self):
41 """
42 Set up the actor and its mapper.
43 """
44
45 self.vtk_actor = vtk.vtkActor()
46 self.vtk_actor.SetMapper(self.vtk_mapper)
47
48 def addActor(self):
49 """
50 Add the actor to the renderer.
51 """
52
53 self.open_scene.getRenderer().AddActor(self.vtk_actor)
54
55 def setOpacity(self, opacity):
56 """
57 Set the opacity (transparency) of the actor.
58
59 @type opacity: Number
60 @param opacity: Opacity (transparency) of the actor
61 """
62
63 self.getProperty().SetOpacity(opacity)
64
65 def setColor(self, red, green, blue):
66 self.getProperty().SetColor(red, green, blue)
67
68 def setRepresentation(self, representation):
69 """
70 Set the representation of the actor.
71
72 @type representation: String
73 @param representation: Representation type (I{i.e. Wireframe})
74 """
75
76 eval("self.getProperty().SetRepresentationTo%s()" % representation)
77
78 def getProperty(self):
79 """
80 Return the property of the actor.
81
82 @rtype: vtkProperty
83 @return: VTK property
84 """
85
86 return self.vtk_actor.GetProperty()
87
88
89 class Component:
90 pass

  ViewVC Help
Powered by ViewVC 1.1.26