/[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 839 - (show annotations)
Wed Sep 6 04:53:50 2006 UTC (14 years, 9 months ago) by jongui
File MIME type: text/x-python
File size: 2124 byte(s)
- Added lookup table spectrum from blue to red and red to blue.
- Updated open scene to scene

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

  ViewVC Help
Powered by ViewVC 1.1.26