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 |
|
|
self.vtk_mapper = None |
27 |
|
|
self.vtk_actor = None |
28 |
gross |
802 |
|
29 |
jongui |
839 |
def setMapper(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 |
827 |
self.vtk_mapper = vtk.vtkDataSetMapper() |
41 |
jongui |
828 |
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 |
828 |
def setActor(self): |
47 |
jongui |
835 |
""" |
48 |
|
|
Set up the actor and its mapper. |
49 |
|
|
""" |
50 |
|
|
|
51 |
jongui |
828 |
self.vtk_actor = vtk.vtkActor() |
52 |
|
|
self.vtk_actor.SetMapper(self.vtk_mapper) |
53 |
|
|
|
54 |
jongui |
845 |
def setTexture(self, texture): |
55 |
|
|
self.vtk_actor.SetTexture(texture) |
56 |
|
|
|
57 |
jongui |
828 |
def addActor(self): |
58 |
jongui |
835 |
""" |
59 |
|
|
Add the actor to the renderer. |
60 |
|
|
""" |
61 |
|
|
|
62 |
jongui |
839 |
self.scene.getRenderer().AddActor(self.vtk_actor) |
63 |
jongui |
828 |
|
64 |
|
|
def setOpacity(self, opacity): |
65 |
jongui |
835 |
""" |
66 |
|
|
Set the opacity (transparency) of the actor. |
67 |
|
|
|
68 |
|
|
@type opacity: Number |
69 |
|
|
@param opacity: Opacity (transparency) of the actor |
70 |
|
|
""" |
71 |
|
|
|
72 |
jongui |
828 |
self.getProperty().SetOpacity(opacity) |
73 |
|
|
|
74 |
|
|
def setColor(self, red, green, blue): |
75 |
|
|
self.getProperty().SetColor(red, green, blue) |
76 |
|
|
|
77 |
|
|
def setRepresentation(self, representation): |
78 |
jongui |
835 |
""" |
79 |
|
|
Set the representation of the actor. |
80 |
|
|
|
81 |
|
|
@type representation: String |
82 |
|
|
@param representation: Representation type (I{i.e. Wireframe}) |
83 |
|
|
""" |
84 |
|
|
|
85 |
jongui |
828 |
eval("self.getProperty().SetRepresentationTo%s()" % representation) |
86 |
|
|
|
87 |
|
|
def getProperty(self): |
88 |
jongui |
835 |
""" |
89 |
|
|
Return the property of the actor. |
90 |
|
|
|
91 |
|
|
@rtype: vtkProperty |
92 |
|
|
@return: VTK property |
93 |
|
|
""" |
94 |
|
|
|
95 |
jongui |
828 |
return self.vtk_actor.GetProperty() |
96 |
|
|
|
97 |
jongui |
827 |
|
98 |
jongui |
835 |
class Component: |
99 |
|
|
pass |