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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26