1 |
""" |
""" |
2 |
Class that defines the common operations invoked by the components. |
|
3 |
|
@author: John Ngui |
4 |
|
@author: Lutz Gross |
5 |
""" |
""" |
6 |
|
|
7 |
import vtk |
import vtk |
8 |
|
|
9 |
class Common: |
class Common: |
10 |
""" |
""" |
11 |
@author: John Ngui |
Class that defines the common operations invoked by the components. |
|
@author: Lutz Gross |
|
12 |
""" |
""" |
13 |
|
|
14 |
def __init__(self, open_scene, data_collector): |
def __init__(self, scene, data_collector): |
15 |
""" |
""" |
16 |
Initialize all the instance variables. |
Initialize all the instance variables. |
17 |
|
|
18 |
@type open_scene: L{OpenScene <openscene.OpenScene>} object |
@type scene: L{OpenScene <scene.Scene>} object |
19 |
@param open_scene: Scene in which components are to be added to |
@param scene: Scene in which components are to be added to |
20 |
@type data_collector: L{DataCollector <datacollector.DataCollector>} |
@type data_collector: L{DataCollector <datacollector.DataCollector>} |
21 |
object |
object |
22 |
@param data_collector: Source of data for visualization |
@param data_collector: Source of data for visualization |
23 |
""" |
""" |
24 |
|
|
25 |
self.open_scene = open_scene |
self.scene = scene |
26 |
self.data_collector = data_collector |
self.data_collector = data_collector |
27 |
self.vtk_mapper = None |
self.vtk_mapper = None |
28 |
self.vtk_actor = None |
self.vtk_actor = None |
29 |
|
|
30 |
def setMapper(self, component): |
def setMapper(self, component, lut = None): |
31 |
""" |
""" |
32 |
Set up the mapper and its input. |
Set up the mapper and its input. |
33 |
|
|
34 |
@type component: String |
@type component: String |
35 |
@param component: Component to be mapped |
@param component: Component to be mapped |
36 |
|
@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 |
""" |
""" |
40 |
|
|
41 |
self.vtk_mapper = vtk.vtkDataSetMapper() |
self.vtk_mapper = vtk.vtkDataSetMapper() |
42 |
eval("self.vtk_mapper.SetInput(%s)" % component) |
eval("self.vtk_mapper.SetInput(%s)" % component) |
43 |
|
|
44 |
|
if(lut != None): |
45 |
|
self.vtk_mapper.SetLookupTable(lut.getLut()) |
46 |
|
|
47 |
def setActor(self): |
def setActor(self): |
48 |
""" |
""" |
57 |
Add the actor to the renderer. |
Add the actor to the renderer. |
58 |
""" |
""" |
59 |
|
|
60 |
self.open_scene.getRenderer().AddActor(self.vtk_actor) |
self.scene.getRenderer().AddActor(self.vtk_actor) |
61 |
|
|
62 |
def setOpacity(self, opacity): |
def setOpacity(self, opacity): |
63 |
""" |
""" |