1 |
gross |
802 |
""" |
2 |
jongui |
839 |
@author: John Ngui |
3 |
|
|
@author: Lutz Gross |
4 |
gross |
802 |
""" |
5 |
|
|
|
6 |
jongui |
827 |
import vtk |
7 |
gross |
802 |
|
8 |
jongui |
828 |
class Common: |
9 |
jongui |
835 |
""" |
10 |
jongui |
839 |
Class that defines the common operations invoked by the components. |
11 |
jongui |
835 |
""" |
12 |
gross |
802 |
|
13 |
jongui |
845 |
def __init__(self, scene, data_collector = None): |
14 |
jongui |
835 |
""" |
15 |
|
|
Initialize all the instance variables. |
16 |
|
|
|
17 |
jongui |
845 |
@type scene: L{Scene <scene.Scene>} object |
18 |
jongui |
839 |
@param scene: Scene in which components are to be added to |
19 |
jongui |
835 |
@type data_collector: L{DataCollector <datacollector.DataCollector>} |
20 |
|
|
object |
21 |
|
|
@param data_collector: Source of data for visualization |
22 |
|
|
""" |
23 |
|
|
|
24 |
jongui |
839 |
self.scene = scene |
25 |
jongui |
828 |
self.data_collector = data_collector |
26 |
jongui |
849 |
self.vtk_mapper = vtk.vtkDataSetMapper() |
27 |
|
|
self.vtk_actor = vtk.vtkActor() |
28 |
gross |
802 |
|
29 |
jongui |
849 |
def setMapperInput(self, component, lut = None): |
30 |
jongui |
835 |
""" |
31 |
|
|
Set up the mapper and its input. |
32 |
|
|
|
33 |
|
|
@type component: String |
34 |
|
|
@param component: Component to be mapped |
35 |
jongui |
839 |
@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 |
jongui |
835 |
""" |
39 |
|
|
|
40 |
jongui |
849 |
self.vtk_mapper.SetInput(component) |
41 |
|
|
#eval("self.vtk_mapper.SetInput(%s)" % component) |
42 |
jongui |
839 |
|
43 |
|
|
if(lut != None): |
44 |
|
|
self.vtk_mapper.SetLookupTable(lut.getLut()) |
45 |
gross |
802 |
|
46 |
jongui |
849 |
def setMapperTexture(self, texture): |
47 |
jongui |
835 |
""" |
48 |
jongui |
846 |
Set the texture of the actor. |
49 |
|
|
|
50 |
|
|
@type texture: vtkTexture |
51 |
|
|
@param texture: Texture map of the image |
52 |
|
|
""" |
53 |
jongui |
845 |
self.vtk_actor.SetTexture(texture) |
54 |
|
|
|
55 |
jongui |
849 |
def setActorInput(self): |
56 |
|
|
""" |
57 |
|
|
Set up the actor and its mapper. |
58 |
|
|
""" |
59 |
|
|
self.vtk_actor.SetMapper(self.vtk_mapper) |
60 |
|
|
|
61 |
|
|
|
62 |
jongui |
828 |
def addActor(self): |
63 |
jongui |
835 |
""" |
64 |
|
|
Add the actor to the renderer. |
65 |
|
|
""" |
66 |
|
|
|
67 |
jongui |
839 |
self.scene.getRenderer().AddActor(self.vtk_actor) |
68 |
jongui |
828 |
|
69 |
jongui |
849 |
def setActorOpacity(self, opacity): |
70 |
jongui |
835 |
""" |
71 |
|
|
Set the opacity (transparency) of the actor. |
72 |
|
|
|
73 |
|
|
@type opacity: Number |
74 |
|
|
@param opacity: Opacity (transparency) of the actor |
75 |
|
|
""" |
76 |
|
|
|
77 |
jongui |
849 |
self.vtk_actor.GetProperty().SetOpacity(opacity) |
78 |
jongui |
828 |
|
79 |
jongui |
849 |
def setActorColor(self, color): |
80 |
|
|
self.vtk_actor.GetProperty().SetColor(color[0], color[1], |
81 |
|
|
color[2]) |
82 |
jongui |
828 |
|
83 |
jongui |
849 |
def setActorRepresentation(self, representation): |
84 |
jongui |
835 |
""" |
85 |
|
|
Set the representation of the actor. |
86 |
|
|
|
87 |
|
|
@type representation: String |
88 |
|
|
@param representation: Representation type (I{i.e. Wireframe}) |
89 |
|
|
""" |
90 |
|
|
|
91 |
jongui |
849 |
eval("self.vtk_actor.GetProperty().SetRepresentationTo%s()" % |
92 |
|
|
representation) |
93 |
jongui |
828 |
|
94 |
jongui |
835 |
|
95 |
|
|
class Component: |
96 |
|
|
pass |