1 |
""" |
2 |
@author: John Ngui |
3 |
@author: Lutz Gross |
4 |
""" |
5 |
|
6 |
import vtk |
7 |
|
8 |
class Light: |
9 |
""" |
10 |
Class that controls the light and its settings. |
11 |
""" |
12 |
|
13 |
def __init__(self, scene, data_collector): |
14 |
""" |
15 |
@type scene: L{Scene <scene.Scene>} object |
16 |
@param scene: Scene in which components are to be added to |
17 |
@type data_collector: L{DataCollector <datacollector.DataCollector>} |
18 |
object |
19 |
@param data_collector: Source of data for visualization |
20 |
""" |
21 |
|
22 |
self.scene = scene |
23 |
self.data_collector = data_collector |
24 |
self.vtk_light = vtk.vtkLight() |
25 |
|
26 |
self.setLight() |
27 |
|
28 |
def setLight(self): |
29 |
""" |
30 |
Set up the light and associate it with the renderer. |
31 |
""" |
32 |
self.scene.getRenderer().AddLight(self.vtk_light) |
33 |
|
34 |
def setColor(self, color): |
35 |
""" |
36 |
Set the light color. |
37 |
@type color: RGB list |
38 |
@param color: Color of the light |
39 |
""" |
40 |
|
41 |
self.vtk_light.SetColor(color[0], color[1], color[2]) |
42 |
|
43 |
def setFocalPoint(self, position): |
44 |
""" |
45 |
Set the focal point of the light. |
46 |
@type position: L{Position <geo.Position>} object |
47 |
@param position: Light focal point |
48 |
""" |
49 |
|
50 |
self.vtk_light.SetFocalPoint(position.getXCoor(), position.getYCoor(), |
51 |
position.getZCoor()) |
52 |
|
53 |
def setPosition(self, position): |
54 |
""" |
55 |
Set the position of the light. |
56 |
@type position: L{Position <geo.Position>} object |
57 |
@param position: Light position |
58 |
""" |
59 |
|
60 |
self.vtk_light.SetPosition(position.getXCoor(), position.getYCoor(), |
61 |
position.getZCoor()) |
62 |
|
63 |
def setIntensity(self, intensity): |
64 |
""" |
65 |
Set the intensity (brightness) of the light. |
66 |
@type intensity: Number |
67 |
@param intensity: Intensity (brightness) of the light |
68 |
""" |
69 |
|
70 |
self.vtk_light.SetIntensity(intensity) |
71 |
|