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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 839 - (hide annotations)
Wed Sep 6 04:53:50 2006 UTC (13 years, 11 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 gross 792 """
2 jongui 839 @author: John Ngui
3     @author: Lutz Gross
4     """
5 gross 792
6 jongui 839 import vtk
7 gross 792
8 jongui 839 class Scene:
9     """
10     Class that defines a scene in which components are displayed.
11     """
12 gross 792
13 jongui 839 def __init__(self, renderer = "vtk-online", x_size = 800, y_size = 600):
14     """
15     Initialize all the instance variables.
16 gross 792
17 jongui 839
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 jongui 822 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 gross 792
32 jongui 839 if(renderer == "vtk-online"):
33     self.setRenderingWindow()
34 gross 792
35 jongui 827 def setRenderingWindow(self):
36 jongui 839 """
37     Set up the renderer and rendering window.
38     """
39    
40 jongui 822 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 jongui 839 self.vtk_renderer.SetBackground(1, 1, 1) # Default color is white
45 gross 792
46 jongui 822 def render(self):
47 jongui 839 """
48     Set up the render window interactor and render the image.
49     """
50    
51 jongui 822 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 gross 792
57 jongui 822 def getRenderer(self):
58 jongui 839 """
59     Return the renderer.
60    
61     @rtype: vtkRenderer
62     @return: VTK renderer
63     """
64    
65 jongui 822 return self.vtk_renderer
66    
67    
68 gross 802
69 gross 792
70 jongui 822
71 gross 792
72    
73 jongui 822

  ViewVC Help
Powered by ViewVC 1.1.26