/[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 847 - (show annotations)
Thu Sep 14 07:54:04 2006 UTC (14 years ago) by jongui
File MIME type: text/x-python
File size: 2316 byte(s)
Added vtkTextProperty to control the style of text and partially completed the carpet module.

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

  ViewVC Help
Powered by ViewVC 1.1.26