/[escript]/trunk/pyvisi/py_src/scene.py
ViewVC logotype

Contents of /trunk/pyvisi/py_src/scene.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 839 - (show annotations)
Wed Sep 6 04:53:50 2006 UTC (13 years, 10 months ago) by jongui
File MIME type: text/x-python
File size: 1592 byte(s)
- Added lookup table spectrum from blue to red and red to blue.
- Updated open scene to scene

1 """
2 @author: John Ngui
3 @author: Lutz Gross
4 """
5
6 import vtk
7
8 class Scene:
9 """
10 Class that defines a scene in which components are displayed.
11 """
12
13 def __init__(self, renderer = "vtk-online", x_size = 800, y_size = 600):
14 """
15 Initialize all the instance variables.
16
17
18 @type renderer: String
19 @param renderer: Type of rendering (I{vtk-online or vtk-offline})
20 @type x_size: Number
21 @param x_size: Size of the rendering window on the x-axis
22 @type y_size: Number
23 @param y_size: Size of the rendering window on the y-axis
24 """
25
26 self.renderer = renderer
27 self.x_size = x_size
28 self.y_size = y_size
29 self.vtk_renderer = None
30 self.vtk_render_window = None
31
32 if(renderer == "vtk-online"):
33 self.setRenderingWindow()
34
35 def setRenderingWindow(self):
36 """
37 Set up the renderer and rendering window.
38 """
39
40 self.vtk_renderer = vtk.vtkRenderer()
41 self.vtk_render_window = vtk.vtkRenderWindow()
42 self.vtk_render_window.AddRenderer(self.vtk_renderer)
43 self.vtk_render_window.SetSize(self.x_size, self.y_size)
44 self.vtk_renderer.SetBackground(1, 1, 1) # Default color is white
45
46 def render(self):
47 """
48 Set up the render window interactor and render the image.
49 """
50
51 vtk_render_window_interactor = vtk.vtkRenderWindowInteractor()
52 vtk_render_window_interactor.SetRenderWindow(self.vtk_render_window)
53 vtk_render_window_interactor.Initialize()
54 self.vtk_render_window.Render()
55 vtk_render_window_interactor.Start()
56
57 def getRenderer(self):
58 """
59 Return the renderer.
60
61 @rtype: vtkRenderer
62 @return: VTK renderer
63 """
64
65 return self.vtk_renderer
66
67
68
69
70
71
72
73

  ViewVC Help
Powered by ViewVC 1.1.26