/[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 835 - (hide annotations)
Mon Sep 4 22:20:28 2006 UTC (14 years, 5 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 gross 802 """
2 jongui 835 Class that defines the common operations invoked by the components.
3 gross 802 """
4    
5 jongui 827 import vtk
6 gross 802
7 jongui 828 class Common:
8 jongui 835 """
9     @author: John Ngui
10     @author: Lutz Gross
11     """
12 gross 802
13 jongui 828 def __init__(self, open_scene, data_collector):
14 jongui 835 """
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 jongui 828 self.open_scene = open_scene
25     self.data_collector = data_collector
26     self.vtk_mapper = None
27     self.vtk_actor = None
28 gross 802
29 jongui 827 def setMapper(self, component):
30 jongui 835 """
31     Set up the mapper and its input.
32    
33     @type component: String
34     @param component: Component to be mapped
35     """
36    
37 jongui 827 self.vtk_mapper = vtk.vtkDataSetMapper()
38 jongui 828 eval("self.vtk_mapper.SetInput(%s)" % component)
39 gross 802
40 jongui 828 def setActor(self):
41 jongui 835 """
42     Set up the actor and its mapper.
43     """
44    
45 jongui 828 self.vtk_actor = vtk.vtkActor()
46     self.vtk_actor.SetMapper(self.vtk_mapper)
47    
48     def addActor(self):
49 jongui 835 """
50     Add the actor to the renderer.
51     """
52    
53 jongui 828 self.open_scene.getRenderer().AddActor(self.vtk_actor)
54    
55     def setOpacity(self, opacity):
56 jongui 835 """
57     Set the opacity (transparency) of the actor.
58    
59     @type opacity: Number
60     @param opacity: Opacity (transparency) of the actor
61     """
62    
63 jongui 828 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 jongui 835 """
70     Set the representation of the actor.
71    
72     @type representation: String
73     @param representation: Representation type (I{i.e. Wireframe})
74     """
75    
76 jongui 828 eval("self.getProperty().SetRepresentationTo%s()" % representation)
77    
78     def getProperty(self):
79 jongui 835 """
80     Return the property of the actor.
81    
82     @rtype: vtkProperty
83     @return: VTK property
84     """
85    
86 jongui 828 return self.vtk_actor.GetProperty()
87    
88 jongui 827
89 jongui 835 class Component:
90     pass

  ViewVC Help
Powered by ViewVC 1.1.26